@getquick/content 0.4.2 → 0.5.1

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