point-click-lib 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3347 @@
1
+ function Ja(a, e) {
2
+ return a + e;
3
+ }
4
+ const Ya = [
5
+ {
6
+ schemaVersion: 3,
7
+ changes: [
8
+ {
9
+ breaking: !1,
10
+ description: "Designs have schemaVersion property"
11
+ },
12
+ {
13
+ breaking: !1,
14
+ description: "storyBoards array is required"
15
+ }
16
+ ]
17
+ },
18
+ {
19
+ schemaVersion: 4,
20
+ changes: [
21
+ {
22
+ breaking: !0,
23
+ description: "Endings deprecated in favour of storyBoards. Any Endings have been converted to Storyboards."
24
+ },
25
+ {
26
+ breaking: !1,
27
+ description: "StoryBoards have end of game option."
28
+ }
29
+ ]
30
+ }
31
+ ];
32
+ var S;
33
+ (function(a) {
34
+ a.assertEqual = (n) => {
35
+ };
36
+ function e(n) {
37
+ }
38
+ a.assertIs = e;
39
+ function t(n) {
40
+ throw new Error();
41
+ }
42
+ a.assertNever = t, a.arrayToEnum = (n) => {
43
+ const r = {};
44
+ for (const i of n)
45
+ r[i] = i;
46
+ return r;
47
+ }, a.getValidEnumValues = (n) => {
48
+ const r = a.objectKeys(n).filter((o) => typeof n[n[o]] != "number"), i = {};
49
+ for (const o of r)
50
+ i[o] = n[o];
51
+ return a.objectValues(i);
52
+ }, a.objectValues = (n) => a.objectKeys(n).map(function(r) {
53
+ return n[r];
54
+ }), a.objectKeys = typeof Object.keys == "function" ? (n) => Object.keys(n) : (n) => {
55
+ const r = [];
56
+ for (const i in n)
57
+ Object.prototype.hasOwnProperty.call(n, i) && r.push(i);
58
+ return r;
59
+ }, a.find = (n, r) => {
60
+ for (const i of n)
61
+ if (r(i))
62
+ return i;
63
+ }, a.isInteger = typeof Number.isInteger == "function" ? (n) => Number.isInteger(n) : (n) => typeof n == "number" && Number.isFinite(n) && Math.floor(n) === n;
64
+ function s(n, r = " | ") {
65
+ return n.map((i) => typeof i == "string" ? `'${i}'` : i).join(r);
66
+ }
67
+ a.joinValues = s, a.jsonStringifyReplacer = (n, r) => typeof r == "bigint" ? r.toString() : r;
68
+ })(S || (S = {}));
69
+ var Ye;
70
+ (function(a) {
71
+ a.mergeShapes = (e, t) => ({
72
+ ...e,
73
+ ...t
74
+ // second overwrites first
75
+ });
76
+ })(Ye || (Ye = {}));
77
+ const h = S.arrayToEnum([
78
+ "string",
79
+ "nan",
80
+ "number",
81
+ "integer",
82
+ "float",
83
+ "boolean",
84
+ "date",
85
+ "bigint",
86
+ "symbol",
87
+ "function",
88
+ "undefined",
89
+ "null",
90
+ "array",
91
+ "object",
92
+ "unknown",
93
+ "promise",
94
+ "void",
95
+ "never",
96
+ "map",
97
+ "set"
98
+ ]), D = (a) => {
99
+ switch (typeof a) {
100
+ case "undefined":
101
+ return h.undefined;
102
+ case "string":
103
+ return h.string;
104
+ case "number":
105
+ return Number.isNaN(a) ? h.nan : h.number;
106
+ case "boolean":
107
+ return h.boolean;
108
+ case "function":
109
+ return h.function;
110
+ case "bigint":
111
+ return h.bigint;
112
+ case "symbol":
113
+ return h.symbol;
114
+ case "object":
115
+ return Array.isArray(a) ? h.array : a === null ? h.null : a.then && typeof a.then == "function" && a.catch && typeof a.catch == "function" ? h.promise : typeof Map < "u" && a instanceof Map ? h.map : typeof Set < "u" && a instanceof Set ? h.set : typeof Date < "u" && a instanceof Date ? h.date : h.object;
116
+ default:
117
+ return h.unknown;
118
+ }
119
+ }, d = S.arrayToEnum([
120
+ "invalid_type",
121
+ "invalid_literal",
122
+ "custom",
123
+ "invalid_union",
124
+ "invalid_union_discriminator",
125
+ "invalid_enum_value",
126
+ "unrecognized_keys",
127
+ "invalid_arguments",
128
+ "invalid_return_type",
129
+ "invalid_date",
130
+ "invalid_string",
131
+ "too_small",
132
+ "too_big",
133
+ "invalid_intersection_types",
134
+ "not_multiple_of",
135
+ "not_finite"
136
+ ]);
137
+ class V extends Error {
138
+ get errors() {
139
+ return this.issues;
140
+ }
141
+ constructor(e) {
142
+ super(), this.issues = [], this.addIssue = (s) => {
143
+ this.issues = [...this.issues, s];
144
+ }, this.addIssues = (s = []) => {
145
+ this.issues = [...this.issues, ...s];
146
+ };
147
+ const t = new.target.prototype;
148
+ Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
149
+ }
150
+ format(e) {
151
+ const t = e || function(r) {
152
+ return r.message;
153
+ }, s = { _errors: [] }, n = (r) => {
154
+ for (const i of r.issues)
155
+ if (i.code === "invalid_union")
156
+ i.unionErrors.map(n);
157
+ else if (i.code === "invalid_return_type")
158
+ n(i.returnTypeError);
159
+ else if (i.code === "invalid_arguments")
160
+ n(i.argumentsError);
161
+ else if (i.path.length === 0)
162
+ s._errors.push(t(i));
163
+ else {
164
+ let o = s, m = 0;
165
+ for (; m < i.path.length; ) {
166
+ const p = i.path[m];
167
+ m === i.path.length - 1 ? (o[p] = o[p] || { _errors: [] }, o[p]._errors.push(t(i))) : o[p] = o[p] || { _errors: [] }, o = o[p], m++;
168
+ }
169
+ }
170
+ };
171
+ return n(this), s;
172
+ }
173
+ static assert(e) {
174
+ if (!(e instanceof V))
175
+ throw new Error(`Not a ZodError: ${e}`);
176
+ }
177
+ toString() {
178
+ return this.message;
179
+ }
180
+ get message() {
181
+ return JSON.stringify(this.issues, S.jsonStringifyReplacer, 2);
182
+ }
183
+ get isEmpty() {
184
+ return this.issues.length === 0;
185
+ }
186
+ flatten(e = (t) => t.message) {
187
+ const t = {}, s = [];
188
+ for (const n of this.issues)
189
+ if (n.path.length > 0) {
190
+ const r = n.path[0];
191
+ t[r] = t[r] || [], t[r].push(e(n));
192
+ } else
193
+ s.push(e(n));
194
+ return { formErrors: s, fieldErrors: t };
195
+ }
196
+ get formErrors() {
197
+ return this.flatten();
198
+ }
199
+ }
200
+ V.create = (a) => new V(a);
201
+ const Re = (a, e) => {
202
+ let t;
203
+ switch (a.code) {
204
+ case d.invalid_type:
205
+ a.received === h.undefined ? t = "Required" : t = `Expected ${a.expected}, received ${a.received}`;
206
+ break;
207
+ case d.invalid_literal:
208
+ t = `Invalid literal value, expected ${JSON.stringify(a.expected, S.jsonStringifyReplacer)}`;
209
+ break;
210
+ case d.unrecognized_keys:
211
+ t = `Unrecognized key(s) in object: ${S.joinValues(a.keys, ", ")}`;
212
+ break;
213
+ case d.invalid_union:
214
+ t = "Invalid input";
215
+ break;
216
+ case d.invalid_union_discriminator:
217
+ t = `Invalid discriminator value. Expected ${S.joinValues(a.options)}`;
218
+ break;
219
+ case d.invalid_enum_value:
220
+ t = `Invalid enum value. Expected ${S.joinValues(a.options)}, received '${a.received}'`;
221
+ break;
222
+ case d.invalid_arguments:
223
+ t = "Invalid function arguments";
224
+ break;
225
+ case d.invalid_return_type:
226
+ t = "Invalid function return type";
227
+ break;
228
+ case d.invalid_date:
229
+ t = "Invalid date";
230
+ break;
231
+ case d.invalid_string:
232
+ typeof a.validation == "object" ? "includes" in a.validation ? (t = `Invalid input: must include "${a.validation.includes}"`, typeof a.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${a.validation.position}`)) : "startsWith" in a.validation ? t = `Invalid input: must start with "${a.validation.startsWith}"` : "endsWith" in a.validation ? t = `Invalid input: must end with "${a.validation.endsWith}"` : S.assertNever(a.validation) : a.validation !== "regex" ? t = `Invalid ${a.validation}` : t = "Invalid";
233
+ break;
234
+ case d.too_small:
235
+ a.type === "array" ? t = `Array must contain ${a.exact ? "exactly" : a.inclusive ? "at least" : "more than"} ${a.minimum} element(s)` : a.type === "string" ? t = `String must contain ${a.exact ? "exactly" : a.inclusive ? "at least" : "over"} ${a.minimum} character(s)` : a.type === "number" ? t = `Number must be ${a.exact ? "exactly equal to " : a.inclusive ? "greater than or equal to " : "greater than "}${a.minimum}` : a.type === "bigint" ? t = `Number must be ${a.exact ? "exactly equal to " : a.inclusive ? "greater than or equal to " : "greater than "}${a.minimum}` : a.type === "date" ? t = `Date must be ${a.exact ? "exactly equal to " : a.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(a.minimum))}` : t = "Invalid input";
236
+ break;
237
+ case d.too_big:
238
+ a.type === "array" ? t = `Array must contain ${a.exact ? "exactly" : a.inclusive ? "at most" : "less than"} ${a.maximum} element(s)` : a.type === "string" ? t = `String must contain ${a.exact ? "exactly" : a.inclusive ? "at most" : "under"} ${a.maximum} character(s)` : a.type === "number" ? t = `Number must be ${a.exact ? "exactly" : a.inclusive ? "less than or equal to" : "less than"} ${a.maximum}` : a.type === "bigint" ? t = `BigInt must be ${a.exact ? "exactly" : a.inclusive ? "less than or equal to" : "less than"} ${a.maximum}` : a.type === "date" ? t = `Date must be ${a.exact ? "exactly" : a.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(a.maximum))}` : t = "Invalid input";
239
+ break;
240
+ case d.custom:
241
+ t = "Invalid input";
242
+ break;
243
+ case d.invalid_intersection_types:
244
+ t = "Intersection results could not be merged";
245
+ break;
246
+ case d.not_multiple_of:
247
+ t = `Number must be a multiple of ${a.multipleOf}`;
248
+ break;
249
+ case d.not_finite:
250
+ t = "Number must be finite";
251
+ break;
252
+ default:
253
+ t = e.defaultError, S.assertNever(a);
254
+ }
255
+ return { message: t };
256
+ };
257
+ let jt = Re;
258
+ function qt() {
259
+ return jt;
260
+ }
261
+ const $t = (a) => {
262
+ const { data: e, path: t, errorMaps: s, issueData: n } = a, r = [...t, ...n.path || []], i = {
263
+ ...n,
264
+ path: r
265
+ };
266
+ if (n.message !== void 0)
267
+ return {
268
+ ...n,
269
+ path: r,
270
+ message: n.message
271
+ };
272
+ let o = "";
273
+ const m = s.filter((p) => !!p).slice().reverse();
274
+ for (const p of m)
275
+ o = p(i, { data: e, defaultError: o }).message;
276
+ return {
277
+ ...n,
278
+ path: r,
279
+ message: o
280
+ };
281
+ };
282
+ function u(a, e) {
283
+ const t = qt(), s = $t({
284
+ issueData: e,
285
+ data: a.data,
286
+ path: a.path,
287
+ errorMaps: [
288
+ a.common.contextualErrorMap,
289
+ // contextual error map is first priority
290
+ a.schemaErrorMap,
291
+ // then schema-bound map if available
292
+ t,
293
+ // then global override map
294
+ t === Re ? void 0 : Re
295
+ // then global default map
296
+ ].filter((n) => !!n)
297
+ });
298
+ a.common.issues.push(s);
299
+ }
300
+ class A {
301
+ constructor() {
302
+ this.value = "valid";
303
+ }
304
+ dirty() {
305
+ this.value === "valid" && (this.value = "dirty");
306
+ }
307
+ abort() {
308
+ this.value !== "aborted" && (this.value = "aborted");
309
+ }
310
+ static mergeArray(e, t) {
311
+ const s = [];
312
+ for (const n of t) {
313
+ if (n.status === "aborted")
314
+ return v;
315
+ n.status === "dirty" && e.dirty(), s.push(n.value);
316
+ }
317
+ return { status: e.value, value: s };
318
+ }
319
+ static async mergeObjectAsync(e, t) {
320
+ const s = [];
321
+ for (const n of t) {
322
+ const r = await n.key, i = await n.value;
323
+ s.push({
324
+ key: r,
325
+ value: i
326
+ });
327
+ }
328
+ return A.mergeObjectSync(e, s);
329
+ }
330
+ static mergeObjectSync(e, t) {
331
+ const s = {};
332
+ for (const n of t) {
333
+ const { key: r, value: i } = n;
334
+ if (r.status === "aborted" || i.status === "aborted")
335
+ return v;
336
+ r.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), r.value !== "__proto__" && (typeof i.value < "u" || n.alwaysSet) && (s[r.value] = i.value);
337
+ }
338
+ return { status: e.value, value: s };
339
+ }
340
+ }
341
+ const v = Object.freeze({
342
+ status: "aborted"
343
+ }), Q = (a) => ({ status: "dirty", value: a }), Z = (a) => ({ status: "valid", value: a }), Xe = (a) => a.status === "aborted", Qe = (a) => a.status === "dirty", W = (a) => a.status === "valid", pe = (a) => typeof Promise < "u" && a instanceof Promise;
344
+ var f;
345
+ (function(a) {
346
+ a.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, a.toString = (e) => typeof e == "string" ? e : e?.message;
347
+ })(f || (f = {}));
348
+ class q {
349
+ constructor(e, t, s, n) {
350
+ this._cachedPath = [], this.parent = e, this.data = t, this._path = s, this._key = n;
351
+ }
352
+ get path() {
353
+ return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
354
+ }
355
+ }
356
+ const Ke = (a, e) => {
357
+ if (W(e))
358
+ return { success: !0, data: e.value };
359
+ if (!a.common.issues.length)
360
+ throw new Error("Validation failed but no issues detected.");
361
+ return {
362
+ success: !1,
363
+ get error() {
364
+ if (this._error)
365
+ return this._error;
366
+ const t = new V(a.common.issues);
367
+ return this._error = t, this._error;
368
+ }
369
+ };
370
+ };
371
+ function x(a) {
372
+ if (!a)
373
+ return {};
374
+ const { errorMap: e, invalid_type_error: t, required_error: s, description: n } = a;
375
+ if (e && (t || s))
376
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
377
+ return e ? { errorMap: e, description: n } : { errorMap: (i, o) => {
378
+ const { message: m } = a;
379
+ return i.code === "invalid_enum_value" ? { message: m ?? o.defaultError } : typeof o.data > "u" ? { message: m ?? s ?? o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: m ?? t ?? o.defaultError };
380
+ }, description: n };
381
+ }
382
+ class k {
383
+ get description() {
384
+ return this._def.description;
385
+ }
386
+ _getType(e) {
387
+ return D(e.data);
388
+ }
389
+ _getOrReturnCtx(e, t) {
390
+ return t || {
391
+ common: e.parent.common,
392
+ data: e.data,
393
+ parsedType: D(e.data),
394
+ schemaErrorMap: this._def.errorMap,
395
+ path: e.path,
396
+ parent: e.parent
397
+ };
398
+ }
399
+ _processInputParams(e) {
400
+ return {
401
+ status: new A(),
402
+ ctx: {
403
+ common: e.parent.common,
404
+ data: e.data,
405
+ parsedType: D(e.data),
406
+ schemaErrorMap: this._def.errorMap,
407
+ path: e.path,
408
+ parent: e.parent
409
+ }
410
+ };
411
+ }
412
+ _parseSync(e) {
413
+ const t = this._parse(e);
414
+ if (pe(t))
415
+ throw new Error("Synchronous parse encountered promise.");
416
+ return t;
417
+ }
418
+ _parseAsync(e) {
419
+ const t = this._parse(e);
420
+ return Promise.resolve(t);
421
+ }
422
+ parse(e, t) {
423
+ const s = this.safeParse(e, t);
424
+ if (s.success)
425
+ return s.data;
426
+ throw s.error;
427
+ }
428
+ safeParse(e, t) {
429
+ const s = {
430
+ common: {
431
+ issues: [],
432
+ async: t?.async ?? !1,
433
+ contextualErrorMap: t?.errorMap
434
+ },
435
+ path: t?.path || [],
436
+ schemaErrorMap: this._def.errorMap,
437
+ parent: null,
438
+ data: e,
439
+ parsedType: D(e)
440
+ }, n = this._parseSync({ data: e, path: s.path, parent: s });
441
+ return Ke(s, n);
442
+ }
443
+ "~validate"(e) {
444
+ const t = {
445
+ common: {
446
+ issues: [],
447
+ async: !!this["~standard"].async
448
+ },
449
+ path: [],
450
+ schemaErrorMap: this._def.errorMap,
451
+ parent: null,
452
+ data: e,
453
+ parsedType: D(e)
454
+ };
455
+ if (!this["~standard"].async)
456
+ try {
457
+ const s = this._parseSync({ data: e, path: [], parent: t });
458
+ return W(s) ? {
459
+ value: s.value
460
+ } : {
461
+ issues: t.common.issues
462
+ };
463
+ } catch (s) {
464
+ s?.message?.toLowerCase()?.includes("encountered") && (this["~standard"].async = !0), t.common = {
465
+ issues: [],
466
+ async: !0
467
+ };
468
+ }
469
+ return this._parseAsync({ data: e, path: [], parent: t }).then((s) => W(s) ? {
470
+ value: s.value
471
+ } : {
472
+ issues: t.common.issues
473
+ });
474
+ }
475
+ async parseAsync(e, t) {
476
+ const s = await this.safeParseAsync(e, t);
477
+ if (s.success)
478
+ return s.data;
479
+ throw s.error;
480
+ }
481
+ async safeParseAsync(e, t) {
482
+ const s = {
483
+ common: {
484
+ issues: [],
485
+ contextualErrorMap: t?.errorMap,
486
+ async: !0
487
+ },
488
+ path: t?.path || [],
489
+ schemaErrorMap: this._def.errorMap,
490
+ parent: null,
491
+ data: e,
492
+ parsedType: D(e)
493
+ }, n = this._parse({ data: e, path: s.path, parent: s }), r = await (pe(n) ? n : Promise.resolve(n));
494
+ return Ke(s, r);
495
+ }
496
+ refine(e, t) {
497
+ const s = (n) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(n) : t;
498
+ return this._refinement((n, r) => {
499
+ const i = e(n), o = () => r.addIssue({
500
+ code: d.custom,
501
+ ...s(n)
502
+ });
503
+ return typeof Promise < "u" && i instanceof Promise ? i.then((m) => m ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
504
+ });
505
+ }
506
+ refinement(e, t) {
507
+ return this._refinement((s, n) => e(s) ? !0 : (n.addIssue(typeof t == "function" ? t(s, n) : t), !1));
508
+ }
509
+ _refinement(e) {
510
+ return new H({
511
+ schema: this,
512
+ typeName: g.ZodEffects,
513
+ effect: { type: "refinement", refinement: e }
514
+ });
515
+ }
516
+ superRefine(e) {
517
+ return this._refinement(e);
518
+ }
519
+ constructor(e) {
520
+ this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
521
+ version: 1,
522
+ vendor: "zod",
523
+ validate: (t) => this["~validate"](t)
524
+ };
525
+ }
526
+ optional() {
527
+ return M.create(this, this._def);
528
+ }
529
+ nullable() {
530
+ return J.create(this, this._def);
531
+ }
532
+ nullish() {
533
+ return this.nullable().optional();
534
+ }
535
+ array() {
536
+ return j.create(this);
537
+ }
538
+ promise() {
539
+ return xe.create(this, this._def);
540
+ }
541
+ or(e) {
542
+ return ge.create([this, e], this._def);
543
+ }
544
+ and(e) {
545
+ return ve.create(this, e, this._def);
546
+ }
547
+ transform(e) {
548
+ return new H({
549
+ ...x(this._def),
550
+ schema: this,
551
+ typeName: g.ZodEffects,
552
+ effect: { type: "transform", transform: e }
553
+ });
554
+ }
555
+ default(e) {
556
+ const t = typeof e == "function" ? e : () => e;
557
+ return new qe({
558
+ ...x(this._def),
559
+ innerType: this,
560
+ defaultValue: t,
561
+ typeName: g.ZodDefault
562
+ });
563
+ }
564
+ brand() {
565
+ return new ra({
566
+ typeName: g.ZodBranded,
567
+ type: this,
568
+ ...x(this._def)
569
+ });
570
+ }
571
+ catch(e) {
572
+ const t = typeof e == "function" ? e : () => e;
573
+ return new $e({
574
+ ...x(this._def),
575
+ innerType: this,
576
+ catchValue: t,
577
+ typeName: g.ZodCatch
578
+ });
579
+ }
580
+ describe(e) {
581
+ const t = this.constructor;
582
+ return new t({
583
+ ...this._def,
584
+ description: e
585
+ });
586
+ }
587
+ pipe(e) {
588
+ return Me.create(this, e);
589
+ }
590
+ readonly() {
591
+ return Ve.create(this);
592
+ }
593
+ isOptional() {
594
+ return this.safeParse(void 0).success;
595
+ }
596
+ isNullable() {
597
+ return this.safeParse(null).success;
598
+ }
599
+ }
600
+ const Vt = /^c[^\s-]{8,}$/i, Dt = /^[0-9a-z]+$/, Mt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, Bt = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, Pt = /^[a-z0-9_-]{21}$/i, Lt = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, zt = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, Ft = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Wt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
601
+ let Ae;
602
+ const Ut = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, Gt = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, Ht = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, Jt = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Yt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Xt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, ht = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", Qt = new RegExp(`^${ht}$`);
603
+ function ft(a) {
604
+ let e = "[0-5]\\d";
605
+ a.precision ? e = `${e}\\.\\d{${a.precision}}` : a.precision == null && (e = `${e}(\\.\\d+)?`);
606
+ const t = a.precision ? "+" : "?";
607
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`;
608
+ }
609
+ function Kt(a) {
610
+ return new RegExp(`^${ft(a)}$`);
611
+ }
612
+ function ea(a) {
613
+ let e = `${ht}T${ft(a)}`;
614
+ const t = [];
615
+ return t.push(a.local ? "Z?" : "Z"), a.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
616
+ }
617
+ function ta(a, e) {
618
+ return !!((e === "v4" || !e) && Ut.test(a) || (e === "v6" || !e) && Ht.test(a));
619
+ }
620
+ function aa(a, e) {
621
+ if (!Lt.test(a))
622
+ return !1;
623
+ try {
624
+ const [t] = a.split(".");
625
+ if (!t)
626
+ return !1;
627
+ const s = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), n = JSON.parse(atob(s));
628
+ return !(typeof n != "object" || n === null || "typ" in n && n?.typ !== "JWT" || !n.alg || e && n.alg !== e);
629
+ } catch {
630
+ return !1;
631
+ }
632
+ }
633
+ function sa(a, e) {
634
+ return !!((e === "v4" || !e) && Gt.test(a) || (e === "v6" || !e) && Jt.test(a));
635
+ }
636
+ class $ extends k {
637
+ _parse(e) {
638
+ if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
639
+ const r = this._getOrReturnCtx(e);
640
+ return u(r, {
641
+ code: d.invalid_type,
642
+ expected: h.string,
643
+ received: r.parsedType
644
+ }), v;
645
+ }
646
+ const s = new A();
647
+ let n;
648
+ for (const r of this._def.checks)
649
+ if (r.kind === "min")
650
+ e.data.length < r.value && (n = this._getOrReturnCtx(e, n), u(n, {
651
+ code: d.too_small,
652
+ minimum: r.value,
653
+ type: "string",
654
+ inclusive: !0,
655
+ exact: !1,
656
+ message: r.message
657
+ }), s.dirty());
658
+ else if (r.kind === "max")
659
+ e.data.length > r.value && (n = this._getOrReturnCtx(e, n), u(n, {
660
+ code: d.too_big,
661
+ maximum: r.value,
662
+ type: "string",
663
+ inclusive: !0,
664
+ exact: !1,
665
+ message: r.message
666
+ }), s.dirty());
667
+ else if (r.kind === "length") {
668
+ const i = e.data.length > r.value, o = e.data.length < r.value;
669
+ (i || o) && (n = this._getOrReturnCtx(e, n), i ? u(n, {
670
+ code: d.too_big,
671
+ maximum: r.value,
672
+ type: "string",
673
+ inclusive: !0,
674
+ exact: !0,
675
+ message: r.message
676
+ }) : o && u(n, {
677
+ code: d.too_small,
678
+ minimum: r.value,
679
+ type: "string",
680
+ inclusive: !0,
681
+ exact: !0,
682
+ message: r.message
683
+ }), s.dirty());
684
+ } else if (r.kind === "email")
685
+ Ft.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
686
+ validation: "email",
687
+ code: d.invalid_string,
688
+ message: r.message
689
+ }), s.dirty());
690
+ else if (r.kind === "emoji")
691
+ Ae || (Ae = new RegExp(Wt, "u")), Ae.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
692
+ validation: "emoji",
693
+ code: d.invalid_string,
694
+ message: r.message
695
+ }), s.dirty());
696
+ else if (r.kind === "uuid")
697
+ Bt.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
698
+ validation: "uuid",
699
+ code: d.invalid_string,
700
+ message: r.message
701
+ }), s.dirty());
702
+ else if (r.kind === "nanoid")
703
+ Pt.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
704
+ validation: "nanoid",
705
+ code: d.invalid_string,
706
+ message: r.message
707
+ }), s.dirty());
708
+ else if (r.kind === "cuid")
709
+ Vt.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
710
+ validation: "cuid",
711
+ code: d.invalid_string,
712
+ message: r.message
713
+ }), s.dirty());
714
+ else if (r.kind === "cuid2")
715
+ Dt.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
716
+ validation: "cuid2",
717
+ code: d.invalid_string,
718
+ message: r.message
719
+ }), s.dirty());
720
+ else if (r.kind === "ulid")
721
+ Mt.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
722
+ validation: "ulid",
723
+ code: d.invalid_string,
724
+ message: r.message
725
+ }), s.dirty());
726
+ else if (r.kind === "url")
727
+ try {
728
+ new URL(e.data);
729
+ } catch {
730
+ n = this._getOrReturnCtx(e, n), u(n, {
731
+ validation: "url",
732
+ code: d.invalid_string,
733
+ message: r.message
734
+ }), s.dirty();
735
+ }
736
+ else r.kind === "regex" ? (r.regex.lastIndex = 0, r.regex.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
737
+ validation: "regex",
738
+ code: d.invalid_string,
739
+ message: r.message
740
+ }), s.dirty())) : r.kind === "trim" ? e.data = e.data.trim() : r.kind === "includes" ? e.data.includes(r.value, r.position) || (n = this._getOrReturnCtx(e, n), u(n, {
741
+ code: d.invalid_string,
742
+ validation: { includes: r.value, position: r.position },
743
+ message: r.message
744
+ }), s.dirty()) : r.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : r.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : r.kind === "startsWith" ? e.data.startsWith(r.value) || (n = this._getOrReturnCtx(e, n), u(n, {
745
+ code: d.invalid_string,
746
+ validation: { startsWith: r.value },
747
+ message: r.message
748
+ }), s.dirty()) : r.kind === "endsWith" ? e.data.endsWith(r.value) || (n = this._getOrReturnCtx(e, n), u(n, {
749
+ code: d.invalid_string,
750
+ validation: { endsWith: r.value },
751
+ message: r.message
752
+ }), s.dirty()) : r.kind === "datetime" ? ea(r).test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
753
+ code: d.invalid_string,
754
+ validation: "datetime",
755
+ message: r.message
756
+ }), s.dirty()) : r.kind === "date" ? Qt.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
757
+ code: d.invalid_string,
758
+ validation: "date",
759
+ message: r.message
760
+ }), s.dirty()) : r.kind === "time" ? Kt(r).test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
761
+ code: d.invalid_string,
762
+ validation: "time",
763
+ message: r.message
764
+ }), s.dirty()) : r.kind === "duration" ? zt.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
765
+ validation: "duration",
766
+ code: d.invalid_string,
767
+ message: r.message
768
+ }), s.dirty()) : r.kind === "ip" ? ta(e.data, r.version) || (n = this._getOrReturnCtx(e, n), u(n, {
769
+ validation: "ip",
770
+ code: d.invalid_string,
771
+ message: r.message
772
+ }), s.dirty()) : r.kind === "jwt" ? aa(e.data, r.alg) || (n = this._getOrReturnCtx(e, n), u(n, {
773
+ validation: "jwt",
774
+ code: d.invalid_string,
775
+ message: r.message
776
+ }), s.dirty()) : r.kind === "cidr" ? sa(e.data, r.version) || (n = this._getOrReturnCtx(e, n), u(n, {
777
+ validation: "cidr",
778
+ code: d.invalid_string,
779
+ message: r.message
780
+ }), s.dirty()) : r.kind === "base64" ? Yt.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
781
+ validation: "base64",
782
+ code: d.invalid_string,
783
+ message: r.message
784
+ }), s.dirty()) : r.kind === "base64url" ? Xt.test(e.data) || (n = this._getOrReturnCtx(e, n), u(n, {
785
+ validation: "base64url",
786
+ code: d.invalid_string,
787
+ message: r.message
788
+ }), s.dirty()) : S.assertNever(r);
789
+ return { status: s.value, value: e.data };
790
+ }
791
+ _regex(e, t, s) {
792
+ return this.refinement((n) => e.test(n), {
793
+ validation: t,
794
+ code: d.invalid_string,
795
+ ...f.errToObj(s)
796
+ });
797
+ }
798
+ _addCheck(e) {
799
+ return new $({
800
+ ...this._def,
801
+ checks: [...this._def.checks, e]
802
+ });
803
+ }
804
+ email(e) {
805
+ return this._addCheck({ kind: "email", ...f.errToObj(e) });
806
+ }
807
+ url(e) {
808
+ return this._addCheck({ kind: "url", ...f.errToObj(e) });
809
+ }
810
+ emoji(e) {
811
+ return this._addCheck({ kind: "emoji", ...f.errToObj(e) });
812
+ }
813
+ uuid(e) {
814
+ return this._addCheck({ kind: "uuid", ...f.errToObj(e) });
815
+ }
816
+ nanoid(e) {
817
+ return this._addCheck({ kind: "nanoid", ...f.errToObj(e) });
818
+ }
819
+ cuid(e) {
820
+ return this._addCheck({ kind: "cuid", ...f.errToObj(e) });
821
+ }
822
+ cuid2(e) {
823
+ return this._addCheck({ kind: "cuid2", ...f.errToObj(e) });
824
+ }
825
+ ulid(e) {
826
+ return this._addCheck({ kind: "ulid", ...f.errToObj(e) });
827
+ }
828
+ base64(e) {
829
+ return this._addCheck({ kind: "base64", ...f.errToObj(e) });
830
+ }
831
+ base64url(e) {
832
+ return this._addCheck({
833
+ kind: "base64url",
834
+ ...f.errToObj(e)
835
+ });
836
+ }
837
+ jwt(e) {
838
+ return this._addCheck({ kind: "jwt", ...f.errToObj(e) });
839
+ }
840
+ ip(e) {
841
+ return this._addCheck({ kind: "ip", ...f.errToObj(e) });
842
+ }
843
+ cidr(e) {
844
+ return this._addCheck({ kind: "cidr", ...f.errToObj(e) });
845
+ }
846
+ datetime(e) {
847
+ return typeof e == "string" ? this._addCheck({
848
+ kind: "datetime",
849
+ precision: null,
850
+ offset: !1,
851
+ local: !1,
852
+ message: e
853
+ }) : this._addCheck({
854
+ kind: "datetime",
855
+ precision: typeof e?.precision > "u" ? null : e?.precision,
856
+ offset: e?.offset ?? !1,
857
+ local: e?.local ?? !1,
858
+ ...f.errToObj(e?.message)
859
+ });
860
+ }
861
+ date(e) {
862
+ return this._addCheck({ kind: "date", message: e });
863
+ }
864
+ time(e) {
865
+ return typeof e == "string" ? this._addCheck({
866
+ kind: "time",
867
+ precision: null,
868
+ message: e
869
+ }) : this._addCheck({
870
+ kind: "time",
871
+ precision: typeof e?.precision > "u" ? null : e?.precision,
872
+ ...f.errToObj(e?.message)
873
+ });
874
+ }
875
+ duration(e) {
876
+ return this._addCheck({ kind: "duration", ...f.errToObj(e) });
877
+ }
878
+ regex(e, t) {
879
+ return this._addCheck({
880
+ kind: "regex",
881
+ regex: e,
882
+ ...f.errToObj(t)
883
+ });
884
+ }
885
+ includes(e, t) {
886
+ return this._addCheck({
887
+ kind: "includes",
888
+ value: e,
889
+ position: t?.position,
890
+ ...f.errToObj(t?.message)
891
+ });
892
+ }
893
+ startsWith(e, t) {
894
+ return this._addCheck({
895
+ kind: "startsWith",
896
+ value: e,
897
+ ...f.errToObj(t)
898
+ });
899
+ }
900
+ endsWith(e, t) {
901
+ return this._addCheck({
902
+ kind: "endsWith",
903
+ value: e,
904
+ ...f.errToObj(t)
905
+ });
906
+ }
907
+ min(e, t) {
908
+ return this._addCheck({
909
+ kind: "min",
910
+ value: e,
911
+ ...f.errToObj(t)
912
+ });
913
+ }
914
+ max(e, t) {
915
+ return this._addCheck({
916
+ kind: "max",
917
+ value: e,
918
+ ...f.errToObj(t)
919
+ });
920
+ }
921
+ length(e, t) {
922
+ return this._addCheck({
923
+ kind: "length",
924
+ value: e,
925
+ ...f.errToObj(t)
926
+ });
927
+ }
928
+ /**
929
+ * Equivalent to `.min(1)`
930
+ */
931
+ nonempty(e) {
932
+ return this.min(1, f.errToObj(e));
933
+ }
934
+ trim() {
935
+ return new $({
936
+ ...this._def,
937
+ checks: [...this._def.checks, { kind: "trim" }]
938
+ });
939
+ }
940
+ toLowerCase() {
941
+ return new $({
942
+ ...this._def,
943
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
944
+ });
945
+ }
946
+ toUpperCase() {
947
+ return new $({
948
+ ...this._def,
949
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
950
+ });
951
+ }
952
+ get isDatetime() {
953
+ return !!this._def.checks.find((e) => e.kind === "datetime");
954
+ }
955
+ get isDate() {
956
+ return !!this._def.checks.find((e) => e.kind === "date");
957
+ }
958
+ get isTime() {
959
+ return !!this._def.checks.find((e) => e.kind === "time");
960
+ }
961
+ get isDuration() {
962
+ return !!this._def.checks.find((e) => e.kind === "duration");
963
+ }
964
+ get isEmail() {
965
+ return !!this._def.checks.find((e) => e.kind === "email");
966
+ }
967
+ get isURL() {
968
+ return !!this._def.checks.find((e) => e.kind === "url");
969
+ }
970
+ get isEmoji() {
971
+ return !!this._def.checks.find((e) => e.kind === "emoji");
972
+ }
973
+ get isUUID() {
974
+ return !!this._def.checks.find((e) => e.kind === "uuid");
975
+ }
976
+ get isNANOID() {
977
+ return !!this._def.checks.find((e) => e.kind === "nanoid");
978
+ }
979
+ get isCUID() {
980
+ return !!this._def.checks.find((e) => e.kind === "cuid");
981
+ }
982
+ get isCUID2() {
983
+ return !!this._def.checks.find((e) => e.kind === "cuid2");
984
+ }
985
+ get isULID() {
986
+ return !!this._def.checks.find((e) => e.kind === "ulid");
987
+ }
988
+ get isIP() {
989
+ return !!this._def.checks.find((e) => e.kind === "ip");
990
+ }
991
+ get isCIDR() {
992
+ return !!this._def.checks.find((e) => e.kind === "cidr");
993
+ }
994
+ get isBase64() {
995
+ return !!this._def.checks.find((e) => e.kind === "base64");
996
+ }
997
+ get isBase64url() {
998
+ return !!this._def.checks.find((e) => e.kind === "base64url");
999
+ }
1000
+ get minLength() {
1001
+ let e = null;
1002
+ for (const t of this._def.checks)
1003
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1004
+ return e;
1005
+ }
1006
+ get maxLength() {
1007
+ let e = null;
1008
+ for (const t of this._def.checks)
1009
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1010
+ return e;
1011
+ }
1012
+ }
1013
+ $.create = (a) => new $({
1014
+ checks: [],
1015
+ typeName: g.ZodString,
1016
+ coerce: a?.coerce ?? !1,
1017
+ ...x(a)
1018
+ });
1019
+ function na(a, e) {
1020
+ const t = (a.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, n = t > s ? t : s, r = Number.parseInt(a.toFixed(n).replace(".", "")), i = Number.parseInt(e.toFixed(n).replace(".", ""));
1021
+ return r % i / 10 ** n;
1022
+ }
1023
+ class U extends k {
1024
+ constructor() {
1025
+ super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
1026
+ }
1027
+ _parse(e) {
1028
+ if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== h.number) {
1029
+ const r = this._getOrReturnCtx(e);
1030
+ return u(r, {
1031
+ code: d.invalid_type,
1032
+ expected: h.number,
1033
+ received: r.parsedType
1034
+ }), v;
1035
+ }
1036
+ let s;
1037
+ const n = new A();
1038
+ for (const r of this._def.checks)
1039
+ r.kind === "int" ? S.isInteger(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
1040
+ code: d.invalid_type,
1041
+ expected: "integer",
1042
+ received: "float",
1043
+ message: r.message
1044
+ }), n.dirty()) : r.kind === "min" ? (r.inclusive ? e.data < r.value : e.data <= r.value) && (s = this._getOrReturnCtx(e, s), u(s, {
1045
+ code: d.too_small,
1046
+ minimum: r.value,
1047
+ type: "number",
1048
+ inclusive: r.inclusive,
1049
+ exact: !1,
1050
+ message: r.message
1051
+ }), n.dirty()) : r.kind === "max" ? (r.inclusive ? e.data > r.value : e.data >= r.value) && (s = this._getOrReturnCtx(e, s), u(s, {
1052
+ code: d.too_big,
1053
+ maximum: r.value,
1054
+ type: "number",
1055
+ inclusive: r.inclusive,
1056
+ exact: !1,
1057
+ message: r.message
1058
+ }), n.dirty()) : r.kind === "multipleOf" ? na(e.data, r.value) !== 0 && (s = this._getOrReturnCtx(e, s), u(s, {
1059
+ code: d.not_multiple_of,
1060
+ multipleOf: r.value,
1061
+ message: r.message
1062
+ }), n.dirty()) : r.kind === "finite" ? Number.isFinite(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
1063
+ code: d.not_finite,
1064
+ message: r.message
1065
+ }), n.dirty()) : S.assertNever(r);
1066
+ return { status: n.value, value: e.data };
1067
+ }
1068
+ gte(e, t) {
1069
+ return this.setLimit("min", e, !0, f.toString(t));
1070
+ }
1071
+ gt(e, t) {
1072
+ return this.setLimit("min", e, !1, f.toString(t));
1073
+ }
1074
+ lte(e, t) {
1075
+ return this.setLimit("max", e, !0, f.toString(t));
1076
+ }
1077
+ lt(e, t) {
1078
+ return this.setLimit("max", e, !1, f.toString(t));
1079
+ }
1080
+ setLimit(e, t, s, n) {
1081
+ return new U({
1082
+ ...this._def,
1083
+ checks: [
1084
+ ...this._def.checks,
1085
+ {
1086
+ kind: e,
1087
+ value: t,
1088
+ inclusive: s,
1089
+ message: f.toString(n)
1090
+ }
1091
+ ]
1092
+ });
1093
+ }
1094
+ _addCheck(e) {
1095
+ return new U({
1096
+ ...this._def,
1097
+ checks: [...this._def.checks, e]
1098
+ });
1099
+ }
1100
+ int(e) {
1101
+ return this._addCheck({
1102
+ kind: "int",
1103
+ message: f.toString(e)
1104
+ });
1105
+ }
1106
+ positive(e) {
1107
+ return this._addCheck({
1108
+ kind: "min",
1109
+ value: 0,
1110
+ inclusive: !1,
1111
+ message: f.toString(e)
1112
+ });
1113
+ }
1114
+ negative(e) {
1115
+ return this._addCheck({
1116
+ kind: "max",
1117
+ value: 0,
1118
+ inclusive: !1,
1119
+ message: f.toString(e)
1120
+ });
1121
+ }
1122
+ nonpositive(e) {
1123
+ return this._addCheck({
1124
+ kind: "max",
1125
+ value: 0,
1126
+ inclusive: !0,
1127
+ message: f.toString(e)
1128
+ });
1129
+ }
1130
+ nonnegative(e) {
1131
+ return this._addCheck({
1132
+ kind: "min",
1133
+ value: 0,
1134
+ inclusive: !0,
1135
+ message: f.toString(e)
1136
+ });
1137
+ }
1138
+ multipleOf(e, t) {
1139
+ return this._addCheck({
1140
+ kind: "multipleOf",
1141
+ value: e,
1142
+ message: f.toString(t)
1143
+ });
1144
+ }
1145
+ finite(e) {
1146
+ return this._addCheck({
1147
+ kind: "finite",
1148
+ message: f.toString(e)
1149
+ });
1150
+ }
1151
+ safe(e) {
1152
+ return this._addCheck({
1153
+ kind: "min",
1154
+ inclusive: !0,
1155
+ value: Number.MIN_SAFE_INTEGER,
1156
+ message: f.toString(e)
1157
+ })._addCheck({
1158
+ kind: "max",
1159
+ inclusive: !0,
1160
+ value: Number.MAX_SAFE_INTEGER,
1161
+ message: f.toString(e)
1162
+ });
1163
+ }
1164
+ get minValue() {
1165
+ let e = null;
1166
+ for (const t of this._def.checks)
1167
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1168
+ return e;
1169
+ }
1170
+ get maxValue() {
1171
+ let e = null;
1172
+ for (const t of this._def.checks)
1173
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1174
+ return e;
1175
+ }
1176
+ get isInt() {
1177
+ return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && S.isInteger(e.value));
1178
+ }
1179
+ get isFinite() {
1180
+ let e = null, t = null;
1181
+ for (const s of this._def.checks) {
1182
+ if (s.kind === "finite" || s.kind === "int" || s.kind === "multipleOf")
1183
+ return !0;
1184
+ s.kind === "min" ? (t === null || s.value > t) && (t = s.value) : s.kind === "max" && (e === null || s.value < e) && (e = s.value);
1185
+ }
1186
+ return Number.isFinite(t) && Number.isFinite(e);
1187
+ }
1188
+ }
1189
+ U.create = (a) => new U({
1190
+ checks: [],
1191
+ typeName: g.ZodNumber,
1192
+ coerce: a?.coerce || !1,
1193
+ ...x(a)
1194
+ });
1195
+ class K extends k {
1196
+ constructor() {
1197
+ super(...arguments), this.min = this.gte, this.max = this.lte;
1198
+ }
1199
+ _parse(e) {
1200
+ if (this._def.coerce)
1201
+ try {
1202
+ e.data = BigInt(e.data);
1203
+ } catch {
1204
+ return this._getInvalidInput(e);
1205
+ }
1206
+ if (this._getType(e) !== h.bigint)
1207
+ return this._getInvalidInput(e);
1208
+ let s;
1209
+ const n = new A();
1210
+ for (const r of this._def.checks)
1211
+ r.kind === "min" ? (r.inclusive ? e.data < r.value : e.data <= r.value) && (s = this._getOrReturnCtx(e, s), u(s, {
1212
+ code: d.too_small,
1213
+ type: "bigint",
1214
+ minimum: r.value,
1215
+ inclusive: r.inclusive,
1216
+ message: r.message
1217
+ }), n.dirty()) : r.kind === "max" ? (r.inclusive ? e.data > r.value : e.data >= r.value) && (s = this._getOrReturnCtx(e, s), u(s, {
1218
+ code: d.too_big,
1219
+ type: "bigint",
1220
+ maximum: r.value,
1221
+ inclusive: r.inclusive,
1222
+ message: r.message
1223
+ }), n.dirty()) : r.kind === "multipleOf" ? e.data % r.value !== BigInt(0) && (s = this._getOrReturnCtx(e, s), u(s, {
1224
+ code: d.not_multiple_of,
1225
+ multipleOf: r.value,
1226
+ message: r.message
1227
+ }), n.dirty()) : S.assertNever(r);
1228
+ return { status: n.value, value: e.data };
1229
+ }
1230
+ _getInvalidInput(e) {
1231
+ const t = this._getOrReturnCtx(e);
1232
+ return u(t, {
1233
+ code: d.invalid_type,
1234
+ expected: h.bigint,
1235
+ received: t.parsedType
1236
+ }), v;
1237
+ }
1238
+ gte(e, t) {
1239
+ return this.setLimit("min", e, !0, f.toString(t));
1240
+ }
1241
+ gt(e, t) {
1242
+ return this.setLimit("min", e, !1, f.toString(t));
1243
+ }
1244
+ lte(e, t) {
1245
+ return this.setLimit("max", e, !0, f.toString(t));
1246
+ }
1247
+ lt(e, t) {
1248
+ return this.setLimit("max", e, !1, f.toString(t));
1249
+ }
1250
+ setLimit(e, t, s, n) {
1251
+ return new K({
1252
+ ...this._def,
1253
+ checks: [
1254
+ ...this._def.checks,
1255
+ {
1256
+ kind: e,
1257
+ value: t,
1258
+ inclusive: s,
1259
+ message: f.toString(n)
1260
+ }
1261
+ ]
1262
+ });
1263
+ }
1264
+ _addCheck(e) {
1265
+ return new K({
1266
+ ...this._def,
1267
+ checks: [...this._def.checks, e]
1268
+ });
1269
+ }
1270
+ positive(e) {
1271
+ return this._addCheck({
1272
+ kind: "min",
1273
+ value: BigInt(0),
1274
+ inclusive: !1,
1275
+ message: f.toString(e)
1276
+ });
1277
+ }
1278
+ negative(e) {
1279
+ return this._addCheck({
1280
+ kind: "max",
1281
+ value: BigInt(0),
1282
+ inclusive: !1,
1283
+ message: f.toString(e)
1284
+ });
1285
+ }
1286
+ nonpositive(e) {
1287
+ return this._addCheck({
1288
+ kind: "max",
1289
+ value: BigInt(0),
1290
+ inclusive: !0,
1291
+ message: f.toString(e)
1292
+ });
1293
+ }
1294
+ nonnegative(e) {
1295
+ return this._addCheck({
1296
+ kind: "min",
1297
+ value: BigInt(0),
1298
+ inclusive: !0,
1299
+ message: f.toString(e)
1300
+ });
1301
+ }
1302
+ multipleOf(e, t) {
1303
+ return this._addCheck({
1304
+ kind: "multipleOf",
1305
+ value: e,
1306
+ message: f.toString(t)
1307
+ });
1308
+ }
1309
+ get minValue() {
1310
+ let e = null;
1311
+ for (const t of this._def.checks)
1312
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1313
+ return e;
1314
+ }
1315
+ get maxValue() {
1316
+ let e = null;
1317
+ for (const t of this._def.checks)
1318
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1319
+ return e;
1320
+ }
1321
+ }
1322
+ K.create = (a) => new K({
1323
+ checks: [],
1324
+ typeName: g.ZodBigInt,
1325
+ coerce: a?.coerce ?? !1,
1326
+ ...x(a)
1327
+ });
1328
+ class Ne extends k {
1329
+ _parse(e) {
1330
+ if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== h.boolean) {
1331
+ const s = this._getOrReturnCtx(e);
1332
+ return u(s, {
1333
+ code: d.invalid_type,
1334
+ expected: h.boolean,
1335
+ received: s.parsedType
1336
+ }), v;
1337
+ }
1338
+ return Z(e.data);
1339
+ }
1340
+ }
1341
+ Ne.create = (a) => new Ne({
1342
+ typeName: g.ZodBoolean,
1343
+ coerce: a?.coerce || !1,
1344
+ ...x(a)
1345
+ });
1346
+ class ye extends k {
1347
+ _parse(e) {
1348
+ if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== h.date) {
1349
+ const r = this._getOrReturnCtx(e);
1350
+ return u(r, {
1351
+ code: d.invalid_type,
1352
+ expected: h.date,
1353
+ received: r.parsedType
1354
+ }), v;
1355
+ }
1356
+ if (Number.isNaN(e.data.getTime())) {
1357
+ const r = this._getOrReturnCtx(e);
1358
+ return u(r, {
1359
+ code: d.invalid_date
1360
+ }), v;
1361
+ }
1362
+ const s = new A();
1363
+ let n;
1364
+ for (const r of this._def.checks)
1365
+ r.kind === "min" ? e.data.getTime() < r.value && (n = this._getOrReturnCtx(e, n), u(n, {
1366
+ code: d.too_small,
1367
+ message: r.message,
1368
+ inclusive: !0,
1369
+ exact: !1,
1370
+ minimum: r.value,
1371
+ type: "date"
1372
+ }), s.dirty()) : r.kind === "max" ? e.data.getTime() > r.value && (n = this._getOrReturnCtx(e, n), u(n, {
1373
+ code: d.too_big,
1374
+ message: r.message,
1375
+ inclusive: !0,
1376
+ exact: !1,
1377
+ maximum: r.value,
1378
+ type: "date"
1379
+ }), s.dirty()) : S.assertNever(r);
1380
+ return {
1381
+ status: s.value,
1382
+ value: new Date(e.data.getTime())
1383
+ };
1384
+ }
1385
+ _addCheck(e) {
1386
+ return new ye({
1387
+ ...this._def,
1388
+ checks: [...this._def.checks, e]
1389
+ });
1390
+ }
1391
+ min(e, t) {
1392
+ return this._addCheck({
1393
+ kind: "min",
1394
+ value: e.getTime(),
1395
+ message: f.toString(t)
1396
+ });
1397
+ }
1398
+ max(e, t) {
1399
+ return this._addCheck({
1400
+ kind: "max",
1401
+ value: e.getTime(),
1402
+ message: f.toString(t)
1403
+ });
1404
+ }
1405
+ get minDate() {
1406
+ let e = null;
1407
+ for (const t of this._def.checks)
1408
+ t.kind === "min" && (e === null || t.value > e) && (e = t.value);
1409
+ return e != null ? new Date(e) : null;
1410
+ }
1411
+ get maxDate() {
1412
+ let e = null;
1413
+ for (const t of this._def.checks)
1414
+ t.kind === "max" && (e === null || t.value < e) && (e = t.value);
1415
+ return e != null ? new Date(e) : null;
1416
+ }
1417
+ }
1418
+ ye.create = (a) => new ye({
1419
+ checks: [],
1420
+ coerce: a?.coerce || !1,
1421
+ typeName: g.ZodDate,
1422
+ ...x(a)
1423
+ });
1424
+ class et extends k {
1425
+ _parse(e) {
1426
+ if (this._getType(e) !== h.symbol) {
1427
+ const s = this._getOrReturnCtx(e);
1428
+ return u(s, {
1429
+ code: d.invalid_type,
1430
+ expected: h.symbol,
1431
+ received: s.parsedType
1432
+ }), v;
1433
+ }
1434
+ return Z(e.data);
1435
+ }
1436
+ }
1437
+ et.create = (a) => new et({
1438
+ typeName: g.ZodSymbol,
1439
+ ...x(a)
1440
+ });
1441
+ class Ze extends k {
1442
+ _parse(e) {
1443
+ if (this._getType(e) !== h.undefined) {
1444
+ const s = this._getOrReturnCtx(e);
1445
+ return u(s, {
1446
+ code: d.invalid_type,
1447
+ expected: h.undefined,
1448
+ received: s.parsedType
1449
+ }), v;
1450
+ }
1451
+ return Z(e.data);
1452
+ }
1453
+ }
1454
+ Ze.create = (a) => new Ze({
1455
+ typeName: g.ZodUndefined,
1456
+ ...x(a)
1457
+ });
1458
+ class tt extends k {
1459
+ _parse(e) {
1460
+ if (this._getType(e) !== h.null) {
1461
+ const s = this._getOrReturnCtx(e);
1462
+ return u(s, {
1463
+ code: d.invalid_type,
1464
+ expected: h.null,
1465
+ received: s.parsedType
1466
+ }), v;
1467
+ }
1468
+ return Z(e.data);
1469
+ }
1470
+ }
1471
+ tt.create = (a) => new tt({
1472
+ typeName: g.ZodNull,
1473
+ ...x(a)
1474
+ });
1475
+ class at extends k {
1476
+ constructor() {
1477
+ super(...arguments), this._any = !0;
1478
+ }
1479
+ _parse(e) {
1480
+ return Z(e.data);
1481
+ }
1482
+ }
1483
+ at.create = (a) => new at({
1484
+ typeName: g.ZodAny,
1485
+ ...x(a)
1486
+ });
1487
+ class st extends k {
1488
+ constructor() {
1489
+ super(...arguments), this._unknown = !0;
1490
+ }
1491
+ _parse(e) {
1492
+ return Z(e.data);
1493
+ }
1494
+ }
1495
+ st.create = (a) => new st({
1496
+ typeName: g.ZodUnknown,
1497
+ ...x(a)
1498
+ });
1499
+ class B extends k {
1500
+ _parse(e) {
1501
+ const t = this._getOrReturnCtx(e);
1502
+ return u(t, {
1503
+ code: d.invalid_type,
1504
+ expected: h.never,
1505
+ received: t.parsedType
1506
+ }), v;
1507
+ }
1508
+ }
1509
+ B.create = (a) => new B({
1510
+ typeName: g.ZodNever,
1511
+ ...x(a)
1512
+ });
1513
+ class nt extends k {
1514
+ _parse(e) {
1515
+ if (this._getType(e) !== h.undefined) {
1516
+ const s = this._getOrReturnCtx(e);
1517
+ return u(s, {
1518
+ code: d.invalid_type,
1519
+ expected: h.void,
1520
+ received: s.parsedType
1521
+ }), v;
1522
+ }
1523
+ return Z(e.data);
1524
+ }
1525
+ }
1526
+ nt.create = (a) => new nt({
1527
+ typeName: g.ZodVoid,
1528
+ ...x(a)
1529
+ });
1530
+ class j extends k {
1531
+ _parse(e) {
1532
+ const { ctx: t, status: s } = this._processInputParams(e), n = this._def;
1533
+ if (t.parsedType !== h.array)
1534
+ return u(t, {
1535
+ code: d.invalid_type,
1536
+ expected: h.array,
1537
+ received: t.parsedType
1538
+ }), v;
1539
+ if (n.exactLength !== null) {
1540
+ const i = t.data.length > n.exactLength.value, o = t.data.length < n.exactLength.value;
1541
+ (i || o) && (u(t, {
1542
+ code: i ? d.too_big : d.too_small,
1543
+ minimum: o ? n.exactLength.value : void 0,
1544
+ maximum: i ? n.exactLength.value : void 0,
1545
+ type: "array",
1546
+ inclusive: !0,
1547
+ exact: !0,
1548
+ message: n.exactLength.message
1549
+ }), s.dirty());
1550
+ }
1551
+ if (n.minLength !== null && t.data.length < n.minLength.value && (u(t, {
1552
+ code: d.too_small,
1553
+ minimum: n.minLength.value,
1554
+ type: "array",
1555
+ inclusive: !0,
1556
+ exact: !1,
1557
+ message: n.minLength.message
1558
+ }), s.dirty()), n.maxLength !== null && t.data.length > n.maxLength.value && (u(t, {
1559
+ code: d.too_big,
1560
+ maximum: n.maxLength.value,
1561
+ type: "array",
1562
+ inclusive: !0,
1563
+ exact: !1,
1564
+ message: n.maxLength.message
1565
+ }), s.dirty()), t.common.async)
1566
+ return Promise.all([...t.data].map((i, o) => n.type._parseAsync(new q(t, i, t.path, o)))).then((i) => A.mergeArray(s, i));
1567
+ const r = [...t.data].map((i, o) => n.type._parseSync(new q(t, i, t.path, o)));
1568
+ return A.mergeArray(s, r);
1569
+ }
1570
+ get element() {
1571
+ return this._def.type;
1572
+ }
1573
+ min(e, t) {
1574
+ return new j({
1575
+ ...this._def,
1576
+ minLength: { value: e, message: f.toString(t) }
1577
+ });
1578
+ }
1579
+ max(e, t) {
1580
+ return new j({
1581
+ ...this._def,
1582
+ maxLength: { value: e, message: f.toString(t) }
1583
+ });
1584
+ }
1585
+ length(e, t) {
1586
+ return new j({
1587
+ ...this._def,
1588
+ exactLength: { value: e, message: f.toString(t) }
1589
+ });
1590
+ }
1591
+ nonempty(e) {
1592
+ return this.min(1, e);
1593
+ }
1594
+ }
1595
+ j.create = (a, e) => new j({
1596
+ type: a,
1597
+ minLength: null,
1598
+ maxLength: null,
1599
+ exactLength: null,
1600
+ typeName: g.ZodArray,
1601
+ ...x(e)
1602
+ });
1603
+ function F(a) {
1604
+ if (a instanceof I) {
1605
+ const e = {};
1606
+ for (const t in a.shape) {
1607
+ const s = a.shape[t];
1608
+ e[t] = M.create(F(s));
1609
+ }
1610
+ return new I({
1611
+ ...a._def,
1612
+ shape: () => e
1613
+ });
1614
+ } else return a instanceof j ? new j({
1615
+ ...a._def,
1616
+ type: F(a.element)
1617
+ }) : a instanceof M ? M.create(F(a.unwrap())) : a instanceof J ? J.create(F(a.unwrap())) : a instanceof z ? z.create(a.items.map((e) => F(e))) : a;
1618
+ }
1619
+ class I extends k {
1620
+ constructor() {
1621
+ super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
1622
+ }
1623
+ _getCached() {
1624
+ if (this._cached !== null)
1625
+ return this._cached;
1626
+ const e = this._def.shape(), t = S.objectKeys(e);
1627
+ return this._cached = { shape: e, keys: t }, this._cached;
1628
+ }
1629
+ _parse(e) {
1630
+ if (this._getType(e) !== h.object) {
1631
+ const p = this._getOrReturnCtx(e);
1632
+ return u(p, {
1633
+ code: d.invalid_type,
1634
+ expected: h.object,
1635
+ received: p.parsedType
1636
+ }), v;
1637
+ }
1638
+ const { status: s, ctx: n } = this._processInputParams(e), { shape: r, keys: i } = this._getCached(), o = [];
1639
+ if (!(this._def.catchall instanceof B && this._def.unknownKeys === "strip"))
1640
+ for (const p in n.data)
1641
+ i.includes(p) || o.push(p);
1642
+ const m = [];
1643
+ for (const p of i) {
1644
+ const b = r[p], L = n.data[p];
1645
+ m.push({
1646
+ key: { status: "valid", value: p },
1647
+ value: b._parse(new q(n, L, n.path, p)),
1648
+ alwaysSet: p in n.data
1649
+ });
1650
+ }
1651
+ if (this._def.catchall instanceof B) {
1652
+ const p = this._def.unknownKeys;
1653
+ if (p === "passthrough")
1654
+ for (const b of o)
1655
+ m.push({
1656
+ key: { status: "valid", value: b },
1657
+ value: { status: "valid", value: n.data[b] }
1658
+ });
1659
+ else if (p === "strict")
1660
+ o.length > 0 && (u(n, {
1661
+ code: d.unrecognized_keys,
1662
+ keys: o
1663
+ }), s.dirty());
1664
+ else if (p !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
1665
+ } else {
1666
+ const p = this._def.catchall;
1667
+ for (const b of o) {
1668
+ const L = n.data[b];
1669
+ m.push({
1670
+ key: { status: "valid", value: b },
1671
+ value: p._parse(
1672
+ new q(n, L, n.path, b)
1673
+ //, ctx.child(key), value, getParsedType(value)
1674
+ ),
1675
+ alwaysSet: b in n.data
1676
+ });
1677
+ }
1678
+ }
1679
+ return n.common.async ? Promise.resolve().then(async () => {
1680
+ const p = [];
1681
+ for (const b of m) {
1682
+ const L = await b.key, Te = await b.value;
1683
+ p.push({
1684
+ key: L,
1685
+ value: Te,
1686
+ alwaysSet: b.alwaysSet
1687
+ });
1688
+ }
1689
+ return p;
1690
+ }).then((p) => A.mergeObjectSync(s, p)) : A.mergeObjectSync(s, m);
1691
+ }
1692
+ get shape() {
1693
+ return this._def.shape();
1694
+ }
1695
+ strict(e) {
1696
+ return f.errToObj, new I({
1697
+ ...this._def,
1698
+ unknownKeys: "strict",
1699
+ ...e !== void 0 ? {
1700
+ errorMap: (t, s) => {
1701
+ const n = this._def.errorMap?.(t, s).message ?? s.defaultError;
1702
+ return t.code === "unrecognized_keys" ? {
1703
+ message: f.errToObj(e).message ?? n
1704
+ } : {
1705
+ message: n
1706
+ };
1707
+ }
1708
+ } : {}
1709
+ });
1710
+ }
1711
+ strip() {
1712
+ return new I({
1713
+ ...this._def,
1714
+ unknownKeys: "strip"
1715
+ });
1716
+ }
1717
+ passthrough() {
1718
+ return new I({
1719
+ ...this._def,
1720
+ unknownKeys: "passthrough"
1721
+ });
1722
+ }
1723
+ // const AugmentFactory =
1724
+ // <Def extends ZodObjectDef>(def: Def) =>
1725
+ // <Augmentation extends ZodRawShape>(
1726
+ // augmentation: Augmentation
1727
+ // ): ZodObject<
1728
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
1729
+ // Def["unknownKeys"],
1730
+ // Def["catchall"]
1731
+ // > => {
1732
+ // return new ZodObject({
1733
+ // ...def,
1734
+ // shape: () => ({
1735
+ // ...def.shape(),
1736
+ // ...augmentation,
1737
+ // }),
1738
+ // }) as any;
1739
+ // };
1740
+ extend(e) {
1741
+ return new I({
1742
+ ...this._def,
1743
+ shape: () => ({
1744
+ ...this._def.shape(),
1745
+ ...e
1746
+ })
1747
+ });
1748
+ }
1749
+ /**
1750
+ * Prior to zod@1.0.12 there was a bug in the
1751
+ * inferred type of merged objects. Please
1752
+ * upgrade if you are experiencing issues.
1753
+ */
1754
+ merge(e) {
1755
+ return new I({
1756
+ unknownKeys: e._def.unknownKeys,
1757
+ catchall: e._def.catchall,
1758
+ shape: () => ({
1759
+ ...this._def.shape(),
1760
+ ...e._def.shape()
1761
+ }),
1762
+ typeName: g.ZodObject
1763
+ });
1764
+ }
1765
+ // merge<
1766
+ // Incoming extends AnyZodObject,
1767
+ // Augmentation extends Incoming["shape"],
1768
+ // NewOutput extends {
1769
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
1770
+ // ? Augmentation[k]["_output"]
1771
+ // : k extends keyof Output
1772
+ // ? Output[k]
1773
+ // : never;
1774
+ // },
1775
+ // NewInput extends {
1776
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
1777
+ // ? Augmentation[k]["_input"]
1778
+ // : k extends keyof Input
1779
+ // ? Input[k]
1780
+ // : never;
1781
+ // }
1782
+ // >(
1783
+ // merging: Incoming
1784
+ // ): ZodObject<
1785
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1786
+ // Incoming["_def"]["unknownKeys"],
1787
+ // Incoming["_def"]["catchall"],
1788
+ // NewOutput,
1789
+ // NewInput
1790
+ // > {
1791
+ // const merged: any = new ZodObject({
1792
+ // unknownKeys: merging._def.unknownKeys,
1793
+ // catchall: merging._def.catchall,
1794
+ // shape: () =>
1795
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1796
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1797
+ // }) as any;
1798
+ // return merged;
1799
+ // }
1800
+ setKey(e, t) {
1801
+ return this.augment({ [e]: t });
1802
+ }
1803
+ // merge<Incoming extends AnyZodObject>(
1804
+ // merging: Incoming
1805
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
1806
+ // ZodObject<
1807
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
1808
+ // Incoming["_def"]["unknownKeys"],
1809
+ // Incoming["_def"]["catchall"]
1810
+ // > {
1811
+ // // const mergedShape = objectUtil.mergeShapes(
1812
+ // // this._def.shape(),
1813
+ // // merging._def.shape()
1814
+ // // );
1815
+ // const merged: any = new ZodObject({
1816
+ // unknownKeys: merging._def.unknownKeys,
1817
+ // catchall: merging._def.catchall,
1818
+ // shape: () =>
1819
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
1820
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
1821
+ // }) as any;
1822
+ // return merged;
1823
+ // }
1824
+ catchall(e) {
1825
+ return new I({
1826
+ ...this._def,
1827
+ catchall: e
1828
+ });
1829
+ }
1830
+ pick(e) {
1831
+ const t = {};
1832
+ for (const s of S.objectKeys(e))
1833
+ e[s] && this.shape[s] && (t[s] = this.shape[s]);
1834
+ return new I({
1835
+ ...this._def,
1836
+ shape: () => t
1837
+ });
1838
+ }
1839
+ omit(e) {
1840
+ const t = {};
1841
+ for (const s of S.objectKeys(this.shape))
1842
+ e[s] || (t[s] = this.shape[s]);
1843
+ return new I({
1844
+ ...this._def,
1845
+ shape: () => t
1846
+ });
1847
+ }
1848
+ /**
1849
+ * @deprecated
1850
+ */
1851
+ deepPartial() {
1852
+ return F(this);
1853
+ }
1854
+ partial(e) {
1855
+ const t = {};
1856
+ for (const s of S.objectKeys(this.shape)) {
1857
+ const n = this.shape[s];
1858
+ e && !e[s] ? t[s] = n : t[s] = n.optional();
1859
+ }
1860
+ return new I({
1861
+ ...this._def,
1862
+ shape: () => t
1863
+ });
1864
+ }
1865
+ required(e) {
1866
+ const t = {};
1867
+ for (const s of S.objectKeys(this.shape))
1868
+ if (e && !e[s])
1869
+ t[s] = this.shape[s];
1870
+ else {
1871
+ let r = this.shape[s];
1872
+ for (; r instanceof M; )
1873
+ r = r._def.innerType;
1874
+ t[s] = r;
1875
+ }
1876
+ return new I({
1877
+ ...this._def,
1878
+ shape: () => t
1879
+ });
1880
+ }
1881
+ keyof() {
1882
+ return mt(S.objectKeys(this.shape));
1883
+ }
1884
+ }
1885
+ I.create = (a, e) => new I({
1886
+ shape: () => a,
1887
+ unknownKeys: "strip",
1888
+ catchall: B.create(),
1889
+ typeName: g.ZodObject,
1890
+ ...x(e)
1891
+ });
1892
+ I.strictCreate = (a, e) => new I({
1893
+ shape: () => a,
1894
+ unknownKeys: "strict",
1895
+ catchall: B.create(),
1896
+ typeName: g.ZodObject,
1897
+ ...x(e)
1898
+ });
1899
+ I.lazycreate = (a, e) => new I({
1900
+ shape: a,
1901
+ unknownKeys: "strip",
1902
+ catchall: B.create(),
1903
+ typeName: g.ZodObject,
1904
+ ...x(e)
1905
+ });
1906
+ class ge extends k {
1907
+ _parse(e) {
1908
+ const { ctx: t } = this._processInputParams(e), s = this._def.options;
1909
+ function n(r) {
1910
+ for (const o of r)
1911
+ if (o.result.status === "valid")
1912
+ return o.result;
1913
+ for (const o of r)
1914
+ if (o.result.status === "dirty")
1915
+ return t.common.issues.push(...o.ctx.common.issues), o.result;
1916
+ const i = r.map((o) => new V(o.ctx.common.issues));
1917
+ return u(t, {
1918
+ code: d.invalid_union,
1919
+ unionErrors: i
1920
+ }), v;
1921
+ }
1922
+ if (t.common.async)
1923
+ return Promise.all(s.map(async (r) => {
1924
+ const i = {
1925
+ ...t,
1926
+ common: {
1927
+ ...t.common,
1928
+ issues: []
1929
+ },
1930
+ parent: null
1931
+ };
1932
+ return {
1933
+ result: await r._parseAsync({
1934
+ data: t.data,
1935
+ path: t.path,
1936
+ parent: i
1937
+ }),
1938
+ ctx: i
1939
+ };
1940
+ })).then(n);
1941
+ {
1942
+ let r;
1943
+ const i = [];
1944
+ for (const m of s) {
1945
+ const p = {
1946
+ ...t,
1947
+ common: {
1948
+ ...t.common,
1949
+ issues: []
1950
+ },
1951
+ parent: null
1952
+ }, b = m._parseSync({
1953
+ data: t.data,
1954
+ path: t.path,
1955
+ parent: p
1956
+ });
1957
+ if (b.status === "valid")
1958
+ return b;
1959
+ b.status === "dirty" && !r && (r = { result: b, ctx: p }), p.common.issues.length && i.push(p.common.issues);
1960
+ }
1961
+ if (r)
1962
+ return t.common.issues.push(...r.ctx.common.issues), r.result;
1963
+ const o = i.map((m) => new V(m));
1964
+ return u(t, {
1965
+ code: d.invalid_union,
1966
+ unionErrors: o
1967
+ }), v;
1968
+ }
1969
+ }
1970
+ get options() {
1971
+ return this._def.options;
1972
+ }
1973
+ }
1974
+ ge.create = (a, e) => new ge({
1975
+ options: a,
1976
+ typeName: g.ZodUnion,
1977
+ ...x(e)
1978
+ });
1979
+ function Ee(a, e) {
1980
+ const t = D(a), s = D(e);
1981
+ if (a === e)
1982
+ return { valid: !0, data: a };
1983
+ if (t === h.object && s === h.object) {
1984
+ const n = S.objectKeys(e), r = S.objectKeys(a).filter((o) => n.indexOf(o) !== -1), i = { ...a, ...e };
1985
+ for (const o of r) {
1986
+ const m = Ee(a[o], e[o]);
1987
+ if (!m.valid)
1988
+ return { valid: !1 };
1989
+ i[o] = m.data;
1990
+ }
1991
+ return { valid: !0, data: i };
1992
+ } else if (t === h.array && s === h.array) {
1993
+ if (a.length !== e.length)
1994
+ return { valid: !1 };
1995
+ const n = [];
1996
+ for (let r = 0; r < a.length; r++) {
1997
+ const i = a[r], o = e[r], m = Ee(i, o);
1998
+ if (!m.valid)
1999
+ return { valid: !1 };
2000
+ n.push(m.data);
2001
+ }
2002
+ return { valid: !0, data: n };
2003
+ } else return t === h.date && s === h.date && +a == +e ? { valid: !0, data: a } : { valid: !1 };
2004
+ }
2005
+ class ve extends k {
2006
+ _parse(e) {
2007
+ const { status: t, ctx: s } = this._processInputParams(e), n = (r, i) => {
2008
+ if (Xe(r) || Xe(i))
2009
+ return v;
2010
+ const o = Ee(r.value, i.value);
2011
+ return o.valid ? ((Qe(r) || Qe(i)) && t.dirty(), { status: t.value, value: o.data }) : (u(s, {
2012
+ code: d.invalid_intersection_types
2013
+ }), v);
2014
+ };
2015
+ return s.common.async ? Promise.all([
2016
+ this._def.left._parseAsync({
2017
+ data: s.data,
2018
+ path: s.path,
2019
+ parent: s
2020
+ }),
2021
+ this._def.right._parseAsync({
2022
+ data: s.data,
2023
+ path: s.path,
2024
+ parent: s
2025
+ })
2026
+ ]).then(([r, i]) => n(r, i)) : n(this._def.left._parseSync({
2027
+ data: s.data,
2028
+ path: s.path,
2029
+ parent: s
2030
+ }), this._def.right._parseSync({
2031
+ data: s.data,
2032
+ path: s.path,
2033
+ parent: s
2034
+ }));
2035
+ }
2036
+ }
2037
+ ve.create = (a, e, t) => new ve({
2038
+ left: a,
2039
+ right: e,
2040
+ typeName: g.ZodIntersection,
2041
+ ...x(t)
2042
+ });
2043
+ class z extends k {
2044
+ _parse(e) {
2045
+ const { status: t, ctx: s } = this._processInputParams(e);
2046
+ if (s.parsedType !== h.array)
2047
+ return u(s, {
2048
+ code: d.invalid_type,
2049
+ expected: h.array,
2050
+ received: s.parsedType
2051
+ }), v;
2052
+ if (s.data.length < this._def.items.length)
2053
+ return u(s, {
2054
+ code: d.too_small,
2055
+ minimum: this._def.items.length,
2056
+ inclusive: !0,
2057
+ exact: !1,
2058
+ type: "array"
2059
+ }), v;
2060
+ !this._def.rest && s.data.length > this._def.items.length && (u(s, {
2061
+ code: d.too_big,
2062
+ maximum: this._def.items.length,
2063
+ inclusive: !0,
2064
+ exact: !1,
2065
+ type: "array"
2066
+ }), t.dirty());
2067
+ const r = [...s.data].map((i, o) => {
2068
+ const m = this._def.items[o] || this._def.rest;
2069
+ return m ? m._parse(new q(s, i, s.path, o)) : null;
2070
+ }).filter((i) => !!i);
2071
+ return s.common.async ? Promise.all(r).then((i) => A.mergeArray(t, i)) : A.mergeArray(t, r);
2072
+ }
2073
+ get items() {
2074
+ return this._def.items;
2075
+ }
2076
+ rest(e) {
2077
+ return new z({
2078
+ ...this._def,
2079
+ rest: e
2080
+ });
2081
+ }
2082
+ }
2083
+ z.create = (a, e) => {
2084
+ if (!Array.isArray(a))
2085
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2086
+ return new z({
2087
+ items: a,
2088
+ typeName: g.ZodTuple,
2089
+ rest: null,
2090
+ ...x(e)
2091
+ });
2092
+ };
2093
+ class _e extends k {
2094
+ get keySchema() {
2095
+ return this._def.keyType;
2096
+ }
2097
+ get valueSchema() {
2098
+ return this._def.valueType;
2099
+ }
2100
+ _parse(e) {
2101
+ const { status: t, ctx: s } = this._processInputParams(e);
2102
+ if (s.parsedType !== h.object)
2103
+ return u(s, {
2104
+ code: d.invalid_type,
2105
+ expected: h.object,
2106
+ received: s.parsedType
2107
+ }), v;
2108
+ const n = [], r = this._def.keyType, i = this._def.valueType;
2109
+ for (const o in s.data)
2110
+ n.push({
2111
+ key: r._parse(new q(s, o, s.path, o)),
2112
+ value: i._parse(new q(s, s.data[o], s.path, o)),
2113
+ alwaysSet: o in s.data
2114
+ });
2115
+ return s.common.async ? A.mergeObjectAsync(t, n) : A.mergeObjectSync(t, n);
2116
+ }
2117
+ get element() {
2118
+ return this._def.valueType;
2119
+ }
2120
+ static create(e, t, s) {
2121
+ return t instanceof k ? new _e({
2122
+ keyType: e,
2123
+ valueType: t,
2124
+ typeName: g.ZodRecord,
2125
+ ...x(s)
2126
+ }) : new _e({
2127
+ keyType: $.create(),
2128
+ valueType: e,
2129
+ typeName: g.ZodRecord,
2130
+ ...x(t)
2131
+ });
2132
+ }
2133
+ }
2134
+ class rt extends k {
2135
+ get keySchema() {
2136
+ return this._def.keyType;
2137
+ }
2138
+ get valueSchema() {
2139
+ return this._def.valueType;
2140
+ }
2141
+ _parse(e) {
2142
+ const { status: t, ctx: s } = this._processInputParams(e);
2143
+ if (s.parsedType !== h.map)
2144
+ return u(s, {
2145
+ code: d.invalid_type,
2146
+ expected: h.map,
2147
+ received: s.parsedType
2148
+ }), v;
2149
+ const n = this._def.keyType, r = this._def.valueType, i = [...s.data.entries()].map(([o, m], p) => ({
2150
+ key: n._parse(new q(s, o, s.path, [p, "key"])),
2151
+ value: r._parse(new q(s, m, s.path, [p, "value"]))
2152
+ }));
2153
+ if (s.common.async) {
2154
+ const o = /* @__PURE__ */ new Map();
2155
+ return Promise.resolve().then(async () => {
2156
+ for (const m of i) {
2157
+ const p = await m.key, b = await m.value;
2158
+ if (p.status === "aborted" || b.status === "aborted")
2159
+ return v;
2160
+ (p.status === "dirty" || b.status === "dirty") && t.dirty(), o.set(p.value, b.value);
2161
+ }
2162
+ return { status: t.value, value: o };
2163
+ });
2164
+ } else {
2165
+ const o = /* @__PURE__ */ new Map();
2166
+ for (const m of i) {
2167
+ const p = m.key, b = m.value;
2168
+ if (p.status === "aborted" || b.status === "aborted")
2169
+ return v;
2170
+ (p.status === "dirty" || b.status === "dirty") && t.dirty(), o.set(p.value, b.value);
2171
+ }
2172
+ return { status: t.value, value: o };
2173
+ }
2174
+ }
2175
+ }
2176
+ rt.create = (a, e, t) => new rt({
2177
+ valueType: e,
2178
+ keyType: a,
2179
+ typeName: g.ZodMap,
2180
+ ...x(t)
2181
+ });
2182
+ class ee extends k {
2183
+ _parse(e) {
2184
+ const { status: t, ctx: s } = this._processInputParams(e);
2185
+ if (s.parsedType !== h.set)
2186
+ return u(s, {
2187
+ code: d.invalid_type,
2188
+ expected: h.set,
2189
+ received: s.parsedType
2190
+ }), v;
2191
+ const n = this._def;
2192
+ n.minSize !== null && s.data.size < n.minSize.value && (u(s, {
2193
+ code: d.too_small,
2194
+ minimum: n.minSize.value,
2195
+ type: "set",
2196
+ inclusive: !0,
2197
+ exact: !1,
2198
+ message: n.minSize.message
2199
+ }), t.dirty()), n.maxSize !== null && s.data.size > n.maxSize.value && (u(s, {
2200
+ code: d.too_big,
2201
+ maximum: n.maxSize.value,
2202
+ type: "set",
2203
+ inclusive: !0,
2204
+ exact: !1,
2205
+ message: n.maxSize.message
2206
+ }), t.dirty());
2207
+ const r = this._def.valueType;
2208
+ function i(m) {
2209
+ const p = /* @__PURE__ */ new Set();
2210
+ for (const b of m) {
2211
+ if (b.status === "aborted")
2212
+ return v;
2213
+ b.status === "dirty" && t.dirty(), p.add(b.value);
2214
+ }
2215
+ return { status: t.value, value: p };
2216
+ }
2217
+ const o = [...s.data.values()].map((m, p) => r._parse(new q(s, m, s.path, p)));
2218
+ return s.common.async ? Promise.all(o).then((m) => i(m)) : i(o);
2219
+ }
2220
+ min(e, t) {
2221
+ return new ee({
2222
+ ...this._def,
2223
+ minSize: { value: e, message: f.toString(t) }
2224
+ });
2225
+ }
2226
+ max(e, t) {
2227
+ return new ee({
2228
+ ...this._def,
2229
+ maxSize: { value: e, message: f.toString(t) }
2230
+ });
2231
+ }
2232
+ size(e, t) {
2233
+ return this.min(e, t).max(e, t);
2234
+ }
2235
+ nonempty(e) {
2236
+ return this.min(1, e);
2237
+ }
2238
+ }
2239
+ ee.create = (a, e) => new ee({
2240
+ valueType: a,
2241
+ minSize: null,
2242
+ maxSize: null,
2243
+ typeName: g.ZodSet,
2244
+ ...x(e)
2245
+ });
2246
+ class it extends k {
2247
+ get schema() {
2248
+ return this._def.getter();
2249
+ }
2250
+ _parse(e) {
2251
+ const { ctx: t } = this._processInputParams(e);
2252
+ return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
2253
+ }
2254
+ }
2255
+ it.create = (a, e) => new it({
2256
+ getter: a,
2257
+ typeName: g.ZodLazy,
2258
+ ...x(e)
2259
+ });
2260
+ class je extends k {
2261
+ _parse(e) {
2262
+ if (e.data !== this._def.value) {
2263
+ const t = this._getOrReturnCtx(e);
2264
+ return u(t, {
2265
+ received: t.data,
2266
+ code: d.invalid_literal,
2267
+ expected: this._def.value
2268
+ }), v;
2269
+ }
2270
+ return { status: "valid", value: e.data };
2271
+ }
2272
+ get value() {
2273
+ return this._def.value;
2274
+ }
2275
+ }
2276
+ je.create = (a, e) => new je({
2277
+ value: a,
2278
+ typeName: g.ZodLiteral,
2279
+ ...x(e)
2280
+ });
2281
+ function mt(a, e) {
2282
+ return new G({
2283
+ values: a,
2284
+ typeName: g.ZodEnum,
2285
+ ...x(e)
2286
+ });
2287
+ }
2288
+ class G extends k {
2289
+ _parse(e) {
2290
+ if (typeof e.data != "string") {
2291
+ const t = this._getOrReturnCtx(e), s = this._def.values;
2292
+ return u(t, {
2293
+ expected: S.joinValues(s),
2294
+ received: t.parsedType,
2295
+ code: d.invalid_type
2296
+ }), v;
2297
+ }
2298
+ if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
2299
+ const t = this._getOrReturnCtx(e), s = this._def.values;
2300
+ return u(t, {
2301
+ received: t.data,
2302
+ code: d.invalid_enum_value,
2303
+ options: s
2304
+ }), v;
2305
+ }
2306
+ return Z(e.data);
2307
+ }
2308
+ get options() {
2309
+ return this._def.values;
2310
+ }
2311
+ get enum() {
2312
+ const e = {};
2313
+ for (const t of this._def.values)
2314
+ e[t] = t;
2315
+ return e;
2316
+ }
2317
+ get Values() {
2318
+ const e = {};
2319
+ for (const t of this._def.values)
2320
+ e[t] = t;
2321
+ return e;
2322
+ }
2323
+ get Enum() {
2324
+ const e = {};
2325
+ for (const t of this._def.values)
2326
+ e[t] = t;
2327
+ return e;
2328
+ }
2329
+ extract(e, t = this._def) {
2330
+ return G.create(e, {
2331
+ ...this._def,
2332
+ ...t
2333
+ });
2334
+ }
2335
+ exclude(e, t = this._def) {
2336
+ return G.create(this.options.filter((s) => !e.includes(s)), {
2337
+ ...this._def,
2338
+ ...t
2339
+ });
2340
+ }
2341
+ }
2342
+ G.create = mt;
2343
+ class ot extends k {
2344
+ _parse(e) {
2345
+ const t = S.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
2346
+ if (s.parsedType !== h.string && s.parsedType !== h.number) {
2347
+ const n = S.objectValues(t);
2348
+ return u(s, {
2349
+ expected: S.joinValues(n),
2350
+ received: s.parsedType,
2351
+ code: d.invalid_type
2352
+ }), v;
2353
+ }
2354
+ if (this._cache || (this._cache = new Set(S.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
2355
+ const n = S.objectValues(t);
2356
+ return u(s, {
2357
+ received: s.data,
2358
+ code: d.invalid_enum_value,
2359
+ options: n
2360
+ }), v;
2361
+ }
2362
+ return Z(e.data);
2363
+ }
2364
+ get enum() {
2365
+ return this._def.values;
2366
+ }
2367
+ }
2368
+ ot.create = (a, e) => new ot({
2369
+ values: a,
2370
+ typeName: g.ZodNativeEnum,
2371
+ ...x(e)
2372
+ });
2373
+ class xe extends k {
2374
+ unwrap() {
2375
+ return this._def.type;
2376
+ }
2377
+ _parse(e) {
2378
+ const { ctx: t } = this._processInputParams(e);
2379
+ if (t.parsedType !== h.promise && t.common.async === !1)
2380
+ return u(t, {
2381
+ code: d.invalid_type,
2382
+ expected: h.promise,
2383
+ received: t.parsedType
2384
+ }), v;
2385
+ const s = t.parsedType === h.promise ? t.data : Promise.resolve(t.data);
2386
+ return Z(s.then((n) => this._def.type.parseAsync(n, {
2387
+ path: t.path,
2388
+ errorMap: t.common.contextualErrorMap
2389
+ })));
2390
+ }
2391
+ }
2392
+ xe.create = (a, e) => new xe({
2393
+ type: a,
2394
+ typeName: g.ZodPromise,
2395
+ ...x(e)
2396
+ });
2397
+ class H extends k {
2398
+ innerType() {
2399
+ return this._def.schema;
2400
+ }
2401
+ sourceType() {
2402
+ return this._def.schema._def.typeName === g.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
2403
+ }
2404
+ _parse(e) {
2405
+ const { status: t, ctx: s } = this._processInputParams(e), n = this._def.effect || null, r = {
2406
+ addIssue: (i) => {
2407
+ u(s, i), i.fatal ? t.abort() : t.dirty();
2408
+ },
2409
+ get path() {
2410
+ return s.path;
2411
+ }
2412
+ };
2413
+ if (r.addIssue = r.addIssue.bind(r), n.type === "preprocess") {
2414
+ const i = n.transform(s.data, r);
2415
+ if (s.common.async)
2416
+ return Promise.resolve(i).then(async (o) => {
2417
+ if (t.value === "aborted")
2418
+ return v;
2419
+ const m = await this._def.schema._parseAsync({
2420
+ data: o,
2421
+ path: s.path,
2422
+ parent: s
2423
+ });
2424
+ return m.status === "aborted" ? v : m.status === "dirty" || t.value === "dirty" ? Q(m.value) : m;
2425
+ });
2426
+ {
2427
+ if (t.value === "aborted")
2428
+ return v;
2429
+ const o = this._def.schema._parseSync({
2430
+ data: i,
2431
+ path: s.path,
2432
+ parent: s
2433
+ });
2434
+ return o.status === "aborted" ? v : o.status === "dirty" || t.value === "dirty" ? Q(o.value) : o;
2435
+ }
2436
+ }
2437
+ if (n.type === "refinement") {
2438
+ const i = (o) => {
2439
+ const m = n.refinement(o, r);
2440
+ if (s.common.async)
2441
+ return Promise.resolve(m);
2442
+ if (m instanceof Promise)
2443
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
2444
+ return o;
2445
+ };
2446
+ if (s.common.async === !1) {
2447
+ const o = this._def.schema._parseSync({
2448
+ data: s.data,
2449
+ path: s.path,
2450
+ parent: s
2451
+ });
2452
+ return o.status === "aborted" ? v : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
2453
+ } else
2454
+ return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ? v : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
2455
+ }
2456
+ if (n.type === "transform")
2457
+ if (s.common.async === !1) {
2458
+ const i = this._def.schema._parseSync({
2459
+ data: s.data,
2460
+ path: s.path,
2461
+ parent: s
2462
+ });
2463
+ if (!W(i))
2464
+ return v;
2465
+ const o = n.transform(i.value, r);
2466
+ if (o instanceof Promise)
2467
+ throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
2468
+ return { status: t.value, value: o };
2469
+ } else
2470
+ return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => W(i) ? Promise.resolve(n.transform(i.value, r)).then((o) => ({
2471
+ status: t.value,
2472
+ value: o
2473
+ })) : v);
2474
+ S.assertNever(n);
2475
+ }
2476
+ }
2477
+ H.create = (a, e, t) => new H({
2478
+ schema: a,
2479
+ typeName: g.ZodEffects,
2480
+ effect: e,
2481
+ ...x(t)
2482
+ });
2483
+ H.createWithPreprocess = (a, e, t) => new H({
2484
+ schema: e,
2485
+ effect: { type: "preprocess", transform: a },
2486
+ typeName: g.ZodEffects,
2487
+ ...x(t)
2488
+ });
2489
+ class M extends k {
2490
+ _parse(e) {
2491
+ return this._getType(e) === h.undefined ? Z(void 0) : this._def.innerType._parse(e);
2492
+ }
2493
+ unwrap() {
2494
+ return this._def.innerType;
2495
+ }
2496
+ }
2497
+ M.create = (a, e) => new M({
2498
+ innerType: a,
2499
+ typeName: g.ZodOptional,
2500
+ ...x(e)
2501
+ });
2502
+ class J extends k {
2503
+ _parse(e) {
2504
+ return this._getType(e) === h.null ? Z(null) : this._def.innerType._parse(e);
2505
+ }
2506
+ unwrap() {
2507
+ return this._def.innerType;
2508
+ }
2509
+ }
2510
+ J.create = (a, e) => new J({
2511
+ innerType: a,
2512
+ typeName: g.ZodNullable,
2513
+ ...x(e)
2514
+ });
2515
+ class qe extends k {
2516
+ _parse(e) {
2517
+ const { ctx: t } = this._processInputParams(e);
2518
+ let s = t.data;
2519
+ return t.parsedType === h.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
2520
+ data: s,
2521
+ path: t.path,
2522
+ parent: t
2523
+ });
2524
+ }
2525
+ removeDefault() {
2526
+ return this._def.innerType;
2527
+ }
2528
+ }
2529
+ qe.create = (a, e) => new qe({
2530
+ innerType: a,
2531
+ typeName: g.ZodDefault,
2532
+ defaultValue: typeof e.default == "function" ? e.default : () => e.default,
2533
+ ...x(e)
2534
+ });
2535
+ class $e extends k {
2536
+ _parse(e) {
2537
+ const { ctx: t } = this._processInputParams(e), s = {
2538
+ ...t,
2539
+ common: {
2540
+ ...t.common,
2541
+ issues: []
2542
+ }
2543
+ }, n = this._def.innerType._parse({
2544
+ data: s.data,
2545
+ path: s.path,
2546
+ parent: {
2547
+ ...s
2548
+ }
2549
+ });
2550
+ return pe(n) ? n.then((r) => ({
2551
+ status: "valid",
2552
+ value: r.status === "valid" ? r.value : this._def.catchValue({
2553
+ get error() {
2554
+ return new V(s.common.issues);
2555
+ },
2556
+ input: s.data
2557
+ })
2558
+ })) : {
2559
+ status: "valid",
2560
+ value: n.status === "valid" ? n.value : this._def.catchValue({
2561
+ get error() {
2562
+ return new V(s.common.issues);
2563
+ },
2564
+ input: s.data
2565
+ })
2566
+ };
2567
+ }
2568
+ removeCatch() {
2569
+ return this._def.innerType;
2570
+ }
2571
+ }
2572
+ $e.create = (a, e) => new $e({
2573
+ innerType: a,
2574
+ typeName: g.ZodCatch,
2575
+ catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
2576
+ ...x(e)
2577
+ });
2578
+ class ct extends k {
2579
+ _parse(e) {
2580
+ if (this._getType(e) !== h.nan) {
2581
+ const s = this._getOrReturnCtx(e);
2582
+ return u(s, {
2583
+ code: d.invalid_type,
2584
+ expected: h.nan,
2585
+ received: s.parsedType
2586
+ }), v;
2587
+ }
2588
+ return { status: "valid", value: e.data };
2589
+ }
2590
+ }
2591
+ ct.create = (a) => new ct({
2592
+ typeName: g.ZodNaN,
2593
+ ...x(a)
2594
+ });
2595
+ class ra extends k {
2596
+ _parse(e) {
2597
+ const { ctx: t } = this._processInputParams(e), s = t.data;
2598
+ return this._def.type._parse({
2599
+ data: s,
2600
+ path: t.path,
2601
+ parent: t
2602
+ });
2603
+ }
2604
+ unwrap() {
2605
+ return this._def.type;
2606
+ }
2607
+ }
2608
+ class Me extends k {
2609
+ _parse(e) {
2610
+ const { status: t, ctx: s } = this._processInputParams(e);
2611
+ if (s.common.async)
2612
+ return (async () => {
2613
+ const r = await this._def.in._parseAsync({
2614
+ data: s.data,
2615
+ path: s.path,
2616
+ parent: s
2617
+ });
2618
+ return r.status === "aborted" ? v : r.status === "dirty" ? (t.dirty(), Q(r.value)) : this._def.out._parseAsync({
2619
+ data: r.value,
2620
+ path: s.path,
2621
+ parent: s
2622
+ });
2623
+ })();
2624
+ {
2625
+ const n = this._def.in._parseSync({
2626
+ data: s.data,
2627
+ path: s.path,
2628
+ parent: s
2629
+ });
2630
+ return n.status === "aborted" ? v : n.status === "dirty" ? (t.dirty(), {
2631
+ status: "dirty",
2632
+ value: n.value
2633
+ }) : this._def.out._parseSync({
2634
+ data: n.value,
2635
+ path: s.path,
2636
+ parent: s
2637
+ });
2638
+ }
2639
+ }
2640
+ static create(e, t) {
2641
+ return new Me({
2642
+ in: e,
2643
+ out: t,
2644
+ typeName: g.ZodPipeline
2645
+ });
2646
+ }
2647
+ }
2648
+ class Ve extends k {
2649
+ _parse(e) {
2650
+ const t = this._def.innerType._parse(e), s = (n) => (W(n) && (n.value = Object.freeze(n.value)), n);
2651
+ return pe(t) ? t.then((n) => s(n)) : s(t);
2652
+ }
2653
+ unwrap() {
2654
+ return this._def.innerType;
2655
+ }
2656
+ }
2657
+ Ve.create = (a, e) => new Ve({
2658
+ innerType: a,
2659
+ typeName: g.ZodReadonly,
2660
+ ...x(e)
2661
+ });
2662
+ var g;
2663
+ (function(a) {
2664
+ a.ZodString = "ZodString", a.ZodNumber = "ZodNumber", a.ZodNaN = "ZodNaN", a.ZodBigInt = "ZodBigInt", a.ZodBoolean = "ZodBoolean", a.ZodDate = "ZodDate", a.ZodSymbol = "ZodSymbol", a.ZodUndefined = "ZodUndefined", a.ZodNull = "ZodNull", a.ZodAny = "ZodAny", a.ZodUnknown = "ZodUnknown", a.ZodNever = "ZodNever", a.ZodVoid = "ZodVoid", a.ZodArray = "ZodArray", a.ZodObject = "ZodObject", a.ZodUnion = "ZodUnion", a.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", a.ZodIntersection = "ZodIntersection", a.ZodTuple = "ZodTuple", a.ZodRecord = "ZodRecord", a.ZodMap = "ZodMap", a.ZodSet = "ZodSet", a.ZodFunction = "ZodFunction", a.ZodLazy = "ZodLazy", a.ZodLiteral = "ZodLiteral", a.ZodEnum = "ZodEnum", a.ZodEffects = "ZodEffects", a.ZodNativeEnum = "ZodNativeEnum", a.ZodOptional = "ZodOptional", a.ZodNullable = "ZodNullable", a.ZodDefault = "ZodDefault", a.ZodCatch = "ZodCatch", a.ZodPromise = "ZodPromise", a.ZodBranded = "ZodBranded", a.ZodPipeline = "ZodPipeline", a.ZodReadonly = "ZodReadonly";
2665
+ })(g || (g = {}));
2666
+ const c = $.create, y = U.create, w = Ne.create, ia = Ze.create;
2667
+ B.create;
2668
+ const R = j.create, l = I.create, Y = ge.create;
2669
+ ve.create;
2670
+ const Be = z.create, P = _e.create, C = je.create, E = G.create;
2671
+ xe.create;
2672
+ const _ = M.create;
2673
+ J.create;
2674
+ const pt = () => w().optional(), te = E(["left", "right", "up", "down"]), Xa = te.options, Pe = l({
2675
+ type: c(),
2676
+ id: c(),
2677
+ name: _(c()),
2678
+ status: _(c())
2679
+ }), oa = l({
2680
+ height: y(),
2681
+ width: y(),
2682
+ sprite: c().optional(),
2683
+ direction: _(te),
2684
+ filter: _(c())
2685
+ }), ca = l({
2686
+ room: _(c()),
2687
+ x: y(),
2688
+ y: y()
2689
+ }), ke = l({
2690
+ imageId: c(),
2691
+ col: y().optional(),
2692
+ row: y().optional()
2693
+ }), O = l({ text: c().array() }), da = l({ x: y(), y: y() }), De = l({
2694
+ soundId: c(),
2695
+ volume: y().optional()
2696
+ }), be = {
2697
+ _started: pt(),
2698
+ narrative: O.optional(),
2699
+ startDirection: te.optional(),
2700
+ endDirection: te.optional(),
2701
+ endStatus: c().optional()
2702
+ }, Qa = {
2703
+ _started: !0,
2704
+ narrative: !0,
2705
+ startDirection: !0,
2706
+ endDirection: !0,
2707
+ endStatus: !0,
2708
+ type: !0
2709
+ }, ua = l({
2710
+ animation: _(c()),
2711
+ x: y(),
2712
+ y: y(),
2713
+ speed: _(y())
2714
+ }), la = l({
2715
+ type: C("move"),
2716
+ roomId: c().optional(),
2717
+ pathIsSet: _(w()),
2718
+ doPendingInteractionWhenFinished: _(w()),
2719
+ steps: R(ua)
2720
+ }).extend(be), ha = l({
2721
+ type: C("goTo"),
2722
+ animation: _(c()),
2723
+ speed: _(y()),
2724
+ targetId: c()
2725
+ }).extend(be), fa = l({
2726
+ type: C("say"),
2727
+ animation: _(c()),
2728
+ text: c(),
2729
+ time: y()
2730
+ }).extend(be), ma = l({
2731
+ animation: _(c()),
2732
+ duration: y(),
2733
+ timeElapsed: _(y()),
2734
+ reverse: _(w())
2735
+ }), pa = l({
2736
+ type: C("act"),
2737
+ steps: R(ma)
2738
+ }).extend(be), Se = Y([la, pa, fa, ha]), Ka = Se.options.map((a) => a.shape.type.value), Le = l({
2739
+ type: C("order"),
2740
+ actorId: c().optional(),
2741
+ orders: R(Se),
2742
+ replaceCurrentOrders: _(w()),
2743
+ narrative: O.optional()
2744
+ }), ae = l({
2745
+ type: C("changeRoom"),
2746
+ roomId: c(),
2747
+ takePlayer: w(),
2748
+ x: _(y()),
2749
+ y: _(y()),
2750
+ narrative: O.optional()
2751
+ }), se = l({
2752
+ type: C("inventory"),
2753
+ itemId: c(),
2754
+ actorId: c().optional(),
2755
+ addOrRemove: E(["ADD", "REMOVE"]),
2756
+ narrative: O.optional()
2757
+ }), ne = l({
2758
+ type: C("removeActor"),
2759
+ actorId: c(),
2760
+ narrative: O.optional()
2761
+ }), re = l({
2762
+ type: C("changeStatus"),
2763
+ targetId: c(),
2764
+ targetType: E(["actor", "item", "hotspot"]),
2765
+ status: c(),
2766
+ narrative: O.optional()
2767
+ }), ze = l({
2768
+ type: C("sequence"),
2769
+ sequence: c(),
2770
+ narrative: O.optional()
2771
+ }), ie = l({
2772
+ type: C("conversation"),
2773
+ conversationId: c(),
2774
+ end: _(w()),
2775
+ narrative: O.optional()
2776
+ }), oe = l({
2777
+ type: C("conversationChoice"),
2778
+ on: w(),
2779
+ conversationId: c(),
2780
+ branchId: c(),
2781
+ choiceRef: c(),
2782
+ narrative: O.optional()
2783
+ }), ce = l({
2784
+ type: C("teleportActor"),
2785
+ actorId: c(),
2786
+ roomId: _(c()),
2787
+ x: y(),
2788
+ y: y(),
2789
+ narrative: O.optional()
2790
+ }), X = l({
2791
+ type: C("toggleZone"),
2792
+ roomId: _(c()),
2793
+ on: w(),
2794
+ ref: c(),
2795
+ zoneType: E(["hotspot", "obstacle", "walkable"]),
2796
+ narrative: O.optional()
2797
+ }), de = l({
2798
+ type: C("soundEffect"),
2799
+ sound: c(),
2800
+ volume: y().optional(),
2801
+ narrative: O.optional()
2802
+ }), ue = l({
2803
+ type: C("backgroundMusic"),
2804
+ sound: c().optional(),
2805
+ roomId: c().optional(),
2806
+ volume: y().optional(),
2807
+ narrative: O.optional()
2808
+ }), le = l({
2809
+ type: C("ambientNoise"),
2810
+ sound: c().optional(),
2811
+ roomId: c().optional(),
2812
+ volume: y().optional(),
2813
+ narrative: O.optional()
2814
+ }), he = l({
2815
+ type: C("flag"),
2816
+ on: w(),
2817
+ flag: c(),
2818
+ narrative: O.optional()
2819
+ }), fe = l({
2820
+ type: C("storyBoardConsequence"),
2821
+ storyBoardId: c(),
2822
+ narrative: O.optional()
2823
+ }), es = X.shape.zoneType.options, ya = Y([
2824
+ Le,
2825
+ ae,
2826
+ se,
2827
+ ne,
2828
+ re,
2829
+ ze,
2830
+ ie,
2831
+ ce,
2832
+ X,
2833
+ de,
2834
+ ue,
2835
+ le,
2836
+ he,
2837
+ oe,
2838
+ fe
2839
+ ]), ga = E([
2840
+ "conversation",
2841
+ "sequence",
2842
+ "changeStatus",
2843
+ "backgroundMusic",
2844
+ "ambientNoise",
2845
+ "removeActor",
2846
+ "inventory",
2847
+ "changeRoom",
2848
+ "order",
2849
+ "teleportActor",
2850
+ "toggleZone",
2851
+ "soundEffect",
2852
+ "flag",
2853
+ "conversationChoice",
2854
+ "storyBoardConsequence"
2855
+ ]), ts = ga.options, as = {
2856
+ conversation: ie,
2857
+ sequence: ze,
2858
+ changeStatus: re,
2859
+ removeActor: ne,
2860
+ inventory: se,
2861
+ changeRoom: ae,
2862
+ order: Le,
2863
+ teleportActor: ce,
2864
+ toggleZone: X,
2865
+ soundEffect: de,
2866
+ flag: he,
2867
+ conversationChoice: oe,
2868
+ backgroundMusic: ue,
2869
+ ambientNoise: le,
2870
+ storyBoardConsequence: fe
2871
+ }, yt = Y([
2872
+ ne,
2873
+ re,
2874
+ se,
2875
+ ie,
2876
+ ce,
2877
+ X,
2878
+ de,
2879
+ he,
2880
+ ae,
2881
+ oe,
2882
+ ue,
2883
+ le,
2884
+ fe
2885
+ ]), ss = yt.options.map((a) => a.shape.type.value), Fe = l({
2886
+ verbId: c(),
2887
+ targetId: c(),
2888
+ roomId: c().optional(),
2889
+ itemId: c().optional(),
2890
+ targetStatus: c().optional(),
2891
+ mustReachFirst: w().optional(),
2892
+ consequences: R(ya),
2893
+ flagsThatMustBeFalse: R(c()).optional(),
2894
+ flagsThatMustBeTrue: R(c()).optional(),
2895
+ requiredInventory: R(c()).optional()
2896
+ }), gt = l({
2897
+ actorOrders: _(
2898
+ P(c(), Se.array())
2899
+ ),
2900
+ immediateConsequences: _(yt.array()),
2901
+ narrative: O.optional(),
2902
+ _started: pt()
2903
+ }), we = l({
2904
+ id: c(),
2905
+ description: c().optional(),
2906
+ stages: gt.array()
2907
+ }), dt = l({
2908
+ conversationId: c().optional(),
2909
+ branchId: c().optional(),
2910
+ choiceRef: c().optional()
2911
+ }), vt = l({
2912
+ ref: c().optional(),
2913
+ text: c(),
2914
+ sequence: c().optional(),
2915
+ nextBranch: _(c()),
2916
+ once: _(w()),
2917
+ disabled: _(w()),
2918
+ enablesChoices: R(dt).optional(),
2919
+ disablesChoices: R(dt).optional(),
2920
+ end: _(w()),
2921
+ choiceSequence: we.optional()
2922
+ }), va = l({
2923
+ choices: R(vt)
2924
+ }), _t = l({
2925
+ id: c(),
2926
+ branches: P(c(), _(va)),
2927
+ currentBranch: _(c()),
2928
+ defaultBranch: c()
2929
+ }), xt = l({
2930
+ id: c(),
2931
+ message: c(),
2932
+ imageId: c().optional(),
2933
+ imageWidth: y().optional()
2934
+ }), kt = l({
2935
+ type: C("ending"),
2936
+ endingId: c(),
2937
+ narrative: O.optional()
2938
+ }), _a = Y([
2939
+ Le,
2940
+ ae,
2941
+ se,
2942
+ ne,
2943
+ re,
2944
+ ze,
2945
+ ie,
2946
+ ce,
2947
+ X,
2948
+ de,
2949
+ ue,
2950
+ le,
2951
+ he,
2952
+ oe,
2953
+ fe,
2954
+ kt
2955
+ ]), xa = Y([
2956
+ ne,
2957
+ re,
2958
+ se,
2959
+ ie,
2960
+ ce,
2961
+ X,
2962
+ de,
2963
+ he,
2964
+ ae,
2965
+ oe,
2966
+ ue,
2967
+ le,
2968
+ fe,
2969
+ kt
2970
+ ]), bt = Fe.merge(l({
2971
+ consequences: R(_a)
2972
+ })), We = we.merge(l({
2973
+ stages: gt.merge(l({
2974
+ immediateConsequences: _(xa.array())
2975
+ })).array()
2976
+ })), ka = vt.merge(l({
2977
+ choiceSequence: We.optional()
2978
+ })), ba = l({
2979
+ choices: R(ka)
2980
+ }), St = _t.merge(l({
2981
+ branches: P(c(), _(ba))
2982
+ })), ut = l({
2983
+ soundId: c(),
2984
+ frameIndex: y().optional(),
2985
+ volume: y().optional()
2986
+ }), Sa = P(c(), ut.or(ut.array()).or(ia())), Ue = Pe.merge(ca).merge(oa).merge(l({
2987
+ type: C("actor"),
2988
+ isPlayer: _(w()),
2989
+ noInteraction: _(w()),
2990
+ speed: _(y()),
2991
+ baseline: _(y()),
2992
+ dialogueColor: _(c()),
2993
+ soundEffectMap: Sa.optional(),
2994
+ walkToX: y().optional(),
2995
+ walkToY: y().optional(),
2996
+ defaultFrame: ke.optional(),
2997
+ statusFrames: P(ke).optional()
2998
+ })), wa = l({
2999
+ value: w(),
3000
+ default: w(),
3001
+ description: c().optional()
3002
+ }), wt = P(c(), wa.optional()), Ce = Pe.extend({
3003
+ type: C("item"),
3004
+ actorId: c().optional()
3005
+ }).and(ke.partial());
3006
+ E(["rect", "circle", "polygon"]);
3007
+ const Ca = R(Be([y(), y()])), Ct = l({
3008
+ type: c().optional(),
3009
+ x: y(),
3010
+ y: y(),
3011
+ path: _(c()),
3012
+ polygon: _(Ca),
3013
+ circle: _(y()),
3014
+ rect: _(Be([y(), y()]))
3015
+ }), lt = Ct.merge(l({
3016
+ ref: c().optional(),
3017
+ disabled: w().optional()
3018
+ })), Tt = Ct.merge(Pe).merge(l({
3019
+ type: C("hotspot"),
3020
+ parallax: y(),
3021
+ walkToX: y().optional(),
3022
+ walkToY: y().optional()
3023
+ })), Ta = l({
3024
+ parallax: y(),
3025
+ imageId: c(),
3026
+ placement: l({
3027
+ x: y(),
3028
+ y: y(),
3029
+ width: y(),
3030
+ height: y()
3031
+ }).optional()
3032
+ }), Ia = R(Be([y(), y()])), It = l({
3033
+ id: c(),
3034
+ frameWidth: y(),
3035
+ frameHeight: y().optional(),
3036
+ width: y(),
3037
+ height: y(),
3038
+ background: Ta.array(),
3039
+ hotspots: Tt.array().optional(),
3040
+ obstacleAreas: _(lt.array()),
3041
+ walkableAreas: _(lt.array()),
3042
+ scaling: _(Ia),
3043
+ backgroundColor: c().optional(),
3044
+ name: c().optional(),
3045
+ narrative: O.optional(),
3046
+ backgroundMusic: De.optional(),
3047
+ ambientNoise: De.optional()
3048
+ }), me = l({
3049
+ imageId: c(),
3050
+ row: y(),
3051
+ col: y()
3052
+ }), Oa = l({
3053
+ left: me.array().optional(),
3054
+ right: me.array().optional(),
3055
+ up: me.array().optional(),
3056
+ down: me.array().optional()
3057
+ }), Ot = l({
3058
+ id: c(),
3059
+ defaultDirection: te,
3060
+ animations: P(c(), Oa)
3061
+ }), Aa = E(["center", "left", "right"]), Ra = E(["center", "top", "bottom"]), Na = l({
3062
+ x: Aa,
3063
+ y: Ra,
3064
+ width: y().optional(),
3065
+ height: y().optional(),
3066
+ aspectRatio: da.optional()
3067
+ }), Za = Na.merge(l({
3068
+ image: ke
3069
+ })), Ea = l({
3070
+ title: c(),
3071
+ narrative: O,
3072
+ pictures: Za.array(),
3073
+ backgroundColor: c(),
3074
+ color: c()
3075
+ }), ja = E(["sound", "buttons"]), qa = E([
3076
+ "serif",
3077
+ "sans-serif",
3078
+ "monospace",
3079
+ "cursive",
3080
+ "fantasy",
3081
+ "math"
3082
+ ]), At = l({
3083
+ id: c(),
3084
+ isEndOfGame: w().optional(),
3085
+ pages: Ea.array(),
3086
+ font: qa.optional(),
3087
+ sound: De.optional(),
3088
+ progression: ja.optional()
3089
+ }), Ge = l({
3090
+ id: c(),
3091
+ label: c(),
3092
+ preposition: c().optional(),
3093
+ isMoveVerb: w().optional(),
3094
+ isNotForItems: w().optional(),
3095
+ isLookVerb: w().optional(),
3096
+ requiresItem: w().optional(),
3097
+ defaultResponseNoItem: c().optional(),
3098
+ defaultResponseWithItem: c().optional(),
3099
+ defaultResponseCannotReach: c().optional()
3100
+ }), $a = l({
3101
+ schemaVersion: y().optional(),
3102
+ rooms: It.array(),
3103
+ items: Ce.array(),
3104
+ actors: Ue.array(),
3105
+ interactions: bt.array(),
3106
+ conversations: St.array(),
3107
+ flagMap: wt,
3108
+ currentRoomId: c(),
3109
+ id: c(),
3110
+ description: c().optional().describe("a short description of your game"),
3111
+ thumbnailAssetId: c().optional()
3112
+ }), Va = l({
3113
+ verbs: Ge.array(),
3114
+ sequences: We.array(),
3115
+ sprites: Ot.array(),
3116
+ endings: xt.array(),
3117
+ openingSequenceId: c().optional(),
3118
+ openingStoryboardId: c().optional(),
3119
+ storyBoards: At.array().optional()
3120
+ }), Da = $a.and(Va).describe("The game schema"), He = 4, Ma = l({
3121
+ sequenceRunning: we.optional(),
3122
+ currentStoryBoardId: c().optional(),
3123
+ actorOrders: P(c(), Se.array()),
3124
+ currentConversationId: c().optional(),
3125
+ pendingInteraction: Fe.optional(),
3126
+ gameNotBegun: w()
3127
+ }), Je = l({
3128
+ schemaVersion: C(He),
3129
+ rooms: It.array(),
3130
+ items: Ce.array(),
3131
+ actors: Ue.array(),
3132
+ interactions: Fe.array(),
3133
+ conversations: _t.array(),
3134
+ flagMap: wt,
3135
+ currentRoomId: c(),
3136
+ id: c(),
3137
+ description: c().optional().describe("a short description of your game"),
3138
+ thumbnailAssetId: c().optional()
3139
+ }), Rt = l({
3140
+ verbs: Ge.array(),
3141
+ sequences: we.array(),
3142
+ sprites: Ot.array(),
3143
+ openingSequenceId: c().optional(),
3144
+ openingStoryboardId: c().optional(),
3145
+ storyBoards: At.array()
3146
+ }), ns = Je.and(Ma), Ba = Je.and(Rt).describe("The game schema"), rs = E([
3147
+ "rooms",
3148
+ "items",
3149
+ "actors",
3150
+ "conversations",
3151
+ "sprites",
3152
+ "sequences",
3153
+ "verbs",
3154
+ "storyBoards"
3155
+ ]), Pa = Je.merge(l({
3156
+ schemaVersion: C(3),
3157
+ interactions: bt.array(),
3158
+ conversations: St.array()
3159
+ })), La = Rt.merge(l({
3160
+ endings: xt.array(),
3161
+ sequences: We.array()
3162
+ })), za = Pa.and(La).describe("The game schema"), Fa = Y([Ue, Ce, Tt]), is = l({
3163
+ verb: Ge,
3164
+ target: Fa,
3165
+ item: _(Ce)
3166
+ }), Wa = (a) => ({
3167
+ ...a,
3168
+ storyBoards: a.storyBoards ?? [],
3169
+ schemaVersion: 3
3170
+ }), Ua = (a) => Nt(Wa(a)), Ga = (a, e) => {
3171
+ const t = a.imageId ? {
3172
+ x: "center",
3173
+ y: "center",
3174
+ width: a.imageWidth ? a.imageWidth / 16 : 20,
3175
+ // imageWidth was in pixels, PagePicture.width is in em
3176
+ height: a.imageWidth ? a.imageWidth / 16 : 20,
3177
+ image: {
3178
+ imageId: a.imageId
3179
+ }
3180
+ } : void 0;
3181
+ return {
3182
+ id: e ?? a.id,
3183
+ isEndOfGame: !0,
3184
+ pages: [
3185
+ {
3186
+ title: a.message,
3187
+ narrative: {
3188
+ text: []
3189
+ },
3190
+ color: "#FFFFFF",
3191
+ backgroundColor: "#000000",
3192
+ pictures: t ? [t] : []
3193
+ }
3194
+ ]
3195
+ };
3196
+ }, Ha = (a, e) => {
3197
+ const t = e.filter((n) => n.startsWith(a)), s = (n = 1) => {
3198
+ const r = `${a}_${n}`;
3199
+ return t.includes(r) ? s(n + 1) : r;
3200
+ };
3201
+ return s();
3202
+ }, Nt = (a) => {
3203
+ const { storyBoards: e, interactions: t, sequences: s, conversations: n } = a, r = e.map((T) => T.id), i = {}, o = a.endings.map((T) => {
3204
+ const N = r.includes(T.id) ? Ha(T.id, r) : void 0;
3205
+ return N && r.push(N), i[T.id] = N ?? T.id, Ga(T, N);
3206
+ }), m = (T) => T.type !== "ending" ? T : {
3207
+ type: "storyBoardConsequence",
3208
+ storyBoardId: i[T.endingId] ?? T.endingId,
3209
+ narrative: T.narrative
3210
+ }, p = (T) => ({
3211
+ ...T,
3212
+ stages: T.stages.map((N) => ({
3213
+ ...N,
3214
+ immediateConsequences: N.immediateConsequences?.map(m)
3215
+ }))
3216
+ }), b = (T) => {
3217
+ const { branches: N } = T;
3218
+ for (let Et in N) {
3219
+ const Ie = N[Et];
3220
+ Ie && (Ie.choices = Ie.choices.map((Oe) => ({
3221
+ ...Oe,
3222
+ choiceSequence: Oe.choiceSequence ? p(Oe.choiceSequence) : void 0
3223
+ })));
3224
+ }
3225
+ return {
3226
+ ...T,
3227
+ branches: N
3228
+ };
3229
+ }, L = t.map((T) => ({ ...T, consequences: T.consequences.map(m) })), Te = s.map(p), Zt = n.map(b);
3230
+ return {
3231
+ ...a,
3232
+ storyBoards: [...e, ...o],
3233
+ interactions: L,
3234
+ sequences: Te,
3235
+ conversations: Zt,
3236
+ schemaVersion: He
3237
+ };
3238
+ }, os = (a) => {
3239
+ const e = Ba.safeParse(a);
3240
+ if (e.success)
3241
+ return {
3242
+ success: !0,
3243
+ gameDesign: e.data,
3244
+ sourceVersion: He,
3245
+ updated: !1
3246
+ };
3247
+ const t = za.safeParse(a);
3248
+ if (t.success)
3249
+ return {
3250
+ success: !0,
3251
+ gameDesign: Nt(t.data),
3252
+ sourceVersion: 3,
3253
+ updated: !0
3254
+ };
3255
+ const s = Da.safeParse(a);
3256
+ return s.success ? {
3257
+ success: !0,
3258
+ gameDesign: Ua(s.data),
3259
+ sourceVersion: 2,
3260
+ updated: !0
3261
+ } : {
3262
+ success: !1,
3263
+ failureMessage: s.error.message
3264
+ };
3265
+ };
3266
+ export {
3267
+ pa as ActOrderSchema,
3268
+ Ue as ActorDataSchema,
3269
+ le as AmbientNoiseConsequenceSchema,
3270
+ da as AspectRatioSchema,
3271
+ ue as BackgroundMusicConsequenceSchema,
3272
+ qa as BoardFontSchema,
3273
+ ja as BoardProgressionSchema,
3274
+ ae as ChangeRoomConsequenceSchema,
3275
+ re as ChangeStatusConsequenceSchema,
3276
+ is as CommandSchema,
3277
+ Fa as CommandTargetSchema,
3278
+ ya as ConsequenceSchema,
3279
+ va as ConversationBranchSchema,
3280
+ oe as ConversationChoiceConsequenceSchema,
3281
+ vt as ConversationChoiceSchema,
3282
+ ie as ConversationConsequenceSchema,
3283
+ _t as ConversationSchema,
3284
+ St as ConversationSchemaWithDeprecatedConsequences,
3285
+ He as DB_VERSION,
3286
+ te as DirectionEnum,
3287
+ kt as EndingConsequenceSchema,
3288
+ xt as EndingSchema,
3289
+ Rt as FixedGameInfoSchema,
3290
+ he as FlagConsequenceSchema,
3291
+ wt as FlagMapSchema,
3292
+ wa as FlagSchema,
3293
+ Je as GameContentsDataSchema,
3294
+ rs as GameDataItemTypeEnum,
3295
+ ns as GameDataSchema,
3296
+ Ba as GameDesignSchema,
3297
+ Ma as GameHappeningsSchema,
3298
+ ha as GotoOrderSchema,
3299
+ Tt as HotspotZoneSchema,
3300
+ Pe as IdentSchema,
3301
+ yt as ImmediateConsequenceSchema,
3302
+ xa as ImmediateConsequenceSchemaWithDeprecated,
3303
+ Fe as InteractionSchema,
3304
+ bt as InteractionSchemaWithDeprecatedConsequences,
3305
+ se as InventoryConsequenceSchema,
3306
+ Ce as ItemDataSchema,
3307
+ la as MoveOrderSchema,
3308
+ O as NarrativeSchema,
3309
+ Le as OrderConsequenceSchema,
3310
+ ca as PositionSchema,
3311
+ ne as RemoveActorConsequenceSchema,
3312
+ It as RoomDataSchema,
3313
+ fa as SayOrderSchema,
3314
+ ze as SequenceConsequenceSchema,
3315
+ we as SequenceSchema,
3316
+ We as SequenceSchemaWithDeprecatedConsequences,
3317
+ de as SoundEffectConsequenceSchema,
3318
+ ut as SoundValueSchema,
3319
+ Ot as SpriteDataSchema,
3320
+ me as SpriteFrameSchema,
3321
+ oa as SpriteParamsSchema,
3322
+ gt as StageSchema,
3323
+ ke as StaticFrameParamsSchema,
3324
+ fe as StoryBoardConsequenceSchema,
3325
+ Ea as StoryBoardPageSchema,
3326
+ At as StoryBoardSchema,
3327
+ ce as TeleportActorConsequenceSchema,
3328
+ X as ToggleZoneConsequenceSchema,
3329
+ Ge as VerbSchema,
3330
+ lt as ZoneSchema,
3331
+ Ya as changeHistory,
3332
+ as as consequenceMap,
3333
+ ts as consequenceTypes,
3334
+ Xa as directions,
3335
+ ss as immediateConsequenceTypes,
3336
+ Qa as orderBaseOmits,
3337
+ Se as orderSchema,
3338
+ Ka as orderTypes,
3339
+ os as parseAndUpgrade,
3340
+ De as soundInstanceSchema,
3341
+ Ja as sum,
3342
+ Da as v2GameDesignSchema,
3343
+ za as v3GameDesignSchema,
3344
+ Aa as xPlacement,
3345
+ Ra as yPlacement,
3346
+ es as zoneTypes
3347
+ };