@getquick/content 0.4.1 → 0.5.0

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.
@@ -167934,6 +167934,68 @@ function structuralMedia(media) {
167934
167934
  return conditions.join(" and ");
167935
167935
  }
167936
167936
  //#endregion
167937
+ const quote = (value) => "\"" + value.replace(/[\\"<>\n\r\f]/g, (character) => "\\" + character.charCodeAt(0).toString(16) + " ") + "\"";
167938
+ const safe = (value, pattern) => {
167939
+ if (typeof value !== "string" || !pattern.test(value)) throw new Error("Invalid font CSS value.");
167940
+ return value;
167941
+ };
167942
+ const weight = /^(?:[1-9][0-9]{0,2}|1000)(?: (?:[1-9][0-9]{0,2}|1000))?$/;
167943
+ const percent = /^[0-9]+(?:\.[0-9]+)?%$/;
167944
+ const optional = (rule) => {
167945
+ try {
167946
+ return rule();
167947
+ } catch {
167948
+ return "";
167949
+ }
167950
+ };
167951
+ const faceRule = (name, face) => `@font-face{font-family:${quote(name)};src:${face.src.map((src) => `url(${quote(src)}) format(${quote(face.format)})`).join(",")};font-weight:${safe(face.weight, weight)};font-style:${safe(face.style, /^(?:normal|italic|oblique)$/)};font-display:${safe(face.display, /^(?:auto|block|swap|fallback|optional)$/)};${face.unicodeRange ? `unicode-range:${safe(face.unicodeRange, /^U\+[0-9A-Fa-f?]{1,6}(?:-[0-9A-Fa-f]{1,6})?(?:,\s*U\+[0-9A-Fa-f?]{1,6}(?:-[0-9A-Fa-f]{1,6})?)*$/)};` : ""}}`;
167952
+ /** Emits the Site font faces, metric-matched fallback faces and font slot variables. */
167953
+ function fontStyleSheet(fonts) {
167954
+ if (!fonts) return "";
167955
+ let css = "";
167956
+ for (const family of fonts.families) {
167957
+ for (const face of family.faces) css += optional(() => faceRule(family.name, face));
167958
+ const fallback = family.fallback;
167959
+ if (fallback) css += optional(() => `@font-face{font-family:${quote(family.name + " Fallback")};src:local(${quote(fallback.local)});size-adjust:${safe(fallback.sizeAdjust, percent)};ascent-override:${safe(fallback.ascentOverride, percent)};descent-override:${safe(fallback.descentOverride, percent)};line-gap-override:${safe(fallback.lineGapOverride, percent)};}`);
167960
+ }
167961
+ let variables = "";
167962
+ for (const [slot, generic] of Object.entries({
167963
+ sans: "sans-serif",
167964
+ serif: "serif",
167965
+ mono: "monospace"
167966
+ })) {
167967
+ const family = fonts.families.find((entry) => entry.slug === fonts.slots[slot]);
167968
+ if (family) variables += `--gqd-font-${slot}:${quote(family.name)}, ${family.fallback ? quote(family.name + " Fallback") + ", " : ""}${generic};`;
167969
+ }
167970
+ return css + (variables ? `:root{${variables}}` : "");
167971
+ }
167972
+ /** Framework-neutral link attributes; inject once in the document head. */
167973
+ function fontPreloads(fonts) {
167974
+ const seen = /* @__PURE__ */ new Set();
167975
+ return (fonts?.families ?? []).flatMap((family) => family.faces.flatMap((face) => {
167976
+ const href = face.src[0];
167977
+ if (!face.preload || !href || seen.has(href) || seen.size >= 2) return [];
167978
+ seen.add(href);
167979
+ return [{
167980
+ rel: "preload",
167981
+ as: "font",
167982
+ href,
167983
+ type: `font/${face.format}`,
167984
+ crossOrigin: "anonymous"
167985
+ }];
167986
+ }));
167987
+ }
167988
+ /** Site text styles follow Preflight; authored important presentation wins. */
167989
+ function textStyleSheet(styles, root = ".gqd-content") {
167990
+ if (!styles) return "";
167991
+ if (!/^(?:\.[a-zA-Z_][\w-]*|:root)$/.test(root)) throw new Error("Choose a simple class selector or :root.");
167992
+ root = root === ":root" ? root : root + root;
167993
+ const declarations = (style) => `font-family:var(--gqd-font-${safe(style.slot, /^(?:sans|serif|mono)$/)});font-weight:${safe(style.weight, /^(?:[1-9][0-9]{0,2}|1000)$/)};line-height:${safe(style.lineHeight, /^[0-9]+(?:\.[0-9]+)?$/)};letter-spacing:${safe(style.letterSpacing, /^-?[0-9]+(?:\.[0-9]+)?(?:em|px|rem)$/)};`;
167994
+ let css = `${root}{${declarations(styles.paragraph)}}${root} h1,${root} h2,${root} h3,${root} h4,${root} h5,${root} h6{${declarations(styles.heading)}}`;
167995
+ for (const [level, size] of Object.entries(styles.heading.sizes)) css += `${root} ${safe(level, /^h[1-6]$/)}{font-size:var(--gqd-text-${safe(size, /^(?:xs|sm|base|lg|xl|[2-9]xl)$/)});}`;
167996
+ return css;
167997
+ }
167998
+ //#endregion
167937
167999
  //#region frontend/src/presentation.ts
167938
168000
  /** Apply the canonical presentation to a saved block's root shell, preserving
167939
168001
  * its content and attributes. Install presentationStyleSheet once for the Site.
@@ -169175,4 +169237,3705 @@ function isLanguageHome(route, among) {
169175
169237
  return among.some((language) => language.home === route);
169176
169238
  }
169177
169239
  //#endregion
169178
- export { selectSiteLogo as $, DESIGN_CAROUSEL_ITEM as A, safeDesignRichText as B, renderDesignQuery as C, renderWordPressBlocks as D, parseWordPressBlocks as E, VIDEO_HERO_BLOCK as F, createPresentationModel as G, navigationStyleSheet as H, renderDesignVideoHero as I, presentationVariables as J, presentationModel as K, youtubeVideoId as L, designCarouselStyle as M, renderDesignCarousel as N, designGridStyle as O, renderDesignCarouselItem as P, resolvePresentationToken as Q, renderDesignImage as R, renderDesignPostBlock as S, hasVideoHero as T, renderDesignNavigation as U, enhanceDesignNavigationHtml as V, presentationHtml as W, designThemeVariables as X, designThemeStyleSheet as Y, resolveDesignTheme as Z, uriPath as _, siteLanguages as a, designQueryItems as b, parseDesignBlocks as c, decodeEntities as d, assertDesignBlocks as et, formatDate as f, stripHtml as g, routeOf as h, routeLanguage as i, DESIGN_CAROUSEL_NAVIGATION as j, DESIGN_CAROUSEL as k, renderDesignPattern as l, responseStatus as m, isLanguageHome as n, safeContentUrl as nt, designMenuItems as o, menuItemHref as p, presentationStyleSheet as q, languageSubject as r, escapeHtml as s, htmlLang as t, enhanceDesignCoverVideosHtml as tt, cmsTime as u, renderDesignCover as v, hasDesignCarousel as w, preloadDesignQueryPosts as x, designPostContext as y, renderDesignText as z };
169240
+ //#region node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
169241
+ var util;
169242
+ (function(util) {
169243
+ util.assertEqual = (_) => {};
169244
+ function assertIs(_arg) {}
169245
+ util.assertIs = assertIs;
169246
+ function assertNever(_x) {
169247
+ throw new Error();
169248
+ }
169249
+ util.assertNever = assertNever;
169250
+ util.arrayToEnum = (items) => {
169251
+ const obj = {};
169252
+ for (const item of items) obj[item] = item;
169253
+ return obj;
169254
+ };
169255
+ util.getValidEnumValues = (obj) => {
169256
+ const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
169257
+ const filtered = {};
169258
+ for (const k of validKeys) filtered[k] = obj[k];
169259
+ return util.objectValues(filtered);
169260
+ };
169261
+ util.objectValues = (obj) => {
169262
+ return util.objectKeys(obj).map(function(e) {
169263
+ return obj[e];
169264
+ });
169265
+ };
169266
+ util.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
169267
+ const keys = [];
169268
+ for (const key in object) if (Object.prototype.hasOwnProperty.call(object, key)) keys.push(key);
169269
+ return keys;
169270
+ };
169271
+ util.find = (arr, checker) => {
169272
+ for (const item of arr) if (checker(item)) return item;
169273
+ };
169274
+ util.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
169275
+ function joinValues(array, separator = " | ") {
169276
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
169277
+ }
169278
+ util.joinValues = joinValues;
169279
+ util.jsonStringifyReplacer = (_, value) => {
169280
+ if (typeof value === "bigint") return value.toString();
169281
+ return value;
169282
+ };
169283
+ })(util || (util = {}));
169284
+ var objectUtil;
169285
+ (function(objectUtil) {
169286
+ objectUtil.mergeShapes = (first, second) => {
169287
+ return {
169288
+ ...first,
169289
+ ...second
169290
+ };
169291
+ };
169292
+ })(objectUtil || (objectUtil = {}));
169293
+ const ZodParsedType = util.arrayToEnum([
169294
+ "string",
169295
+ "nan",
169296
+ "number",
169297
+ "integer",
169298
+ "float",
169299
+ "boolean",
169300
+ "date",
169301
+ "bigint",
169302
+ "symbol",
169303
+ "function",
169304
+ "undefined",
169305
+ "null",
169306
+ "array",
169307
+ "object",
169308
+ "unknown",
169309
+ "promise",
169310
+ "void",
169311
+ "never",
169312
+ "map",
169313
+ "set"
169314
+ ]);
169315
+ const getParsedType = (data) => {
169316
+ switch (typeof data) {
169317
+ case "undefined": return ZodParsedType.undefined;
169318
+ case "string": return ZodParsedType.string;
169319
+ case "number": return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
169320
+ case "boolean": return ZodParsedType.boolean;
169321
+ case "function": return ZodParsedType.function;
169322
+ case "bigint": return ZodParsedType.bigint;
169323
+ case "symbol": return ZodParsedType.symbol;
169324
+ case "object":
169325
+ if (Array.isArray(data)) return ZodParsedType.array;
169326
+ if (data === null) return ZodParsedType.null;
169327
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") return ZodParsedType.promise;
169328
+ if (typeof Map !== "undefined" && data instanceof Map) return ZodParsedType.map;
169329
+ if (typeof Set !== "undefined" && data instanceof Set) return ZodParsedType.set;
169330
+ if (typeof Date !== "undefined" && data instanceof Date) return ZodParsedType.date;
169331
+ return ZodParsedType.object;
169332
+ default: return ZodParsedType.unknown;
169333
+ }
169334
+ };
169335
+ //#endregion
169336
+ //#region node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js
169337
+ const ZodIssueCode = util.arrayToEnum([
169338
+ "invalid_type",
169339
+ "invalid_literal",
169340
+ "custom",
169341
+ "invalid_union",
169342
+ "invalid_union_discriminator",
169343
+ "invalid_enum_value",
169344
+ "unrecognized_keys",
169345
+ "invalid_arguments",
169346
+ "invalid_return_type",
169347
+ "invalid_date",
169348
+ "invalid_string",
169349
+ "too_small",
169350
+ "too_big",
169351
+ "invalid_intersection_types",
169352
+ "not_multiple_of",
169353
+ "not_finite"
169354
+ ]);
169355
+ var ZodError = class ZodError extends Error {
169356
+ get errors() {
169357
+ return this.issues;
169358
+ }
169359
+ constructor(issues) {
169360
+ super();
169361
+ this.issues = [];
169362
+ this.addIssue = (sub) => {
169363
+ this.issues = [...this.issues, sub];
169364
+ };
169365
+ this.addIssues = (subs = []) => {
169366
+ this.issues = [...this.issues, ...subs];
169367
+ };
169368
+ const actualProto = new.target.prototype;
169369
+ if (Object.setPrototypeOf) Object.setPrototypeOf(this, actualProto);
169370
+ else this.__proto__ = actualProto;
169371
+ this.name = "ZodError";
169372
+ this.issues = issues;
169373
+ }
169374
+ format(_mapper) {
169375
+ const mapper = _mapper || function(issue) {
169376
+ return issue.message;
169377
+ };
169378
+ const fieldErrors = { _errors: [] };
169379
+ const processError = (error) => {
169380
+ for (const issue of error.issues) if (issue.code === "invalid_union") issue.unionErrors.map(processError);
169381
+ else if (issue.code === "invalid_return_type") processError(issue.returnTypeError);
169382
+ else if (issue.code === "invalid_arguments") processError(issue.argumentsError);
169383
+ else if (issue.path.length === 0) fieldErrors._errors.push(mapper(issue));
169384
+ else {
169385
+ let curr = fieldErrors;
169386
+ let i = 0;
169387
+ while (i < issue.path.length) {
169388
+ const el = issue.path[i];
169389
+ if (!(i === issue.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
169390
+ else {
169391
+ curr[el] = curr[el] || { _errors: [] };
169392
+ curr[el]._errors.push(mapper(issue));
169393
+ }
169394
+ curr = curr[el];
169395
+ i++;
169396
+ }
169397
+ }
169398
+ };
169399
+ processError(this);
169400
+ return fieldErrors;
169401
+ }
169402
+ static assert(value) {
169403
+ if (!(value instanceof ZodError)) throw new Error(`Not a ZodError: ${value}`);
169404
+ }
169405
+ toString() {
169406
+ return this.message;
169407
+ }
169408
+ get message() {
169409
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
169410
+ }
169411
+ get isEmpty() {
169412
+ return this.issues.length === 0;
169413
+ }
169414
+ flatten(mapper = (issue) => issue.message) {
169415
+ const fieldErrors = {};
169416
+ const formErrors = [];
169417
+ for (const sub of this.issues) if (sub.path.length > 0) {
169418
+ const firstEl = sub.path[0];
169419
+ fieldErrors[firstEl] = fieldErrors[firstEl] || [];
169420
+ fieldErrors[firstEl].push(mapper(sub));
169421
+ } else formErrors.push(mapper(sub));
169422
+ return {
169423
+ formErrors,
169424
+ fieldErrors
169425
+ };
169426
+ }
169427
+ get formErrors() {
169428
+ return this.flatten();
169429
+ }
169430
+ };
169431
+ ZodError.create = (issues) => {
169432
+ return new ZodError(issues);
169433
+ };
169434
+ //#endregion
169435
+ //#region node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js
169436
+ const errorMap = (issue, _ctx) => {
169437
+ let message;
169438
+ switch (issue.code) {
169439
+ case ZodIssueCode.invalid_type:
169440
+ if (issue.received === ZodParsedType.undefined) message = "Required";
169441
+ else message = `Expected ${issue.expected}, received ${issue.received}`;
169442
+ break;
169443
+ case ZodIssueCode.invalid_literal:
169444
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
169445
+ break;
169446
+ case ZodIssueCode.unrecognized_keys:
169447
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
169448
+ break;
169449
+ case ZodIssueCode.invalid_union:
169450
+ message = `Invalid input`;
169451
+ break;
169452
+ case ZodIssueCode.invalid_union_discriminator:
169453
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
169454
+ break;
169455
+ case ZodIssueCode.invalid_enum_value:
169456
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
169457
+ break;
169458
+ case ZodIssueCode.invalid_arguments:
169459
+ message = `Invalid function arguments`;
169460
+ break;
169461
+ case ZodIssueCode.invalid_return_type:
169462
+ message = `Invalid function return type`;
169463
+ break;
169464
+ case ZodIssueCode.invalid_date:
169465
+ message = `Invalid date`;
169466
+ break;
169467
+ case ZodIssueCode.invalid_string:
169468
+ if (typeof issue.validation === "object") {
169469
+ if ("includes" in issue.validation) {
169470
+ message = `Invalid input: must include "${issue.validation.includes}"`;
169471
+ if (typeof issue.validation.position === "number") message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
169472
+ } else if ("startsWith" in issue.validation) message = `Invalid input: must start with "${issue.validation.startsWith}"`;
169473
+ else if ("endsWith" in issue.validation) message = `Invalid input: must end with "${issue.validation.endsWith}"`;
169474
+ else util.assertNever(issue.validation);
169475
+ } else if (issue.validation !== "regex") message = `Invalid ${issue.validation}`;
169476
+ else message = "Invalid";
169477
+ break;
169478
+ case ZodIssueCode.too_small:
169479
+ if (issue.type === "array") message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
169480
+ else if (issue.type === "string") message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
169481
+ else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
169482
+ else if (issue.type === "bigint") message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
169483
+ else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
169484
+ else message = "Invalid input";
169485
+ break;
169486
+ case ZodIssueCode.too_big:
169487
+ if (issue.type === "array") message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
169488
+ else if (issue.type === "string") message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
169489
+ else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
169490
+ else if (issue.type === "bigint") message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
169491
+ else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
169492
+ else message = "Invalid input";
169493
+ break;
169494
+ case ZodIssueCode.custom:
169495
+ message = `Invalid input`;
169496
+ break;
169497
+ case ZodIssueCode.invalid_intersection_types:
169498
+ message = `Intersection results could not be merged`;
169499
+ break;
169500
+ case ZodIssueCode.not_multiple_of:
169501
+ message = `Number must be a multiple of ${issue.multipleOf}`;
169502
+ break;
169503
+ case ZodIssueCode.not_finite:
169504
+ message = "Number must be finite";
169505
+ break;
169506
+ default:
169507
+ message = _ctx.defaultError;
169508
+ util.assertNever(issue);
169509
+ }
169510
+ return { message };
169511
+ };
169512
+ //#endregion
169513
+ //#region node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js
169514
+ let overrideErrorMap = errorMap;
169515
+ function getErrorMap() {
169516
+ return overrideErrorMap;
169517
+ }
169518
+ //#endregion
169519
+ //#region node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
169520
+ const makeIssue = (params) => {
169521
+ const { data, path, errorMaps, issueData } = params;
169522
+ const fullPath = [...path, ...issueData.path || []];
169523
+ const fullIssue = {
169524
+ ...issueData,
169525
+ path: fullPath
169526
+ };
169527
+ if (issueData.message !== void 0) return {
169528
+ ...issueData,
169529
+ path: fullPath,
169530
+ message: issueData.message
169531
+ };
169532
+ let errorMessage = "";
169533
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
169534
+ for (const map of maps) errorMessage = map(fullIssue, {
169535
+ data,
169536
+ defaultError: errorMessage
169537
+ }).message;
169538
+ return {
169539
+ ...issueData,
169540
+ path: fullPath,
169541
+ message: errorMessage
169542
+ };
169543
+ };
169544
+ function addIssueToContext(ctx, issueData) {
169545
+ const overrideMap = getErrorMap();
169546
+ const issue = makeIssue({
169547
+ issueData,
169548
+ data: ctx.data,
169549
+ path: ctx.path,
169550
+ errorMaps: [
169551
+ ctx.common.contextualErrorMap,
169552
+ ctx.schemaErrorMap,
169553
+ overrideMap,
169554
+ overrideMap === errorMap ? void 0 : errorMap
169555
+ ].filter((x) => !!x)
169556
+ });
169557
+ ctx.common.issues.push(issue);
169558
+ }
169559
+ var ParseStatus = class ParseStatus {
169560
+ constructor() {
169561
+ this.value = "valid";
169562
+ }
169563
+ dirty() {
169564
+ if (this.value === "valid") this.value = "dirty";
169565
+ }
169566
+ abort() {
169567
+ if (this.value !== "aborted") this.value = "aborted";
169568
+ }
169569
+ static mergeArray(status, results) {
169570
+ const arrayValue = [];
169571
+ for (const s of results) {
169572
+ if (s.status === "aborted") return INVALID;
169573
+ if (s.status === "dirty") status.dirty();
169574
+ arrayValue.push(s.value);
169575
+ }
169576
+ return {
169577
+ status: status.value,
169578
+ value: arrayValue
169579
+ };
169580
+ }
169581
+ static async mergeObjectAsync(status, pairs) {
169582
+ const syncPairs = [];
169583
+ for (const pair of pairs) {
169584
+ const key = await pair.key;
169585
+ const value = await pair.value;
169586
+ syncPairs.push({
169587
+ key,
169588
+ value
169589
+ });
169590
+ }
169591
+ return ParseStatus.mergeObjectSync(status, syncPairs);
169592
+ }
169593
+ static mergeObjectSync(status, pairs) {
169594
+ const finalObject = {};
169595
+ for (const pair of pairs) {
169596
+ const { key, value } = pair;
169597
+ if (key.status === "aborted") return INVALID;
169598
+ if (value.status === "aborted") return INVALID;
169599
+ if (key.status === "dirty") status.dirty();
169600
+ if (value.status === "dirty") status.dirty();
169601
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) finalObject[key.value] = value.value;
169602
+ }
169603
+ return {
169604
+ status: status.value,
169605
+ value: finalObject
169606
+ };
169607
+ }
169608
+ };
169609
+ const INVALID = Object.freeze({ status: "aborted" });
169610
+ const DIRTY = (value) => ({
169611
+ status: "dirty",
169612
+ value
169613
+ });
169614
+ const OK = (value) => ({
169615
+ status: "valid",
169616
+ value
169617
+ });
169618
+ const isAborted = (x) => x.status === "aborted";
169619
+ const isDirty = (x) => x.status === "dirty";
169620
+ const isValid = (x) => x.status === "valid";
169621
+ const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
169622
+ //#endregion
169623
+ //#region node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
169624
+ var errorUtil;
169625
+ (function(errorUtil) {
169626
+ errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
169627
+ errorUtil.toString = (message) => typeof message === "string" ? message : message?.message;
169628
+ })(errorUtil || (errorUtil = {}));
169629
+ //#endregion
169630
+ //#region node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
169631
+ var ParseInputLazyPath = class {
169632
+ constructor(parent, value, path, key) {
169633
+ this._cachedPath = [];
169634
+ this.parent = parent;
169635
+ this.data = value;
169636
+ this._path = path;
169637
+ this._key = key;
169638
+ }
169639
+ get path() {
169640
+ if (!this._cachedPath.length) {
169641
+ if (Array.isArray(this._key)) this._cachedPath.push(...this._path, ...this._key);
169642
+ else this._cachedPath.push(...this._path, this._key);
169643
+ }
169644
+ return this._cachedPath;
169645
+ }
169646
+ };
169647
+ const handleResult = (ctx, result) => {
169648
+ if (isValid(result)) return {
169649
+ success: true,
169650
+ data: result.value
169651
+ };
169652
+ else {
169653
+ if (!ctx.common.issues.length) throw new Error("Validation failed but no issues detected.");
169654
+ return {
169655
+ success: false,
169656
+ get error() {
169657
+ if (this._error) return this._error;
169658
+ const error = new ZodError(ctx.common.issues);
169659
+ this._error = error;
169660
+ return this._error;
169661
+ }
169662
+ };
169663
+ }
169664
+ };
169665
+ function processCreateParams(params) {
169666
+ if (!params) return {};
169667
+ const { errorMap, invalid_type_error, required_error, description } = params;
169668
+ if (errorMap && (invalid_type_error || required_error)) throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
169669
+ if (errorMap) return {
169670
+ errorMap,
169671
+ description
169672
+ };
169673
+ const customMap = (iss, ctx) => {
169674
+ const { message } = params;
169675
+ if (iss.code === "invalid_enum_value") return { message: message ?? ctx.defaultError };
169676
+ if (typeof ctx.data === "undefined") return { message: message ?? required_error ?? ctx.defaultError };
169677
+ if (iss.code !== "invalid_type") return { message: ctx.defaultError };
169678
+ return { message: message ?? invalid_type_error ?? ctx.defaultError };
169679
+ };
169680
+ return {
169681
+ errorMap: customMap,
169682
+ description
169683
+ };
169684
+ }
169685
+ var ZodType = class {
169686
+ get description() {
169687
+ return this._def.description;
169688
+ }
169689
+ _getType(input) {
169690
+ return getParsedType(input.data);
169691
+ }
169692
+ _getOrReturnCtx(input, ctx) {
169693
+ return ctx || {
169694
+ common: input.parent.common,
169695
+ data: input.data,
169696
+ parsedType: getParsedType(input.data),
169697
+ schemaErrorMap: this._def.errorMap,
169698
+ path: input.path,
169699
+ parent: input.parent
169700
+ };
169701
+ }
169702
+ _processInputParams(input) {
169703
+ return {
169704
+ status: new ParseStatus(),
169705
+ ctx: {
169706
+ common: input.parent.common,
169707
+ data: input.data,
169708
+ parsedType: getParsedType(input.data),
169709
+ schemaErrorMap: this._def.errorMap,
169710
+ path: input.path,
169711
+ parent: input.parent
169712
+ }
169713
+ };
169714
+ }
169715
+ _parseSync(input) {
169716
+ const result = this._parse(input);
169717
+ if (isAsync(result)) throw new Error("Synchronous parse encountered promise.");
169718
+ return result;
169719
+ }
169720
+ _parseAsync(input) {
169721
+ const result = this._parse(input);
169722
+ return Promise.resolve(result);
169723
+ }
169724
+ parse(data, params) {
169725
+ const result = this.safeParse(data, params);
169726
+ if (result.success) return result.data;
169727
+ throw result.error;
169728
+ }
169729
+ safeParse(data, params) {
169730
+ const ctx = {
169731
+ common: {
169732
+ issues: [],
169733
+ async: params?.async ?? false,
169734
+ contextualErrorMap: params?.errorMap
169735
+ },
169736
+ path: params?.path || [],
169737
+ schemaErrorMap: this._def.errorMap,
169738
+ parent: null,
169739
+ data,
169740
+ parsedType: getParsedType(data)
169741
+ };
169742
+ const result = this._parseSync({
169743
+ data,
169744
+ path: ctx.path,
169745
+ parent: ctx
169746
+ });
169747
+ return handleResult(ctx, result);
169748
+ }
169749
+ "~validate"(data) {
169750
+ const ctx = {
169751
+ common: {
169752
+ issues: [],
169753
+ async: !!this["~standard"].async
169754
+ },
169755
+ path: [],
169756
+ schemaErrorMap: this._def.errorMap,
169757
+ parent: null,
169758
+ data,
169759
+ parsedType: getParsedType(data)
169760
+ };
169761
+ if (!this["~standard"].async) try {
169762
+ const result = this._parseSync({
169763
+ data,
169764
+ path: [],
169765
+ parent: ctx
169766
+ });
169767
+ return isValid(result) ? { value: result.value } : { issues: ctx.common.issues };
169768
+ } catch (err) {
169769
+ if (err?.message?.toLowerCase()?.includes("encountered")) this["~standard"].async = true;
169770
+ ctx.common = {
169771
+ issues: [],
169772
+ async: true
169773
+ };
169774
+ }
169775
+ return this._parseAsync({
169776
+ data,
169777
+ path: [],
169778
+ parent: ctx
169779
+ }).then((result) => isValid(result) ? { value: result.value } : { issues: ctx.common.issues });
169780
+ }
169781
+ async parseAsync(data, params) {
169782
+ const result = await this.safeParseAsync(data, params);
169783
+ if (result.success) return result.data;
169784
+ throw result.error;
169785
+ }
169786
+ async safeParseAsync(data, params) {
169787
+ const ctx = {
169788
+ common: {
169789
+ issues: [],
169790
+ contextualErrorMap: params?.errorMap,
169791
+ async: true
169792
+ },
169793
+ path: params?.path || [],
169794
+ schemaErrorMap: this._def.errorMap,
169795
+ parent: null,
169796
+ data,
169797
+ parsedType: getParsedType(data)
169798
+ };
169799
+ const maybeAsyncResult = this._parse({
169800
+ data,
169801
+ path: ctx.path,
169802
+ parent: ctx
169803
+ });
169804
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
169805
+ return handleResult(ctx, result);
169806
+ }
169807
+ refine(check, message) {
169808
+ const getIssueProperties = (val) => {
169809
+ if (typeof message === "string" || typeof message === "undefined") return { message };
169810
+ else if (typeof message === "function") return message(val);
169811
+ else return message;
169812
+ };
169813
+ return this._refinement((val, ctx) => {
169814
+ const result = check(val);
169815
+ const setError = () => ctx.addIssue({
169816
+ code: ZodIssueCode.custom,
169817
+ ...getIssueProperties(val)
169818
+ });
169819
+ if (typeof Promise !== "undefined" && result instanceof Promise) return result.then((data) => {
169820
+ if (!data) {
169821
+ setError();
169822
+ return false;
169823
+ } else return true;
169824
+ });
169825
+ if (!result) {
169826
+ setError();
169827
+ return false;
169828
+ } else return true;
169829
+ });
169830
+ }
169831
+ refinement(check, refinementData) {
169832
+ return this._refinement((val, ctx) => {
169833
+ if (!check(val)) {
169834
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
169835
+ return false;
169836
+ } else return true;
169837
+ });
169838
+ }
169839
+ _refinement(refinement) {
169840
+ return new ZodEffects({
169841
+ schema: this,
169842
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
169843
+ effect: {
169844
+ type: "refinement",
169845
+ refinement
169846
+ }
169847
+ });
169848
+ }
169849
+ superRefine(refinement) {
169850
+ return this._refinement(refinement);
169851
+ }
169852
+ constructor(def) {
169853
+ /** Alias of safeParseAsync */
169854
+ this.spa = this.safeParseAsync;
169855
+ this._def = def;
169856
+ this.parse = this.parse.bind(this);
169857
+ this.safeParse = this.safeParse.bind(this);
169858
+ this.parseAsync = this.parseAsync.bind(this);
169859
+ this.safeParseAsync = this.safeParseAsync.bind(this);
169860
+ this.spa = this.spa.bind(this);
169861
+ this.refine = this.refine.bind(this);
169862
+ this.refinement = this.refinement.bind(this);
169863
+ this.superRefine = this.superRefine.bind(this);
169864
+ this.optional = this.optional.bind(this);
169865
+ this.nullable = this.nullable.bind(this);
169866
+ this.nullish = this.nullish.bind(this);
169867
+ this.array = this.array.bind(this);
169868
+ this.promise = this.promise.bind(this);
169869
+ this.or = this.or.bind(this);
169870
+ this.and = this.and.bind(this);
169871
+ this.transform = this.transform.bind(this);
169872
+ this.brand = this.brand.bind(this);
169873
+ this.default = this.default.bind(this);
169874
+ this.catch = this.catch.bind(this);
169875
+ this.describe = this.describe.bind(this);
169876
+ this.pipe = this.pipe.bind(this);
169877
+ this.readonly = this.readonly.bind(this);
169878
+ this.isNullable = this.isNullable.bind(this);
169879
+ this.isOptional = this.isOptional.bind(this);
169880
+ this["~standard"] = {
169881
+ version: 1,
169882
+ vendor: "zod",
169883
+ validate: (data) => this["~validate"](data)
169884
+ };
169885
+ }
169886
+ optional() {
169887
+ return ZodOptional.create(this, this._def);
169888
+ }
169889
+ nullable() {
169890
+ return ZodNullable.create(this, this._def);
169891
+ }
169892
+ nullish() {
169893
+ return this.nullable().optional();
169894
+ }
169895
+ array() {
169896
+ return ZodArray.create(this);
169897
+ }
169898
+ promise() {
169899
+ return ZodPromise.create(this, this._def);
169900
+ }
169901
+ or(option) {
169902
+ return ZodUnion.create([this, option], this._def);
169903
+ }
169904
+ and(incoming) {
169905
+ return ZodIntersection.create(this, incoming, this._def);
169906
+ }
169907
+ transform(transform) {
169908
+ return new ZodEffects({
169909
+ ...processCreateParams(this._def),
169910
+ schema: this,
169911
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
169912
+ effect: {
169913
+ type: "transform",
169914
+ transform
169915
+ }
169916
+ });
169917
+ }
169918
+ default(def) {
169919
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
169920
+ return new ZodDefault({
169921
+ ...processCreateParams(this._def),
169922
+ innerType: this,
169923
+ defaultValue: defaultValueFunc,
169924
+ typeName: ZodFirstPartyTypeKind.ZodDefault
169925
+ });
169926
+ }
169927
+ brand() {
169928
+ return new ZodBranded({
169929
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
169930
+ type: this,
169931
+ ...processCreateParams(this._def)
169932
+ });
169933
+ }
169934
+ catch(def) {
169935
+ const catchValueFunc = typeof def === "function" ? def : () => def;
169936
+ return new ZodCatch({
169937
+ ...processCreateParams(this._def),
169938
+ innerType: this,
169939
+ catchValue: catchValueFunc,
169940
+ typeName: ZodFirstPartyTypeKind.ZodCatch
169941
+ });
169942
+ }
169943
+ describe(description) {
169944
+ const This = this.constructor;
169945
+ return new This({
169946
+ ...this._def,
169947
+ description
169948
+ });
169949
+ }
169950
+ pipe(target) {
169951
+ return ZodPipeline.create(this, target);
169952
+ }
169953
+ readonly() {
169954
+ return ZodReadonly.create(this);
169955
+ }
169956
+ isOptional() {
169957
+ return this.safeParse(void 0).success;
169958
+ }
169959
+ isNullable() {
169960
+ return this.safeParse(null).success;
169961
+ }
169962
+ };
169963
+ const cuidRegex = /^c[^\s-]{8,}$/i;
169964
+ const cuid2Regex = /^[0-9a-z]+$/;
169965
+ const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
169966
+ const uuidRegex = /^[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;
169967
+ const nanoidRegex = /^[a-z0-9_-]{21}$/i;
169968
+ const jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
169969
+ const durationRegex = /^[-+]?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)?)??$/;
169970
+ const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
169971
+ const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
169972
+ let emojiRegex;
169973
+ const ipv4Regex = /^(?:(?: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])$/;
169974
+ const ipv4CidrRegex = /^(?:(?: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])$/;
169975
+ const ipv6Regex = /^(([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]))$/;
169976
+ const ipv6CidrRegex = /^(([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])$/;
169977
+ const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
169978
+ const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
169979
+ const dateRegexSource = `((\\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])))`;
169980
+ const dateRegex = new RegExp(`^${dateRegexSource}$`);
169981
+ function timeRegexSource(args) {
169982
+ let secondsRegexSource = `[0-5]\\d`;
169983
+ if (args.precision) secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
169984
+ else if (args.precision == null) secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
169985
+ const secondsQuantifier = args.precision ? "+" : "?";
169986
+ return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
169987
+ }
169988
+ function timeRegex(args) {
169989
+ return new RegExp(`^${timeRegexSource(args)}$`);
169990
+ }
169991
+ function datetimeRegex(args) {
169992
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
169993
+ const opts = [];
169994
+ opts.push(args.local ? `Z?` : `Z`);
169995
+ if (args.offset) opts.push(`([+-]\\d{2}:?\\d{2})`);
169996
+ regex = `${regex}(${opts.join("|")})`;
169997
+ return new RegExp(`^${regex}$`);
169998
+ }
169999
+ function isValidIP(ip, version) {
170000
+ if ((version === "v4" || !version) && ipv4Regex.test(ip)) return true;
170001
+ if ((version === "v6" || !version) && ipv6Regex.test(ip)) return true;
170002
+ return false;
170003
+ }
170004
+ function isValidJWT(jwt, alg) {
170005
+ if (!jwtRegex.test(jwt)) return false;
170006
+ try {
170007
+ const [header] = jwt.split(".");
170008
+ if (!header) return false;
170009
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
170010
+ const decoded = JSON.parse(atob(base64));
170011
+ if (typeof decoded !== "object" || decoded === null) return false;
170012
+ if ("typ" in decoded && decoded?.typ !== "JWT") return false;
170013
+ if (!decoded.alg) return false;
170014
+ if (alg && decoded.alg !== alg) return false;
170015
+ return true;
170016
+ } catch {
170017
+ return false;
170018
+ }
170019
+ }
170020
+ function isValidCidr(ip, version) {
170021
+ if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) return true;
170022
+ if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) return true;
170023
+ return false;
170024
+ }
170025
+ var ZodString = class ZodString extends ZodType {
170026
+ _parse(input) {
170027
+ if (this._def.coerce) input.data = String(input.data);
170028
+ if (this._getType(input) !== ZodParsedType.string) {
170029
+ const ctx = this._getOrReturnCtx(input);
170030
+ addIssueToContext(ctx, {
170031
+ code: ZodIssueCode.invalid_type,
170032
+ expected: ZodParsedType.string,
170033
+ received: ctx.parsedType
170034
+ });
170035
+ return INVALID;
170036
+ }
170037
+ const status = new ParseStatus();
170038
+ let ctx = void 0;
170039
+ for (const check of this._def.checks) if (check.kind === "min") {
170040
+ if (input.data.length < check.value) {
170041
+ ctx = this._getOrReturnCtx(input, ctx);
170042
+ addIssueToContext(ctx, {
170043
+ code: ZodIssueCode.too_small,
170044
+ minimum: check.value,
170045
+ type: "string",
170046
+ inclusive: true,
170047
+ exact: false,
170048
+ message: check.message
170049
+ });
170050
+ status.dirty();
170051
+ }
170052
+ } else if (check.kind === "max") {
170053
+ if (input.data.length > check.value) {
170054
+ ctx = this._getOrReturnCtx(input, ctx);
170055
+ addIssueToContext(ctx, {
170056
+ code: ZodIssueCode.too_big,
170057
+ maximum: check.value,
170058
+ type: "string",
170059
+ inclusive: true,
170060
+ exact: false,
170061
+ message: check.message
170062
+ });
170063
+ status.dirty();
170064
+ }
170065
+ } else if (check.kind === "length") {
170066
+ const tooBig = input.data.length > check.value;
170067
+ const tooSmall = input.data.length < check.value;
170068
+ if (tooBig || tooSmall) {
170069
+ ctx = this._getOrReturnCtx(input, ctx);
170070
+ if (tooBig) addIssueToContext(ctx, {
170071
+ code: ZodIssueCode.too_big,
170072
+ maximum: check.value,
170073
+ type: "string",
170074
+ inclusive: true,
170075
+ exact: true,
170076
+ message: check.message
170077
+ });
170078
+ else if (tooSmall) addIssueToContext(ctx, {
170079
+ code: ZodIssueCode.too_small,
170080
+ minimum: check.value,
170081
+ type: "string",
170082
+ inclusive: true,
170083
+ exact: true,
170084
+ message: check.message
170085
+ });
170086
+ status.dirty();
170087
+ }
170088
+ } else if (check.kind === "email") {
170089
+ if (!emailRegex.test(input.data)) {
170090
+ ctx = this._getOrReturnCtx(input, ctx);
170091
+ addIssueToContext(ctx, {
170092
+ validation: "email",
170093
+ code: ZodIssueCode.invalid_string,
170094
+ message: check.message
170095
+ });
170096
+ status.dirty();
170097
+ }
170098
+ } else if (check.kind === "emoji") {
170099
+ if (!emojiRegex) emojiRegex = new RegExp(_emojiRegex, "u");
170100
+ if (!emojiRegex.test(input.data)) {
170101
+ ctx = this._getOrReturnCtx(input, ctx);
170102
+ addIssueToContext(ctx, {
170103
+ validation: "emoji",
170104
+ code: ZodIssueCode.invalid_string,
170105
+ message: check.message
170106
+ });
170107
+ status.dirty();
170108
+ }
170109
+ } else if (check.kind === "uuid") {
170110
+ if (!uuidRegex.test(input.data)) {
170111
+ ctx = this._getOrReturnCtx(input, ctx);
170112
+ addIssueToContext(ctx, {
170113
+ validation: "uuid",
170114
+ code: ZodIssueCode.invalid_string,
170115
+ message: check.message
170116
+ });
170117
+ status.dirty();
170118
+ }
170119
+ } else if (check.kind === "nanoid") {
170120
+ if (!nanoidRegex.test(input.data)) {
170121
+ ctx = this._getOrReturnCtx(input, ctx);
170122
+ addIssueToContext(ctx, {
170123
+ validation: "nanoid",
170124
+ code: ZodIssueCode.invalid_string,
170125
+ message: check.message
170126
+ });
170127
+ status.dirty();
170128
+ }
170129
+ } else if (check.kind === "cuid") {
170130
+ if (!cuidRegex.test(input.data)) {
170131
+ ctx = this._getOrReturnCtx(input, ctx);
170132
+ addIssueToContext(ctx, {
170133
+ validation: "cuid",
170134
+ code: ZodIssueCode.invalid_string,
170135
+ message: check.message
170136
+ });
170137
+ status.dirty();
170138
+ }
170139
+ } else if (check.kind === "cuid2") {
170140
+ if (!cuid2Regex.test(input.data)) {
170141
+ ctx = this._getOrReturnCtx(input, ctx);
170142
+ addIssueToContext(ctx, {
170143
+ validation: "cuid2",
170144
+ code: ZodIssueCode.invalid_string,
170145
+ message: check.message
170146
+ });
170147
+ status.dirty();
170148
+ }
170149
+ } else if (check.kind === "ulid") {
170150
+ if (!ulidRegex.test(input.data)) {
170151
+ ctx = this._getOrReturnCtx(input, ctx);
170152
+ addIssueToContext(ctx, {
170153
+ validation: "ulid",
170154
+ code: ZodIssueCode.invalid_string,
170155
+ message: check.message
170156
+ });
170157
+ status.dirty();
170158
+ }
170159
+ } else if (check.kind === "url") try {
170160
+ new URL(input.data);
170161
+ } catch {
170162
+ ctx = this._getOrReturnCtx(input, ctx);
170163
+ addIssueToContext(ctx, {
170164
+ validation: "url",
170165
+ code: ZodIssueCode.invalid_string,
170166
+ message: check.message
170167
+ });
170168
+ status.dirty();
170169
+ }
170170
+ else if (check.kind === "regex") {
170171
+ check.regex.lastIndex = 0;
170172
+ if (!check.regex.test(input.data)) {
170173
+ ctx = this._getOrReturnCtx(input, ctx);
170174
+ addIssueToContext(ctx, {
170175
+ validation: "regex",
170176
+ code: ZodIssueCode.invalid_string,
170177
+ message: check.message
170178
+ });
170179
+ status.dirty();
170180
+ }
170181
+ } else if (check.kind === "trim") input.data = input.data.trim();
170182
+ else if (check.kind === "includes") {
170183
+ if (!input.data.includes(check.value, check.position)) {
170184
+ ctx = this._getOrReturnCtx(input, ctx);
170185
+ addIssueToContext(ctx, {
170186
+ code: ZodIssueCode.invalid_string,
170187
+ validation: {
170188
+ includes: check.value,
170189
+ position: check.position
170190
+ },
170191
+ message: check.message
170192
+ });
170193
+ status.dirty();
170194
+ }
170195
+ } else if (check.kind === "toLowerCase") input.data = input.data.toLowerCase();
170196
+ else if (check.kind === "toUpperCase") input.data = input.data.toUpperCase();
170197
+ else if (check.kind === "startsWith") {
170198
+ if (!input.data.startsWith(check.value)) {
170199
+ ctx = this._getOrReturnCtx(input, ctx);
170200
+ addIssueToContext(ctx, {
170201
+ code: ZodIssueCode.invalid_string,
170202
+ validation: { startsWith: check.value },
170203
+ message: check.message
170204
+ });
170205
+ status.dirty();
170206
+ }
170207
+ } else if (check.kind === "endsWith") {
170208
+ if (!input.data.endsWith(check.value)) {
170209
+ ctx = this._getOrReturnCtx(input, ctx);
170210
+ addIssueToContext(ctx, {
170211
+ code: ZodIssueCode.invalid_string,
170212
+ validation: { endsWith: check.value },
170213
+ message: check.message
170214
+ });
170215
+ status.dirty();
170216
+ }
170217
+ } else if (check.kind === "datetime") {
170218
+ if (!datetimeRegex(check).test(input.data)) {
170219
+ ctx = this._getOrReturnCtx(input, ctx);
170220
+ addIssueToContext(ctx, {
170221
+ code: ZodIssueCode.invalid_string,
170222
+ validation: "datetime",
170223
+ message: check.message
170224
+ });
170225
+ status.dirty();
170226
+ }
170227
+ } else if (check.kind === "date") {
170228
+ if (!dateRegex.test(input.data)) {
170229
+ ctx = this._getOrReturnCtx(input, ctx);
170230
+ addIssueToContext(ctx, {
170231
+ code: ZodIssueCode.invalid_string,
170232
+ validation: "date",
170233
+ message: check.message
170234
+ });
170235
+ status.dirty();
170236
+ }
170237
+ } else if (check.kind === "time") {
170238
+ if (!timeRegex(check).test(input.data)) {
170239
+ ctx = this._getOrReturnCtx(input, ctx);
170240
+ addIssueToContext(ctx, {
170241
+ code: ZodIssueCode.invalid_string,
170242
+ validation: "time",
170243
+ message: check.message
170244
+ });
170245
+ status.dirty();
170246
+ }
170247
+ } else if (check.kind === "duration") {
170248
+ if (!durationRegex.test(input.data)) {
170249
+ ctx = this._getOrReturnCtx(input, ctx);
170250
+ addIssueToContext(ctx, {
170251
+ validation: "duration",
170252
+ code: ZodIssueCode.invalid_string,
170253
+ message: check.message
170254
+ });
170255
+ status.dirty();
170256
+ }
170257
+ } else if (check.kind === "ip") {
170258
+ if (!isValidIP(input.data, check.version)) {
170259
+ ctx = this._getOrReturnCtx(input, ctx);
170260
+ addIssueToContext(ctx, {
170261
+ validation: "ip",
170262
+ code: ZodIssueCode.invalid_string,
170263
+ message: check.message
170264
+ });
170265
+ status.dirty();
170266
+ }
170267
+ } else if (check.kind === "jwt") {
170268
+ if (!isValidJWT(input.data, check.alg)) {
170269
+ ctx = this._getOrReturnCtx(input, ctx);
170270
+ addIssueToContext(ctx, {
170271
+ validation: "jwt",
170272
+ code: ZodIssueCode.invalid_string,
170273
+ message: check.message
170274
+ });
170275
+ status.dirty();
170276
+ }
170277
+ } else if (check.kind === "cidr") {
170278
+ if (!isValidCidr(input.data, check.version)) {
170279
+ ctx = this._getOrReturnCtx(input, ctx);
170280
+ addIssueToContext(ctx, {
170281
+ validation: "cidr",
170282
+ code: ZodIssueCode.invalid_string,
170283
+ message: check.message
170284
+ });
170285
+ status.dirty();
170286
+ }
170287
+ } else if (check.kind === "base64") {
170288
+ if (!base64Regex.test(input.data)) {
170289
+ ctx = this._getOrReturnCtx(input, ctx);
170290
+ addIssueToContext(ctx, {
170291
+ validation: "base64",
170292
+ code: ZodIssueCode.invalid_string,
170293
+ message: check.message
170294
+ });
170295
+ status.dirty();
170296
+ }
170297
+ } else if (check.kind === "base64url") {
170298
+ if (!base64urlRegex.test(input.data)) {
170299
+ ctx = this._getOrReturnCtx(input, ctx);
170300
+ addIssueToContext(ctx, {
170301
+ validation: "base64url",
170302
+ code: ZodIssueCode.invalid_string,
170303
+ message: check.message
170304
+ });
170305
+ status.dirty();
170306
+ }
170307
+ } else util.assertNever(check);
170308
+ return {
170309
+ status: status.value,
170310
+ value: input.data
170311
+ };
170312
+ }
170313
+ _regex(regex, validation, message) {
170314
+ return this.refinement((data) => regex.test(data), {
170315
+ validation,
170316
+ code: ZodIssueCode.invalid_string,
170317
+ ...errorUtil.errToObj(message)
170318
+ });
170319
+ }
170320
+ _addCheck(check) {
170321
+ return new ZodString({
170322
+ ...this._def,
170323
+ checks: [...this._def.checks, check]
170324
+ });
170325
+ }
170326
+ email(message) {
170327
+ return this._addCheck({
170328
+ kind: "email",
170329
+ ...errorUtil.errToObj(message)
170330
+ });
170331
+ }
170332
+ url(message) {
170333
+ return this._addCheck({
170334
+ kind: "url",
170335
+ ...errorUtil.errToObj(message)
170336
+ });
170337
+ }
170338
+ emoji(message) {
170339
+ return this._addCheck({
170340
+ kind: "emoji",
170341
+ ...errorUtil.errToObj(message)
170342
+ });
170343
+ }
170344
+ uuid(message) {
170345
+ return this._addCheck({
170346
+ kind: "uuid",
170347
+ ...errorUtil.errToObj(message)
170348
+ });
170349
+ }
170350
+ nanoid(message) {
170351
+ return this._addCheck({
170352
+ kind: "nanoid",
170353
+ ...errorUtil.errToObj(message)
170354
+ });
170355
+ }
170356
+ cuid(message) {
170357
+ return this._addCheck({
170358
+ kind: "cuid",
170359
+ ...errorUtil.errToObj(message)
170360
+ });
170361
+ }
170362
+ cuid2(message) {
170363
+ return this._addCheck({
170364
+ kind: "cuid2",
170365
+ ...errorUtil.errToObj(message)
170366
+ });
170367
+ }
170368
+ ulid(message) {
170369
+ return this._addCheck({
170370
+ kind: "ulid",
170371
+ ...errorUtil.errToObj(message)
170372
+ });
170373
+ }
170374
+ base64(message) {
170375
+ return this._addCheck({
170376
+ kind: "base64",
170377
+ ...errorUtil.errToObj(message)
170378
+ });
170379
+ }
170380
+ base64url(message) {
170381
+ return this._addCheck({
170382
+ kind: "base64url",
170383
+ ...errorUtil.errToObj(message)
170384
+ });
170385
+ }
170386
+ jwt(options) {
170387
+ return this._addCheck({
170388
+ kind: "jwt",
170389
+ ...errorUtil.errToObj(options)
170390
+ });
170391
+ }
170392
+ ip(options) {
170393
+ return this._addCheck({
170394
+ kind: "ip",
170395
+ ...errorUtil.errToObj(options)
170396
+ });
170397
+ }
170398
+ cidr(options) {
170399
+ return this._addCheck({
170400
+ kind: "cidr",
170401
+ ...errorUtil.errToObj(options)
170402
+ });
170403
+ }
170404
+ datetime(options) {
170405
+ if (typeof options === "string") return this._addCheck({
170406
+ kind: "datetime",
170407
+ precision: null,
170408
+ offset: false,
170409
+ local: false,
170410
+ message: options
170411
+ });
170412
+ return this._addCheck({
170413
+ kind: "datetime",
170414
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
170415
+ offset: options?.offset ?? false,
170416
+ local: options?.local ?? false,
170417
+ ...errorUtil.errToObj(options?.message)
170418
+ });
170419
+ }
170420
+ date(message) {
170421
+ return this._addCheck({
170422
+ kind: "date",
170423
+ message
170424
+ });
170425
+ }
170426
+ time(options) {
170427
+ if (typeof options === "string") return this._addCheck({
170428
+ kind: "time",
170429
+ precision: null,
170430
+ message: options
170431
+ });
170432
+ return this._addCheck({
170433
+ kind: "time",
170434
+ precision: typeof options?.precision === "undefined" ? null : options?.precision,
170435
+ ...errorUtil.errToObj(options?.message)
170436
+ });
170437
+ }
170438
+ duration(message) {
170439
+ return this._addCheck({
170440
+ kind: "duration",
170441
+ ...errorUtil.errToObj(message)
170442
+ });
170443
+ }
170444
+ regex(regex, message) {
170445
+ return this._addCheck({
170446
+ kind: "regex",
170447
+ regex,
170448
+ ...errorUtil.errToObj(message)
170449
+ });
170450
+ }
170451
+ includes(value, options) {
170452
+ return this._addCheck({
170453
+ kind: "includes",
170454
+ value,
170455
+ position: options?.position,
170456
+ ...errorUtil.errToObj(options?.message)
170457
+ });
170458
+ }
170459
+ startsWith(value, message) {
170460
+ return this._addCheck({
170461
+ kind: "startsWith",
170462
+ value,
170463
+ ...errorUtil.errToObj(message)
170464
+ });
170465
+ }
170466
+ endsWith(value, message) {
170467
+ return this._addCheck({
170468
+ kind: "endsWith",
170469
+ value,
170470
+ ...errorUtil.errToObj(message)
170471
+ });
170472
+ }
170473
+ min(minLength, message) {
170474
+ return this._addCheck({
170475
+ kind: "min",
170476
+ value: minLength,
170477
+ ...errorUtil.errToObj(message)
170478
+ });
170479
+ }
170480
+ max(maxLength, message) {
170481
+ return this._addCheck({
170482
+ kind: "max",
170483
+ value: maxLength,
170484
+ ...errorUtil.errToObj(message)
170485
+ });
170486
+ }
170487
+ length(len, message) {
170488
+ return this._addCheck({
170489
+ kind: "length",
170490
+ value: len,
170491
+ ...errorUtil.errToObj(message)
170492
+ });
170493
+ }
170494
+ /**
170495
+ * Equivalent to `.min(1)`
170496
+ */
170497
+ nonempty(message) {
170498
+ return this.min(1, errorUtil.errToObj(message));
170499
+ }
170500
+ trim() {
170501
+ return new ZodString({
170502
+ ...this._def,
170503
+ checks: [...this._def.checks, { kind: "trim" }]
170504
+ });
170505
+ }
170506
+ toLowerCase() {
170507
+ return new ZodString({
170508
+ ...this._def,
170509
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
170510
+ });
170511
+ }
170512
+ toUpperCase() {
170513
+ return new ZodString({
170514
+ ...this._def,
170515
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
170516
+ });
170517
+ }
170518
+ get isDatetime() {
170519
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
170520
+ }
170521
+ get isDate() {
170522
+ return !!this._def.checks.find((ch) => ch.kind === "date");
170523
+ }
170524
+ get isTime() {
170525
+ return !!this._def.checks.find((ch) => ch.kind === "time");
170526
+ }
170527
+ get isDuration() {
170528
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
170529
+ }
170530
+ get isEmail() {
170531
+ return !!this._def.checks.find((ch) => ch.kind === "email");
170532
+ }
170533
+ get isURL() {
170534
+ return !!this._def.checks.find((ch) => ch.kind === "url");
170535
+ }
170536
+ get isEmoji() {
170537
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
170538
+ }
170539
+ get isUUID() {
170540
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
170541
+ }
170542
+ get isNANOID() {
170543
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
170544
+ }
170545
+ get isCUID() {
170546
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
170547
+ }
170548
+ get isCUID2() {
170549
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
170550
+ }
170551
+ get isULID() {
170552
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
170553
+ }
170554
+ get isIP() {
170555
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
170556
+ }
170557
+ get isCIDR() {
170558
+ return !!this._def.checks.find((ch) => ch.kind === "cidr");
170559
+ }
170560
+ get isBase64() {
170561
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
170562
+ }
170563
+ get isBase64url() {
170564
+ return !!this._def.checks.find((ch) => ch.kind === "base64url");
170565
+ }
170566
+ get minLength() {
170567
+ let min = null;
170568
+ for (const ch of this._def.checks) if (ch.kind === "min") {
170569
+ if (min === null || ch.value > min) min = ch.value;
170570
+ }
170571
+ return min;
170572
+ }
170573
+ get maxLength() {
170574
+ let max = null;
170575
+ for (const ch of this._def.checks) if (ch.kind === "max") {
170576
+ if (max === null || ch.value < max) max = ch.value;
170577
+ }
170578
+ return max;
170579
+ }
170580
+ };
170581
+ ZodString.create = (params) => {
170582
+ return new ZodString({
170583
+ checks: [],
170584
+ typeName: ZodFirstPartyTypeKind.ZodString,
170585
+ coerce: params?.coerce ?? false,
170586
+ ...processCreateParams(params)
170587
+ });
170588
+ };
170589
+ function floatSafeRemainder(val, step) {
170590
+ const valDecCount = (val.toString().split(".")[1] || "").length;
170591
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
170592
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
170593
+ return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
170594
+ }
170595
+ var ZodNumber = class ZodNumber extends ZodType {
170596
+ constructor() {
170597
+ super(...arguments);
170598
+ this.min = this.gte;
170599
+ this.max = this.lte;
170600
+ this.step = this.multipleOf;
170601
+ }
170602
+ _parse(input) {
170603
+ if (this._def.coerce) input.data = Number(input.data);
170604
+ if (this._getType(input) !== ZodParsedType.number) {
170605
+ const ctx = this._getOrReturnCtx(input);
170606
+ addIssueToContext(ctx, {
170607
+ code: ZodIssueCode.invalid_type,
170608
+ expected: ZodParsedType.number,
170609
+ received: ctx.parsedType
170610
+ });
170611
+ return INVALID;
170612
+ }
170613
+ let ctx = void 0;
170614
+ const status = new ParseStatus();
170615
+ for (const check of this._def.checks) if (check.kind === "int") {
170616
+ if (!util.isInteger(input.data)) {
170617
+ ctx = this._getOrReturnCtx(input, ctx);
170618
+ addIssueToContext(ctx, {
170619
+ code: ZodIssueCode.invalid_type,
170620
+ expected: "integer",
170621
+ received: "float",
170622
+ message: check.message
170623
+ });
170624
+ status.dirty();
170625
+ }
170626
+ } else if (check.kind === "min") {
170627
+ if (check.inclusive ? input.data < check.value : input.data <= check.value) {
170628
+ ctx = this._getOrReturnCtx(input, ctx);
170629
+ addIssueToContext(ctx, {
170630
+ code: ZodIssueCode.too_small,
170631
+ minimum: check.value,
170632
+ type: "number",
170633
+ inclusive: check.inclusive,
170634
+ exact: false,
170635
+ message: check.message
170636
+ });
170637
+ status.dirty();
170638
+ }
170639
+ } else if (check.kind === "max") {
170640
+ if (check.inclusive ? input.data > check.value : input.data >= check.value) {
170641
+ ctx = this._getOrReturnCtx(input, ctx);
170642
+ addIssueToContext(ctx, {
170643
+ code: ZodIssueCode.too_big,
170644
+ maximum: check.value,
170645
+ type: "number",
170646
+ inclusive: check.inclusive,
170647
+ exact: false,
170648
+ message: check.message
170649
+ });
170650
+ status.dirty();
170651
+ }
170652
+ } else if (check.kind === "multipleOf") {
170653
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
170654
+ ctx = this._getOrReturnCtx(input, ctx);
170655
+ addIssueToContext(ctx, {
170656
+ code: ZodIssueCode.not_multiple_of,
170657
+ multipleOf: check.value,
170658
+ message: check.message
170659
+ });
170660
+ status.dirty();
170661
+ }
170662
+ } else if (check.kind === "finite") {
170663
+ if (!Number.isFinite(input.data)) {
170664
+ ctx = this._getOrReturnCtx(input, ctx);
170665
+ addIssueToContext(ctx, {
170666
+ code: ZodIssueCode.not_finite,
170667
+ message: check.message
170668
+ });
170669
+ status.dirty();
170670
+ }
170671
+ } else util.assertNever(check);
170672
+ return {
170673
+ status: status.value,
170674
+ value: input.data
170675
+ };
170676
+ }
170677
+ gte(value, message) {
170678
+ return this.setLimit("min", value, true, errorUtil.toString(message));
170679
+ }
170680
+ gt(value, message) {
170681
+ return this.setLimit("min", value, false, errorUtil.toString(message));
170682
+ }
170683
+ lte(value, message) {
170684
+ return this.setLimit("max", value, true, errorUtil.toString(message));
170685
+ }
170686
+ lt(value, message) {
170687
+ return this.setLimit("max", value, false, errorUtil.toString(message));
170688
+ }
170689
+ setLimit(kind, value, inclusive, message) {
170690
+ return new ZodNumber({
170691
+ ...this._def,
170692
+ checks: [...this._def.checks, {
170693
+ kind,
170694
+ value,
170695
+ inclusive,
170696
+ message: errorUtil.toString(message)
170697
+ }]
170698
+ });
170699
+ }
170700
+ _addCheck(check) {
170701
+ return new ZodNumber({
170702
+ ...this._def,
170703
+ checks: [...this._def.checks, check]
170704
+ });
170705
+ }
170706
+ int(message) {
170707
+ return this._addCheck({
170708
+ kind: "int",
170709
+ message: errorUtil.toString(message)
170710
+ });
170711
+ }
170712
+ positive(message) {
170713
+ return this._addCheck({
170714
+ kind: "min",
170715
+ value: 0,
170716
+ inclusive: false,
170717
+ message: errorUtil.toString(message)
170718
+ });
170719
+ }
170720
+ negative(message) {
170721
+ return this._addCheck({
170722
+ kind: "max",
170723
+ value: 0,
170724
+ inclusive: false,
170725
+ message: errorUtil.toString(message)
170726
+ });
170727
+ }
170728
+ nonpositive(message) {
170729
+ return this._addCheck({
170730
+ kind: "max",
170731
+ value: 0,
170732
+ inclusive: true,
170733
+ message: errorUtil.toString(message)
170734
+ });
170735
+ }
170736
+ nonnegative(message) {
170737
+ return this._addCheck({
170738
+ kind: "min",
170739
+ value: 0,
170740
+ inclusive: true,
170741
+ message: errorUtil.toString(message)
170742
+ });
170743
+ }
170744
+ multipleOf(value, message) {
170745
+ return this._addCheck({
170746
+ kind: "multipleOf",
170747
+ value,
170748
+ message: errorUtil.toString(message)
170749
+ });
170750
+ }
170751
+ finite(message) {
170752
+ return this._addCheck({
170753
+ kind: "finite",
170754
+ message: errorUtil.toString(message)
170755
+ });
170756
+ }
170757
+ safe(message) {
170758
+ return this._addCheck({
170759
+ kind: "min",
170760
+ inclusive: true,
170761
+ value: Number.MIN_SAFE_INTEGER,
170762
+ message: errorUtil.toString(message)
170763
+ })._addCheck({
170764
+ kind: "max",
170765
+ inclusive: true,
170766
+ value: Number.MAX_SAFE_INTEGER,
170767
+ message: errorUtil.toString(message)
170768
+ });
170769
+ }
170770
+ get minValue() {
170771
+ let min = null;
170772
+ for (const ch of this._def.checks) if (ch.kind === "min") {
170773
+ if (min === null || ch.value > min) min = ch.value;
170774
+ }
170775
+ return min;
170776
+ }
170777
+ get maxValue() {
170778
+ let max = null;
170779
+ for (const ch of this._def.checks) if (ch.kind === "max") {
170780
+ if (max === null || ch.value < max) max = ch.value;
170781
+ }
170782
+ return max;
170783
+ }
170784
+ get isInt() {
170785
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
170786
+ }
170787
+ get isFinite() {
170788
+ let max = null;
170789
+ let min = null;
170790
+ for (const ch of this._def.checks) if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") return true;
170791
+ else if (ch.kind === "min") {
170792
+ if (min === null || ch.value > min) min = ch.value;
170793
+ } else if (ch.kind === "max") {
170794
+ if (max === null || ch.value < max) max = ch.value;
170795
+ }
170796
+ return Number.isFinite(min) && Number.isFinite(max);
170797
+ }
170798
+ };
170799
+ ZodNumber.create = (params) => {
170800
+ return new ZodNumber({
170801
+ checks: [],
170802
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
170803
+ coerce: params?.coerce || false,
170804
+ ...processCreateParams(params)
170805
+ });
170806
+ };
170807
+ var ZodBigInt = class ZodBigInt extends ZodType {
170808
+ constructor() {
170809
+ super(...arguments);
170810
+ this.min = this.gte;
170811
+ this.max = this.lte;
170812
+ }
170813
+ _parse(input) {
170814
+ if (this._def.coerce) try {
170815
+ input.data = BigInt(input.data);
170816
+ } catch {
170817
+ return this._getInvalidInput(input);
170818
+ }
170819
+ if (this._getType(input) !== ZodParsedType.bigint) return this._getInvalidInput(input);
170820
+ let ctx = void 0;
170821
+ const status = new ParseStatus();
170822
+ for (const check of this._def.checks) if (check.kind === "min") {
170823
+ if (check.inclusive ? input.data < check.value : input.data <= check.value) {
170824
+ ctx = this._getOrReturnCtx(input, ctx);
170825
+ addIssueToContext(ctx, {
170826
+ code: ZodIssueCode.too_small,
170827
+ type: "bigint",
170828
+ minimum: check.value,
170829
+ inclusive: check.inclusive,
170830
+ message: check.message
170831
+ });
170832
+ status.dirty();
170833
+ }
170834
+ } else if (check.kind === "max") {
170835
+ if (check.inclusive ? input.data > check.value : input.data >= check.value) {
170836
+ ctx = this._getOrReturnCtx(input, ctx);
170837
+ addIssueToContext(ctx, {
170838
+ code: ZodIssueCode.too_big,
170839
+ type: "bigint",
170840
+ maximum: check.value,
170841
+ inclusive: check.inclusive,
170842
+ message: check.message
170843
+ });
170844
+ status.dirty();
170845
+ }
170846
+ } else if (check.kind === "multipleOf") {
170847
+ if (input.data % check.value !== BigInt(0)) {
170848
+ ctx = this._getOrReturnCtx(input, ctx);
170849
+ addIssueToContext(ctx, {
170850
+ code: ZodIssueCode.not_multiple_of,
170851
+ multipleOf: check.value,
170852
+ message: check.message
170853
+ });
170854
+ status.dirty();
170855
+ }
170856
+ } else util.assertNever(check);
170857
+ return {
170858
+ status: status.value,
170859
+ value: input.data
170860
+ };
170861
+ }
170862
+ _getInvalidInput(input) {
170863
+ const ctx = this._getOrReturnCtx(input);
170864
+ addIssueToContext(ctx, {
170865
+ code: ZodIssueCode.invalid_type,
170866
+ expected: ZodParsedType.bigint,
170867
+ received: ctx.parsedType
170868
+ });
170869
+ return INVALID;
170870
+ }
170871
+ gte(value, message) {
170872
+ return this.setLimit("min", value, true, errorUtil.toString(message));
170873
+ }
170874
+ gt(value, message) {
170875
+ return this.setLimit("min", value, false, errorUtil.toString(message));
170876
+ }
170877
+ lte(value, message) {
170878
+ return this.setLimit("max", value, true, errorUtil.toString(message));
170879
+ }
170880
+ lt(value, message) {
170881
+ return this.setLimit("max", value, false, errorUtil.toString(message));
170882
+ }
170883
+ setLimit(kind, value, inclusive, message) {
170884
+ return new ZodBigInt({
170885
+ ...this._def,
170886
+ checks: [...this._def.checks, {
170887
+ kind,
170888
+ value,
170889
+ inclusive,
170890
+ message: errorUtil.toString(message)
170891
+ }]
170892
+ });
170893
+ }
170894
+ _addCheck(check) {
170895
+ return new ZodBigInt({
170896
+ ...this._def,
170897
+ checks: [...this._def.checks, check]
170898
+ });
170899
+ }
170900
+ positive(message) {
170901
+ return this._addCheck({
170902
+ kind: "min",
170903
+ value: BigInt(0),
170904
+ inclusive: false,
170905
+ message: errorUtil.toString(message)
170906
+ });
170907
+ }
170908
+ negative(message) {
170909
+ return this._addCheck({
170910
+ kind: "max",
170911
+ value: BigInt(0),
170912
+ inclusive: false,
170913
+ message: errorUtil.toString(message)
170914
+ });
170915
+ }
170916
+ nonpositive(message) {
170917
+ return this._addCheck({
170918
+ kind: "max",
170919
+ value: BigInt(0),
170920
+ inclusive: true,
170921
+ message: errorUtil.toString(message)
170922
+ });
170923
+ }
170924
+ nonnegative(message) {
170925
+ return this._addCheck({
170926
+ kind: "min",
170927
+ value: BigInt(0),
170928
+ inclusive: true,
170929
+ message: errorUtil.toString(message)
170930
+ });
170931
+ }
170932
+ multipleOf(value, message) {
170933
+ return this._addCheck({
170934
+ kind: "multipleOf",
170935
+ value,
170936
+ message: errorUtil.toString(message)
170937
+ });
170938
+ }
170939
+ get minValue() {
170940
+ let min = null;
170941
+ for (const ch of this._def.checks) if (ch.kind === "min") {
170942
+ if (min === null || ch.value > min) min = ch.value;
170943
+ }
170944
+ return min;
170945
+ }
170946
+ get maxValue() {
170947
+ let max = null;
170948
+ for (const ch of this._def.checks) if (ch.kind === "max") {
170949
+ if (max === null || ch.value < max) max = ch.value;
170950
+ }
170951
+ return max;
170952
+ }
170953
+ };
170954
+ ZodBigInt.create = (params) => {
170955
+ return new ZodBigInt({
170956
+ checks: [],
170957
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
170958
+ coerce: params?.coerce ?? false,
170959
+ ...processCreateParams(params)
170960
+ });
170961
+ };
170962
+ var ZodBoolean = class extends ZodType {
170963
+ _parse(input) {
170964
+ if (this._def.coerce) input.data = Boolean(input.data);
170965
+ if (this._getType(input) !== ZodParsedType.boolean) {
170966
+ const ctx = this._getOrReturnCtx(input);
170967
+ addIssueToContext(ctx, {
170968
+ code: ZodIssueCode.invalid_type,
170969
+ expected: ZodParsedType.boolean,
170970
+ received: ctx.parsedType
170971
+ });
170972
+ return INVALID;
170973
+ }
170974
+ return OK(input.data);
170975
+ }
170976
+ };
170977
+ ZodBoolean.create = (params) => {
170978
+ return new ZodBoolean({
170979
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
170980
+ coerce: params?.coerce || false,
170981
+ ...processCreateParams(params)
170982
+ });
170983
+ };
170984
+ var ZodDate = class ZodDate extends ZodType {
170985
+ _parse(input) {
170986
+ if (this._def.coerce) input.data = new Date(input.data);
170987
+ if (this._getType(input) !== ZodParsedType.date) {
170988
+ const ctx = this._getOrReturnCtx(input);
170989
+ addIssueToContext(ctx, {
170990
+ code: ZodIssueCode.invalid_type,
170991
+ expected: ZodParsedType.date,
170992
+ received: ctx.parsedType
170993
+ });
170994
+ return INVALID;
170995
+ }
170996
+ if (Number.isNaN(input.data.getTime())) {
170997
+ addIssueToContext(this._getOrReturnCtx(input), { code: ZodIssueCode.invalid_date });
170998
+ return INVALID;
170999
+ }
171000
+ const status = new ParseStatus();
171001
+ let ctx = void 0;
171002
+ for (const check of this._def.checks) if (check.kind === "min") {
171003
+ if (input.data.getTime() < check.value) {
171004
+ ctx = this._getOrReturnCtx(input, ctx);
171005
+ addIssueToContext(ctx, {
171006
+ code: ZodIssueCode.too_small,
171007
+ message: check.message,
171008
+ inclusive: true,
171009
+ exact: false,
171010
+ minimum: check.value,
171011
+ type: "date"
171012
+ });
171013
+ status.dirty();
171014
+ }
171015
+ } else if (check.kind === "max") {
171016
+ if (input.data.getTime() > check.value) {
171017
+ ctx = this._getOrReturnCtx(input, ctx);
171018
+ addIssueToContext(ctx, {
171019
+ code: ZodIssueCode.too_big,
171020
+ message: check.message,
171021
+ inclusive: true,
171022
+ exact: false,
171023
+ maximum: check.value,
171024
+ type: "date"
171025
+ });
171026
+ status.dirty();
171027
+ }
171028
+ } else util.assertNever(check);
171029
+ return {
171030
+ status: status.value,
171031
+ value: new Date(input.data.getTime())
171032
+ };
171033
+ }
171034
+ _addCheck(check) {
171035
+ return new ZodDate({
171036
+ ...this._def,
171037
+ checks: [...this._def.checks, check]
171038
+ });
171039
+ }
171040
+ min(minDate, message) {
171041
+ return this._addCheck({
171042
+ kind: "min",
171043
+ value: minDate.getTime(),
171044
+ message: errorUtil.toString(message)
171045
+ });
171046
+ }
171047
+ max(maxDate, message) {
171048
+ return this._addCheck({
171049
+ kind: "max",
171050
+ value: maxDate.getTime(),
171051
+ message: errorUtil.toString(message)
171052
+ });
171053
+ }
171054
+ get minDate() {
171055
+ let min = null;
171056
+ for (const ch of this._def.checks) if (ch.kind === "min") {
171057
+ if (min === null || ch.value > min) min = ch.value;
171058
+ }
171059
+ return min != null ? new Date(min) : null;
171060
+ }
171061
+ get maxDate() {
171062
+ let max = null;
171063
+ for (const ch of this._def.checks) if (ch.kind === "max") {
171064
+ if (max === null || ch.value < max) max = ch.value;
171065
+ }
171066
+ return max != null ? new Date(max) : null;
171067
+ }
171068
+ };
171069
+ ZodDate.create = (params) => {
171070
+ return new ZodDate({
171071
+ checks: [],
171072
+ coerce: params?.coerce || false,
171073
+ typeName: ZodFirstPartyTypeKind.ZodDate,
171074
+ ...processCreateParams(params)
171075
+ });
171076
+ };
171077
+ var ZodSymbol = class extends ZodType {
171078
+ _parse(input) {
171079
+ if (this._getType(input) !== ZodParsedType.symbol) {
171080
+ const ctx = this._getOrReturnCtx(input);
171081
+ addIssueToContext(ctx, {
171082
+ code: ZodIssueCode.invalid_type,
171083
+ expected: ZodParsedType.symbol,
171084
+ received: ctx.parsedType
171085
+ });
171086
+ return INVALID;
171087
+ }
171088
+ return OK(input.data);
171089
+ }
171090
+ };
171091
+ ZodSymbol.create = (params) => {
171092
+ return new ZodSymbol({
171093
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
171094
+ ...processCreateParams(params)
171095
+ });
171096
+ };
171097
+ var ZodUndefined = class extends ZodType {
171098
+ _parse(input) {
171099
+ if (this._getType(input) !== ZodParsedType.undefined) {
171100
+ const ctx = this._getOrReturnCtx(input);
171101
+ addIssueToContext(ctx, {
171102
+ code: ZodIssueCode.invalid_type,
171103
+ expected: ZodParsedType.undefined,
171104
+ received: ctx.parsedType
171105
+ });
171106
+ return INVALID;
171107
+ }
171108
+ return OK(input.data);
171109
+ }
171110
+ };
171111
+ ZodUndefined.create = (params) => {
171112
+ return new ZodUndefined({
171113
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
171114
+ ...processCreateParams(params)
171115
+ });
171116
+ };
171117
+ var ZodNull = class extends ZodType {
171118
+ _parse(input) {
171119
+ if (this._getType(input) !== ZodParsedType.null) {
171120
+ const ctx = this._getOrReturnCtx(input);
171121
+ addIssueToContext(ctx, {
171122
+ code: ZodIssueCode.invalid_type,
171123
+ expected: ZodParsedType.null,
171124
+ received: ctx.parsedType
171125
+ });
171126
+ return INVALID;
171127
+ }
171128
+ return OK(input.data);
171129
+ }
171130
+ };
171131
+ ZodNull.create = (params) => {
171132
+ return new ZodNull({
171133
+ typeName: ZodFirstPartyTypeKind.ZodNull,
171134
+ ...processCreateParams(params)
171135
+ });
171136
+ };
171137
+ var ZodAny = class extends ZodType {
171138
+ constructor() {
171139
+ super(...arguments);
171140
+ this._any = true;
171141
+ }
171142
+ _parse(input) {
171143
+ return OK(input.data);
171144
+ }
171145
+ };
171146
+ ZodAny.create = (params) => {
171147
+ return new ZodAny({
171148
+ typeName: ZodFirstPartyTypeKind.ZodAny,
171149
+ ...processCreateParams(params)
171150
+ });
171151
+ };
171152
+ var ZodUnknown = class extends ZodType {
171153
+ constructor() {
171154
+ super(...arguments);
171155
+ this._unknown = true;
171156
+ }
171157
+ _parse(input) {
171158
+ return OK(input.data);
171159
+ }
171160
+ };
171161
+ ZodUnknown.create = (params) => {
171162
+ return new ZodUnknown({
171163
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
171164
+ ...processCreateParams(params)
171165
+ });
171166
+ };
171167
+ var ZodNever = class extends ZodType {
171168
+ _parse(input) {
171169
+ const ctx = this._getOrReturnCtx(input);
171170
+ addIssueToContext(ctx, {
171171
+ code: ZodIssueCode.invalid_type,
171172
+ expected: ZodParsedType.never,
171173
+ received: ctx.parsedType
171174
+ });
171175
+ return INVALID;
171176
+ }
171177
+ };
171178
+ ZodNever.create = (params) => {
171179
+ return new ZodNever({
171180
+ typeName: ZodFirstPartyTypeKind.ZodNever,
171181
+ ...processCreateParams(params)
171182
+ });
171183
+ };
171184
+ var ZodVoid = class extends ZodType {
171185
+ _parse(input) {
171186
+ if (this._getType(input) !== ZodParsedType.undefined) {
171187
+ const ctx = this._getOrReturnCtx(input);
171188
+ addIssueToContext(ctx, {
171189
+ code: ZodIssueCode.invalid_type,
171190
+ expected: ZodParsedType.void,
171191
+ received: ctx.parsedType
171192
+ });
171193
+ return INVALID;
171194
+ }
171195
+ return OK(input.data);
171196
+ }
171197
+ };
171198
+ ZodVoid.create = (params) => {
171199
+ return new ZodVoid({
171200
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
171201
+ ...processCreateParams(params)
171202
+ });
171203
+ };
171204
+ var ZodArray = class ZodArray extends ZodType {
171205
+ _parse(input) {
171206
+ const { ctx, status } = this._processInputParams(input);
171207
+ const def = this._def;
171208
+ if (ctx.parsedType !== ZodParsedType.array) {
171209
+ addIssueToContext(ctx, {
171210
+ code: ZodIssueCode.invalid_type,
171211
+ expected: ZodParsedType.array,
171212
+ received: ctx.parsedType
171213
+ });
171214
+ return INVALID;
171215
+ }
171216
+ if (def.exactLength !== null) {
171217
+ const tooBig = ctx.data.length > def.exactLength.value;
171218
+ const tooSmall = ctx.data.length < def.exactLength.value;
171219
+ if (tooBig || tooSmall) {
171220
+ addIssueToContext(ctx, {
171221
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
171222
+ minimum: tooSmall ? def.exactLength.value : void 0,
171223
+ maximum: tooBig ? def.exactLength.value : void 0,
171224
+ type: "array",
171225
+ inclusive: true,
171226
+ exact: true,
171227
+ message: def.exactLength.message
171228
+ });
171229
+ status.dirty();
171230
+ }
171231
+ }
171232
+ if (def.minLength !== null) {
171233
+ if (ctx.data.length < def.minLength.value) {
171234
+ addIssueToContext(ctx, {
171235
+ code: ZodIssueCode.too_small,
171236
+ minimum: def.minLength.value,
171237
+ type: "array",
171238
+ inclusive: true,
171239
+ exact: false,
171240
+ message: def.minLength.message
171241
+ });
171242
+ status.dirty();
171243
+ }
171244
+ }
171245
+ if (def.maxLength !== null) {
171246
+ if (ctx.data.length > def.maxLength.value) {
171247
+ addIssueToContext(ctx, {
171248
+ code: ZodIssueCode.too_big,
171249
+ maximum: def.maxLength.value,
171250
+ type: "array",
171251
+ inclusive: true,
171252
+ exact: false,
171253
+ message: def.maxLength.message
171254
+ });
171255
+ status.dirty();
171256
+ }
171257
+ }
171258
+ if (ctx.common.async) return Promise.all([...ctx.data].map((item, i) => {
171259
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
171260
+ })).then((result) => {
171261
+ return ParseStatus.mergeArray(status, result);
171262
+ });
171263
+ const result = [...ctx.data].map((item, i) => {
171264
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
171265
+ });
171266
+ return ParseStatus.mergeArray(status, result);
171267
+ }
171268
+ get element() {
171269
+ return this._def.type;
171270
+ }
171271
+ min(minLength, message) {
171272
+ return new ZodArray({
171273
+ ...this._def,
171274
+ minLength: {
171275
+ value: minLength,
171276
+ message: errorUtil.toString(message)
171277
+ }
171278
+ });
171279
+ }
171280
+ max(maxLength, message) {
171281
+ return new ZodArray({
171282
+ ...this._def,
171283
+ maxLength: {
171284
+ value: maxLength,
171285
+ message: errorUtil.toString(message)
171286
+ }
171287
+ });
171288
+ }
171289
+ length(len, message) {
171290
+ return new ZodArray({
171291
+ ...this._def,
171292
+ exactLength: {
171293
+ value: len,
171294
+ message: errorUtil.toString(message)
171295
+ }
171296
+ });
171297
+ }
171298
+ nonempty(message) {
171299
+ return this.min(1, message);
171300
+ }
171301
+ };
171302
+ ZodArray.create = (schema, params) => {
171303
+ return new ZodArray({
171304
+ type: schema,
171305
+ minLength: null,
171306
+ maxLength: null,
171307
+ exactLength: null,
171308
+ typeName: ZodFirstPartyTypeKind.ZodArray,
171309
+ ...processCreateParams(params)
171310
+ });
171311
+ };
171312
+ function deepPartialify(schema) {
171313
+ if (schema instanceof ZodObject) {
171314
+ const newShape = {};
171315
+ for (const key in schema.shape) {
171316
+ const fieldSchema = schema.shape[key];
171317
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
171318
+ }
171319
+ return new ZodObject({
171320
+ ...schema._def,
171321
+ shape: () => newShape
171322
+ });
171323
+ } else if (schema instanceof ZodArray) return new ZodArray({
171324
+ ...schema._def,
171325
+ type: deepPartialify(schema.element)
171326
+ });
171327
+ else if (schema instanceof ZodOptional) return ZodOptional.create(deepPartialify(schema.unwrap()));
171328
+ else if (schema instanceof ZodNullable) return ZodNullable.create(deepPartialify(schema.unwrap()));
171329
+ else if (schema instanceof ZodTuple) return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
171330
+ else return schema;
171331
+ }
171332
+ var ZodObject = class ZodObject extends ZodType {
171333
+ constructor() {
171334
+ super(...arguments);
171335
+ this._cached = null;
171336
+ /**
171337
+ * @deprecated In most cases, this is no longer needed - unknown properties are now silently stripped.
171338
+ * If you want to pass through unknown properties, use `.passthrough()` instead.
171339
+ */
171340
+ this.nonstrict = this.passthrough;
171341
+ /**
171342
+ * @deprecated Use `.extend` instead
171343
+ * */
171344
+ this.augment = this.extend;
171345
+ }
171346
+ _getCached() {
171347
+ if (this._cached !== null) return this._cached;
171348
+ const shape = this._def.shape();
171349
+ const keys = util.objectKeys(shape);
171350
+ this._cached = {
171351
+ shape,
171352
+ keys
171353
+ };
171354
+ return this._cached;
171355
+ }
171356
+ _parse(input) {
171357
+ if (this._getType(input) !== ZodParsedType.object) {
171358
+ const ctx = this._getOrReturnCtx(input);
171359
+ addIssueToContext(ctx, {
171360
+ code: ZodIssueCode.invalid_type,
171361
+ expected: ZodParsedType.object,
171362
+ received: ctx.parsedType
171363
+ });
171364
+ return INVALID;
171365
+ }
171366
+ const { status, ctx } = this._processInputParams(input);
171367
+ const { shape, keys: shapeKeys } = this._getCached();
171368
+ const extraKeys = [];
171369
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
171370
+ for (const key in ctx.data) if (!shapeKeys.includes(key)) extraKeys.push(key);
171371
+ }
171372
+ const pairs = [];
171373
+ for (const key of shapeKeys) {
171374
+ const keyValidator = shape[key];
171375
+ const value = ctx.data[key];
171376
+ pairs.push({
171377
+ key: {
171378
+ status: "valid",
171379
+ value: key
171380
+ },
171381
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
171382
+ alwaysSet: key in ctx.data
171383
+ });
171384
+ }
171385
+ if (this._def.catchall instanceof ZodNever) {
171386
+ const unknownKeys = this._def.unknownKeys;
171387
+ if (unknownKeys === "passthrough") for (const key of extraKeys) pairs.push({
171388
+ key: {
171389
+ status: "valid",
171390
+ value: key
171391
+ },
171392
+ value: {
171393
+ status: "valid",
171394
+ value: ctx.data[key]
171395
+ }
171396
+ });
171397
+ else if (unknownKeys === "strict") {
171398
+ if (extraKeys.length > 0) {
171399
+ addIssueToContext(ctx, {
171400
+ code: ZodIssueCode.unrecognized_keys,
171401
+ keys: extraKeys
171402
+ });
171403
+ status.dirty();
171404
+ }
171405
+ } else if (unknownKeys === "strip") {} else throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
171406
+ } else {
171407
+ const catchall = this._def.catchall;
171408
+ for (const key of extraKeys) {
171409
+ const value = ctx.data[key];
171410
+ pairs.push({
171411
+ key: {
171412
+ status: "valid",
171413
+ value: key
171414
+ },
171415
+ value: catchall._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
171416
+ alwaysSet: key in ctx.data
171417
+ });
171418
+ }
171419
+ }
171420
+ if (ctx.common.async) return Promise.resolve().then(async () => {
171421
+ const syncPairs = [];
171422
+ for (const pair of pairs) {
171423
+ const key = await pair.key;
171424
+ const value = await pair.value;
171425
+ syncPairs.push({
171426
+ key,
171427
+ value,
171428
+ alwaysSet: pair.alwaysSet
171429
+ });
171430
+ }
171431
+ return syncPairs;
171432
+ }).then((syncPairs) => {
171433
+ return ParseStatus.mergeObjectSync(status, syncPairs);
171434
+ });
171435
+ else return ParseStatus.mergeObjectSync(status, pairs);
171436
+ }
171437
+ get shape() {
171438
+ return this._def.shape();
171439
+ }
171440
+ strict(message) {
171441
+ errorUtil.errToObj;
171442
+ return new ZodObject({
171443
+ ...this._def,
171444
+ unknownKeys: "strict",
171445
+ ...message !== void 0 ? { errorMap: (issue, ctx) => {
171446
+ const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
171447
+ if (issue.code === "unrecognized_keys") return { message: errorUtil.errToObj(message).message ?? defaultError };
171448
+ return { message: defaultError };
171449
+ } } : {}
171450
+ });
171451
+ }
171452
+ strip() {
171453
+ return new ZodObject({
171454
+ ...this._def,
171455
+ unknownKeys: "strip"
171456
+ });
171457
+ }
171458
+ passthrough() {
171459
+ return new ZodObject({
171460
+ ...this._def,
171461
+ unknownKeys: "passthrough"
171462
+ });
171463
+ }
171464
+ extend(augmentation) {
171465
+ return new ZodObject({
171466
+ ...this._def,
171467
+ shape: () => ({
171468
+ ...this._def.shape(),
171469
+ ...augmentation
171470
+ })
171471
+ });
171472
+ }
171473
+ /**
171474
+ * Prior to zod@1.0.12 there was a bug in the
171475
+ * inferred type of merged objects. Please
171476
+ * upgrade if you are experiencing issues.
171477
+ */
171478
+ merge(merging) {
171479
+ return new ZodObject({
171480
+ unknownKeys: merging._def.unknownKeys,
171481
+ catchall: merging._def.catchall,
171482
+ shape: () => ({
171483
+ ...this._def.shape(),
171484
+ ...merging._def.shape()
171485
+ }),
171486
+ typeName: ZodFirstPartyTypeKind.ZodObject
171487
+ });
171488
+ }
171489
+ setKey(key, schema) {
171490
+ return this.augment({ [key]: schema });
171491
+ }
171492
+ catchall(index) {
171493
+ return new ZodObject({
171494
+ ...this._def,
171495
+ catchall: index
171496
+ });
171497
+ }
171498
+ pick(mask) {
171499
+ const shape = {};
171500
+ for (const key of util.objectKeys(mask)) if (mask[key] && this.shape[key]) shape[key] = this.shape[key];
171501
+ return new ZodObject({
171502
+ ...this._def,
171503
+ shape: () => shape
171504
+ });
171505
+ }
171506
+ omit(mask) {
171507
+ const shape = {};
171508
+ for (const key of util.objectKeys(this.shape)) if (!mask[key]) shape[key] = this.shape[key];
171509
+ return new ZodObject({
171510
+ ...this._def,
171511
+ shape: () => shape
171512
+ });
171513
+ }
171514
+ /**
171515
+ * @deprecated
171516
+ */
171517
+ deepPartial() {
171518
+ return deepPartialify(this);
171519
+ }
171520
+ partial(mask) {
171521
+ const newShape = {};
171522
+ for (const key of util.objectKeys(this.shape)) {
171523
+ const fieldSchema = this.shape[key];
171524
+ if (mask && !mask[key]) newShape[key] = fieldSchema;
171525
+ else newShape[key] = fieldSchema.optional();
171526
+ }
171527
+ return new ZodObject({
171528
+ ...this._def,
171529
+ shape: () => newShape
171530
+ });
171531
+ }
171532
+ required(mask) {
171533
+ const newShape = {};
171534
+ for (const key of util.objectKeys(this.shape)) if (mask && !mask[key]) newShape[key] = this.shape[key];
171535
+ else {
171536
+ let newField = this.shape[key];
171537
+ while (newField instanceof ZodOptional) newField = newField._def.innerType;
171538
+ newShape[key] = newField;
171539
+ }
171540
+ return new ZodObject({
171541
+ ...this._def,
171542
+ shape: () => newShape
171543
+ });
171544
+ }
171545
+ keyof() {
171546
+ return createZodEnum(util.objectKeys(this.shape));
171547
+ }
171548
+ };
171549
+ ZodObject.create = (shape, params) => {
171550
+ return new ZodObject({
171551
+ shape: () => shape,
171552
+ unknownKeys: "strip",
171553
+ catchall: ZodNever.create(),
171554
+ typeName: ZodFirstPartyTypeKind.ZodObject,
171555
+ ...processCreateParams(params)
171556
+ });
171557
+ };
171558
+ ZodObject.strictCreate = (shape, params) => {
171559
+ return new ZodObject({
171560
+ shape: () => shape,
171561
+ unknownKeys: "strict",
171562
+ catchall: ZodNever.create(),
171563
+ typeName: ZodFirstPartyTypeKind.ZodObject,
171564
+ ...processCreateParams(params)
171565
+ });
171566
+ };
171567
+ ZodObject.lazycreate = (shape, params) => {
171568
+ return new ZodObject({
171569
+ shape,
171570
+ unknownKeys: "strip",
171571
+ catchall: ZodNever.create(),
171572
+ typeName: ZodFirstPartyTypeKind.ZodObject,
171573
+ ...processCreateParams(params)
171574
+ });
171575
+ };
171576
+ var ZodUnion = class extends ZodType {
171577
+ _parse(input) {
171578
+ const { ctx } = this._processInputParams(input);
171579
+ const options = this._def.options;
171580
+ function handleResults(results) {
171581
+ for (const result of results) if (result.result.status === "valid") return result.result;
171582
+ for (const result of results) if (result.result.status === "dirty") {
171583
+ ctx.common.issues.push(...result.ctx.common.issues);
171584
+ return result.result;
171585
+ }
171586
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
171587
+ addIssueToContext(ctx, {
171588
+ code: ZodIssueCode.invalid_union,
171589
+ unionErrors
171590
+ });
171591
+ return INVALID;
171592
+ }
171593
+ if (ctx.common.async) return Promise.all(options.map(async (option) => {
171594
+ const childCtx = {
171595
+ ...ctx,
171596
+ common: {
171597
+ ...ctx.common,
171598
+ issues: []
171599
+ },
171600
+ parent: null
171601
+ };
171602
+ return {
171603
+ result: await option._parseAsync({
171604
+ data: ctx.data,
171605
+ path: ctx.path,
171606
+ parent: childCtx
171607
+ }),
171608
+ ctx: childCtx
171609
+ };
171610
+ })).then(handleResults);
171611
+ else {
171612
+ let dirty = void 0;
171613
+ const issues = [];
171614
+ for (const option of options) {
171615
+ const childCtx = {
171616
+ ...ctx,
171617
+ common: {
171618
+ ...ctx.common,
171619
+ issues: []
171620
+ },
171621
+ parent: null
171622
+ };
171623
+ const result = option._parseSync({
171624
+ data: ctx.data,
171625
+ path: ctx.path,
171626
+ parent: childCtx
171627
+ });
171628
+ if (result.status === "valid") return result;
171629
+ else if (result.status === "dirty" && !dirty) dirty = {
171630
+ result,
171631
+ ctx: childCtx
171632
+ };
171633
+ if (childCtx.common.issues.length) issues.push(childCtx.common.issues);
171634
+ }
171635
+ if (dirty) {
171636
+ ctx.common.issues.push(...dirty.ctx.common.issues);
171637
+ return dirty.result;
171638
+ }
171639
+ const unionErrors = issues.map((issues) => new ZodError(issues));
171640
+ addIssueToContext(ctx, {
171641
+ code: ZodIssueCode.invalid_union,
171642
+ unionErrors
171643
+ });
171644
+ return INVALID;
171645
+ }
171646
+ }
171647
+ get options() {
171648
+ return this._def.options;
171649
+ }
171650
+ };
171651
+ ZodUnion.create = (types, params) => {
171652
+ return new ZodUnion({
171653
+ options: types,
171654
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
171655
+ ...processCreateParams(params)
171656
+ });
171657
+ };
171658
+ const getDiscriminator = (type) => {
171659
+ if (type instanceof ZodLazy) return getDiscriminator(type.schema);
171660
+ else if (type instanceof ZodEffects) return getDiscriminator(type.innerType());
171661
+ else if (type instanceof ZodLiteral) return [type.value];
171662
+ else if (type instanceof ZodEnum) return type.options;
171663
+ else if (type instanceof ZodNativeEnum) return util.objectValues(type.enum);
171664
+ else if (type instanceof ZodDefault) return getDiscriminator(type._def.innerType);
171665
+ else if (type instanceof ZodUndefined) return [void 0];
171666
+ else if (type instanceof ZodNull) return [null];
171667
+ else if (type instanceof ZodOptional) return [void 0, ...getDiscriminator(type.unwrap())];
171668
+ else if (type instanceof ZodNullable) return [null, ...getDiscriminator(type.unwrap())];
171669
+ else if (type instanceof ZodBranded) return getDiscriminator(type.unwrap());
171670
+ else if (type instanceof ZodReadonly) return getDiscriminator(type.unwrap());
171671
+ else if (type instanceof ZodCatch) return getDiscriminator(type._def.innerType);
171672
+ else return [];
171673
+ };
171674
+ var ZodDiscriminatedUnion = class ZodDiscriminatedUnion extends ZodType {
171675
+ _parse(input) {
171676
+ const { ctx } = this._processInputParams(input);
171677
+ if (ctx.parsedType !== ZodParsedType.object) {
171678
+ addIssueToContext(ctx, {
171679
+ code: ZodIssueCode.invalid_type,
171680
+ expected: ZodParsedType.object,
171681
+ received: ctx.parsedType
171682
+ });
171683
+ return INVALID;
171684
+ }
171685
+ const discriminator = this.discriminator;
171686
+ const discriminatorValue = ctx.data[discriminator];
171687
+ const option = this.optionsMap.get(discriminatorValue);
171688
+ if (!option) {
171689
+ addIssueToContext(ctx, {
171690
+ code: ZodIssueCode.invalid_union_discriminator,
171691
+ options: Array.from(this.optionsMap.keys()),
171692
+ path: [discriminator]
171693
+ });
171694
+ return INVALID;
171695
+ }
171696
+ if (ctx.common.async) return option._parseAsync({
171697
+ data: ctx.data,
171698
+ path: ctx.path,
171699
+ parent: ctx
171700
+ });
171701
+ else return option._parseSync({
171702
+ data: ctx.data,
171703
+ path: ctx.path,
171704
+ parent: ctx
171705
+ });
171706
+ }
171707
+ get discriminator() {
171708
+ return this._def.discriminator;
171709
+ }
171710
+ get options() {
171711
+ return this._def.options;
171712
+ }
171713
+ get optionsMap() {
171714
+ return this._def.optionsMap;
171715
+ }
171716
+ /**
171717
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
171718
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
171719
+ * have a different value for each object in the union.
171720
+ * @param discriminator the name of the discriminator property
171721
+ * @param types an array of object schemas
171722
+ * @param params
171723
+ */
171724
+ static create(discriminator, options, params) {
171725
+ const optionsMap = /* @__PURE__ */ new Map();
171726
+ for (const type of options) {
171727
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
171728
+ if (!discriminatorValues.length) throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
171729
+ for (const value of discriminatorValues) {
171730
+ if (optionsMap.has(value)) throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
171731
+ optionsMap.set(value, type);
171732
+ }
171733
+ }
171734
+ return new ZodDiscriminatedUnion({
171735
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
171736
+ discriminator,
171737
+ options,
171738
+ optionsMap,
171739
+ ...processCreateParams(params)
171740
+ });
171741
+ }
171742
+ };
171743
+ function mergeValues(a, b) {
171744
+ const aType = getParsedType(a);
171745
+ const bType = getParsedType(b);
171746
+ if (a === b) return {
171747
+ valid: true,
171748
+ data: a
171749
+ };
171750
+ else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
171751
+ const bKeys = util.objectKeys(b);
171752
+ const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
171753
+ const newObj = {
171754
+ ...a,
171755
+ ...b
171756
+ };
171757
+ for (const key of sharedKeys) {
171758
+ const sharedValue = mergeValues(a[key], b[key]);
171759
+ if (!sharedValue.valid) return { valid: false };
171760
+ newObj[key] = sharedValue.data;
171761
+ }
171762
+ return {
171763
+ valid: true,
171764
+ data: newObj
171765
+ };
171766
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
171767
+ if (a.length !== b.length) return { valid: false };
171768
+ const newArray = [];
171769
+ for (let index = 0; index < a.length; index++) {
171770
+ const itemA = a[index];
171771
+ const itemB = b[index];
171772
+ const sharedValue = mergeValues(itemA, itemB);
171773
+ if (!sharedValue.valid) return { valid: false };
171774
+ newArray.push(sharedValue.data);
171775
+ }
171776
+ return {
171777
+ valid: true,
171778
+ data: newArray
171779
+ };
171780
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) return {
171781
+ valid: true,
171782
+ data: a
171783
+ };
171784
+ else return { valid: false };
171785
+ }
171786
+ var ZodIntersection = class extends ZodType {
171787
+ _parse(input) {
171788
+ const { status, ctx } = this._processInputParams(input);
171789
+ const handleParsed = (parsedLeft, parsedRight) => {
171790
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) return INVALID;
171791
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
171792
+ if (!merged.valid) {
171793
+ addIssueToContext(ctx, { code: ZodIssueCode.invalid_intersection_types });
171794
+ return INVALID;
171795
+ }
171796
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) status.dirty();
171797
+ return {
171798
+ status: status.value,
171799
+ value: merged.data
171800
+ };
171801
+ };
171802
+ if (ctx.common.async) return Promise.all([this._def.left._parseAsync({
171803
+ data: ctx.data,
171804
+ path: ctx.path,
171805
+ parent: ctx
171806
+ }), this._def.right._parseAsync({
171807
+ data: ctx.data,
171808
+ path: ctx.path,
171809
+ parent: ctx
171810
+ })]).then(([left, right]) => handleParsed(left, right));
171811
+ else return handleParsed(this._def.left._parseSync({
171812
+ data: ctx.data,
171813
+ path: ctx.path,
171814
+ parent: ctx
171815
+ }), this._def.right._parseSync({
171816
+ data: ctx.data,
171817
+ path: ctx.path,
171818
+ parent: ctx
171819
+ }));
171820
+ }
171821
+ };
171822
+ ZodIntersection.create = (left, right, params) => {
171823
+ return new ZodIntersection({
171824
+ left,
171825
+ right,
171826
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
171827
+ ...processCreateParams(params)
171828
+ });
171829
+ };
171830
+ var ZodTuple = class ZodTuple extends ZodType {
171831
+ _parse(input) {
171832
+ const { status, ctx } = this._processInputParams(input);
171833
+ if (ctx.parsedType !== ZodParsedType.array) {
171834
+ addIssueToContext(ctx, {
171835
+ code: ZodIssueCode.invalid_type,
171836
+ expected: ZodParsedType.array,
171837
+ received: ctx.parsedType
171838
+ });
171839
+ return INVALID;
171840
+ }
171841
+ if (ctx.data.length < this._def.items.length) {
171842
+ addIssueToContext(ctx, {
171843
+ code: ZodIssueCode.too_small,
171844
+ minimum: this._def.items.length,
171845
+ inclusive: true,
171846
+ exact: false,
171847
+ type: "array"
171848
+ });
171849
+ return INVALID;
171850
+ }
171851
+ if (!this._def.rest && ctx.data.length > this._def.items.length) {
171852
+ addIssueToContext(ctx, {
171853
+ code: ZodIssueCode.too_big,
171854
+ maximum: this._def.items.length,
171855
+ inclusive: true,
171856
+ exact: false,
171857
+ type: "array"
171858
+ });
171859
+ status.dirty();
171860
+ }
171861
+ const items = [...ctx.data].map((item, itemIndex) => {
171862
+ const schema = this._def.items[itemIndex] || this._def.rest;
171863
+ if (!schema) return null;
171864
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
171865
+ }).filter((x) => !!x);
171866
+ if (ctx.common.async) return Promise.all(items).then((results) => {
171867
+ return ParseStatus.mergeArray(status, results);
171868
+ });
171869
+ else return ParseStatus.mergeArray(status, items);
171870
+ }
171871
+ get items() {
171872
+ return this._def.items;
171873
+ }
171874
+ rest(rest) {
171875
+ return new ZodTuple({
171876
+ ...this._def,
171877
+ rest
171878
+ });
171879
+ }
171880
+ };
171881
+ ZodTuple.create = (schemas, params) => {
171882
+ if (!Array.isArray(schemas)) throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
171883
+ return new ZodTuple({
171884
+ items: schemas,
171885
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
171886
+ rest: null,
171887
+ ...processCreateParams(params)
171888
+ });
171889
+ };
171890
+ var ZodRecord = class ZodRecord extends ZodType {
171891
+ get keySchema() {
171892
+ return this._def.keyType;
171893
+ }
171894
+ get valueSchema() {
171895
+ return this._def.valueType;
171896
+ }
171897
+ _parse(input) {
171898
+ const { status, ctx } = this._processInputParams(input);
171899
+ if (ctx.parsedType !== ZodParsedType.object) {
171900
+ addIssueToContext(ctx, {
171901
+ code: ZodIssueCode.invalid_type,
171902
+ expected: ZodParsedType.object,
171903
+ received: ctx.parsedType
171904
+ });
171905
+ return INVALID;
171906
+ }
171907
+ const pairs = [];
171908
+ const keyType = this._def.keyType;
171909
+ const valueType = this._def.valueType;
171910
+ for (const key in ctx.data) pairs.push({
171911
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
171912
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
171913
+ alwaysSet: key in ctx.data
171914
+ });
171915
+ if (ctx.common.async) return ParseStatus.mergeObjectAsync(status, pairs);
171916
+ else return ParseStatus.mergeObjectSync(status, pairs);
171917
+ }
171918
+ get element() {
171919
+ return this._def.valueType;
171920
+ }
171921
+ static create(first, second, third) {
171922
+ if (second instanceof ZodType) return new ZodRecord({
171923
+ keyType: first,
171924
+ valueType: second,
171925
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
171926
+ ...processCreateParams(third)
171927
+ });
171928
+ return new ZodRecord({
171929
+ keyType: ZodString.create(),
171930
+ valueType: first,
171931
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
171932
+ ...processCreateParams(second)
171933
+ });
171934
+ }
171935
+ };
171936
+ var ZodMap = class extends ZodType {
171937
+ get keySchema() {
171938
+ return this._def.keyType;
171939
+ }
171940
+ get valueSchema() {
171941
+ return this._def.valueType;
171942
+ }
171943
+ _parse(input) {
171944
+ const { status, ctx } = this._processInputParams(input);
171945
+ if (ctx.parsedType !== ZodParsedType.map) {
171946
+ addIssueToContext(ctx, {
171947
+ code: ZodIssueCode.invalid_type,
171948
+ expected: ZodParsedType.map,
171949
+ received: ctx.parsedType
171950
+ });
171951
+ return INVALID;
171952
+ }
171953
+ const keyType = this._def.keyType;
171954
+ const valueType = this._def.valueType;
171955
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
171956
+ return {
171957
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
171958
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
171959
+ };
171960
+ });
171961
+ if (ctx.common.async) {
171962
+ const finalMap = /* @__PURE__ */ new Map();
171963
+ return Promise.resolve().then(async () => {
171964
+ for (const pair of pairs) {
171965
+ const key = await pair.key;
171966
+ const value = await pair.value;
171967
+ if (key.status === "aborted" || value.status === "aborted") return INVALID;
171968
+ if (key.status === "dirty" || value.status === "dirty") status.dirty();
171969
+ finalMap.set(key.value, value.value);
171970
+ }
171971
+ return {
171972
+ status: status.value,
171973
+ value: finalMap
171974
+ };
171975
+ });
171976
+ } else {
171977
+ const finalMap = /* @__PURE__ */ new Map();
171978
+ for (const pair of pairs) {
171979
+ const key = pair.key;
171980
+ const value = pair.value;
171981
+ if (key.status === "aborted" || value.status === "aborted") return INVALID;
171982
+ if (key.status === "dirty" || value.status === "dirty") status.dirty();
171983
+ finalMap.set(key.value, value.value);
171984
+ }
171985
+ return {
171986
+ status: status.value,
171987
+ value: finalMap
171988
+ };
171989
+ }
171990
+ }
171991
+ };
171992
+ ZodMap.create = (keyType, valueType, params) => {
171993
+ return new ZodMap({
171994
+ valueType,
171995
+ keyType,
171996
+ typeName: ZodFirstPartyTypeKind.ZodMap,
171997
+ ...processCreateParams(params)
171998
+ });
171999
+ };
172000
+ var ZodSet = class ZodSet extends ZodType {
172001
+ _parse(input) {
172002
+ const { status, ctx } = this._processInputParams(input);
172003
+ if (ctx.parsedType !== ZodParsedType.set) {
172004
+ addIssueToContext(ctx, {
172005
+ code: ZodIssueCode.invalid_type,
172006
+ expected: ZodParsedType.set,
172007
+ received: ctx.parsedType
172008
+ });
172009
+ return INVALID;
172010
+ }
172011
+ const def = this._def;
172012
+ if (def.minSize !== null) {
172013
+ if (ctx.data.size < def.minSize.value) {
172014
+ addIssueToContext(ctx, {
172015
+ code: ZodIssueCode.too_small,
172016
+ minimum: def.minSize.value,
172017
+ type: "set",
172018
+ inclusive: true,
172019
+ exact: false,
172020
+ message: def.minSize.message
172021
+ });
172022
+ status.dirty();
172023
+ }
172024
+ }
172025
+ if (def.maxSize !== null) {
172026
+ if (ctx.data.size > def.maxSize.value) {
172027
+ addIssueToContext(ctx, {
172028
+ code: ZodIssueCode.too_big,
172029
+ maximum: def.maxSize.value,
172030
+ type: "set",
172031
+ inclusive: true,
172032
+ exact: false,
172033
+ message: def.maxSize.message
172034
+ });
172035
+ status.dirty();
172036
+ }
172037
+ }
172038
+ const valueType = this._def.valueType;
172039
+ function finalizeSet(elements) {
172040
+ const parsedSet = /* @__PURE__ */ new Set();
172041
+ for (const element of elements) {
172042
+ if (element.status === "aborted") return INVALID;
172043
+ if (element.status === "dirty") status.dirty();
172044
+ parsedSet.add(element.value);
172045
+ }
172046
+ return {
172047
+ status: status.value,
172048
+ value: parsedSet
172049
+ };
172050
+ }
172051
+ const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
172052
+ if (ctx.common.async) return Promise.all(elements).then((elements) => finalizeSet(elements));
172053
+ else return finalizeSet(elements);
172054
+ }
172055
+ min(minSize, message) {
172056
+ return new ZodSet({
172057
+ ...this._def,
172058
+ minSize: {
172059
+ value: minSize,
172060
+ message: errorUtil.toString(message)
172061
+ }
172062
+ });
172063
+ }
172064
+ max(maxSize, message) {
172065
+ return new ZodSet({
172066
+ ...this._def,
172067
+ maxSize: {
172068
+ value: maxSize,
172069
+ message: errorUtil.toString(message)
172070
+ }
172071
+ });
172072
+ }
172073
+ size(size, message) {
172074
+ return this.min(size, message).max(size, message);
172075
+ }
172076
+ nonempty(message) {
172077
+ return this.min(1, message);
172078
+ }
172079
+ };
172080
+ ZodSet.create = (valueType, params) => {
172081
+ return new ZodSet({
172082
+ valueType,
172083
+ minSize: null,
172084
+ maxSize: null,
172085
+ typeName: ZodFirstPartyTypeKind.ZodSet,
172086
+ ...processCreateParams(params)
172087
+ });
172088
+ };
172089
+ var ZodFunction = class ZodFunction extends ZodType {
172090
+ constructor() {
172091
+ super(...arguments);
172092
+ this.validate = this.implement;
172093
+ }
172094
+ _parse(input) {
172095
+ const { ctx } = this._processInputParams(input);
172096
+ if (ctx.parsedType !== ZodParsedType.function) {
172097
+ addIssueToContext(ctx, {
172098
+ code: ZodIssueCode.invalid_type,
172099
+ expected: ZodParsedType.function,
172100
+ received: ctx.parsedType
172101
+ });
172102
+ return INVALID;
172103
+ }
172104
+ function makeArgsIssue(args, error) {
172105
+ return makeIssue({
172106
+ data: args,
172107
+ path: ctx.path,
172108
+ errorMaps: [
172109
+ ctx.common.contextualErrorMap,
172110
+ ctx.schemaErrorMap,
172111
+ getErrorMap(),
172112
+ errorMap
172113
+ ].filter((x) => !!x),
172114
+ issueData: {
172115
+ code: ZodIssueCode.invalid_arguments,
172116
+ argumentsError: error
172117
+ }
172118
+ });
172119
+ }
172120
+ function makeReturnsIssue(returns, error) {
172121
+ return makeIssue({
172122
+ data: returns,
172123
+ path: ctx.path,
172124
+ errorMaps: [
172125
+ ctx.common.contextualErrorMap,
172126
+ ctx.schemaErrorMap,
172127
+ getErrorMap(),
172128
+ errorMap
172129
+ ].filter((x) => !!x),
172130
+ issueData: {
172131
+ code: ZodIssueCode.invalid_return_type,
172132
+ returnTypeError: error
172133
+ }
172134
+ });
172135
+ }
172136
+ const params = { errorMap: ctx.common.contextualErrorMap };
172137
+ const fn = ctx.data;
172138
+ if (this._def.returns instanceof ZodPromise) {
172139
+ const me = this;
172140
+ return OK(async function(...args) {
172141
+ const error = new ZodError([]);
172142
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
172143
+ error.addIssue(makeArgsIssue(args, e));
172144
+ throw error;
172145
+ });
172146
+ const result = await Reflect.apply(fn, this, parsedArgs);
172147
+ return await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
172148
+ error.addIssue(makeReturnsIssue(result, e));
172149
+ throw error;
172150
+ });
172151
+ });
172152
+ } else {
172153
+ const me = this;
172154
+ return OK(function(...args) {
172155
+ const parsedArgs = me._def.args.safeParse(args, params);
172156
+ if (!parsedArgs.success) throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
172157
+ const result = Reflect.apply(fn, this, parsedArgs.data);
172158
+ const parsedReturns = me._def.returns.safeParse(result, params);
172159
+ if (!parsedReturns.success) throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
172160
+ return parsedReturns.data;
172161
+ });
172162
+ }
172163
+ }
172164
+ parameters() {
172165
+ return this._def.args;
172166
+ }
172167
+ returnType() {
172168
+ return this._def.returns;
172169
+ }
172170
+ args(...items) {
172171
+ return new ZodFunction({
172172
+ ...this._def,
172173
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
172174
+ });
172175
+ }
172176
+ returns(returnType) {
172177
+ return new ZodFunction({
172178
+ ...this._def,
172179
+ returns: returnType
172180
+ });
172181
+ }
172182
+ implement(func) {
172183
+ return this.parse(func);
172184
+ }
172185
+ strictImplement(func) {
172186
+ return this.parse(func);
172187
+ }
172188
+ static create(args, returns, params) {
172189
+ return new ZodFunction({
172190
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
172191
+ returns: returns || ZodUnknown.create(),
172192
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
172193
+ ...processCreateParams(params)
172194
+ });
172195
+ }
172196
+ };
172197
+ var ZodLazy = class extends ZodType {
172198
+ get schema() {
172199
+ return this._def.getter();
172200
+ }
172201
+ _parse(input) {
172202
+ const { ctx } = this._processInputParams(input);
172203
+ return this._def.getter()._parse({
172204
+ data: ctx.data,
172205
+ path: ctx.path,
172206
+ parent: ctx
172207
+ });
172208
+ }
172209
+ };
172210
+ ZodLazy.create = (getter, params) => {
172211
+ return new ZodLazy({
172212
+ getter,
172213
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
172214
+ ...processCreateParams(params)
172215
+ });
172216
+ };
172217
+ var ZodLiteral = class extends ZodType {
172218
+ _parse(input) {
172219
+ if (input.data !== this._def.value) {
172220
+ const ctx = this._getOrReturnCtx(input);
172221
+ addIssueToContext(ctx, {
172222
+ received: ctx.data,
172223
+ code: ZodIssueCode.invalid_literal,
172224
+ expected: this._def.value
172225
+ });
172226
+ return INVALID;
172227
+ }
172228
+ return {
172229
+ status: "valid",
172230
+ value: input.data
172231
+ };
172232
+ }
172233
+ get value() {
172234
+ return this._def.value;
172235
+ }
172236
+ };
172237
+ ZodLiteral.create = (value, params) => {
172238
+ return new ZodLiteral({
172239
+ value,
172240
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
172241
+ ...processCreateParams(params)
172242
+ });
172243
+ };
172244
+ function createZodEnum(values, params) {
172245
+ return new ZodEnum({
172246
+ values,
172247
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
172248
+ ...processCreateParams(params)
172249
+ });
172250
+ }
172251
+ var ZodEnum = class ZodEnum extends ZodType {
172252
+ _parse(input) {
172253
+ if (typeof input.data !== "string") {
172254
+ const ctx = this._getOrReturnCtx(input);
172255
+ const expectedValues = this._def.values;
172256
+ addIssueToContext(ctx, {
172257
+ expected: util.joinValues(expectedValues),
172258
+ received: ctx.parsedType,
172259
+ code: ZodIssueCode.invalid_type
172260
+ });
172261
+ return INVALID;
172262
+ }
172263
+ if (!this._cache) this._cache = new Set(this._def.values);
172264
+ if (!this._cache.has(input.data)) {
172265
+ const ctx = this._getOrReturnCtx(input);
172266
+ const expectedValues = this._def.values;
172267
+ addIssueToContext(ctx, {
172268
+ received: ctx.data,
172269
+ code: ZodIssueCode.invalid_enum_value,
172270
+ options: expectedValues
172271
+ });
172272
+ return INVALID;
172273
+ }
172274
+ return OK(input.data);
172275
+ }
172276
+ get options() {
172277
+ return this._def.values;
172278
+ }
172279
+ get enum() {
172280
+ const enumValues = {};
172281
+ for (const val of this._def.values) enumValues[val] = val;
172282
+ return enumValues;
172283
+ }
172284
+ get Values() {
172285
+ const enumValues = {};
172286
+ for (const val of this._def.values) enumValues[val] = val;
172287
+ return enumValues;
172288
+ }
172289
+ get Enum() {
172290
+ const enumValues = {};
172291
+ for (const val of this._def.values) enumValues[val] = val;
172292
+ return enumValues;
172293
+ }
172294
+ extract(values, newDef = this._def) {
172295
+ return ZodEnum.create(values, {
172296
+ ...this._def,
172297
+ ...newDef
172298
+ });
172299
+ }
172300
+ exclude(values, newDef = this._def) {
172301
+ return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
172302
+ ...this._def,
172303
+ ...newDef
172304
+ });
172305
+ }
172306
+ };
172307
+ ZodEnum.create = createZodEnum;
172308
+ var ZodNativeEnum = class extends ZodType {
172309
+ _parse(input) {
172310
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
172311
+ const ctx = this._getOrReturnCtx(input);
172312
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
172313
+ const expectedValues = util.objectValues(nativeEnumValues);
172314
+ addIssueToContext(ctx, {
172315
+ expected: util.joinValues(expectedValues),
172316
+ received: ctx.parsedType,
172317
+ code: ZodIssueCode.invalid_type
172318
+ });
172319
+ return INVALID;
172320
+ }
172321
+ if (!this._cache) this._cache = new Set(util.getValidEnumValues(this._def.values));
172322
+ if (!this._cache.has(input.data)) {
172323
+ const expectedValues = util.objectValues(nativeEnumValues);
172324
+ addIssueToContext(ctx, {
172325
+ received: ctx.data,
172326
+ code: ZodIssueCode.invalid_enum_value,
172327
+ options: expectedValues
172328
+ });
172329
+ return INVALID;
172330
+ }
172331
+ return OK(input.data);
172332
+ }
172333
+ get enum() {
172334
+ return this._def.values;
172335
+ }
172336
+ };
172337
+ ZodNativeEnum.create = (values, params) => {
172338
+ return new ZodNativeEnum({
172339
+ values,
172340
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
172341
+ ...processCreateParams(params)
172342
+ });
172343
+ };
172344
+ var ZodPromise = class extends ZodType {
172345
+ unwrap() {
172346
+ return this._def.type;
172347
+ }
172348
+ _parse(input) {
172349
+ const { ctx } = this._processInputParams(input);
172350
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
172351
+ addIssueToContext(ctx, {
172352
+ code: ZodIssueCode.invalid_type,
172353
+ expected: ZodParsedType.promise,
172354
+ received: ctx.parsedType
172355
+ });
172356
+ return INVALID;
172357
+ }
172358
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
172359
+ return OK(promisified.then((data) => {
172360
+ return this._def.type.parseAsync(data, {
172361
+ path: ctx.path,
172362
+ errorMap: ctx.common.contextualErrorMap
172363
+ });
172364
+ }));
172365
+ }
172366
+ };
172367
+ ZodPromise.create = (schema, params) => {
172368
+ return new ZodPromise({
172369
+ type: schema,
172370
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
172371
+ ...processCreateParams(params)
172372
+ });
172373
+ };
172374
+ var ZodEffects = class extends ZodType {
172375
+ innerType() {
172376
+ return this._def.schema;
172377
+ }
172378
+ sourceType() {
172379
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
172380
+ }
172381
+ _parse(input) {
172382
+ const { status, ctx } = this._processInputParams(input);
172383
+ const effect = this._def.effect || null;
172384
+ const checkCtx = {
172385
+ addIssue: (arg) => {
172386
+ addIssueToContext(ctx, arg);
172387
+ if (arg.fatal) status.abort();
172388
+ else status.dirty();
172389
+ },
172390
+ get path() {
172391
+ return ctx.path;
172392
+ }
172393
+ };
172394
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
172395
+ if (effect.type === "preprocess") {
172396
+ const processed = effect.transform(ctx.data, checkCtx);
172397
+ if (ctx.common.async) return Promise.resolve(processed).then(async (processed) => {
172398
+ if (status.value === "aborted") return INVALID;
172399
+ const result = await this._def.schema._parseAsync({
172400
+ data: processed,
172401
+ path: ctx.path,
172402
+ parent: ctx
172403
+ });
172404
+ if (result.status === "aborted") return INVALID;
172405
+ if (result.status === "dirty") return DIRTY(result.value);
172406
+ if (status.value === "dirty") return DIRTY(result.value);
172407
+ return result;
172408
+ });
172409
+ else {
172410
+ if (status.value === "aborted") return INVALID;
172411
+ const result = this._def.schema._parseSync({
172412
+ data: processed,
172413
+ path: ctx.path,
172414
+ parent: ctx
172415
+ });
172416
+ if (result.status === "aborted") return INVALID;
172417
+ if (result.status === "dirty") return DIRTY(result.value);
172418
+ if (status.value === "dirty") return DIRTY(result.value);
172419
+ return result;
172420
+ }
172421
+ }
172422
+ if (effect.type === "refinement") {
172423
+ const executeRefinement = (acc) => {
172424
+ const result = effect.refinement(acc, checkCtx);
172425
+ if (ctx.common.async) return Promise.resolve(result);
172426
+ if (result instanceof Promise) throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
172427
+ return acc;
172428
+ };
172429
+ if (ctx.common.async === false) {
172430
+ const inner = this._def.schema._parseSync({
172431
+ data: ctx.data,
172432
+ path: ctx.path,
172433
+ parent: ctx
172434
+ });
172435
+ if (inner.status === "aborted") return INVALID;
172436
+ if (inner.status === "dirty") status.dirty();
172437
+ executeRefinement(inner.value);
172438
+ return {
172439
+ status: status.value,
172440
+ value: inner.value
172441
+ };
172442
+ } else return this._def.schema._parseAsync({
172443
+ data: ctx.data,
172444
+ path: ctx.path,
172445
+ parent: ctx
172446
+ }).then((inner) => {
172447
+ if (inner.status === "aborted") return INVALID;
172448
+ if (inner.status === "dirty") status.dirty();
172449
+ return executeRefinement(inner.value).then(() => {
172450
+ return {
172451
+ status: status.value,
172452
+ value: inner.value
172453
+ };
172454
+ });
172455
+ });
172456
+ }
172457
+ if (effect.type === "transform") {
172458
+ if (ctx.common.async === false) {
172459
+ const base = this._def.schema._parseSync({
172460
+ data: ctx.data,
172461
+ path: ctx.path,
172462
+ parent: ctx
172463
+ });
172464
+ if (!isValid(base)) return INVALID;
172465
+ const result = effect.transform(base.value, checkCtx);
172466
+ if (result instanceof Promise) throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
172467
+ return {
172468
+ status: status.value,
172469
+ value: result
172470
+ };
172471
+ } else return this._def.schema._parseAsync({
172472
+ data: ctx.data,
172473
+ path: ctx.path,
172474
+ parent: ctx
172475
+ }).then((base) => {
172476
+ if (!isValid(base)) return INVALID;
172477
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
172478
+ status: status.value,
172479
+ value: result
172480
+ }));
172481
+ });
172482
+ }
172483
+ util.assertNever(effect);
172484
+ }
172485
+ };
172486
+ ZodEffects.create = (schema, effect, params) => {
172487
+ return new ZodEffects({
172488
+ schema,
172489
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
172490
+ effect,
172491
+ ...processCreateParams(params)
172492
+ });
172493
+ };
172494
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
172495
+ return new ZodEffects({
172496
+ schema,
172497
+ effect: {
172498
+ type: "preprocess",
172499
+ transform: preprocess
172500
+ },
172501
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
172502
+ ...processCreateParams(params)
172503
+ });
172504
+ };
172505
+ var ZodOptional = class extends ZodType {
172506
+ _parse(input) {
172507
+ if (this._getType(input) === ZodParsedType.undefined) return OK(void 0);
172508
+ return this._def.innerType._parse(input);
172509
+ }
172510
+ unwrap() {
172511
+ return this._def.innerType;
172512
+ }
172513
+ };
172514
+ ZodOptional.create = (type, params) => {
172515
+ return new ZodOptional({
172516
+ innerType: type,
172517
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
172518
+ ...processCreateParams(params)
172519
+ });
172520
+ };
172521
+ var ZodNullable = class extends ZodType {
172522
+ _parse(input) {
172523
+ if (this._getType(input) === ZodParsedType.null) return OK(null);
172524
+ return this._def.innerType._parse(input);
172525
+ }
172526
+ unwrap() {
172527
+ return this._def.innerType;
172528
+ }
172529
+ };
172530
+ ZodNullable.create = (type, params) => {
172531
+ return new ZodNullable({
172532
+ innerType: type,
172533
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
172534
+ ...processCreateParams(params)
172535
+ });
172536
+ };
172537
+ var ZodDefault = class extends ZodType {
172538
+ _parse(input) {
172539
+ const { ctx } = this._processInputParams(input);
172540
+ let data = ctx.data;
172541
+ if (ctx.parsedType === ZodParsedType.undefined) data = this._def.defaultValue();
172542
+ return this._def.innerType._parse({
172543
+ data,
172544
+ path: ctx.path,
172545
+ parent: ctx
172546
+ });
172547
+ }
172548
+ removeDefault() {
172549
+ return this._def.innerType;
172550
+ }
172551
+ };
172552
+ ZodDefault.create = (type, params) => {
172553
+ return new ZodDefault({
172554
+ innerType: type,
172555
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
172556
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
172557
+ ...processCreateParams(params)
172558
+ });
172559
+ };
172560
+ var ZodCatch = class extends ZodType {
172561
+ _parse(input) {
172562
+ const { ctx } = this._processInputParams(input);
172563
+ const newCtx = {
172564
+ ...ctx,
172565
+ common: {
172566
+ ...ctx.common,
172567
+ issues: []
172568
+ }
172569
+ };
172570
+ const result = this._def.innerType._parse({
172571
+ data: newCtx.data,
172572
+ path: newCtx.path,
172573
+ parent: { ...newCtx }
172574
+ });
172575
+ if (isAsync(result)) return result.then((result) => {
172576
+ return {
172577
+ status: "valid",
172578
+ value: result.status === "valid" ? result.value : this._def.catchValue({
172579
+ get error() {
172580
+ return new ZodError(newCtx.common.issues);
172581
+ },
172582
+ input: newCtx.data
172583
+ })
172584
+ };
172585
+ });
172586
+ else return {
172587
+ status: "valid",
172588
+ value: result.status === "valid" ? result.value : this._def.catchValue({
172589
+ get error() {
172590
+ return new ZodError(newCtx.common.issues);
172591
+ },
172592
+ input: newCtx.data
172593
+ })
172594
+ };
172595
+ }
172596
+ removeCatch() {
172597
+ return this._def.innerType;
172598
+ }
172599
+ };
172600
+ ZodCatch.create = (type, params) => {
172601
+ return new ZodCatch({
172602
+ innerType: type,
172603
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
172604
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
172605
+ ...processCreateParams(params)
172606
+ });
172607
+ };
172608
+ var ZodNaN = class extends ZodType {
172609
+ _parse(input) {
172610
+ if (this._getType(input) !== ZodParsedType.nan) {
172611
+ const ctx = this._getOrReturnCtx(input);
172612
+ addIssueToContext(ctx, {
172613
+ code: ZodIssueCode.invalid_type,
172614
+ expected: ZodParsedType.nan,
172615
+ received: ctx.parsedType
172616
+ });
172617
+ return INVALID;
172618
+ }
172619
+ return {
172620
+ status: "valid",
172621
+ value: input.data
172622
+ };
172623
+ }
172624
+ };
172625
+ ZodNaN.create = (params) => {
172626
+ return new ZodNaN({
172627
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
172628
+ ...processCreateParams(params)
172629
+ });
172630
+ };
172631
+ var ZodBranded = class extends ZodType {
172632
+ _parse(input) {
172633
+ const { ctx } = this._processInputParams(input);
172634
+ const data = ctx.data;
172635
+ return this._def.type._parse({
172636
+ data,
172637
+ path: ctx.path,
172638
+ parent: ctx
172639
+ });
172640
+ }
172641
+ unwrap() {
172642
+ return this._def.type;
172643
+ }
172644
+ };
172645
+ var ZodPipeline = class ZodPipeline extends ZodType {
172646
+ _parse(input) {
172647
+ const { status, ctx } = this._processInputParams(input);
172648
+ if (ctx.common.async) {
172649
+ const handleAsync = async () => {
172650
+ const inResult = await this._def.in._parseAsync({
172651
+ data: ctx.data,
172652
+ path: ctx.path,
172653
+ parent: ctx
172654
+ });
172655
+ if (inResult.status === "aborted") return INVALID;
172656
+ if (inResult.status === "dirty") {
172657
+ status.dirty();
172658
+ return DIRTY(inResult.value);
172659
+ } else return this._def.out._parseAsync({
172660
+ data: inResult.value,
172661
+ path: ctx.path,
172662
+ parent: ctx
172663
+ });
172664
+ };
172665
+ return handleAsync();
172666
+ } else {
172667
+ const inResult = this._def.in._parseSync({
172668
+ data: ctx.data,
172669
+ path: ctx.path,
172670
+ parent: ctx
172671
+ });
172672
+ if (inResult.status === "aborted") return INVALID;
172673
+ if (inResult.status === "dirty") {
172674
+ status.dirty();
172675
+ return {
172676
+ status: "dirty",
172677
+ value: inResult.value
172678
+ };
172679
+ } else return this._def.out._parseSync({
172680
+ data: inResult.value,
172681
+ path: ctx.path,
172682
+ parent: ctx
172683
+ });
172684
+ }
172685
+ }
172686
+ static create(a, b) {
172687
+ return new ZodPipeline({
172688
+ in: a,
172689
+ out: b,
172690
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
172691
+ });
172692
+ }
172693
+ };
172694
+ var ZodReadonly = class extends ZodType {
172695
+ _parse(input) {
172696
+ const result = this._def.innerType._parse(input);
172697
+ const freeze = (data) => {
172698
+ if (isValid(data)) data.value = Object.freeze(data.value);
172699
+ return data;
172700
+ };
172701
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
172702
+ }
172703
+ unwrap() {
172704
+ return this._def.innerType;
172705
+ }
172706
+ };
172707
+ ZodReadonly.create = (type, params) => {
172708
+ return new ZodReadonly({
172709
+ innerType: type,
172710
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
172711
+ ...processCreateParams(params)
172712
+ });
172713
+ };
172714
+ ZodObject.lazycreate;
172715
+ var ZodFirstPartyTypeKind;
172716
+ (function(ZodFirstPartyTypeKind) {
172717
+ ZodFirstPartyTypeKind["ZodString"] = "ZodString";
172718
+ ZodFirstPartyTypeKind["ZodNumber"] = "ZodNumber";
172719
+ ZodFirstPartyTypeKind["ZodNaN"] = "ZodNaN";
172720
+ ZodFirstPartyTypeKind["ZodBigInt"] = "ZodBigInt";
172721
+ ZodFirstPartyTypeKind["ZodBoolean"] = "ZodBoolean";
172722
+ ZodFirstPartyTypeKind["ZodDate"] = "ZodDate";
172723
+ ZodFirstPartyTypeKind["ZodSymbol"] = "ZodSymbol";
172724
+ ZodFirstPartyTypeKind["ZodUndefined"] = "ZodUndefined";
172725
+ ZodFirstPartyTypeKind["ZodNull"] = "ZodNull";
172726
+ ZodFirstPartyTypeKind["ZodAny"] = "ZodAny";
172727
+ ZodFirstPartyTypeKind["ZodUnknown"] = "ZodUnknown";
172728
+ ZodFirstPartyTypeKind["ZodNever"] = "ZodNever";
172729
+ ZodFirstPartyTypeKind["ZodVoid"] = "ZodVoid";
172730
+ ZodFirstPartyTypeKind["ZodArray"] = "ZodArray";
172731
+ ZodFirstPartyTypeKind["ZodObject"] = "ZodObject";
172732
+ ZodFirstPartyTypeKind["ZodUnion"] = "ZodUnion";
172733
+ ZodFirstPartyTypeKind["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
172734
+ ZodFirstPartyTypeKind["ZodIntersection"] = "ZodIntersection";
172735
+ ZodFirstPartyTypeKind["ZodTuple"] = "ZodTuple";
172736
+ ZodFirstPartyTypeKind["ZodRecord"] = "ZodRecord";
172737
+ ZodFirstPartyTypeKind["ZodMap"] = "ZodMap";
172738
+ ZodFirstPartyTypeKind["ZodSet"] = "ZodSet";
172739
+ ZodFirstPartyTypeKind["ZodFunction"] = "ZodFunction";
172740
+ ZodFirstPartyTypeKind["ZodLazy"] = "ZodLazy";
172741
+ ZodFirstPartyTypeKind["ZodLiteral"] = "ZodLiteral";
172742
+ ZodFirstPartyTypeKind["ZodEnum"] = "ZodEnum";
172743
+ ZodFirstPartyTypeKind["ZodEffects"] = "ZodEffects";
172744
+ ZodFirstPartyTypeKind["ZodNativeEnum"] = "ZodNativeEnum";
172745
+ ZodFirstPartyTypeKind["ZodOptional"] = "ZodOptional";
172746
+ ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
172747
+ ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
172748
+ ZodFirstPartyTypeKind["ZodCatch"] = "ZodCatch";
172749
+ ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
172750
+ ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
172751
+ ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
172752
+ ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
172753
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
172754
+ const stringType = ZodString.create;
172755
+ const numberType = ZodNumber.create;
172756
+ ZodNaN.create;
172757
+ ZodBigInt.create;
172758
+ const booleanType = ZodBoolean.create;
172759
+ ZodDate.create;
172760
+ ZodSymbol.create;
172761
+ ZodUndefined.create;
172762
+ ZodNull.create;
172763
+ ZodAny.create;
172764
+ const unknownType = ZodUnknown.create;
172765
+ ZodNever.create;
172766
+ ZodVoid.create;
172767
+ const arrayType = ZodArray.create;
172768
+ const objectType = ZodObject.create;
172769
+ ZodObject.strictCreate;
172770
+ const unionType = ZodUnion.create;
172771
+ ZodDiscriminatedUnion.create;
172772
+ ZodIntersection.create;
172773
+ ZodTuple.create;
172774
+ const recordType = ZodRecord.create;
172775
+ ZodMap.create;
172776
+ ZodSet.create;
172777
+ ZodFunction.create;
172778
+ const lazyType = ZodLazy.create;
172779
+ const literalType = ZodLiteral.create;
172780
+ const enumType = ZodEnum.create;
172781
+ ZodNativeEnum.create;
172782
+ ZodPromise.create;
172783
+ ZodEffects.create;
172784
+ ZodOptional.create;
172785
+ ZodNullable.create;
172786
+ ZodEffects.createWithPreprocess;
172787
+ ZodPipeline.create;
172788
+ const NEVER = INVALID;
172789
+ //#endregion
172790
+ //#region frontend/src/design-fonts.ts
172791
+ const slot = enumType([
172792
+ "sans",
172793
+ "serif",
172794
+ "mono"
172795
+ ]);
172796
+ const size = enumType([
172797
+ "xs",
172798
+ "sm",
172799
+ "base",
172800
+ "lg",
172801
+ "xl",
172802
+ "2xl",
172803
+ "3xl",
172804
+ "4xl",
172805
+ "5xl",
172806
+ "6xl",
172807
+ "7xl",
172808
+ "8xl",
172809
+ "9xl"
172810
+ ]);
172811
+ const textStyle = {
172812
+ slot,
172813
+ weight: stringType(),
172814
+ lineHeight: stringType(),
172815
+ letterSpacing: stringType()
172816
+ };
172817
+ /** The contract's `fonts`; GraphQL's null (no fonts delivered) reads as absent. */
172818
+ const designFontsSchema = objectType({
172819
+ families: arrayType(objectType({
172820
+ slug: stringType(),
172821
+ name: stringType(),
172822
+ fallback: objectType({
172823
+ local: stringType(),
172824
+ sizeAdjust: stringType(),
172825
+ ascentOverride: stringType(),
172826
+ descentOverride: stringType(),
172827
+ lineGapOverride: stringType()
172828
+ }).nullable(),
172829
+ faces: arrayType(objectType({
172830
+ src: arrayType(stringType()).nonempty(),
172831
+ format: enumType([
172832
+ "woff2",
172833
+ "woff",
172834
+ "truetype",
172835
+ "opentype"
172836
+ ]),
172837
+ weight: stringType(),
172838
+ style: enumType([
172839
+ "normal",
172840
+ "italic",
172841
+ "oblique"
172842
+ ]),
172843
+ unicodeRange: stringType(),
172844
+ display: enumType([
172845
+ "auto",
172846
+ "block",
172847
+ "swap",
172848
+ "fallback",
172849
+ "optional"
172850
+ ]),
172851
+ preload: booleanType()
172852
+ }))
172853
+ })),
172854
+ slots: objectType({
172855
+ sans: stringType().nullable(),
172856
+ serif: stringType().nullable(),
172857
+ mono: stringType().nullable()
172858
+ })
172859
+ }).nullish().transform((fonts) => fonts ?? void 0);
172860
+ /** The contract's `textStyles`; GraphQL's null reads as absent. */
172861
+ const designTextStylesSchema = objectType({
172862
+ heading: objectType({
172863
+ ...textStyle,
172864
+ sizes: objectType({
172865
+ h1: size,
172866
+ h2: size,
172867
+ h3: size,
172868
+ h4: size,
172869
+ h5: size,
172870
+ h6: size
172871
+ })
172872
+ }),
172873
+ paragraph: objectType(textStyle)
172874
+ }).nullish().transform((styles) => styles ?? void 0);
172875
+ /** Hosts a Site's fonts must never come from (ADR 0006 in gq-design). */
172876
+ const GOOGLE = /(?:^|\.)(?:googleapis\.com|gstatic\.com|google\.com)$/i;
172877
+ function selfHosted(src) {
172878
+ try {
172879
+ const url = new URL(src);
172880
+ return (url.protocol === "https:" || url.protocol === "http:") && !GOOGLE.test(url.hostname);
172881
+ } catch {
172882
+ return false;
172883
+ }
172884
+ }
172885
+ /**
172886
+ * The fonts with only faces whose every file is an absolute URL off Google's
172887
+ * hosts. GQ Design already rejects any other host; this keeps a visitor's
172888
+ * browser from ever contacting Google even if a stored publication says otherwise.
172889
+ */
172890
+ function selfHostedFonts(fonts) {
172891
+ if (!fonts) return void 0;
172892
+ return {
172893
+ ...fonts,
172894
+ families: fonts.families.map((family) => ({
172895
+ ...family,
172896
+ faces: family.faces.filter((face) => face.src.every(selfHosted))
172897
+ }))
172898
+ };
172899
+ }
172900
+ const ROOT = /^(?:\.[a-zA-Z_][\w-]*|:root)$/;
172901
+ /**
172902
+ * The `@font-face` rules (Site faces with `font-display` as delivered, and the
172903
+ * metric-matched fallback faces) and the assigned slots' `--gqd-font-*` stacks.
172904
+ * The stacks are set on `:root` and again on the content root: the theme
172905
+ * stylesheet declares the system stacks on that root, which would otherwise
172906
+ * shadow the assignment inside Design content.
172907
+ */
172908
+ function designFontStyleSheet(fonts, root = ".gqd-content") {
172909
+ if (!ROOT.test(root)) throw new Error("Choose a simple class selector or :root.");
172910
+ const css = fontStyleSheet(selfHostedFonts(fonts ?? void 0));
172911
+ const slots = /:root\{([^{}]*)\}$/.exec(css);
172912
+ return slots && root !== ":root" ? `${css}${root}${root}{${slots[1]}}` : css;
172913
+ }
172914
+ /** At most two WOFF2 preloads GQ Design marks (the text styles' primary Latin faces). */
172915
+ function designFontPreloads(fonts) {
172916
+ return fontPreloads(selfHostedFonts(fonts ?? void 0));
172917
+ }
172918
+ /** The Heading and Paragraph text styles for Design content under `root`. */
172919
+ function designTextStyleSheet(textStyles, root = ".gqd-content") {
172920
+ return textStyleSheet(textStyles ?? void 0, root);
172921
+ }
172922
+ /**
172923
+ * The document head's font markup for the delivered design presets: the font
172924
+ * preloads (`<link rel="preload" as="font" type="font/woff2" crossorigin>`),
172925
+ * then the font and text style sheets. Emit it once per response, after
172926
+ * `designThemeStyleSheet(theme)`. Without fonts or text styles (an older CMS
172927
+ * or design publication) it is empty; font URLs only ever come from the presets.
172928
+ */
172929
+ function designFontsHead(design, options = {}) {
172930
+ const root = options.root ?? ".gqd-content";
172931
+ const links = designFontPreloads(design?.fonts).map((link) => `<link rel="preload" as="font" type="${escapeAttribute(link.type)}" href="${escapeAttribute(link.href)}" crossorigin>`);
172932
+ const fonts = designFontStyleSheet(design?.fonts, root);
172933
+ const text = designTextStyleSheet(design?.textStyles, root);
172934
+ return [
172935
+ ...links,
172936
+ ...fonts ? [`<style data-gqd-fonts>${fonts}</style>`] : [],
172937
+ ...text ? [`<style data-gqd-text-styles>${text}</style>`] : []
172938
+ ].join("");
172939
+ }
172940
+ //#endregion
172941
+ export { VIDEO_HERO_BLOCK as $, formatDate as A, renderDesignPostBlock as B, siteLanguages as C, renderDesignPattern as D, parseDesignBlocks as E, uriPath as F, renderWordPressBlocks as G, hasDesignCarousel as H, renderDesignCover as I, DESIGN_CAROUSEL_ITEM as J, designGridStyle as K, designPostContext as L, responseStatus as M, routeOf as N, cmsTime as O, stripHtml as P, renderDesignCarouselItem as Q, designQueryItems as R, routeLanguage as S, escapeHtml as T, hasVideoHero as U, renderDesignQuery as V, parseWordPressBlocks as W, designCarouselStyle as X, DESIGN_CAROUSEL_NAVIGATION as Y, renderDesignCarousel as Z, unionType as _, selectSiteLogo as _t, designTextStyleSheet as a, enhanceDesignNavigationHtml as at, isLanguageHome as b, safeContentUrl as bt, arrayType as c, presentationHtml as ct, lazyType as d, presentationStyleSheet as dt, renderDesignVideoHero as et, literalType as f, presentationVariables as ft, stringType as g, resolvePresentationToken as gt, recordType as h, resolveDesignTheme as ht, designFontsSchema as i, safeDesignRichText as it, menuItemHref as j, decodeEntities as k, booleanType as l, createPresentationModel as lt, objectType as m, designThemeVariables as mt, designFontStyleSheet as n, renderDesignImage as nt, designTextStylesSchema as o, navigationStyleSheet as ot, numberType as p, designThemeStyleSheet as pt, DESIGN_CAROUSEL as q, designFontsHead as r, renderDesignText as rt, NEVER as s, renderDesignNavigation as st, designFontPreloads as t, youtubeVideoId as tt, enumType as u, presentationModel as ut, unknownType as v, assertDesignBlocks as vt, designMenuItems as w, languageSubject as x, htmlLang as y, enhanceDesignCoverVideosHtml as yt, preloadDesignQueryPosts as z };