@genspectrum/dashboard-components 1.5.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +4 -0
  2. package/custom-elements.json +37 -2
  3. package/dist/{NumberRangeFilterChangedEvent-CQ32Qy8D.js → NumberRangeFilterChangedEvent-BnPI-Asz.js} +17 -3
  4. package/dist/NumberRangeFilterChangedEvent-BnPI-Asz.js.map +1 -0
  5. package/dist/assets/{mutationOverTimeWorker-BJ_P2T8Y.js.map → mutationOverTimeWorker-DPS3tmOd.js.map} +1 -1
  6. package/dist/components.d.ts +50 -29
  7. package/dist/components.js +155 -61
  8. package/dist/components.js.map +1 -1
  9. package/dist/util.d.ts +53 -29
  10. package/dist/util.js +2 -1
  11. package/package.json +1 -1
  12. package/src/preact/genomeViewer/CDSPlot.tsx +13 -2
  13. package/src/preact/genomeViewer/loadGff3.ts +6 -0
  14. package/src/preact/mutationFilter/mutation-filter-info.tsx +2 -2
  15. package/src/preact/mutationFilter/mutation-filter.stories.tsx +72 -1
  16. package/src/preact/mutationFilter/mutation-filter.tsx +75 -37
  17. package/src/preact/mutationFilter/parseAndValidateMutation.ts +11 -11
  18. package/src/preact/mutationFilter/parseMutation.spec.ts +32 -22
  19. package/src/preact/mutationsOverTime/mutations-over-time.tsx +7 -4
  20. package/src/query/queryMutationsOverTime.ts +1 -1
  21. package/src/types.ts +17 -1
  22. package/src/utilEntrypoint.ts +4 -0
  23. package/src/utils/mutations.spec.ts +32 -0
  24. package/src/utils/mutations.ts +57 -10
  25. package/src/web-components/input/gs-mutation-filter.stories.ts +30 -1
  26. package/src/web-components/input/gs-mutation-filter.tsx +25 -2
  27. package/standalone-bundle/assets/{mutationOverTimeWorker-CkeGpKWp.js.map → mutationOverTimeWorker-Dp-A14AP.js.map} +1 -1
  28. package/standalone-bundle/dashboard-components.js +8187 -8116
  29. package/standalone-bundle/dashboard-components.js.map +1 -1
  30. package/dist/NumberRangeFilterChangedEvent-CQ32Qy8D.js.map +0 -1
@@ -3,7 +3,7 @@ import { Task } from "@lit/task";
3
3
  import { LitElement, html, unsafeCSS } from "lit";
4
4
  import z$2 from "zod";
5
5
  import { createContext as createContext$1, options, Fragment, Component, createElement, toChildArray, createRef, cloneElement, render, hydrate } from "preact";
6
- import { g as gsEventNames, v as views, s as sequenceTypeSchema, n as namedLapisFilterSchema, l as lapisFilterSchema, t as temporalGranularitySchema, c as dateRangeValueSchema, e as dateRangeOptionSchema, f as toYYYYMMDD, D as DateRangeOptionChangedEvent, h as lapisLocationFilterSchema, L as LocationChangedEvent, T as TextFilterChangedEvent, m as mutationsFilterSchema, a as LineageFilterChangedEvent, i as numberRangeSchema, b as NumberRangeValueChangedEvent, N as NumberRangeFilterChangedEvent } from "./NumberRangeFilterChangedEvent-CQ32Qy8D.js";
6
+ import { g as gsEventNames, v as views, s as sequenceTypeSchema, n as namedLapisFilterSchema, l as lapisFilterSchema, t as temporalGranularitySchema, c as dateRangeValueSchema, e as dateRangeOptionSchema, f as toYYYYMMDD, D as DateRangeOptionChangedEvent, h as lapisLocationFilterSchema, L as LocationChangedEvent, T as TextFilterChangedEvent, m as mutationType, i as mutationTypeSchema, j as mutationsFilterSchema, a as LineageFilterChangedEvent, k as numberRangeSchema, b as NumberRangeValueChangedEvent, N as NumberRangeFilterChangedEvent } from "./NumberRangeFilterChangedEvent-BnPI-Asz.js";
7
7
  import { ReactiveElement } from "@lit/reactive-element";
8
8
  import DOMPurify from "dompurify";
9
9
  import { useRef, Grid } from "gridjs";
@@ -1633,9 +1633,16 @@ function getMaxTickNumber(fullWidth) {
1633
1633
  return Math.max(MIN_TICK_NUMBER, Math.min(MAX_TICK_NUMBER, ticks));
1634
1634
  }
1635
1635
  function getTicks(zoomStart, zoomEnd, fullWidth) {
1636
- const maxTickNumber = getMaxTickNumber(fullWidth);
1636
+ let maxTickNumber = getMaxTickNumber(fullWidth);
1637
1637
  const length = zoomEnd - zoomStart;
1638
- const minTickSize = length / maxTickNumber;
1638
+ let minTickSize = length / maxTickNumber;
1639
+ if (minTickSize <= 1) {
1640
+ maxTickNumber = MIN_TICK_NUMBER;
1641
+ minTickSize = length / maxTickNumber;
1642
+ }
1643
+ if (minTickSize <= 1) {
1644
+ return [];
1645
+ }
1639
1646
  let maxTickSize = 10 ** Math.round(Math.log(minTickSize) / Math.log(10));
1640
1647
  const numTicks = Math.round(length / maxTickSize);
1641
1648
  if (numTicks > maxTickNumber) {
@@ -1716,6 +1723,9 @@ const CDSBars = (componentProps) => {
1716
1723
  if (start >= end) {
1717
1724
  return null;
1718
1725
  }
1726
+ if (zoomEnd - zoomStart <= 2) {
1727
+ return null;
1728
+ }
1719
1729
  const widthPercent = (end - start) / visibleRegionLength * 100;
1720
1730
  const leftPercent = (start - zoomStart) / visibleRegionLength * 100;
1721
1731
  const tooltipPosition = getTooltipPosition$1(start, end, visibleRegionLength);
@@ -1781,6 +1791,12 @@ async function loadGff3(gff3Source, genomeLength) {
1781
1791
  throw new UserFacingError("Invalid gff3 source", `Invalid URL passed to parseGFF3: "${gff3Source}"`);
1782
1792
  }
1783
1793
  const response = await fetch(gff3Source);
1794
+ if (!response.ok) {
1795
+ throw new UserFacingError(
1796
+ "GFF3 download failed",
1797
+ `Server returned ${response.status} ${response.statusText} for ${response.url}`
1798
+ );
1799
+ }
1784
1800
  const content = await response.text();
1785
1801
  genomeLength ?? (genomeLength = loadGenomeLength(content));
1786
1802
  return { features: parseGFF3(content), length: genomeLength };
@@ -2317,7 +2333,20 @@ const MutationComparisonTable = ({
2317
2333
  const tableData = getMutationComparisonTableData(data, proportionInterval).map((row) => Object.values(row));
2318
2334
  return /* @__PURE__ */ u$1(Table, { data: tableData, columns: headers, pageSize });
2319
2335
  };
2320
- const substitutionRegex = /^((?<segment>[A-Z0-9_-]+)(?=:):)?(?<valueAtReference>[A-Z])?(?<position>\d+)(?<substitutionValue>[A-Z.*])?$/i;
2336
+ const nucleotideChars = "ACGTRYKMSWBDHVN";
2337
+ const aminoAcidChars = "ACDEFGHIKLMNPQRSTVWY";
2338
+ function segmentPart(type) {
2339
+ return type === "aminoAcid" ? `(?<segment>[A-Z0-9_-]+):` : `((?<segment>[A-Z0-9_-]+)(?=:):)?`;
2340
+ }
2341
+ function buildSubstitutionRegex(type) {
2342
+ const chars = type === "nucleotide" ? nucleotideChars : aminoAcidChars;
2343
+ return new RegExp(
2344
+ `^${segmentPart(type)}(?<valueAtReference>[${chars}*])?(?<position>\\d+)(?<substitutionValue>[${chars}.*])?$`,
2345
+ "i"
2346
+ );
2347
+ }
2348
+ const nucleotideSubstitutionRegex = buildSubstitutionRegex("nucleotide");
2349
+ const aminoAcidSubstitutionRegex = buildSubstitutionRegex("aminoAcid");
2321
2350
  class SubstitutionClass {
2322
2351
  constructor(segment, valueAtReference, substitutionValue, position) {
2323
2352
  this.segment = segment;
@@ -2340,7 +2369,9 @@ class SubstitutionClass {
2340
2369
  return this.code;
2341
2370
  }
2342
2371
  static parse(mutationStr) {
2343
- const match = substitutionRegex.exec(mutationStr);
2372
+ const matchNucleotide = nucleotideSubstitutionRegex.exec(mutationStr);
2373
+ const matchAminoAcid = aminoAcidSubstitutionRegex.exec(mutationStr);
2374
+ const match = matchNucleotide ?? matchAminoAcid;
2344
2375
  if ((match == null ? void 0 : match.groups) === void 0) {
2345
2376
  return null;
2346
2377
  }
@@ -2352,7 +2383,15 @@ class SubstitutionClass {
2352
2383
  );
2353
2384
  }
2354
2385
  }
2355
- const deletionRegex = /^((?<segment>[A-Z0-9_-]+)(?=:):)?(?<valueAtReference>[A-Z])?(?<position>\d+)(-)$/i;
2386
+ function buildDeletionRegex(type) {
2387
+ const chars = type === "nucleotide" ? nucleotideChars : aminoAcidChars;
2388
+ return new RegExp(
2389
+ `^${segmentPart(type)}(?<valueAtReference>[${chars}*])?(?<position>\\d+)(-)$`,
2390
+ "i"
2391
+ );
2392
+ }
2393
+ const nucleotideDeletionRegex = buildDeletionRegex("nucleotide");
2394
+ const aminoAcidDeletionRegex = buildDeletionRegex("aminoAcid");
2356
2395
  class DeletionClass {
2357
2396
  constructor(segment, valueAtReference, position) {
2358
2397
  this.segment = segment;
@@ -2373,7 +2412,9 @@ class DeletionClass {
2373
2412
  return this.code;
2374
2413
  }
2375
2414
  static parse(mutationStr) {
2376
- const match = deletionRegex.exec(mutationStr);
2415
+ const matchNucleotide = nucleotideDeletionRegex.exec(mutationStr);
2416
+ const matchAminoAcid = aminoAcidDeletionRegex.exec(mutationStr);
2417
+ const match = matchNucleotide ?? matchAminoAcid;
2377
2418
  if ((match == null ? void 0 : match.groups) === void 0) {
2378
2419
  return null;
2379
2420
  }
@@ -2384,7 +2425,16 @@ class DeletionClass {
2384
2425
  );
2385
2426
  }
2386
2427
  }
2387
- const insertionRegexp = /^ins_((?<segment>[A-Z0-9_-]+)(?=:):)?(?<position>\d+):(?<insertedSymbols>(([A-Z?]|(\.\*))+))$/i;
2428
+ function buildInsertionRegex(type) {
2429
+ const chars = type === "nucleotide" ? nucleotideChars : aminoAcidChars;
2430
+ const wildcardToken = `(?:\\.\\*)`;
2431
+ return new RegExp(
2432
+ `^ins_${segmentPart(type)}(?<position>\\d+):(?<insertedSymbols>(?:[${chars}?*]|${wildcardToken})+)$`,
2433
+ "i"
2434
+ );
2435
+ }
2436
+ const nucleotideInsertionRegex = buildInsertionRegex("nucleotide");
2437
+ const aminoAcidInsertionRegex = buildInsertionRegex("aminoAcid");
2388
2438
  class InsertionClass {
2389
2439
  constructor(segment, position, insertedSymbols) {
2390
2440
  this.segment = segment;
@@ -2403,7 +2453,9 @@ class InsertionClass {
2403
2453
  return this.code;
2404
2454
  }
2405
2455
  static parse(mutationStr) {
2406
- const match = insertionRegexp.exec(mutationStr);
2456
+ const matchNucleotide = nucleotideInsertionRegex.exec(mutationStr);
2457
+ const matchAminoAcid = aminoAcidInsertionRegex.exec(mutationStr);
2458
+ const match = matchNucleotide ?? matchAminoAcid;
2407
2459
  if ((match == null ? void 0 : match.groups) === void 0) {
2408
2460
  return null;
2409
2461
  }
@@ -7025,7 +7077,7 @@ __decorateClass$a([
7025
7077
  NumberSequencesOverTimeComponent = __decorateClass$a([
7026
7078
  t$3("gs-number-sequences-over-time")
7027
7079
  ], NumberSequencesOverTimeComponent);
7028
- const jsContent = '(function() {\n "use strict";\n var util;\n (function(util2) {\n util2.assertEqual = (_) => {\n };\n function assertIs(_arg) {\n }\n util2.assertIs = assertIs;\n function assertNever(_x) {\n throw new Error();\n }\n util2.assertNever = assertNever;\n util2.arrayToEnum = (items) => {\n const obj = {};\n for (const item of items) {\n obj[item] = item;\n }\n return obj;\n };\n util2.getValidEnumValues = (obj) => {\n const validKeys = util2.objectKeys(obj).filter((k2) => typeof obj[obj[k2]] !== "number");\n const filtered = {};\n for (const k2 of validKeys) {\n filtered[k2] = obj[k2];\n }\n return util2.objectValues(filtered);\n };\n util2.objectValues = (obj) => {\n return util2.objectKeys(obj).map(function(e2) {\n return obj[e2];\n });\n };\n util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {\n const keys = [];\n for (const key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n keys.push(key);\n }\n }\n return keys;\n };\n util2.find = (arr, checker) => {\n for (const item of arr) {\n if (checker(item))\n return item;\n }\n return void 0;\n };\n util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;\n function joinValues(array, separator = " | ") {\n return array.map((val) => typeof val === "string" ? `\'${val}\'` : val).join(separator);\n }\n util2.joinValues = joinValues;\n util2.jsonStringifyReplacer = (_, value) => {\n if (typeof value === "bigint") {\n return value.toString();\n }\n return value;\n };\n })(util || (util = {}));\n var objectUtil;\n (function(objectUtil2) {\n objectUtil2.mergeShapes = (first, second) => {\n return {\n ...first,\n ...second\n // second overwrites first\n };\n };\n })(objectUtil || (objectUtil = {}));\n const ZodParsedType = util.arrayToEnum([\n "string",\n "nan",\n "number",\n "integer",\n "float",\n "boolean",\n "date",\n "bigint",\n "symbol",\n "function",\n "undefined",\n "null",\n "array",\n "object",\n "unknown",\n "promise",\n "void",\n "never",\n "map",\n "set"\n ]);\n const getParsedType = (data) => {\n const t = typeof data;\n switch (t) {\n case "undefined":\n return ZodParsedType.undefined;\n case "string":\n return ZodParsedType.string;\n case "number":\n return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;\n case "boolean":\n return ZodParsedType.boolean;\n case "function":\n return ZodParsedType.function;\n case "bigint":\n return ZodParsedType.bigint;\n case "symbol":\n return ZodParsedType.symbol;\n case "object":\n if (Array.isArray(data)) {\n return ZodParsedType.array;\n }\n if (data === null) {\n return ZodParsedType.null;\n }\n if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {\n return ZodParsedType.promise;\n }\n if (typeof Map !== "undefined" && data instanceof Map) {\n return ZodParsedType.map;\n }\n if (typeof Set !== "undefined" && data instanceof Set) {\n return ZodParsedType.set;\n }\n if (typeof Date !== "undefined" && data instanceof Date) {\n return ZodParsedType.date;\n }\n return ZodParsedType.object;\n default:\n return ZodParsedType.unknown;\n }\n };\n const ZodIssueCode = util.arrayToEnum([\n "invalid_type",\n "invalid_literal",\n "custom",\n "invalid_union",\n "invalid_union_discriminator",\n "invalid_enum_value",\n "unrecognized_keys",\n "invalid_arguments",\n "invalid_return_type",\n "invalid_date",\n "invalid_string",\n "too_small",\n "too_big",\n "invalid_intersection_types",\n "not_multiple_of",\n "not_finite"\n ]);\n const quotelessJson = (obj) => {\n const json = JSON.stringify(obj, null, 2);\n return json.replace(/"([^"]+)":/g, "$1:");\n };\n class ZodError extends Error {\n get errors() {\n return this.issues;\n }\n constructor(issues) {\n super();\n this.issues = [];\n this.addIssue = (sub) => {\n this.issues = [...this.issues, sub];\n };\n this.addIssues = (subs = []) => {\n this.issues = [...this.issues, ...subs];\n };\n const actualProto = new.target.prototype;\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(this, actualProto);\n } else {\n this.__proto__ = actualProto;\n }\n this.name = "ZodError";\n this.issues = issues;\n }\n format(_mapper) {\n const mapper = _mapper || function(issue) {\n return issue.message;\n };\n const fieldErrors = { _errors: [] };\n const processError = (error) => {\n for (const issue of error.issues) {\n if (issue.code === "invalid_union") {\n issue.unionErrors.map(processError);\n } else if (issue.code === "invalid_return_type") {\n processError(issue.returnTypeError);\n } else if (issue.code === "invalid_arguments") {\n processError(issue.argumentsError);\n } else if (issue.path.length === 0) {\n fieldErrors._errors.push(mapper(issue));\n } else {\n let curr = fieldErrors;\n let i2 = 0;\n while (i2 < issue.path.length) {\n const el = issue.path[i2];\n const terminal = i2 === issue.path.length - 1;\n if (!terminal) {\n curr[el] = curr[el] || { _errors: [] };\n } else {\n curr[el] = curr[el] || { _errors: [] };\n curr[el]._errors.push(mapper(issue));\n }\n curr = curr[el];\n i2++;\n }\n }\n }\n };\n processError(this);\n return fieldErrors;\n }\n static assert(value) {\n if (!(value instanceof ZodError)) {\n throw new Error(`Not a ZodError: ${value}`);\n }\n }\n toString() {\n return this.message;\n }\n get message() {\n return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);\n }\n get isEmpty() {\n return this.issues.length === 0;\n }\n flatten(mapper = (issue) => issue.message) {\n const fieldErrors = {};\n const formErrors = [];\n for (const sub of this.issues) {\n if (sub.path.length > 0) {\n const firstEl = sub.path[0];\n fieldErrors[firstEl] = fieldErrors[firstEl] || [];\n fieldErrors[firstEl].push(mapper(sub));\n } else {\n formErrors.push(mapper(sub));\n }\n }\n return { formErrors, fieldErrors };\n }\n get formErrors() {\n return this.flatten();\n }\n }\n ZodError.create = (issues) => {\n const error = new ZodError(issues);\n return error;\n };\n const errorMap = (issue, _ctx) => {\n let message;\n switch (issue.code) {\n case ZodIssueCode.invalid_type:\n if (issue.received === ZodParsedType.undefined) {\n message = "Required";\n } else {\n message = `Expected ${issue.expected}, received ${issue.received}`;\n }\n break;\n case ZodIssueCode.invalid_literal:\n message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;\n break;\n case ZodIssueCode.unrecognized_keys:\n message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;\n break;\n case ZodIssueCode.invalid_union:\n message = `Invalid input`;\n break;\n case ZodIssueCode.invalid_union_discriminator:\n message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;\n break;\n case ZodIssueCode.invalid_enum_value:\n message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received \'${issue.received}\'`;\n break;\n case ZodIssueCode.invalid_arguments:\n message = `Invalid function arguments`;\n break;\n case ZodIssueCode.invalid_return_type:\n message = `Invalid function return type`;\n break;\n case ZodIssueCode.invalid_date:\n message = `Invalid date`;\n break;\n case ZodIssueCode.invalid_string:\n if (typeof issue.validation === "object") {\n if ("includes" in issue.validation) {\n message = `Invalid input: must include "${issue.validation.includes}"`;\n if (typeof issue.validation.position === "number") {\n message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;\n }\n } else if ("startsWith" in issue.validation) {\n message = `Invalid input: must start with "${issue.validation.startsWith}"`;\n } else if ("endsWith" in issue.validation) {\n message = `Invalid input: must end with "${issue.validation.endsWith}"`;\n } else {\n util.assertNever(issue.validation);\n }\n } else if (issue.validation !== "regex") {\n message = `Invalid ${issue.validation}`;\n } else {\n message = "Invalid";\n }\n break;\n case ZodIssueCode.too_small:\n if (issue.type === "array")\n message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;\n else if (issue.type === "string")\n message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;\n else if (issue.type === "number")\n message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;\n else if (issue.type === "bigint")\n message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;\n else if (issue.type === "date")\n message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;\n else\n message = "Invalid input";\n break;\n case ZodIssueCode.too_big:\n if (issue.type === "array")\n message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;\n else if (issue.type === "string")\n message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;\n else if (issue.type === "number")\n message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;\n else if (issue.type === "bigint")\n message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;\n else if (issue.type === "date")\n message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;\n else\n message = "Invalid input";\n break;\n case ZodIssueCode.custom:\n message = `Invalid input`;\n break;\n case ZodIssueCode.invalid_intersection_types:\n message = `Intersection results could not be merged`;\n break;\n case ZodIssueCode.not_multiple_of:\n message = `Number must be a multiple of ${issue.multipleOf}`;\n break;\n case ZodIssueCode.not_finite:\n message = "Number must be finite";\n break;\n default:\n message = _ctx.defaultError;\n util.assertNever(issue);\n }\n return { message };\n };\n let overrideErrorMap = errorMap;\n function setErrorMap(map) {\n overrideErrorMap = map;\n }\n function getErrorMap() {\n return overrideErrorMap;\n }\n const makeIssue = (params) => {\n const { data, path, errorMaps, issueData } = params;\n const fullPath = [...path, ...issueData.path || []];\n const fullIssue = {\n ...issueData,\n path: fullPath\n };\n if (issueData.message !== void 0) {\n return {\n ...issueData,\n path: fullPath,\n message: issueData.message\n };\n }\n let errorMessage = "";\n const maps = errorMaps.filter((m2) => !!m2).slice().reverse();\n for (const map of maps) {\n errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;\n }\n return {\n ...issueData,\n path: fullPath,\n message: errorMessage\n };\n };\n const EMPTY_PATH = [];\n function addIssueToContext(ctx, issueData) {\n const overrideMap = getErrorMap();\n const issue = makeIssue({\n issueData,\n data: ctx.data,\n path: ctx.path,\n errorMaps: [\n ctx.common.contextualErrorMap,\n // contextual error map is first priority\n ctx.schemaErrorMap,\n // then schema-bound map if available\n overrideMap,\n // then global override map\n overrideMap === errorMap ? void 0 : errorMap\n // then global default map\n ].filter((x) => !!x)\n });\n ctx.common.issues.push(issue);\n }\n class ParseStatus {\n constructor() {\n this.value = "valid";\n }\n dirty() {\n if (this.value === "valid")\n this.value = "dirty";\n }\n abort() {\n if (this.value !== "aborted")\n this.value = "aborted";\n }\n static mergeArray(status, results) {\n const arrayValue = [];\n for (const s2 of results) {\n if (s2.status === "aborted")\n return INVALID;\n if (s2.status === "dirty")\n status.dirty();\n arrayValue.push(s2.value);\n }\n return { status: status.value, value: arrayValue };\n }\n static async mergeObjectAsync(status, pairs) {\n const syncPairs = [];\n for (const pair of pairs) {\n const key = await pair.key;\n const value = await pair.value;\n syncPairs.push({\n key,\n value\n });\n }\n return ParseStatus.mergeObjectSync(status, syncPairs);\n }\n static mergeObjectSync(status, pairs) {\n const finalObject = {};\n for (const pair of pairs) {\n const { key, value } = pair;\n if (key.status === "aborted")\n return INVALID;\n if (value.status === "aborted")\n return INVALID;\n if (key.status === "dirty")\n status.dirty();\n if (value.status === "dirty")\n status.dirty();\n if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {\n finalObject[key.value] = value.value;\n }\n }\n return { status: status.value, value: finalObject };\n }\n }\n const INVALID = Object.freeze({\n status: "aborted"\n });\n const DIRTY = (value) => ({ status: "dirty", value });\n const OK = (value) => ({ status: "valid", value });\n const isAborted = (x) => x.status === "aborted";\n const isDirty = (x) => x.status === "dirty";\n const isValid = (x) => x.status === "valid";\n const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;\n var errorUtil;\n (function(errorUtil2) {\n errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};\n errorUtil2.toString = (message) => typeof message === "string" ? message : message == null ? void 0 : message.message;\n })(errorUtil || (errorUtil = {}));\n class ParseInputLazyPath {\n constructor(parent, value, path, key) {\n this._cachedPath = [];\n this.parent = parent;\n this.data = value;\n this._path = path;\n this._key = key;\n }\n get path() {\n if (!this._cachedPath.length) {\n if (Array.isArray(this._key)) {\n this._cachedPath.push(...this._path, ...this._key);\n } else {\n this._cachedPath.push(...this._path, this._key);\n }\n }\n return this._cachedPath;\n }\n }\n const handleResult = (ctx, result) => {\n if (isValid(result)) {\n return { success: true, data: result.value };\n } else {\n if (!ctx.common.issues.length) {\n throw new Error("Validation failed but no issues detected.");\n }\n return {\n success: false,\n get error() {\n if (this._error)\n return this._error;\n const error = new ZodError(ctx.common.issues);\n this._error = error;\n return this._error;\n }\n };\n }\n };\n function processCreateParams(params) {\n if (!params)\n return {};\n const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;\n if (errorMap2 && (invalid_type_error || required_error)) {\n throw new Error(`Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.`);\n }\n if (errorMap2)\n return { errorMap: errorMap2, description };\n const customMap = (iss, ctx) => {\n const { message } = params;\n if (iss.code === "invalid_enum_value") {\n return { message: message ?? ctx.defaultError };\n }\n if (typeof ctx.data === "undefined") {\n return { message: message ?? required_error ?? ctx.defaultError };\n }\n if (iss.code !== "invalid_type")\n return { message: ctx.defaultError };\n return { message: message ?? invalid_type_error ?? ctx.defaultError };\n };\n return { errorMap: customMap, description };\n }\n class ZodType {\n get description() {\n return this._def.description;\n }\n _getType(input) {\n return getParsedType(input.data);\n }\n _getOrReturnCtx(input, ctx) {\n return ctx || {\n common: input.parent.common,\n data: input.data,\n parsedType: getParsedType(input.data),\n schemaErrorMap: this._def.errorMap,\n path: input.path,\n parent: input.parent\n };\n }\n _processInputParams(input) {\n return {\n status: new ParseStatus(),\n ctx: {\n common: input.parent.common,\n data: input.data,\n parsedType: getParsedType(input.data),\n schemaErrorMap: this._def.errorMap,\n path: input.path,\n parent: input.parent\n }\n };\n }\n _parseSync(input) {\n const result = this._parse(input);\n if (isAsync(result)) {\n throw new Error("Synchronous parse encountered promise.");\n }\n return result;\n }\n _parseAsync(input) {\n const result = this._parse(input);\n return Promise.resolve(result);\n }\n parse(data, params) {\n const result = this.safeParse(data, params);\n if (result.success)\n return result.data;\n throw result.error;\n }\n safeParse(data, params) {\n const ctx = {\n common: {\n issues: [],\n async: (params == null ? void 0 : params.async) ?? false,\n contextualErrorMap: params == null ? void 0 : params.errorMap\n },\n path: (params == null ? void 0 : params.path) || [],\n schemaErrorMap: this._def.errorMap,\n parent: null,\n data,\n parsedType: getParsedType(data)\n };\n const result = this._parseSync({ data, path: ctx.path, parent: ctx });\n return handleResult(ctx, result);\n }\n "~validate"(data) {\n var _a, _b;\n const ctx = {\n common: {\n issues: [],\n async: !!this["~standard"].async\n },\n path: [],\n schemaErrorMap: this._def.errorMap,\n parent: null,\n data,\n parsedType: getParsedType(data)\n };\n if (!this["~standard"].async) {\n try {\n const result = this._parseSync({ data, path: [], parent: ctx });\n return isValid(result) ? {\n value: result.value\n } : {\n issues: ctx.common.issues\n };\n } catch (err) {\n if ((_b = (_a = err == null ? void 0 : err.message) == null ? void 0 : _a.toLowerCase()) == null ? void 0 : _b.includes("encountered")) {\n this["~standard"].async = true;\n }\n ctx.common = {\n issues: [],\n async: true\n };\n }\n }\n return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {\n value: result.value\n } : {\n issues: ctx.common.issues\n });\n }\n async parseAsync(data, params) {\n const result = await this.safeParseAsync(data, params);\n if (result.success)\n return result.data;\n throw result.error;\n }\n async safeParseAsync(data, params) {\n const ctx = {\n common: {\n issues: [],\n contextualErrorMap: params == null ? void 0 : params.errorMap,\n async: true\n },\n path: (params == null ? void 0 : params.path) || [],\n schemaErrorMap: this._def.errorMap,\n parent: null,\n data,\n parsedType: getParsedType(data)\n };\n const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });\n const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));\n return handleResult(ctx, result);\n }\n refine(check, message) {\n const getIssueProperties = (val) => {\n if (typeof message === "string" || typeof message === "undefined") {\n return { message };\n } else if (typeof message === "function") {\n return message(val);\n } else {\n return message;\n }\n };\n return this._refinement((val, ctx) => {\n const result = check(val);\n const setError = () => ctx.addIssue({\n code: ZodIssueCode.custom,\n ...getIssueProperties(val)\n });\n if (typeof Promise !== "undefined" && result instanceof Promise) {\n return result.then((data) => {\n if (!data) {\n setError();\n return false;\n } else {\n return true;\n }\n });\n }\n if (!result) {\n setError();\n return false;\n } else {\n return true;\n }\n });\n }\n refinement(check, refinementData) {\n return this._refinement((val, ctx) => {\n if (!check(val)) {\n ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);\n return false;\n } else {\n return true;\n }\n });\n }\n _refinement(refinement) {\n return new ZodEffects({\n schema: this,\n typeName: ZodFirstPartyTypeKind.ZodEffects,\n effect: { type: "refinement", refinement }\n });\n }\n superRefine(refinement) {\n return this._refinement(refinement);\n }\n constructor(def) {\n this.spa = this.safeParseAsync;\n this._def = def;\n this.parse = this.parse.bind(this);\n this.safeParse = this.safeParse.bind(this);\n this.parseAsync = this.parseAsync.bind(this);\n this.safeParseAsync = this.safeParseAsync.bind(this);\n this.spa = this.spa.bind(this);\n this.refine = this.refine.bind(this);\n this.refinement = this.refinement.bind(this);\n this.superRefine = this.superRefine.bind(this);\n this.optional = this.optional.bind(this);\n this.nullable = this.nullable.bind(this);\n this.nullish = this.nullish.bind(this);\n this.array = this.array.bind(this);\n this.promise = this.promise.bind(this);\n this.or = this.or.bind(this);\n this.and = this.and.bind(this);\n this.transform = this.transform.bind(this);\n this.brand = this.brand.bind(this);\n this.default = this.default.bind(this);\n this.catch = this.catch.bind(this);\n this.describe = this.describe.bind(this);\n this.pipe = this.pipe.bind(this);\n this.readonly = this.readonly.bind(this);\n this.isNullable = this.isNullable.bind(this);\n this.isOptional = this.isOptional.bind(this);\n this["~standard"] = {\n version: 1,\n vendor: "zod",\n validate: (data) => this["~validate"](data)\n };\n }\n optional() {\n return ZodOptional.create(this, this._def);\n }\n nullable() {\n return ZodNullable.create(this, this._def);\n }\n nullish() {\n return this.nullable().optional();\n }\n array() {\n return ZodArray.create(this);\n }\n promise() {\n return ZodPromise.create(this, this._def);\n }\n or(option) {\n return ZodUnion.create([this, option], this._def);\n }\n and(incoming) {\n return ZodIntersection.create(this, incoming, this._def);\n }\n transform(transform) {\n return new ZodEffects({\n ...processCreateParams(this._def),\n schema: this,\n typeName: ZodFirstPartyTypeKind.ZodEffects,\n effect: { type: "transform", transform }\n });\n }\n default(def) {\n const defaultValueFunc = typeof def === "function" ? def : () => def;\n return new ZodDefault({\n ...processCreateParams(this._def),\n innerType: this,\n defaultValue: defaultValueFunc,\n typeName: ZodFirstPartyTypeKind.ZodDefault\n });\n }\n brand() {\n return new ZodBranded({\n typeName: ZodFirstPartyTypeKind.ZodBranded,\n type: this,\n ...processCreateParams(this._def)\n });\n }\n catch(def) {\n const catchValueFunc = typeof def === "function" ? def : () => def;\n return new ZodCatch({\n ...processCreateParams(this._def),\n innerType: this,\n catchValue: catchValueFunc,\n typeName: ZodFirstPartyTypeKind.ZodCatch\n });\n }\n describe(description) {\n const This = this.constructor;\n return new This({\n ...this._def,\n description\n });\n }\n pipe(target) {\n return ZodPipeline.create(this, target);\n }\n readonly() {\n return ZodReadonly.create(this);\n }\n isOptional() {\n return this.safeParse(void 0).success;\n }\n isNullable() {\n return this.safeParse(null).success;\n }\n }\n const cuidRegex = /^c[^\\s-]{8,}$/i;\n const cuid2Regex = /^[0-9a-z]+$/;\n const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;\n 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;\n const nanoidRegex = /^[a-z0-9_-]{21}$/i;\n const jwtRegex = /^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]*$/;\n 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)?)??$/;\n const emailRegex = /^(?!\\.)(?!.*\\.\\.)([A-Z0-9_\'+\\-\\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\\-]*\\.)+[A-Z]{2,}$/i;\n const _emojiRegex = `^(\\\\p{Extended_Pictographic}|\\\\p{Emoji_Component})+$`;\n let emojiRegex;\n 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])$/;\n 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])$/;\n 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]))$/;\n 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])$/;\n const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;\n const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;\n 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])))`;\n const dateRegex = new RegExp(`^${dateRegexSource}$`);\n function timeRegexSource(args) {\n let secondsRegexSource = `[0-5]\\\\d`;\n if (args.precision) {\n secondsRegexSource = `${secondsRegexSource}\\\\.\\\\d{${args.precision}}`;\n } else if (args.precision == null) {\n secondsRegexSource = `${secondsRegexSource}(\\\\.\\\\d+)?`;\n }\n const secondsQuantifier = args.precision ? "+" : "?";\n return `([01]\\\\d|2[0-3]):[0-5]\\\\d(:${secondsRegexSource})${secondsQuantifier}`;\n }\n function timeRegex(args) {\n return new RegExp(`^${timeRegexSource(args)}$`);\n }\n function datetimeRegex(args) {\n let regex = `${dateRegexSource}T${timeRegexSource(args)}`;\n const opts = [];\n opts.push(args.local ? `Z?` : `Z`);\n if (args.offset)\n opts.push(`([+-]\\\\d{2}:?\\\\d{2})`);\n regex = `${regex}(${opts.join("|")})`;\n return new RegExp(`^${regex}$`);\n }\n function isValidIP(ip, version) {\n if ((version === "v4" || !version) && ipv4Regex.test(ip)) {\n return true;\n }\n if ((version === "v6" || !version) && ipv6Regex.test(ip)) {\n return true;\n }\n return false;\n }\n function isValidJWT(jwt, alg) {\n if (!jwtRegex.test(jwt))\n return false;\n try {\n const [header] = jwt.split(".");\n if (!header)\n return false;\n const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");\n const decoded = JSON.parse(atob(base64));\n if (typeof decoded !== "object" || decoded === null)\n return false;\n if ("typ" in decoded && (decoded == null ? void 0 : decoded.typ) !== "JWT")\n return false;\n if (!decoded.alg)\n return false;\n if (alg && decoded.alg !== alg)\n return false;\n return true;\n } catch {\n return false;\n }\n }\n function isValidCidr(ip, version) {\n if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {\n return true;\n }\n if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {\n return true;\n }\n return false;\n }\n class ZodString extends ZodType {\n _parse(input) {\n if (this._def.coerce) {\n input.data = String(input.data);\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.string) {\n const ctx2 = this._getOrReturnCtx(input);\n addIssueToContext(ctx2, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.string,\n received: ctx2.parsedType\n });\n return INVALID;\n }\n const status = new ParseStatus();\n let ctx = void 0;\n for (const check of this._def.checks) {\n if (check.kind === "min") {\n if (input.data.length < check.value) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: check.value,\n type: "string",\n inclusive: true,\n exact: false,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "max") {\n if (input.data.length > check.value) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: check.value,\n type: "string",\n inclusive: true,\n exact: false,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "length") {\n const tooBig = input.data.length > check.value;\n const tooSmall = input.data.length < check.value;\n if (tooBig || tooSmall) {\n ctx = this._getOrReturnCtx(input, ctx);\n if (tooBig) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: check.value,\n type: "string",\n inclusive: true,\n exact: true,\n message: check.message\n });\n } else if (tooSmall) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: check.value,\n type: "string",\n inclusive: true,\n exact: true,\n message: check.message\n });\n }\n status.dirty();\n }\n } else if (check.kind === "email") {\n if (!emailRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "email",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "emoji") {\n if (!emojiRegex) {\n emojiRegex = new RegExp(_emojiRegex, "u");\n }\n if (!emojiRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "emoji",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "uuid") {\n if (!uuidRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "uuid",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "nanoid") {\n if (!nanoidRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "nanoid",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "cuid") {\n if (!cuidRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "cuid",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "cuid2") {\n if (!cuid2Regex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "cuid2",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "ulid") {\n if (!ulidRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "ulid",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "url") {\n try {\n new URL(input.data);\n } catch {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "url",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "regex") {\n check.regex.lastIndex = 0;\n const testResult = check.regex.test(input.data);\n if (!testResult) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "regex",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "trim") {\n input.data = input.data.trim();\n } else if (check.kind === "includes") {\n if (!input.data.includes(check.value, check.position)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: { includes: check.value, position: check.position },\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "toLowerCase") {\n input.data = input.data.toLowerCase();\n } else if (check.kind === "toUpperCase") {\n input.data = input.data.toUpperCase();\n } else if (check.kind === "startsWith") {\n if (!input.data.startsWith(check.value)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: { startsWith: check.value },\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "endsWith") {\n if (!input.data.endsWith(check.value)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: { endsWith: check.value },\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "datetime") {\n const regex = datetimeRegex(check);\n if (!regex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: "datetime",\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "date") {\n const regex = dateRegex;\n if (!regex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: "date",\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "time") {\n const regex = timeRegex(check);\n if (!regex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: "time",\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "duration") {\n if (!durationRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "duration",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "ip") {\n if (!isValidIP(input.data, check.version)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "ip",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "jwt") {\n if (!isValidJWT(input.data, check.alg)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "jwt",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "cidr") {\n if (!isValidCidr(input.data, check.version)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "cidr",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "base64") {\n if (!base64Regex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "base64",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "base64url") {\n if (!base64urlRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "base64url",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else {\n util.assertNever(check);\n }\n }\n return { status: status.value, value: input.data };\n }\n _regex(regex, validation, message) {\n return this.refinement((data) => regex.test(data), {\n validation,\n code: ZodIssueCode.invalid_string,\n ...errorUtil.errToObj(message)\n });\n }\n _addCheck(check) {\n return new ZodString({\n ...this._def,\n checks: [...this._def.checks, check]\n });\n }\n email(message) {\n return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });\n }\n url(message) {\n return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });\n }\n emoji(message) {\n return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });\n }\n uuid(message) {\n return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });\n }\n nanoid(message) {\n return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });\n }\n cuid(message) {\n return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });\n }\n cuid2(message) {\n return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });\n }\n ulid(message) {\n return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });\n }\n base64(message) {\n return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });\n }\n base64url(message) {\n return this._addCheck({\n kind: "base64url",\n ...errorUtil.errToObj(message)\n });\n }\n jwt(options) {\n return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });\n }\n ip(options) {\n return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });\n }\n cidr(options) {\n return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });\n }\n datetime(options) {\n if (typeof options === "string") {\n return this._addCheck({\n kind: "datetime",\n precision: null,\n offset: false,\n local: false,\n message: options\n });\n }\n return this._addCheck({\n kind: "datetime",\n precision: typeof (options == null ? void 0 : options.precision) === "undefined" ? null : options == null ? void 0 : options.precision,\n offset: (options == null ? void 0 : options.offset) ?? false,\n local: (options == null ? void 0 : options.local) ?? false,\n ...errorUtil.errToObj(options == null ? void 0 : options.message)\n });\n }\n date(message) {\n return this._addCheck({ kind: "date", message });\n }\n time(options) {\n if (typeof options === "string") {\n return this._addCheck({\n kind: "time",\n precision: null,\n message: options\n });\n }\n return this._addCheck({\n kind: "time",\n precision: typeof (options == null ? void 0 : options.precision) === "undefined" ? null : options == null ? void 0 : options.precision,\n ...errorUtil.errToObj(options == null ? void 0 : options.message)\n });\n }\n duration(message) {\n return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });\n }\n regex(regex, message) {\n return this._addCheck({\n kind: "regex",\n regex,\n ...errorUtil.errToObj(message)\n });\n }\n includes(value, options) {\n return this._addCheck({\n kind: "includes",\n value,\n position: options == null ? void 0 : options.position,\n ...errorUtil.errToObj(options == null ? void 0 : options.message)\n });\n }\n startsWith(value, message) {\n return this._addCheck({\n kind: "startsWith",\n value,\n ...errorUtil.errToObj(message)\n });\n }\n endsWith(value, message) {\n return this._addCheck({\n kind: "endsWith",\n value,\n ...errorUtil.errToObj(message)\n });\n }\n min(minLength, message) {\n return this._addCheck({\n kind: "min",\n value: minLength,\n ...errorUtil.errToObj(message)\n });\n }\n max(maxLength, message) {\n return this._addCheck({\n kind: "max",\n value: maxLength,\n ...errorUtil.errToObj(message)\n });\n }\n length(len, message) {\n return this._addCheck({\n kind: "length",\n value: len,\n ...errorUtil.errToObj(message)\n });\n }\n /**\n * Equivalent to `.min(1)`\n */\n nonempty(message) {\n return this.min(1, errorUtil.errToObj(message));\n }\n trim() {\n return new ZodString({\n ...this._def,\n checks: [...this._def.checks, { kind: "trim" }]\n });\n }\n toLowerCase() {\n return new ZodString({\n ...this._def,\n checks: [...this._def.checks, { kind: "toLowerCase" }]\n });\n }\n toUpperCase() {\n return new ZodString({\n ...this._def,\n checks: [...this._def.checks, { kind: "toUpperCase" }]\n });\n }\n get isDatetime() {\n return !!this._def.checks.find((ch) => ch.kind === "datetime");\n }\n get isDate() {\n return !!this._def.checks.find((ch) => ch.kind === "date");\n }\n get isTime() {\n return !!this._def.checks.find((ch) => ch.kind === "time");\n }\n get isDuration() {\n return !!this._def.checks.find((ch) => ch.kind === "duration");\n }\n get isEmail() {\n return !!this._def.checks.find((ch) => ch.kind === "email");\n }\n get isURL() {\n return !!this._def.checks.find((ch) => ch.kind === "url");\n }\n get isEmoji() {\n return !!this._def.checks.find((ch) => ch.kind === "emoji");\n }\n get isUUID() {\n return !!this._def.checks.find((ch) => ch.kind === "uuid");\n }\n get isNANOID() {\n return !!this._def.checks.find((ch) => ch.kind === "nanoid");\n }\n get isCUID() {\n return !!this._def.checks.find((ch) => ch.kind === "cuid");\n }\n get isCUID2() {\n return !!this._def.checks.find((ch) => ch.kind === "cuid2");\n }\n get isULID() {\n return !!this._def.checks.find((ch) => ch.kind === "ulid");\n }\n get isIP() {\n return !!this._def.checks.find((ch) => ch.kind === "ip");\n }\n get isCIDR() {\n return !!this._def.checks.find((ch) => ch.kind === "cidr");\n }\n get isBase64() {\n return !!this._def.checks.find((ch) => ch.kind === "base64");\n }\n get isBase64url() {\n return !!this._def.checks.find((ch) => ch.kind === "base64url");\n }\n get minLength() {\n let min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === "min") {\n if (min === null || ch.value > min)\n min = ch.value;\n }\n }\n return min;\n }\n get maxLength() {\n let max = null;\n for (const ch of this._def.checks) {\n if (ch.kind === "max") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return max;\n }\n }\n ZodString.create = (params) => {\n return new ZodString({\n checks: [],\n typeName: ZodFirstPartyTypeKind.ZodString,\n coerce: (params == null ? void 0 : params.coerce) ?? false,\n ...processCreateParams(params)\n });\n };\n function floatSafeRemainder(val, step) {\n const valDecCount = (val.toString().split(".")[1] || "").length;\n const stepDecCount = (step.toString().split(".")[1] || "").length;\n const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;\n const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));\n const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));\n return valInt % stepInt / 10 ** decCount;\n }\n class ZodNumber extends ZodType {\n constructor() {\n super(...arguments);\n this.min = this.gte;\n this.max = this.lte;\n this.step = this.multipleOf;\n }\n _parse(input) {\n if (this._def.coerce) {\n input.data = Number(input.data);\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.number) {\n const ctx2 = this._getOrReturnCtx(input);\n addIssueToContext(ctx2, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.number,\n received: ctx2.parsedType\n });\n return INVALID;\n }\n let ctx = void 0;\n const status = new ParseStatus();\n for (const check of this._def.checks) {\n if (check.kind === "int") {\n if (!util.isInteger(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: "integer",\n received: "float",\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "min") {\n const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;\n if (tooSmall) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: check.value,\n type: "number",\n inclusive: check.inclusive,\n exact: false,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "max") {\n const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;\n if (tooBig) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: check.value,\n type: "number",\n inclusive: check.inclusive,\n exact: false,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "multipleOf") {\n if (floatSafeRemainder(input.data, check.value) !== 0) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.not_multiple_of,\n multipleOf: check.value,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "finite") {\n if (!Number.isFinite(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.not_finite,\n message: check.message\n });\n status.dirty();\n }\n } else {\n util.assertNever(check);\n }\n }\n return { status: status.value, value: input.data };\n }\n gte(value, message) {\n return this.setLimit("min", value, true, errorUtil.toString(message));\n }\n gt(value, message) {\n return this.setLimit("min", value, false, errorUtil.toString(message));\n }\n lte(value, message) {\n return this.setLimit("max", value, true, errorUtil.toString(message));\n }\n lt(value, message) {\n return this.setLimit("max", value, false, errorUtil.toString(message));\n }\n setLimit(kind, value, inclusive, message) {\n return new ZodNumber({\n ...this._def,\n checks: [\n ...this._def.checks,\n {\n kind,\n value,\n inclusive,\n message: errorUtil.toString(message)\n }\n ]\n });\n }\n _addCheck(check) {\n return new ZodNumber({\n ...this._def,\n checks: [...this._def.checks, check]\n });\n }\n int(message) {\n return this._addCheck({\n kind: "int",\n message: errorUtil.toString(message)\n });\n }\n positive(message) {\n return this._addCheck({\n kind: "min",\n value: 0,\n inclusive: false,\n message: errorUtil.toString(message)\n });\n }\n negative(message) {\n return this._addCheck({\n kind: "max",\n value: 0,\n inclusive: false,\n message: errorUtil.toString(message)\n });\n }\n nonpositive(message) {\n return this._addCheck({\n kind: "max",\n value: 0,\n inclusive: true,\n message: errorUtil.toString(message)\n });\n }\n nonnegative(message) {\n return this._addCheck({\n kind: "min",\n value: 0,\n inclusive: true,\n message: errorUtil.toString(message)\n });\n }\n multipleOf(value, message) {\n return this._addCheck({\n kind: "multipleOf",\n value,\n message: errorUtil.toString(message)\n });\n }\n finite(message) {\n return this._addCheck({\n kind: "finite",\n message: errorUtil.toString(message)\n });\n }\n safe(message) {\n return this._addCheck({\n kind: "min",\n inclusive: true,\n value: Number.MIN_SAFE_INTEGER,\n message: errorUtil.toString(message)\n })._addCheck({\n kind: "max",\n inclusive: true,\n value: Number.MAX_SAFE_INTEGER,\n message: errorUtil.toString(message)\n });\n }\n get minValue() {\n let min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === "min") {\n if (min === null || ch.value > min)\n min = ch.value;\n }\n }\n return min;\n }\n get maxValue() {\n let max = null;\n for (const ch of this._def.checks) {\n if (ch.kind === "max") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return max;\n }\n get isInt() {\n return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));\n }\n get isFinite() {\n let max = null;\n let min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {\n return true;\n } else if (ch.kind === "min") {\n if (min === null || ch.value > min)\n min = ch.value;\n } else if (ch.kind === "max") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return Number.isFinite(min) && Number.isFinite(max);\n }\n }\n ZodNumber.create = (params) => {\n return new ZodNumber({\n checks: [],\n typeName: ZodFirstPartyTypeKind.ZodNumber,\n coerce: (params == null ? void 0 : params.coerce) || false,\n ...processCreateParams(params)\n });\n };\n class ZodBigInt extends ZodType {\n constructor() {\n super(...arguments);\n this.min = this.gte;\n this.max = this.lte;\n }\n _parse(input) {\n if (this._def.coerce) {\n try {\n input.data = BigInt(input.data);\n } catch {\n return this._getInvalidInput(input);\n }\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.bigint) {\n return this._getInvalidInput(input);\n }\n let ctx = void 0;\n const status = new ParseStatus();\n for (const check of this._def.checks) {\n if (check.kind === "min") {\n const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;\n if (tooSmall) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n type: "bigint",\n minimum: check.value,\n inclusive: check.inclusive,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "max") {\n const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;\n if (tooBig) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n type: "bigint",\n maximum: check.value,\n inclusive: check.inclusive,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "multipleOf") {\n if (input.data % check.value !== BigInt(0)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.not_multiple_of,\n multipleOf: check.value,\n message: check.message\n });\n status.dirty();\n }\n } else {\n util.assertNever(check);\n }\n }\n return { status: status.value, value: input.data };\n }\n _getInvalidInput(input) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.bigint,\n received: ctx.parsedType\n });\n return INVALID;\n }\n gte(value, message) {\n return this.setLimit("min", value, true, errorUtil.toString(message));\n }\n gt(value, message) {\n return this.setLimit("min", value, false, errorUtil.toString(message));\n }\n lte(value, message) {\n return this.setLimit("max", value, true, errorUtil.toString(message));\n }\n lt(value, message) {\n return this.setLimit("max", value, false, errorUtil.toString(message));\n }\n setLimit(kind, value, inclusive, message) {\n return new ZodBigInt({\n ...this._def,\n checks: [\n ...this._def.checks,\n {\n kind,\n value,\n inclusive,\n message: errorUtil.toString(message)\n }\n ]\n });\n }\n _addCheck(check) {\n return new ZodBigInt({\n ...this._def,\n checks: [...this._def.checks, check]\n });\n }\n positive(message) {\n return this._addCheck({\n kind: "min",\n value: BigInt(0),\n inclusive: false,\n message: errorUtil.toString(message)\n });\n }\n negative(message) {\n return this._addCheck({\n kind: "max",\n value: BigInt(0),\n inclusive: false,\n message: errorUtil.toString(message)\n });\n }\n nonpositive(message) {\n return this._addCheck({\n kind: "max",\n value: BigInt(0),\n inclusive: true,\n message: errorUtil.toString(message)\n });\n }\n nonnegative(message) {\n return this._addCheck({\n kind: "min",\n value: BigInt(0),\n inclusive: true,\n message: errorUtil.toString(message)\n });\n }\n multipleOf(value, message) {\n return this._addCheck({\n kind: "multipleOf",\n value,\n message: errorUtil.toString(message)\n });\n }\n get minValue() {\n let min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === "min") {\n if (min === null || ch.value > min)\n min = ch.value;\n }\n }\n return min;\n }\n get maxValue() {\n let max = null;\n for (const ch of this._def.checks) {\n if (ch.kind === "max") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return max;\n }\n }\n ZodBigInt.create = (params) => {\n return new ZodBigInt({\n checks: [],\n typeName: ZodFirstPartyTypeKind.ZodBigInt,\n coerce: (params == null ? void 0 : params.coerce) ?? false,\n ...processCreateParams(params)\n });\n };\n class ZodBoolean extends ZodType {\n _parse(input) {\n if (this._def.coerce) {\n input.data = Boolean(input.data);\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.boolean) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.boolean,\n received: ctx.parsedType\n });\n return INVALID;\n }\n return OK(input.data);\n }\n }\n ZodBoolean.create = (params) => {\n return new ZodBoolean({\n typeName: ZodFirstPartyTypeKind.ZodBoolean,\n coerce: (params == null ? void 0 : params.coerce) || false,\n ...processCreateParams(params)\n });\n };\n class ZodDate extends ZodType {\n _parse(input) {\n if (this._def.coerce) {\n input.data = new Date(input.data);\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.date) {\n const ctx2 = this._getOrReturnCtx(input);\n addIssueToContext(ctx2, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.date,\n received: ctx2.parsedType\n });\n return INVALID;\n }\n if (Number.isNaN(input.data.getTime())) {\n const ctx2 = this._getOrReturnCtx(input);\n addIssueToContext(ctx2, {\n code: ZodIssueCode.invalid_date\n });\n return INVALID;\n }\n const status = new ParseStatus();\n let ctx = void 0;\n for (const check of this._def.checks) {\n if (check.kind === "min") {\n if (input.data.getTime() < check.value) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n message: check.message,\n inclusive: true,\n exact: false,\n minimum: check.value,\n type: "date"\n });\n status.dirty();\n }\n } else if (check.kind === "max") {\n if (input.data.getTime() > check.value) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n message: check.message,\n inclusive: true,\n exact: false,\n maximum: check.value,\n type: "date"\n });\n status.dirty();\n }\n } else {\n util.assertNever(check);\n }\n }\n return {\n status: status.value,\n value: new Date(input.data.getTime())\n };\n }\n _addCheck(check) {\n return new ZodDate({\n ...this._def,\n checks: [...this._def.checks, check]\n });\n }\n min(minDate, message) {\n return this._addCheck({\n kind: "min",\n value: minDate.getTime(),\n message: errorUtil.toString(message)\n });\n }\n max(maxDate, message) {\n return this._addCheck({\n kind: "max",\n value: maxDate.getTime(),\n message: errorUtil.toString(message)\n });\n }\n get minDate() {\n let min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === "min") {\n if (min === null || ch.value > min)\n min = ch.value;\n }\n }\n return min != null ? new Date(min) : null;\n }\n get maxDate() {\n let max = null;\n for (const ch of this._def.checks) {\n if (ch.kind === "max") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return max != null ? new Date(max) : null;\n }\n }\n ZodDate.create = (params) => {\n return new ZodDate({\n checks: [],\n coerce: (params == null ? void 0 : params.coerce) || false,\n typeName: ZodFirstPartyTypeKind.ZodDate,\n ...processCreateParams(params)\n });\n };\n class ZodSymbol extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.symbol) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.symbol,\n received: ctx.parsedType\n });\n return INVALID;\n }\n return OK(input.data);\n }\n }\n ZodSymbol.create = (params) => {\n return new ZodSymbol({\n typeName: ZodFirstPartyTypeKind.ZodSymbol,\n ...processCreateParams(params)\n });\n };\n class ZodUndefined extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.undefined) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.undefined,\n received: ctx.parsedType\n });\n return INVALID;\n }\n return OK(input.data);\n }\n }\n ZodUndefined.create = (params) => {\n return new ZodUndefined({\n typeName: ZodFirstPartyTypeKind.ZodUndefined,\n ...processCreateParams(params)\n });\n };\n class ZodNull extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.null) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.null,\n received: ctx.parsedType\n });\n return INVALID;\n }\n return OK(input.data);\n }\n }\n ZodNull.create = (params) => {\n return new ZodNull({\n typeName: ZodFirstPartyTypeKind.ZodNull,\n ...processCreateParams(params)\n });\n };\n class ZodAny extends ZodType {\n constructor() {\n super(...arguments);\n this._any = true;\n }\n _parse(input) {\n return OK(input.data);\n }\n }\n ZodAny.create = (params) => {\n return new ZodAny({\n typeName: ZodFirstPartyTypeKind.ZodAny,\n ...processCreateParams(params)\n });\n };\n class ZodUnknown extends ZodType {\n constructor() {\n super(...arguments);\n this._unknown = true;\n }\n _parse(input) {\n return OK(input.data);\n }\n }\n ZodUnknown.create = (params) => {\n return new ZodUnknown({\n typeName: ZodFirstPartyTypeKind.ZodUnknown,\n ...processCreateParams(params)\n });\n };\n class ZodNever extends ZodType {\n _parse(input) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.never,\n received: ctx.parsedType\n });\n return INVALID;\n }\n }\n ZodNever.create = (params) => {\n return new ZodNever({\n typeName: ZodFirstPartyTypeKind.ZodNever,\n ...processCreateParams(params)\n });\n };\n class ZodVoid extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.undefined) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.void,\n received: ctx.parsedType\n });\n return INVALID;\n }\n return OK(input.data);\n }\n }\n ZodVoid.create = (params) => {\n return new ZodVoid({\n typeName: ZodFirstPartyTypeKind.ZodVoid,\n ...processCreateParams(params)\n });\n };\n class ZodArray extends ZodType {\n _parse(input) {\n const { ctx, status } = this._processInputParams(input);\n const def = this._def;\n if (ctx.parsedType !== ZodParsedType.array) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.array,\n received: ctx.parsedType\n });\n return INVALID;\n }\n if (def.exactLength !== null) {\n const tooBig = ctx.data.length > def.exactLength.value;\n const tooSmall = ctx.data.length < def.exactLength.value;\n if (tooBig || tooSmall) {\n addIssueToContext(ctx, {\n code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,\n minimum: tooSmall ? def.exactLength.value : void 0,\n maximum: tooBig ? def.exactLength.value : void 0,\n type: "array",\n inclusive: true,\n exact: true,\n message: def.exactLength.message\n });\n status.dirty();\n }\n }\n if (def.minLength !== null) {\n if (ctx.data.length < def.minLength.value) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: def.minLength.value,\n type: "array",\n inclusive: true,\n exact: false,\n message: def.minLength.message\n });\n status.dirty();\n }\n }\n if (def.maxLength !== null) {\n if (ctx.data.length > def.maxLength.value) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: def.maxLength.value,\n type: "array",\n inclusive: true,\n exact: false,\n message: def.maxLength.message\n });\n status.dirty();\n }\n }\n if (ctx.common.async) {\n return Promise.all([...ctx.data].map((item, i2) => {\n return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i2));\n })).then((result2) => {\n return ParseStatus.mergeArray(status, result2);\n });\n }\n const result = [...ctx.data].map((item, i2) => {\n return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i2));\n });\n return ParseStatus.mergeArray(status, result);\n }\n get element() {\n return this._def.type;\n }\n min(minLength, message) {\n return new ZodArray({\n ...this._def,\n minLength: { value: minLength, message: errorUtil.toString(message) }\n });\n }\n max(maxLength, message) {\n return new ZodArray({\n ...this._def,\n maxLength: { value: maxLength, message: errorUtil.toString(message) }\n });\n }\n length(len, message) {\n return new ZodArray({\n ...this._def,\n exactLength: { value: len, message: errorUtil.toString(message) }\n });\n }\n nonempty(message) {\n return this.min(1, message);\n }\n }\n ZodArray.create = (schema, params) => {\n return new ZodArray({\n type: schema,\n minLength: null,\n maxLength: null,\n exactLength: null,\n typeName: ZodFirstPartyTypeKind.ZodArray,\n ...processCreateParams(params)\n });\n };\n function deepPartialify(schema) {\n if (schema instanceof ZodObject) {\n const newShape = {};\n for (const key in schema.shape) {\n const fieldSchema = schema.shape[key];\n newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));\n }\n return new ZodObject({\n ...schema._def,\n shape: () => newShape\n });\n } else if (schema instanceof ZodArray) {\n return new ZodArray({\n ...schema._def,\n type: deepPartialify(schema.element)\n });\n } else if (schema instanceof ZodOptional) {\n return ZodOptional.create(deepPartialify(schema.unwrap()));\n } else if (schema instanceof ZodNullable) {\n return ZodNullable.create(deepPartialify(schema.unwrap()));\n } else if (schema instanceof ZodTuple) {\n return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));\n } else {\n return schema;\n }\n }\n class ZodObject extends ZodType {\n constructor() {\n super(...arguments);\n this._cached = null;\n this.nonstrict = this.passthrough;\n this.augment = this.extend;\n }\n _getCached() {\n if (this._cached !== null)\n return this._cached;\n const shape = this._def.shape();\n const keys = util.objectKeys(shape);\n this._cached = { shape, keys };\n return this._cached;\n }\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.object) {\n const ctx2 = this._getOrReturnCtx(input);\n addIssueToContext(ctx2, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.object,\n received: ctx2.parsedType\n });\n return INVALID;\n }\n const { status, ctx } = this._processInputParams(input);\n const { shape, keys: shapeKeys } = this._getCached();\n const extraKeys = [];\n if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {\n for (const key in ctx.data) {\n if (!shapeKeys.includes(key)) {\n extraKeys.push(key);\n }\n }\n }\n const pairs = [];\n for (const key of shapeKeys) {\n const keyValidator = shape[key];\n const value = ctx.data[key];\n pairs.push({\n key: { status: "valid", value: key },\n value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),\n alwaysSet: key in ctx.data\n });\n }\n if (this._def.catchall instanceof ZodNever) {\n const unknownKeys = this._def.unknownKeys;\n if (unknownKeys === "passthrough") {\n for (const key of extraKeys) {\n pairs.push({\n key: { status: "valid", value: key },\n value: { status: "valid", value: ctx.data[key] }\n });\n }\n } else if (unknownKeys === "strict") {\n if (extraKeys.length > 0) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.unrecognized_keys,\n keys: extraKeys\n });\n status.dirty();\n }\n } else if (unknownKeys === "strip") ;\n else {\n throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);\n }\n } else {\n const catchall = this._def.catchall;\n for (const key of extraKeys) {\n const value = ctx.data[key];\n pairs.push({\n key: { status: "valid", value: key },\n value: catchall._parse(\n new ParseInputLazyPath(ctx, value, ctx.path, key)\n //, ctx.child(key), value, getParsedType(value)\n ),\n alwaysSet: key in ctx.data\n });\n }\n }\n if (ctx.common.async) {\n return Promise.resolve().then(async () => {\n const syncPairs = [];\n for (const pair of pairs) {\n const key = await pair.key;\n const value = await pair.value;\n syncPairs.push({\n key,\n value,\n alwaysSet: pair.alwaysSet\n });\n }\n return syncPairs;\n }).then((syncPairs) => {\n return ParseStatus.mergeObjectSync(status, syncPairs);\n });\n } else {\n return ParseStatus.mergeObjectSync(status, pairs);\n }\n }\n get shape() {\n return this._def.shape();\n }\n strict(message) {\n errorUtil.errToObj;\n return new ZodObject({\n ...this._def,\n unknownKeys: "strict",\n ...message !== void 0 ? {\n errorMap: (issue, ctx) => {\n var _a, _b;\n const defaultError = ((_b = (_a = this._def).errorMap) == null ? void 0 : _b.call(_a, issue, ctx).message) ?? ctx.defaultError;\n if (issue.code === "unrecognized_keys")\n return {\n message: errorUtil.errToObj(message).message ?? defaultError\n };\n return {\n message: defaultError\n };\n }\n } : {}\n });\n }\n strip() {\n return new ZodObject({\n ...this._def,\n unknownKeys: "strip"\n });\n }\n passthrough() {\n return new ZodObject({\n ...this._def,\n unknownKeys: "passthrough"\n });\n }\n // const AugmentFactory =\n // <Def extends ZodObjectDef>(def: Def) =>\n // <Augmentation extends ZodRawShape>(\n // augmentation: Augmentation\n // ): ZodObject<\n // extendShape<ReturnType<Def["shape"]>, Augmentation>,\n // Def["unknownKeys"],\n // Def["catchall"]\n // > => {\n // return new ZodObject({\n // ...def,\n // shape: () => ({\n // ...def.shape(),\n // ...augmentation,\n // }),\n // }) as any;\n // };\n extend(augmentation) {\n return new ZodObject({\n ...this._def,\n shape: () => ({\n ...this._def.shape(),\n ...augmentation\n })\n });\n }\n /**\n * Prior to zod@1.0.12 there was a bug in the\n * inferred type of merged objects. Please\n * upgrade if you are experiencing issues.\n */\n merge(merging) {\n const merged = new ZodObject({\n unknownKeys: merging._def.unknownKeys,\n catchall: merging._def.catchall,\n shape: () => ({\n ...this._def.shape(),\n ...merging._def.shape()\n }),\n typeName: ZodFirstPartyTypeKind.ZodObject\n });\n return merged;\n }\n // merge<\n // Incoming extends AnyZodObject,\n // Augmentation extends Incoming["shape"],\n // NewOutput extends {\n // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation\n // ? Augmentation[k]["_output"]\n // : k extends keyof Output\n // ? Output[k]\n // : never;\n // },\n // NewInput extends {\n // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation\n // ? Augmentation[k]["_input"]\n // : k extends keyof Input\n // ? Input[k]\n // : never;\n // }\n // >(\n // merging: Incoming\n // ): ZodObject<\n // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,\n // Incoming["_def"]["unknownKeys"],\n // Incoming["_def"]["catchall"],\n // NewOutput,\n // NewInput\n // > {\n // const merged: any = new ZodObject({\n // unknownKeys: merging._def.unknownKeys,\n // catchall: merging._def.catchall,\n // shape: () =>\n // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),\n // typeName: ZodFirstPartyTypeKind.ZodObject,\n // }) as any;\n // return merged;\n // }\n setKey(key, schema) {\n return this.augment({ [key]: schema });\n }\n // merge<Incoming extends AnyZodObject>(\n // merging: Incoming\n // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {\n // ZodObject<\n // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,\n // Incoming["_def"]["unknownKeys"],\n // Incoming["_def"]["catchall"]\n // > {\n // // const mergedShape = objectUtil.mergeShapes(\n // // this._def.shape(),\n // // merging._def.shape()\n // // );\n // const merged: any = new ZodObject({\n // unknownKeys: merging._def.unknownKeys,\n // catchall: merging._def.catchall,\n // shape: () =>\n // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),\n // typeName: ZodFirstPartyTypeKind.ZodObject,\n // }) as any;\n // return merged;\n // }\n catchall(index) {\n return new ZodObject({\n ...this._def,\n catchall: index\n });\n }\n pick(mask) {\n const shape = {};\n for (const key of util.objectKeys(mask)) {\n if (mask[key] && this.shape[key]) {\n shape[key] = this.shape[key];\n }\n }\n return new ZodObject({\n ...this._def,\n shape: () => shape\n });\n }\n omit(mask) {\n const shape = {};\n for (const key of util.objectKeys(this.shape)) {\n if (!mask[key]) {\n shape[key] = this.shape[key];\n }\n }\n return new ZodObject({\n ...this._def,\n shape: () => shape\n });\n }\n /**\n * @deprecated\n */\n deepPartial() {\n return deepPartialify(this);\n }\n partial(mask) {\n const newShape = {};\n for (const key of util.objectKeys(this.shape)) {\n const fieldSchema = this.shape[key];\n if (mask && !mask[key]) {\n newShape[key] = fieldSchema;\n } else {\n newShape[key] = fieldSchema.optional();\n }\n }\n return new ZodObject({\n ...this._def,\n shape: () => newShape\n });\n }\n required(mask) {\n const newShape = {};\n for (const key of util.objectKeys(this.shape)) {\n if (mask && !mask[key]) {\n newShape[key] = this.shape[key];\n } else {\n const fieldSchema = this.shape[key];\n let newField = fieldSchema;\n while (newField instanceof ZodOptional) {\n newField = newField._def.innerType;\n }\n newShape[key] = newField;\n }\n }\n return new ZodObject({\n ...this._def,\n shape: () => newShape\n });\n }\n keyof() {\n return createZodEnum(util.objectKeys(this.shape));\n }\n }\n ZodObject.create = (shape, params) => {\n return new ZodObject({\n shape: () => shape,\n unknownKeys: "strip",\n catchall: ZodNever.create(),\n typeName: ZodFirstPartyTypeKind.ZodObject,\n ...processCreateParams(params)\n });\n };\n ZodObject.strictCreate = (shape, params) => {\n return new ZodObject({\n shape: () => shape,\n unknownKeys: "strict",\n catchall: ZodNever.create(),\n typeName: ZodFirstPartyTypeKind.ZodObject,\n ...processCreateParams(params)\n });\n };\n ZodObject.lazycreate = (shape, params) => {\n return new ZodObject({\n shape,\n unknownKeys: "strip",\n catchall: ZodNever.create(),\n typeName: ZodFirstPartyTypeKind.ZodObject,\n ...processCreateParams(params)\n });\n };\n class ZodUnion extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n const options = this._def.options;\n function handleResults(results) {\n for (const result of results) {\n if (result.result.status === "valid") {\n return result.result;\n }\n }\n for (const result of results) {\n if (result.result.status === "dirty") {\n ctx.common.issues.push(...result.ctx.common.issues);\n return result.result;\n }\n }\n const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_union,\n unionErrors\n });\n return INVALID;\n }\n if (ctx.common.async) {\n return Promise.all(options.map(async (option) => {\n const childCtx = {\n ...ctx,\n common: {\n ...ctx.common,\n issues: []\n },\n parent: null\n };\n return {\n result: await option._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: childCtx\n }),\n ctx: childCtx\n };\n })).then(handleResults);\n } else {\n let dirty = void 0;\n const issues = [];\n for (const option of options) {\n const childCtx = {\n ...ctx,\n common: {\n ...ctx.common,\n issues: []\n },\n parent: null\n };\n const result = option._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: childCtx\n });\n if (result.status === "valid") {\n return result;\n } else if (result.status === "dirty" && !dirty) {\n dirty = { result, ctx: childCtx };\n }\n if (childCtx.common.issues.length) {\n issues.push(childCtx.common.issues);\n }\n }\n if (dirty) {\n ctx.common.issues.push(...dirty.ctx.common.issues);\n return dirty.result;\n }\n const unionErrors = issues.map((issues2) => new ZodError(issues2));\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_union,\n unionErrors\n });\n return INVALID;\n }\n }\n get options() {\n return this._def.options;\n }\n }\n ZodUnion.create = (types, params) => {\n return new ZodUnion({\n options: types,\n typeName: ZodFirstPartyTypeKind.ZodUnion,\n ...processCreateParams(params)\n });\n };\n const getDiscriminator = (type) => {\n if (type instanceof ZodLazy) {\n return getDiscriminator(type.schema);\n } else if (type instanceof ZodEffects) {\n return getDiscriminator(type.innerType());\n } else if (type instanceof ZodLiteral) {\n return [type.value];\n } else if (type instanceof ZodEnum) {\n return type.options;\n } else if (type instanceof ZodNativeEnum) {\n return util.objectValues(type.enum);\n } else if (type instanceof ZodDefault) {\n return getDiscriminator(type._def.innerType);\n } else if (type instanceof ZodUndefined) {\n return [void 0];\n } else if (type instanceof ZodNull) {\n return [null];\n } else if (type instanceof ZodOptional) {\n return [void 0, ...getDiscriminator(type.unwrap())];\n } else if (type instanceof ZodNullable) {\n return [null, ...getDiscriminator(type.unwrap())];\n } else if (type instanceof ZodBranded) {\n return getDiscriminator(type.unwrap());\n } else if (type instanceof ZodReadonly) {\n return getDiscriminator(type.unwrap());\n } else if (type instanceof ZodCatch) {\n return getDiscriminator(type._def.innerType);\n } else {\n return [];\n }\n };\n class ZodDiscriminatedUnion extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.object) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.object,\n received: ctx.parsedType\n });\n return INVALID;\n }\n const discriminator = this.discriminator;\n const discriminatorValue = ctx.data[discriminator];\n const option = this.optionsMap.get(discriminatorValue);\n if (!option) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_union_discriminator,\n options: Array.from(this.optionsMap.keys()),\n path: [discriminator]\n });\n return INVALID;\n }\n if (ctx.common.async) {\n return option._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n });\n } else {\n return option._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n });\n }\n }\n get discriminator() {\n return this._def.discriminator;\n }\n get options() {\n return this._def.options;\n }\n get optionsMap() {\n return this._def.optionsMap;\n }\n /**\n * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.\n * However, it only allows a union of objects, all of which need to share a discriminator property. This property must\n * have a different value for each object in the union.\n * @param discriminator the name of the discriminator property\n * @param types an array of object schemas\n * @param params\n */\n static create(discriminator, options, params) {\n const optionsMap = /* @__PURE__ */ new Map();\n for (const type of options) {\n const discriminatorValues = getDiscriminator(type.shape[discriminator]);\n if (!discriminatorValues.length) {\n throw new Error(`A discriminator value for key \\`${discriminator}\\` could not be extracted from all schema options`);\n }\n for (const value of discriminatorValues) {\n if (optionsMap.has(value)) {\n throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);\n }\n optionsMap.set(value, type);\n }\n }\n return new ZodDiscriminatedUnion({\n typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,\n discriminator,\n options,\n optionsMap,\n ...processCreateParams(params)\n });\n }\n }\n function mergeValues(a2, b) {\n const aType = getParsedType(a2);\n const bType = getParsedType(b);\n if (a2 === b) {\n return { valid: true, data: a2 };\n } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {\n const bKeys = util.objectKeys(b);\n const sharedKeys = util.objectKeys(a2).filter((key) => bKeys.indexOf(key) !== -1);\n const newObj = { ...a2, ...b };\n for (const key of sharedKeys) {\n const sharedValue = mergeValues(a2[key], b[key]);\n if (!sharedValue.valid) {\n return { valid: false };\n }\n newObj[key] = sharedValue.data;\n }\n return { valid: true, data: newObj };\n } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {\n if (a2.length !== b.length) {\n return { valid: false };\n }\n const newArray = [];\n for (let index = 0; index < a2.length; index++) {\n const itemA = a2[index];\n const itemB = b[index];\n const sharedValue = mergeValues(itemA, itemB);\n if (!sharedValue.valid) {\n return { valid: false };\n }\n newArray.push(sharedValue.data);\n }\n return { valid: true, data: newArray };\n } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a2 === +b) {\n return { valid: true, data: a2 };\n } else {\n return { valid: false };\n }\n }\n class ZodIntersection extends ZodType {\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n const handleParsed = (parsedLeft, parsedRight) => {\n if (isAborted(parsedLeft) || isAborted(parsedRight)) {\n return INVALID;\n }\n const merged = mergeValues(parsedLeft.value, parsedRight.value);\n if (!merged.valid) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_intersection_types\n });\n return INVALID;\n }\n if (isDirty(parsedLeft) || isDirty(parsedRight)) {\n status.dirty();\n }\n return { status: status.value, value: merged.data };\n };\n if (ctx.common.async) {\n return Promise.all([\n this._def.left._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n }),\n this._def.right._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n })\n ]).then(([left, right]) => handleParsed(left, right));\n } else {\n return handleParsed(this._def.left._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n }), this._def.right._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n }));\n }\n }\n }\n ZodIntersection.create = (left, right, params) => {\n return new ZodIntersection({\n left,\n right,\n typeName: ZodFirstPartyTypeKind.ZodIntersection,\n ...processCreateParams(params)\n });\n };\n class ZodTuple extends ZodType {\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.array) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.array,\n received: ctx.parsedType\n });\n return INVALID;\n }\n if (ctx.data.length < this._def.items.length) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: this._def.items.length,\n inclusive: true,\n exact: false,\n type: "array"\n });\n return INVALID;\n }\n const rest = this._def.rest;\n if (!rest && ctx.data.length > this._def.items.length) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: this._def.items.length,\n inclusive: true,\n exact: false,\n type: "array"\n });\n status.dirty();\n }\n const items = [...ctx.data].map((item, itemIndex) => {\n const schema = this._def.items[itemIndex] || this._def.rest;\n if (!schema)\n return null;\n return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));\n }).filter((x) => !!x);\n if (ctx.common.async) {\n return Promise.all(items).then((results) => {\n return ParseStatus.mergeArray(status, results);\n });\n } else {\n return ParseStatus.mergeArray(status, items);\n }\n }\n get items() {\n return this._def.items;\n }\n rest(rest) {\n return new ZodTuple({\n ...this._def,\n rest\n });\n }\n }\n ZodTuple.create = (schemas, params) => {\n if (!Array.isArray(schemas)) {\n throw new Error("You must pass an array of schemas to z.tuple([ ... ])");\n }\n return new ZodTuple({\n items: schemas,\n typeName: ZodFirstPartyTypeKind.ZodTuple,\n rest: null,\n ...processCreateParams(params)\n });\n };\n class ZodRecord extends ZodType {\n get keySchema() {\n return this._def.keyType;\n }\n get valueSchema() {\n return this._def.valueType;\n }\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.object) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.object,\n received: ctx.parsedType\n });\n return INVALID;\n }\n const pairs = [];\n const keyType = this._def.keyType;\n const valueType = this._def.valueType;\n for (const key in ctx.data) {\n pairs.push({\n key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),\n value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),\n alwaysSet: key in ctx.data\n });\n }\n if (ctx.common.async) {\n return ParseStatus.mergeObjectAsync(status, pairs);\n } else {\n return ParseStatus.mergeObjectSync(status, pairs);\n }\n }\n get element() {\n return this._def.valueType;\n }\n static create(first, second, third) {\n if (second instanceof ZodType) {\n return new ZodRecord({\n keyType: first,\n valueType: second,\n typeName: ZodFirstPartyTypeKind.ZodRecord,\n ...processCreateParams(third)\n });\n }\n return new ZodRecord({\n keyType: ZodString.create(),\n valueType: first,\n typeName: ZodFirstPartyTypeKind.ZodRecord,\n ...processCreateParams(second)\n });\n }\n }\n class ZodMap extends ZodType {\n get keySchema() {\n return this._def.keyType;\n }\n get valueSchema() {\n return this._def.valueType;\n }\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.map) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.map,\n received: ctx.parsedType\n });\n return INVALID;\n }\n const keyType = this._def.keyType;\n const valueType = this._def.valueType;\n const pairs = [...ctx.data.entries()].map(([key, value], index) => {\n return {\n key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),\n value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))\n };\n });\n if (ctx.common.async) {\n const finalMap = /* @__PURE__ */ new Map();\n return Promise.resolve().then(async () => {\n for (const pair of pairs) {\n const key = await pair.key;\n const value = await pair.value;\n if (key.status === "aborted" || value.status === "aborted") {\n return INVALID;\n }\n if (key.status === "dirty" || value.status === "dirty") {\n status.dirty();\n }\n finalMap.set(key.value, value.value);\n }\n return { status: status.value, value: finalMap };\n });\n } else {\n const finalMap = /* @__PURE__ */ new Map();\n for (const pair of pairs) {\n const key = pair.key;\n const value = pair.value;\n if (key.status === "aborted" || value.status === "aborted") {\n return INVALID;\n }\n if (key.status === "dirty" || value.status === "dirty") {\n status.dirty();\n }\n finalMap.set(key.value, value.value);\n }\n return { status: status.value, value: finalMap };\n }\n }\n }\n ZodMap.create = (keyType, valueType, params) => {\n return new ZodMap({\n valueType,\n keyType,\n typeName: ZodFirstPartyTypeKind.ZodMap,\n ...processCreateParams(params)\n });\n };\n class ZodSet extends ZodType {\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.set) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.set,\n received: ctx.parsedType\n });\n return INVALID;\n }\n const def = this._def;\n if (def.minSize !== null) {\n if (ctx.data.size < def.minSize.value) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: def.minSize.value,\n type: "set",\n inclusive: true,\n exact: false,\n message: def.minSize.message\n });\n status.dirty();\n }\n }\n if (def.maxSize !== null) {\n if (ctx.data.size > def.maxSize.value) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: def.maxSize.value,\n type: "set",\n inclusive: true,\n exact: false,\n message: def.maxSize.message\n });\n status.dirty();\n }\n }\n const valueType = this._def.valueType;\n function finalizeSet(elements2) {\n const parsedSet = /* @__PURE__ */ new Set();\n for (const element of elements2) {\n if (element.status === "aborted")\n return INVALID;\n if (element.status === "dirty")\n status.dirty();\n parsedSet.add(element.value);\n }\n return { status: status.value, value: parsedSet };\n }\n const elements = [...ctx.data.values()].map((item, i2) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i2)));\n if (ctx.common.async) {\n return Promise.all(elements).then((elements2) => finalizeSet(elements2));\n } else {\n return finalizeSet(elements);\n }\n }\n min(minSize, message) {\n return new ZodSet({\n ...this._def,\n minSize: { value: minSize, message: errorUtil.toString(message) }\n });\n }\n max(maxSize, message) {\n return new ZodSet({\n ...this._def,\n maxSize: { value: maxSize, message: errorUtil.toString(message) }\n });\n }\n size(size, message) {\n return this.min(size, message).max(size, message);\n }\n nonempty(message) {\n return this.min(1, message);\n }\n }\n ZodSet.create = (valueType, params) => {\n return new ZodSet({\n valueType,\n minSize: null,\n maxSize: null,\n typeName: ZodFirstPartyTypeKind.ZodSet,\n ...processCreateParams(params)\n });\n };\n class ZodFunction extends ZodType {\n constructor() {\n super(...arguments);\n this.validate = this.implement;\n }\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.function) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.function,\n received: ctx.parsedType\n });\n return INVALID;\n }\n function makeArgsIssue(args, error) {\n return makeIssue({\n data: args,\n path: ctx.path,\n errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), errorMap].filter((x) => !!x),\n issueData: {\n code: ZodIssueCode.invalid_arguments,\n argumentsError: error\n }\n });\n }\n function makeReturnsIssue(returns, error) {\n return makeIssue({\n data: returns,\n path: ctx.path,\n errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), errorMap].filter((x) => !!x),\n issueData: {\n code: ZodIssueCode.invalid_return_type,\n returnTypeError: error\n }\n });\n }\n const params = { errorMap: ctx.common.contextualErrorMap };\n const fn = ctx.data;\n if (this._def.returns instanceof ZodPromise) {\n const me = this;\n return OK(async function(...args) {\n const error = new ZodError([]);\n const parsedArgs = await me._def.args.parseAsync(args, params).catch((e2) => {\n error.addIssue(makeArgsIssue(args, e2));\n throw error;\n });\n const result = await Reflect.apply(fn, this, parsedArgs);\n const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e2) => {\n error.addIssue(makeReturnsIssue(result, e2));\n throw error;\n });\n return parsedReturns;\n });\n } else {\n const me = this;\n return OK(function(...args) {\n const parsedArgs = me._def.args.safeParse(args, params);\n if (!parsedArgs.success) {\n throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);\n }\n const result = Reflect.apply(fn, this, parsedArgs.data);\n const parsedReturns = me._def.returns.safeParse(result, params);\n if (!parsedReturns.success) {\n throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);\n }\n return parsedReturns.data;\n });\n }\n }\n parameters() {\n return this._def.args;\n }\n returnType() {\n return this._def.returns;\n }\n args(...items) {\n return new ZodFunction({\n ...this._def,\n args: ZodTuple.create(items).rest(ZodUnknown.create())\n });\n }\n returns(returnType) {\n return new ZodFunction({\n ...this._def,\n returns: returnType\n });\n }\n implement(func) {\n const validatedFunc = this.parse(func);\n return validatedFunc;\n }\n strictImplement(func) {\n const validatedFunc = this.parse(func);\n return validatedFunc;\n }\n static create(args, returns, params) {\n return new ZodFunction({\n args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),\n returns: returns || ZodUnknown.create(),\n typeName: ZodFirstPartyTypeKind.ZodFunction,\n ...processCreateParams(params)\n });\n }\n }\n class ZodLazy extends ZodType {\n get schema() {\n return this._def.getter();\n }\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n const lazySchema = this._def.getter();\n return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });\n }\n }\n ZodLazy.create = (getter, params) => {\n return new ZodLazy({\n getter,\n typeName: ZodFirstPartyTypeKind.ZodLazy,\n ...processCreateParams(params)\n });\n };\n class ZodLiteral extends ZodType {\n _parse(input) {\n if (input.data !== this._def.value) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n received: ctx.data,\n code: ZodIssueCode.invalid_literal,\n expected: this._def.value\n });\n return INVALID;\n }\n return { status: "valid", value: input.data };\n }\n get value() {\n return this._def.value;\n }\n }\n ZodLiteral.create = (value, params) => {\n return new ZodLiteral({\n value,\n typeName: ZodFirstPartyTypeKind.ZodLiteral,\n ...processCreateParams(params)\n });\n };\n function createZodEnum(values, params) {\n return new ZodEnum({\n values,\n typeName: ZodFirstPartyTypeKind.ZodEnum,\n ...processCreateParams(params)\n });\n }\n class ZodEnum extends ZodType {\n _parse(input) {\n if (typeof input.data !== "string") {\n const ctx = this._getOrReturnCtx(input);\n const expectedValues = this._def.values;\n addIssueToContext(ctx, {\n expected: util.joinValues(expectedValues),\n received: ctx.parsedType,\n code: ZodIssueCode.invalid_type\n });\n return INVALID;\n }\n if (!this._cache) {\n this._cache = new Set(this._def.values);\n }\n if (!this._cache.has(input.data)) {\n const ctx = this._getOrReturnCtx(input);\n const expectedValues = this._def.values;\n addIssueToContext(ctx, {\n received: ctx.data,\n code: ZodIssueCode.invalid_enum_value,\n options: expectedValues\n });\n return INVALID;\n }\n return OK(input.data);\n }\n get options() {\n return this._def.values;\n }\n get enum() {\n const enumValues = {};\n for (const val of this._def.values) {\n enumValues[val] = val;\n }\n return enumValues;\n }\n get Values() {\n const enumValues = {};\n for (const val of this._def.values) {\n enumValues[val] = val;\n }\n return enumValues;\n }\n get Enum() {\n const enumValues = {};\n for (const val of this._def.values) {\n enumValues[val] = val;\n }\n return enumValues;\n }\n extract(values, newDef = this._def) {\n return ZodEnum.create(values, {\n ...this._def,\n ...newDef\n });\n }\n exclude(values, newDef = this._def) {\n return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {\n ...this._def,\n ...newDef\n });\n }\n }\n ZodEnum.create = createZodEnum;\n class ZodNativeEnum extends ZodType {\n _parse(input) {\n const nativeEnumValues = util.getValidEnumValues(this._def.values);\n const ctx = this._getOrReturnCtx(input);\n if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {\n const expectedValues = util.objectValues(nativeEnumValues);\n addIssueToContext(ctx, {\n expected: util.joinValues(expectedValues),\n received: ctx.parsedType,\n code: ZodIssueCode.invalid_type\n });\n return INVALID;\n }\n if (!this._cache) {\n this._cache = new Set(util.getValidEnumValues(this._def.values));\n }\n if (!this._cache.has(input.data)) {\n const expectedValues = util.objectValues(nativeEnumValues);\n addIssueToContext(ctx, {\n received: ctx.data,\n code: ZodIssueCode.invalid_enum_value,\n options: expectedValues\n });\n return INVALID;\n }\n return OK(input.data);\n }\n get enum() {\n return this._def.values;\n }\n }\n ZodNativeEnum.create = (values, params) => {\n return new ZodNativeEnum({\n values,\n typeName: ZodFirstPartyTypeKind.ZodNativeEnum,\n ...processCreateParams(params)\n });\n };\n class ZodPromise extends ZodType {\n unwrap() {\n return this._def.type;\n }\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.promise,\n received: ctx.parsedType\n });\n return INVALID;\n }\n const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);\n return OK(promisified.then((data) => {\n return this._def.type.parseAsync(data, {\n path: ctx.path,\n errorMap: ctx.common.contextualErrorMap\n });\n }));\n }\n }\n ZodPromise.create = (schema, params) => {\n return new ZodPromise({\n type: schema,\n typeName: ZodFirstPartyTypeKind.ZodPromise,\n ...processCreateParams(params)\n });\n };\n class ZodEffects extends ZodType {\n innerType() {\n return this._def.schema;\n }\n sourceType() {\n return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;\n }\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n const effect = this._def.effect || null;\n const checkCtx = {\n addIssue: (arg) => {\n addIssueToContext(ctx, arg);\n if (arg.fatal) {\n status.abort();\n } else {\n status.dirty();\n }\n },\n get path() {\n return ctx.path;\n }\n };\n checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);\n if (effect.type === "preprocess") {\n const processed = effect.transform(ctx.data, checkCtx);\n if (ctx.common.async) {\n return Promise.resolve(processed).then(async (processed2) => {\n if (status.value === "aborted")\n return INVALID;\n const result = await this._def.schema._parseAsync({\n data: processed2,\n path: ctx.path,\n parent: ctx\n });\n if (result.status === "aborted")\n return INVALID;\n if (result.status === "dirty")\n return DIRTY(result.value);\n if (status.value === "dirty")\n return DIRTY(result.value);\n return result;\n });\n } else {\n if (status.value === "aborted")\n return INVALID;\n const result = this._def.schema._parseSync({\n data: processed,\n path: ctx.path,\n parent: ctx\n });\n if (result.status === "aborted")\n return INVALID;\n if (result.status === "dirty")\n return DIRTY(result.value);\n if (status.value === "dirty")\n return DIRTY(result.value);\n return result;\n }\n }\n if (effect.type === "refinement") {\n const executeRefinement = (acc) => {\n const result = effect.refinement(acc, checkCtx);\n if (ctx.common.async) {\n return Promise.resolve(result);\n }\n if (result instanceof Promise) {\n throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");\n }\n return acc;\n };\n if (ctx.common.async === false) {\n const inner = this._def.schema._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n });\n if (inner.status === "aborted")\n return INVALID;\n if (inner.status === "dirty")\n status.dirty();\n executeRefinement(inner.value);\n return { status: status.value, value: inner.value };\n } else {\n return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {\n if (inner.status === "aborted")\n return INVALID;\n if (inner.status === "dirty")\n status.dirty();\n return executeRefinement(inner.value).then(() => {\n return { status: status.value, value: inner.value };\n });\n });\n }\n }\n if (effect.type === "transform") {\n if (ctx.common.async === false) {\n const base = this._def.schema._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n });\n if (!isValid(base))\n return INVALID;\n const result = effect.transform(base.value, checkCtx);\n if (result instanceof Promise) {\n throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);\n }\n return { status: status.value, value: result };\n } else {\n return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {\n if (!isValid(base))\n return INVALID;\n return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({\n status: status.value,\n value: result\n }));\n });\n }\n }\n util.assertNever(effect);\n }\n }\n ZodEffects.create = (schema, effect, params) => {\n return new ZodEffects({\n schema,\n typeName: ZodFirstPartyTypeKind.ZodEffects,\n effect,\n ...processCreateParams(params)\n });\n };\n ZodEffects.createWithPreprocess = (preprocess, schema, params) => {\n return new ZodEffects({\n schema,\n effect: { type: "preprocess", transform: preprocess },\n typeName: ZodFirstPartyTypeKind.ZodEffects,\n ...processCreateParams(params)\n });\n };\n class ZodOptional extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType === ZodParsedType.undefined) {\n return OK(void 0);\n }\n return this._def.innerType._parse(input);\n }\n unwrap() {\n return this._def.innerType;\n }\n }\n ZodOptional.create = (type, params) => {\n return new ZodOptional({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodOptional,\n ...processCreateParams(params)\n });\n };\n class ZodNullable extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType === ZodParsedType.null) {\n return OK(null);\n }\n return this._def.innerType._parse(input);\n }\n unwrap() {\n return this._def.innerType;\n }\n }\n ZodNullable.create = (type, params) => {\n return new ZodNullable({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodNullable,\n ...processCreateParams(params)\n });\n };\n class ZodDefault extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n let data = ctx.data;\n if (ctx.parsedType === ZodParsedType.undefined) {\n data = this._def.defaultValue();\n }\n return this._def.innerType._parse({\n data,\n path: ctx.path,\n parent: ctx\n });\n }\n removeDefault() {\n return this._def.innerType;\n }\n }\n ZodDefault.create = (type, params) => {\n return new ZodDefault({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodDefault,\n defaultValue: typeof params.default === "function" ? params.default : () => params.default,\n ...processCreateParams(params)\n });\n };\n class ZodCatch extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n const newCtx = {\n ...ctx,\n common: {\n ...ctx.common,\n issues: []\n }\n };\n const result = this._def.innerType._parse({\n data: newCtx.data,\n path: newCtx.path,\n parent: {\n ...newCtx\n }\n });\n if (isAsync(result)) {\n return result.then((result2) => {\n return {\n status: "valid",\n value: result2.status === "valid" ? result2.value : this._def.catchValue({\n get error() {\n return new ZodError(newCtx.common.issues);\n },\n input: newCtx.data\n })\n };\n });\n } else {\n return {\n status: "valid",\n value: result.status === "valid" ? result.value : this._def.catchValue({\n get error() {\n return new ZodError(newCtx.common.issues);\n },\n input: newCtx.data\n })\n };\n }\n }\n removeCatch() {\n return this._def.innerType;\n }\n }\n ZodCatch.create = (type, params) => {\n return new ZodCatch({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodCatch,\n catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,\n ...processCreateParams(params)\n });\n };\n class ZodNaN extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.nan) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.nan,\n received: ctx.parsedType\n });\n return INVALID;\n }\n return { status: "valid", value: input.data };\n }\n }\n ZodNaN.create = (params) => {\n return new ZodNaN({\n typeName: ZodFirstPartyTypeKind.ZodNaN,\n ...processCreateParams(params)\n });\n };\n const BRAND = Symbol("zod_brand");\n class ZodBranded extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n const data = ctx.data;\n return this._def.type._parse({\n data,\n path: ctx.path,\n parent: ctx\n });\n }\n unwrap() {\n return this._def.type;\n }\n }\n class ZodPipeline extends ZodType {\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.common.async) {\n const handleAsync = async () => {\n const inResult = await this._def.in._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n });\n if (inResult.status === "aborted")\n return INVALID;\n if (inResult.status === "dirty") {\n status.dirty();\n return DIRTY(inResult.value);\n } else {\n return this._def.out._parseAsync({\n data: inResult.value,\n path: ctx.path,\n parent: ctx\n });\n }\n };\n return handleAsync();\n } else {\n const inResult = this._def.in._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n });\n if (inResult.status === "aborted")\n return INVALID;\n if (inResult.status === "dirty") {\n status.dirty();\n return {\n status: "dirty",\n value: inResult.value\n };\n } else {\n return this._def.out._parseSync({\n data: inResult.value,\n path: ctx.path,\n parent: ctx\n });\n }\n }\n }\n static create(a2, b) {\n return new ZodPipeline({\n in: a2,\n out: b,\n typeName: ZodFirstPartyTypeKind.ZodPipeline\n });\n }\n }\n class ZodReadonly extends ZodType {\n _parse(input) {\n const result = this._def.innerType._parse(input);\n const freeze = (data) => {\n if (isValid(data)) {\n data.value = Object.freeze(data.value);\n }\n return data;\n };\n return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);\n }\n unwrap() {\n return this._def.innerType;\n }\n }\n ZodReadonly.create = (type, params) => {\n return new ZodReadonly({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodReadonly,\n ...processCreateParams(params)\n });\n };\n function cleanParams(params, data) {\n const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;\n const p2 = typeof p === "string" ? { message: p } : p;\n return p2;\n }\n function custom(check, _params = {}, fatal) {\n if (check)\n return ZodAny.create().superRefine((data, ctx) => {\n const r2 = check(data);\n if (r2 instanceof Promise) {\n return r2.then((r3) => {\n if (!r3) {\n const params = cleanParams(_params, data);\n const _fatal = params.fatal ?? fatal ?? true;\n ctx.addIssue({ code: "custom", ...params, fatal: _fatal });\n }\n });\n }\n if (!r2) {\n const params = cleanParams(_params, data);\n const _fatal = params.fatal ?? fatal ?? true;\n ctx.addIssue({ code: "custom", ...params, fatal: _fatal });\n }\n return;\n });\n return ZodAny.create();\n }\n const late = {\n object: ZodObject.lazycreate\n };\n var ZodFirstPartyTypeKind;\n (function(ZodFirstPartyTypeKind2) {\n ZodFirstPartyTypeKind2["ZodString"] = "ZodString";\n ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";\n ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";\n ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";\n ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";\n ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";\n ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";\n ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";\n ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";\n ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";\n ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";\n ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";\n ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";\n ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";\n ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";\n ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";\n ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";\n ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";\n ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";\n ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";\n ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";\n ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";\n ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";\n ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";\n ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";\n ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";\n ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";\n ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";\n ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";\n ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";\n ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";\n ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";\n ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";\n ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";\n ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";\n ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";\n })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));\n const instanceOfType = (cls, params = {\n message: `Input not instance of ${cls.name}`\n }) => custom((data) => data instanceof cls, params);\n const stringType = ZodString.create;\n const numberType = ZodNumber.create;\n const nanType = ZodNaN.create;\n const bigIntType = ZodBigInt.create;\n const booleanType = ZodBoolean.create;\n const dateType = ZodDate.create;\n const symbolType = ZodSymbol.create;\n const undefinedType = ZodUndefined.create;\n const nullType = ZodNull.create;\n const anyType = ZodAny.create;\n const unknownType = ZodUnknown.create;\n const neverType = ZodNever.create;\n const voidType = ZodVoid.create;\n const arrayType = ZodArray.create;\n const objectType = ZodObject.create;\n const strictObjectType = ZodObject.strictCreate;\n const unionType = ZodUnion.create;\n const discriminatedUnionType = ZodDiscriminatedUnion.create;\n const intersectionType = ZodIntersection.create;\n const tupleType = ZodTuple.create;\n const recordType = ZodRecord.create;\n const mapType = ZodMap.create;\n const setType = ZodSet.create;\n const functionType = ZodFunction.create;\n const lazyType = ZodLazy.create;\n const literalType = ZodLiteral.create;\n const enumType = ZodEnum.create;\n const nativeEnumType = ZodNativeEnum.create;\n const promiseType = ZodPromise.create;\n const effectsType = ZodEffects.create;\n const optionalType = ZodOptional.create;\n const nullableType = ZodNullable.create;\n const preprocessType = ZodEffects.createWithPreprocess;\n const pipelineType = ZodPipeline.create;\n const ostring = () => stringType().optional();\n const onumber = () => numberType().optional();\n const oboolean = () => booleanType().optional();\n const coerce = {\n string: (arg) => ZodString.create({ ...arg, coerce: true }),\n number: (arg) => ZodNumber.create({ ...arg, coerce: true }),\n boolean: (arg) => ZodBoolean.create({\n ...arg,\n coerce: true\n }),\n bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),\n date: (arg) => ZodDate.create({ ...arg, coerce: true })\n };\n const NEVER = INVALID;\n var z$1 = /* @__PURE__ */ Object.freeze({\n __proto__: null,\n BRAND,\n DIRTY,\n EMPTY_PATH,\n INVALID,\n NEVER,\n OK,\n ParseStatus,\n Schema: ZodType,\n ZodAny,\n ZodArray,\n ZodBigInt,\n ZodBoolean,\n ZodBranded,\n ZodCatch,\n ZodDate,\n ZodDefault,\n ZodDiscriminatedUnion,\n ZodEffects,\n ZodEnum,\n ZodError,\n get ZodFirstPartyTypeKind() {\n return ZodFirstPartyTypeKind;\n },\n ZodFunction,\n ZodIntersection,\n ZodIssueCode,\n ZodLazy,\n ZodLiteral,\n ZodMap,\n ZodNaN,\n ZodNativeEnum,\n ZodNever,\n ZodNull,\n ZodNullable,\n ZodNumber,\n ZodObject,\n ZodOptional,\n ZodParsedType,\n ZodPipeline,\n ZodPromise,\n ZodReadonly,\n ZodRecord,\n ZodSchema: ZodType,\n ZodSet,\n ZodString,\n ZodSymbol,\n ZodTransformer: ZodEffects,\n ZodTuple,\n ZodType,\n ZodUndefined,\n ZodUnion,\n ZodUnknown,\n ZodVoid,\n addIssueToContext,\n any: anyType,\n array: arrayType,\n bigint: bigIntType,\n boolean: booleanType,\n coerce,\n custom,\n date: dateType,\n datetimeRegex,\n defaultErrorMap: errorMap,\n discriminatedUnion: discriminatedUnionType,\n effect: effectsType,\n enum: enumType,\n function: functionType,\n getErrorMap,\n getParsedType,\n instanceof: instanceOfType,\n intersection: intersectionType,\n isAborted,\n isAsync,\n isDirty,\n isValid,\n late,\n lazy: lazyType,\n literal: literalType,\n makeIssue,\n map: mapType,\n nan: nanType,\n nativeEnum: nativeEnumType,\n never: neverType,\n null: nullType,\n nullable: nullableType,\n number: numberType,\n object: objectType,\n get objectUtil() {\n return objectUtil;\n },\n oboolean,\n onumber,\n optional: optionalType,\n ostring,\n pipeline: pipelineType,\n preprocess: preprocessType,\n promise: promiseType,\n quotelessJson,\n record: recordType,\n set: setType,\n setErrorMap,\n strictObject: strictObjectType,\n string: stringType,\n symbol: symbolType,\n transformer: effectsType,\n tuple: tupleType,\n undefined: undefinedType,\n union: unionType,\n unknown: unknownType,\n get util() {\n return util;\n },\n void: voidType\n });\n z$1.object({\n nucleotideSequences: z$1.array(\n z$1.object({\n name: z$1.string(),\n sequence: z$1.string()\n })\n ),\n genes: z$1.array(\n z$1.object({\n name: z$1.string(),\n sequence: z$1.string()\n })\n )\n });\n const orderByType = z$1.enum(["ascending", "descending"]);\n const orderBy = z$1.object({\n field: z$1.string(),\n type: orderByType\n });\n const filterValue = z$1.union([z$1.string(), z$1.number(), z$1.boolean(), z$1.null(), z$1.undefined(), z$1.array(z$1.string())]);\n const dateRange = z$1.object({\n dateFrom: z$1.string(),\n dateTo: z$1.string()\n });\n const lapisBaseRequest = z$1.object({\n limit: z$1.number().optional(),\n offset: z$1.number().optional(),\n fields: z$1.array(z$1.string()).optional(),\n orderBy: z$1.array(orderBy).optional()\n }).catchall(filterValue);\n lapisBaseRequest.extend({ minProportion: z$1.number().optional() });\n const mutationProportionCount = z$1.object({\n mutation: z$1.string(),\n proportion: z$1.number(),\n count: z$1.number(),\n sequenceName: z$1.union([z$1.string(), z$1.null()]),\n mutationFrom: z$1.string(),\n mutationTo: z$1.string(),\n position: z$1.number()\n });\n const mutationsResponse = makeLapisResponse(z$1.array(mutationProportionCount));\n z$1.object({\n filters: z$1.record(filterValue),\n downloadAsFile: z$1.boolean().optional(),\n downloadFileBasename: z$1.string().optional(),\n compression: z$1.enum(["gzip", "none"]).optional(),\n includeMutations: z$1.array(z$1.string()).optional(),\n dateRanges: z$1.array(dateRange).optional(),\n dateField: z$1.string().optional()\n });\n const mutationsOverTimeResponse = makeLapisResponse(\n z$1.object({\n mutations: z$1.array(z$1.string()),\n dateRanges: z$1.array(dateRange),\n data: z$1.array(\n z$1.array(\n z$1.object({\n count: z$1.number(),\n coverage: z$1.number()\n })\n )\n )\n })\n );\n const insertionCount = z$1.object({\n insertion: z$1.string(),\n count: z$1.number(),\n insertedSymbols: z$1.string(),\n position: z$1.number(),\n sequenceName: z$1.union([z$1.string(), z$1.null()])\n });\n makeLapisResponse(z$1.array(insertionCount));\n const baseResponseValueSchema = z$1.union([z$1.string(), z$1.number(), z$1.boolean(), z$1.null()]);\n const aggregatedItem = z$1.object({ count: z$1.number() }).catchall(baseResponseValueSchema);\n const aggregatedResponse = makeLapisResponse(z$1.array(aggregatedItem));\n const detailsItem = z$1.object({}).catchall(baseResponseValueSchema);\n makeLapisResponse(z$1.array(detailsItem));\n function makeLapisResponse(data) {\n return z$1.object({\n data\n });\n }\n const problemDetail = z$1.object({\n title: z$1.string().optional(),\n status: z$1.number(),\n detail: z$1.string().optional(),\n type: z$1.string(),\n instance: z$1.string().optional()\n });\n const lapisError = z$1.object({\n error: problemDetail\n });\n const lineage = z$1.object({\n parents: z$1.array(z$1.string()).optional(),\n aliases: z$1.array(z$1.string()).optional()\n });\n z$1.record(lineage);\n class UnknownLapisError extends Error {\n constructor(message, status, requestedData) {\n super(message);\n this.status = status;\n this.requestedData = requestedData;\n this.name = "UnknownLapisError";\n }\n }\n class LapisError extends Error {\n constructor(message, status, problemDetail2, requestedData) {\n super(message);\n this.status = status;\n this.problemDetail = problemDetail2;\n this.requestedData = requestedData;\n this.name = "LapisError";\n }\n }\n async function fetchAggregated(lapisUrl, body, signal) {\n const response = await callLapis(\n aggregatedEndpoint(lapisUrl),\n {\n method: "POST",\n headers: {\n "Content-Type": "application/json"\n },\n body: JSON.stringify(body),\n signal\n },\n "aggregated data"\n );\n return aggregatedResponse.parse(await response.json());\n }\n async function fetchSubstitutionsOrDeletions(lapisUrl, body, sequenceType, signal) {\n const response = await callLapis(\n substitutionsOrDeletionsEndpoint(lapisUrl, sequenceType),\n {\n method: "POST",\n headers: {\n "Content-Type": "application/json"\n },\n body: JSON.stringify(body),\n signal\n },\n `${sequenceType} mutations`\n );\n return mutationsResponse.parse(await response.json());\n }\n async function fetchMutationsOverTime(lapisUrl, body, sequenceType, signal) {\n const response = await callLapis(\n mutationsOverTimeEndpoint(lapisUrl, sequenceType),\n {\n method: "POST",\n headers: {\n "Content-Type": "application/json"\n },\n body: JSON.stringify(body),\n signal\n },\n `${sequenceType} mutations over time`\n );\n return mutationsOverTimeResponse.parse(await response.json());\n }\n async function callLapis(input, init, requestedDataName) {\n try {\n const response = await fetch(input, init);\n await handleErrors(response, requestedDataName);\n return response;\n } catch (error) {\n const message = error instanceof Error ? error.message : `${error}`;\n throw new UnknownLapisError(`Failed to connect to LAPIS: ${message}`, 500, requestedDataName);\n }\n }\n const handleErrors = async (response, requestedData) => {\n if (!response.ok) {\n if (response.status >= 400 && response.status < 500) {\n const json = await response.json();\n const lapisErrorResult = lapisError.safeParse(json);\n if (lapisErrorResult.success) {\n throw new LapisError(\n response.statusText + (lapisErrorResult.data.error.detail ?? ""),\n response.status,\n lapisErrorResult.data.error,\n requestedData\n );\n }\n const problemDetailResult = problemDetail.safeParse(json);\n if (problemDetailResult.success) {\n throw new LapisError(\n response.statusText + (problemDetailResult.data.detail ?? ""),\n response.status,\n problemDetailResult.data,\n requestedData\n );\n }\n throw new UnknownLapisError(\n `${response.statusText}: ${JSON.stringify(json)}`,\n response.status,\n requestedData\n );\n }\n throw new UnknownLapisError(`${response.statusText}: ${response.status}`, response.status, requestedData);\n }\n };\n const aggregatedEndpoint = (lapisUrl) => `${lapisUrl}/sample/aggregated`;\n const substitutionsOrDeletionsEndpoint = (lapisUrl, sequenceType) => {\n return sequenceType === "amino acid" ? `${lapisUrl}/sample/aminoAcidMutations` : `${lapisUrl}/sample/nucleotideMutations`;\n };\n const mutationsOverTimeEndpoint = (lapisUrl, sequenceType) => {\n return sequenceType === "amino acid" ? `${lapisUrl}/component/aminoAcidMutationsOverTime` : `${lapisUrl}/component/nucleotideMutationsOverTime`;\n };\n class FetchAggregatedOperator {\n constructor(filter, fields = []) {\n this.filter = filter;\n this.fields = fields;\n }\n async evaluate(lapisUrl, signal) {\n const aggregatedResponse2 = (await fetchAggregated(\n lapisUrl,\n {\n ...this.filter,\n fields: this.fields\n },\n signal\n )).data;\n if (isFieldsArrayWithCount(aggregatedResponse2)) {\n return {\n content: aggregatedResponse2\n };\n }\n throw new Error("Aggregated response does not have count");\n }\n }\n function isFieldsArrayWithCount(data) {\n return data.every((item) => typeof item === "object" && "count" in item && typeof item.count === "number");\n }\n class GroupByOperator {\n constructor(child, field, aggregate) {\n this.child = child;\n this.field = field;\n this.aggregate = aggregate;\n }\n async evaluate(lapis, signal) {\n const childEvaluated = await this.child.evaluate(lapis, signal);\n const grouped = /* @__PURE__ */ new Map();\n for (const row of childEvaluated.content) {\n const key = row[this.field];\n if (!grouped.has(key)) {\n grouped.set(key, []);\n }\n grouped.get(key).push(row);\n }\n const result = new Array();\n for (const [, values] of grouped) {\n result.push(this.aggregate(values));\n }\n return {\n content: result\n };\n }\n }\n class GroupByAndSumOperator extends GroupByOperator {\n constructor(child, groupByField, sumField) {\n super(child, groupByField, (values) => {\n let n = 0;\n for (const value of values) {\n n += value[sumField];\n }\n return {\n [groupByField]: values[0][groupByField],\n [sumField]: n\n };\n });\n }\n }\n class MapOperator {\n constructor(child, func) {\n this.child = child;\n this.func = func;\n }\n async evaluate(lapis, signal) {\n const childEvaluated = await this.child.evaluate(lapis, signal);\n return {\n content: childEvaluated.content.map(this.func)\n };\n }\n }\n class RenameFieldOperator extends MapOperator {\n constructor(child, oldFieldName, newFieldName) {\n super(\n child,\n (value) => ({\n ...value,\n [newFieldName]: value[oldFieldName]\n })\n );\n }\n }\n class SortOperator {\n constructor(child, compareFn) {\n this.child = child;\n this.compareFn = compareFn;\n }\n async evaluate(lapis, signal) {\n const childEvaluated = await this.child.evaluate(lapis, signal);\n return {\n content: childEvaluated.content.sort(this.compareFn)\n };\n }\n }\n var SECONDS_A_MINUTE = 60;\n var SECONDS_A_HOUR = SECONDS_A_MINUTE * 60;\n var SECONDS_A_DAY = SECONDS_A_HOUR * 24;\n var SECONDS_A_WEEK = SECONDS_A_DAY * 7;\n var MILLISECONDS_A_SECOND = 1e3;\n var MILLISECONDS_A_MINUTE = SECONDS_A_MINUTE * MILLISECONDS_A_SECOND;\n var MILLISECONDS_A_HOUR = SECONDS_A_HOUR * MILLISECONDS_A_SECOND;\n var MILLISECONDS_A_DAY = SECONDS_A_DAY * MILLISECONDS_A_SECOND;\n var MILLISECONDS_A_WEEK = SECONDS_A_WEEK * MILLISECONDS_A_SECOND;\n var MS = "millisecond";\n var S = "second";\n var MIN = "minute";\n var H = "hour";\n var D = "day";\n var W = "week";\n var M = "month";\n var Q = "quarter";\n var Y = "year";\n var DATE = "date";\n var FORMAT_DEFAULT = "YYYY-MM-DDTHH:mm:ssZ";\n var INVALID_DATE_STRING = "Invalid Date";\n var REGEX_PARSE = /^(\\d{4})[-/]?(\\d{1,2})?[-/]?(\\d{0,2})[Tt\\s]*(\\d{1,2})?:?(\\d{1,2})?:?(\\d{1,2})?[.:]?(\\d+)?$/;\n var REGEX_FORMAT = /\\[([^\\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;\n var en = {\n name: "en",\n weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),\n months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),\n ordinal: function ordinal(n) {\n var s2 = ["th", "st", "nd", "rd"];\n var v2 = n % 100;\n return "[" + n + (s2[(v2 - 20) % 10] || s2[v2] || s2[0]) + "]";\n }\n };\n var padStart = function padStart2(string, length, pad) {\n var s2 = String(string);\n if (!s2 || s2.length >= length) return string;\n return "" + Array(length + 1 - s2.length).join(pad) + string;\n };\n var padZoneStr = function padZoneStr2(instance) {\n var negMinutes = -instance.utcOffset();\n var minutes = Math.abs(negMinutes);\n var hourOffset = Math.floor(minutes / 60);\n var minuteOffset = minutes % 60;\n return (negMinutes <= 0 ? "+" : "-") + padStart(hourOffset, 2, "0") + ":" + padStart(minuteOffset, 2, "0");\n };\n var monthDiff = function monthDiff2(a2, b) {\n if (a2.date() < b.date()) return -monthDiff2(b, a2);\n var wholeMonthDiff = (b.year() - a2.year()) * 12 + (b.month() - a2.month());\n var anchor = a2.clone().add(wholeMonthDiff, M);\n var c2 = b - anchor < 0;\n var anchor2 = a2.clone().add(wholeMonthDiff + (c2 ? -1 : 1), M);\n return +(-(wholeMonthDiff + (b - anchor) / (c2 ? anchor - anchor2 : anchor2 - anchor)) || 0);\n };\n var absFloor = function absFloor2(n) {\n return n < 0 ? Math.ceil(n) || 0 : Math.floor(n);\n };\n var prettyUnit = function prettyUnit2(u2) {\n var special = {\n M,\n y: Y,\n w: W,\n d: D,\n D: DATE,\n h: H,\n m: MIN,\n s: S,\n ms: MS,\n Q\n };\n return special[u2] || String(u2 || "").toLowerCase().replace(/s$/, "");\n };\n var isUndefined = function isUndefined2(s2) {\n return s2 === void 0;\n };\n var U = {\n s: padStart,\n z: padZoneStr,\n m: monthDiff,\n a: absFloor,\n p: prettyUnit,\n u: isUndefined\n };\n var L = "en";\n var Ls = {};\n Ls[L] = en;\n var IS_DAYJS = "$isDayjsObject";\n var isDayjs = function isDayjs2(d) {\n return d instanceof Dayjs || !!(d && d[IS_DAYJS]);\n };\n var parseLocale = function parseLocale2(preset, object, isLocal) {\n var l2;\n if (!preset) return L;\n if (typeof preset === "string") {\n var presetLower = preset.toLowerCase();\n if (Ls[presetLower]) {\n l2 = presetLower;\n }\n if (object) {\n Ls[presetLower] = object;\n l2 = presetLower;\n }\n var presetSplit = preset.split("-");\n if (!l2 && presetSplit.length > 1) {\n return parseLocale2(presetSplit[0]);\n }\n } else {\n var name = preset.name;\n Ls[name] = preset;\n l2 = name;\n }\n if (!isLocal && l2) L = l2;\n return l2 || !isLocal && L;\n };\n var dayjs = function dayjs2(date, c2) {\n if (isDayjs(date)) {\n return date.clone();\n }\n var cfg = typeof c2 === "object" ? c2 : {};\n cfg.date = date;\n cfg.args = arguments;\n return new Dayjs(cfg);\n };\n var wrapper = function wrapper2(date, instance) {\n return dayjs(date, {\n locale: instance.$L,\n utc: instance.$u,\n x: instance.$x,\n $offset: instance.$offset\n // todo: refactor; do not use this.$offset in you code\n });\n };\n var Utils = U;\n Utils.l = parseLocale;\n Utils.i = isDayjs;\n Utils.w = wrapper;\n var parseDate = function parseDate2(cfg) {\n var date = cfg.date, utc = cfg.utc;\n if (date === null) return /* @__PURE__ */ new Date(NaN);\n if (Utils.u(date)) return /* @__PURE__ */ new Date();\n if (date instanceof Date) return new Date(date);\n if (typeof date === "string" && !/Z$/i.test(date)) {\n var d = date.match(REGEX_PARSE);\n if (d) {\n var m2 = d[2] - 1 || 0;\n var ms = (d[7] || "0").substring(0, 3);\n if (utc) {\n return new Date(Date.UTC(d[1], m2, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms));\n }\n return new Date(d[1], m2, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms);\n }\n }\n return new Date(date);\n };\n var Dayjs = /* @__PURE__ */ function() {\n function Dayjs2(cfg) {\n this.$L = parseLocale(cfg.locale, null, true);\n this.parse(cfg);\n this.$x = this.$x || cfg.x || {};\n this[IS_DAYJS] = true;\n }\n var _proto = Dayjs2.prototype;\n _proto.parse = function parse(cfg) {\n this.$d = parseDate(cfg);\n this.init();\n };\n _proto.init = function init() {\n var $d = this.$d;\n this.$y = $d.getFullYear();\n this.$M = $d.getMonth();\n this.$D = $d.getDate();\n this.$W = $d.getDay();\n this.$H = $d.getHours();\n this.$m = $d.getMinutes();\n this.$s = $d.getSeconds();\n this.$ms = $d.getMilliseconds();\n };\n _proto.$utils = function $utils() {\n return Utils;\n };\n _proto.isValid = function isValid2() {\n return !(this.$d.toString() === INVALID_DATE_STRING);\n };\n _proto.isSame = function isSame(that, units) {\n var other = dayjs(that);\n return this.startOf(units) <= other && other <= this.endOf(units);\n };\n _proto.isAfter = function isAfter(that, units) {\n return dayjs(that) < this.startOf(units);\n };\n _proto.isBefore = function isBefore(that, units) {\n return this.endOf(units) < dayjs(that);\n };\n _proto.$g = function $g(input, get, set) {\n if (Utils.u(input)) return this[get];\n return this.set(set, input);\n };\n _proto.unix = function unix() {\n return Math.floor(this.valueOf() / 1e3);\n };\n _proto.valueOf = function valueOf() {\n return this.$d.getTime();\n };\n _proto.startOf = function startOf(units, _startOf) {\n var _this = this;\n var isStartOf = !Utils.u(_startOf) ? _startOf : true;\n var unit = Utils.p(units);\n var instanceFactory = function instanceFactory2(d, m2) {\n var ins = Utils.w(_this.$u ? Date.UTC(_this.$y, m2, d) : new Date(_this.$y, m2, d), _this);\n return isStartOf ? ins : ins.endOf(D);\n };\n var instanceFactorySet = function instanceFactorySet2(method, slice) {\n var argumentStart = [0, 0, 0, 0];\n var argumentEnd = [23, 59, 59, 999];\n return Utils.w(_this.toDate()[method].apply(\n // eslint-disable-line prefer-spread\n _this.toDate("s"),\n (isStartOf ? argumentStart : argumentEnd).slice(slice)\n ), _this);\n };\n var $W = this.$W, $M = this.$M, $D = this.$D;\n var utcPad = "set" + (this.$u ? "UTC" : "");\n switch (unit) {\n case Y:\n return isStartOf ? instanceFactory(1, 0) : instanceFactory(31, 11);\n case M:\n return isStartOf ? instanceFactory(1, $M) : instanceFactory(0, $M + 1);\n case W: {\n var weekStart = this.$locale().weekStart || 0;\n var gap = ($W < weekStart ? $W + 7 : $W) - weekStart;\n return instanceFactory(isStartOf ? $D - gap : $D + (6 - gap), $M);\n }\n case D:\n case DATE:\n return instanceFactorySet(utcPad + "Hours", 0);\n case H:\n return instanceFactorySet(utcPad + "Minutes", 1);\n case MIN:\n return instanceFactorySet(utcPad + "Seconds", 2);\n case S:\n return instanceFactorySet(utcPad + "Milliseconds", 3);\n default:\n return this.clone();\n }\n };\n _proto.endOf = function endOf(arg) {\n return this.startOf(arg, false);\n };\n _proto.$set = function $set(units, _int) {\n var _C$D$C$DATE$C$M$C$Y$C;\n var unit = Utils.p(units);\n var utcPad = "set" + (this.$u ? "UTC" : "");\n var name = (_C$D$C$DATE$C$M$C$Y$C = {}, _C$D$C$DATE$C$M$C$Y$C[D] = utcPad + "Date", _C$D$C$DATE$C$M$C$Y$C[DATE] = utcPad + "Date", _C$D$C$DATE$C$M$C$Y$C[M] = utcPad + "Month", _C$D$C$DATE$C$M$C$Y$C[Y] = utcPad + "FullYear", _C$D$C$DATE$C$M$C$Y$C[H] = utcPad + "Hours", _C$D$C$DATE$C$M$C$Y$C[MIN] = utcPad + "Minutes", _C$D$C$DATE$C$M$C$Y$C[S] = utcPad + "Seconds", _C$D$C$DATE$C$M$C$Y$C[MS] = utcPad + "Milliseconds", _C$D$C$DATE$C$M$C$Y$C)[unit];\n var arg = unit === D ? this.$D + (_int - this.$W) : _int;\n if (unit === M || unit === Y) {\n var date = this.clone().set(DATE, 1);\n date.$d[name](arg);\n date.init();\n this.$d = date.set(DATE, Math.min(this.$D, date.daysInMonth())).$d;\n } else if (name) this.$d[name](arg);\n this.init();\n return this;\n };\n _proto.set = function set(string, _int2) {\n return this.clone().$set(string, _int2);\n };\n _proto.get = function get(unit) {\n return this[Utils.p(unit)]();\n };\n _proto.add = function add(number, units) {\n var _this2 = this, _C$MIN$C$H$C$S$unit;\n number = Number(number);\n var unit = Utils.p(units);\n var instanceFactorySet = function instanceFactorySet2(n) {\n var d = dayjs(_this2);\n return Utils.w(d.date(d.date() + Math.round(n * number)), _this2);\n };\n if (unit === M) {\n return this.set(M, this.$M + number);\n }\n if (unit === Y) {\n return this.set(Y, this.$y + number);\n }\n if (unit === D) {\n return instanceFactorySet(1);\n }\n if (unit === W) {\n return instanceFactorySet(7);\n }\n var step = (_C$MIN$C$H$C$S$unit = {}, _C$MIN$C$H$C$S$unit[MIN] = MILLISECONDS_A_MINUTE, _C$MIN$C$H$C$S$unit[H] = MILLISECONDS_A_HOUR, _C$MIN$C$H$C$S$unit[S] = MILLISECONDS_A_SECOND, _C$MIN$C$H$C$S$unit)[unit] || 1;\n var nextTimeStamp = this.$d.getTime() + number * step;\n return Utils.w(nextTimeStamp, this);\n };\n _proto.subtract = function subtract(number, string) {\n return this.add(number * -1, string);\n };\n _proto.format = function format(formatStr) {\n var _this3 = this;\n var locale = this.$locale();\n if (!this.isValid()) return locale.invalidDate || INVALID_DATE_STRING;\n var str = formatStr || FORMAT_DEFAULT;\n var zoneStr = Utils.z(this);\n var $H = this.$H, $m = this.$m, $M = this.$M;\n var weekdays = locale.weekdays, months = locale.months, meridiem = locale.meridiem;\n var getShort = function getShort2(arr, index, full, length) {\n return arr && (arr[index] || arr(_this3, str)) || full[index].slice(0, length);\n };\n var get$H = function get$H2(num) {\n return Utils.s($H % 12 || 12, num, "0");\n };\n var meridiemFunc = meridiem || function(hour, minute, isLowercase) {\n var m2 = hour < 12 ? "AM" : "PM";\n return isLowercase ? m2.toLowerCase() : m2;\n };\n var matches = function matches2(match) {\n switch (match) {\n case "YY":\n return String(_this3.$y).slice(-2);\n case "YYYY":\n return Utils.s(_this3.$y, 4, "0");\n case "M":\n return $M + 1;\n case "MM":\n return Utils.s($M + 1, 2, "0");\n case "MMM":\n return getShort(locale.monthsShort, $M, months, 3);\n case "MMMM":\n return getShort(months, $M);\n case "D":\n return _this3.$D;\n case "DD":\n return Utils.s(_this3.$D, 2, "0");\n case "d":\n return String(_this3.$W);\n case "dd":\n return getShort(locale.weekdaysMin, _this3.$W, weekdays, 2);\n case "ddd":\n return getShort(locale.weekdaysShort, _this3.$W, weekdays, 3);\n case "dddd":\n return weekdays[_this3.$W];\n case "H":\n return String($H);\n case "HH":\n return Utils.s($H, 2, "0");\n case "h":\n return get$H(1);\n case "hh":\n return get$H(2);\n case "a":\n return meridiemFunc($H, $m, true);\n case "A":\n return meridiemFunc($H, $m, false);\n case "m":\n return String($m);\n case "mm":\n return Utils.s($m, 2, "0");\n case "s":\n return String(_this3.$s);\n case "ss":\n return Utils.s(_this3.$s, 2, "0");\n case "SSS":\n return Utils.s(_this3.$ms, 3, "0");\n case "Z":\n return zoneStr;\n }\n return null;\n };\n return str.replace(REGEX_FORMAT, function(match, $1) {\n return $1 || matches(match) || zoneStr.replace(":", "");\n });\n };\n _proto.utcOffset = function utcOffset() {\n return -Math.round(this.$d.getTimezoneOffset() / 15) * 15;\n };\n _proto.diff = function diff(input, units, _float) {\n var _this4 = this;\n var unit = Utils.p(units);\n var that = dayjs(input);\n var zoneDelta = (that.utcOffset() - this.utcOffset()) * MILLISECONDS_A_MINUTE;\n var diff2 = this - that;\n var getMonth = function getMonth2() {\n return Utils.m(_this4, that);\n };\n var result;\n switch (unit) {\n case Y:\n result = getMonth() / 12;\n break;\n case M:\n result = getMonth();\n break;\n case Q:\n result = getMonth() / 3;\n break;\n case W:\n result = (diff2 - zoneDelta) / MILLISECONDS_A_WEEK;\n break;\n case D:\n result = (diff2 - zoneDelta) / MILLISECONDS_A_DAY;\n break;\n case H:\n result = diff2 / MILLISECONDS_A_HOUR;\n break;\n case MIN:\n result = diff2 / MILLISECONDS_A_MINUTE;\n break;\n case S:\n result = diff2 / MILLISECONDS_A_SECOND;\n break;\n default:\n result = diff2;\n break;\n }\n return _float ? result : Utils.a(result);\n };\n _proto.daysInMonth = function daysInMonth() {\n return this.endOf(M).$D;\n };\n _proto.$locale = function $locale() {\n return Ls[this.$L];\n };\n _proto.locale = function locale(preset, object) {\n if (!preset) return this.$L;\n var that = this.clone();\n var nextLocaleName = parseLocale(preset, object, true);\n if (nextLocaleName) that.$L = nextLocaleName;\n return that;\n };\n _proto.clone = function clone() {\n return Utils.w(this.$d, this);\n };\n _proto.toDate = function toDate() {\n return new Date(this.valueOf());\n };\n _proto.toJSON = function toJSON() {\n return this.isValid() ? this.toISOString() : null;\n };\n _proto.toISOString = function toISOString() {\n return this.$d.toISOString();\n };\n _proto.toString = function toString() {\n return this.$d.toUTCString();\n };\n return Dayjs2;\n }();\n var proto = Dayjs.prototype;\n dayjs.prototype = proto;\n [["$ms", MS], ["$s", S], ["$m", MIN], ["$H", H], ["$W", D], ["$M", M], ["$y", Y], ["$D", DATE]].forEach(function(g) {\n proto[g[1]] = function(input) {\n return this.$g(input, g[0], g[1]);\n };\n });\n dayjs.extend = function(plugin, option) {\n if (!plugin.$i) {\n plugin(option, Dayjs, dayjs);\n plugin.$i = true;\n }\n return dayjs;\n };\n dayjs.locale = parseLocale;\n dayjs.isDayjs = isDayjs;\n dayjs.unix = function(timestamp) {\n return dayjs(timestamp * 1e3);\n };\n dayjs.en = Ls[L];\n dayjs.Ls = Ls;\n dayjs.p = {};\n var advancedFormat = function(o, c2) {\n var proto2 = c2.prototype;\n var oldFormat = proto2.format;\n proto2.format = function(formatStr) {\n var _this = this;\n var locale = this.$locale();\n if (!this.isValid()) {\n return oldFormat.bind(this)(formatStr);\n }\n var utils = this.$utils();\n var str = formatStr || FORMAT_DEFAULT;\n var result = str.replace(/\\[([^\\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g, function(match) {\n switch (match) {\n case "Q":\n return Math.ceil((_this.$M + 1) / 3);\n case "Do":\n return locale.ordinal(_this.$D);\n case "gggg":\n return _this.weekYear();\n case "GGGG":\n return _this.isoWeekYear();\n case "wo":\n return locale.ordinal(_this.week(), "W");\n // W for week\n case "w":\n case "ww":\n return utils.s(_this.week(), match === "w" ? 1 : 2, "0");\n case "W":\n case "WW":\n return utils.s(_this.isoWeek(), match === "W" ? 1 : 2, "0");\n case "k":\n case "kk":\n return utils.s(String(_this.$H === 0 ? 24 : _this.$H), match === "k" ? 1 : 2, "0");\n case "X":\n return Math.floor(_this.$d.getTime() / 1e3);\n case "x":\n return _this.$d.getTime();\n case "z":\n return "[" + _this.offsetName() + "]";\n case "zzz":\n return "[" + _this.offsetName("long") + "]";\n default:\n return match;\n }\n });\n return oldFormat.bind(this)(result);\n };\n };\n var isoWeekPrettyUnit = "isoweek";\n var isoWeek = function(o, c2, d) {\n var getYearFirstThursday = function getYearFirstThursday2(year, isUtc) {\n var yearFirstDay = (isUtc ? d.utc : d)().year(year).startOf(Y);\n var addDiffDays = 4 - yearFirstDay.isoWeekday();\n if (yearFirstDay.isoWeekday() > 4) {\n addDiffDays += 7;\n }\n return yearFirstDay.add(addDiffDays, D);\n };\n var getCurrentWeekThursday = function getCurrentWeekThursday2(ins) {\n return ins.add(4 - ins.isoWeekday(), D);\n };\n var proto2 = c2.prototype;\n proto2.isoWeekYear = function() {\n var nowWeekThursday = getCurrentWeekThursday(this);\n return nowWeekThursday.year();\n };\n proto2.isoWeek = function(week) {\n if (!this.$utils().u(week)) {\n return this.add((week - this.isoWeek()) * 7, D);\n }\n var nowWeekThursday = getCurrentWeekThursday(this);\n var diffWeekThursday = getYearFirstThursday(this.isoWeekYear(), this.$u);\n return nowWeekThursday.diff(diffWeekThursday, W) + 1;\n };\n proto2.isoWeekday = function(week) {\n if (!this.$utils().u(week)) {\n return this.day(this.day() % 7 ? week : week - 7);\n }\n return this.day() || 7;\n };\n var oldStartOf = proto2.startOf;\n proto2.startOf = function(units, startOf) {\n var utils = this.$utils();\n var isStartOf = !utils.u(startOf) ? startOf : true;\n var unit = utils.p(units);\n if (unit === isoWeekPrettyUnit) {\n return isStartOf ? this.date(this.date() - (this.isoWeekday() - 1)).startOf("day") : this.date(this.date() - 1 - (this.isoWeekday() - 1) + 7).endOf("day");\n }\n return oldStartOf.bind(this)(units, startOf);\n };\n };\n dayjs.extend(isoWeek);\n dayjs.extend(advancedFormat);\n const FORMAT_ISO_WEEK_YEAR_WEEK = "GGGG-[W]WW";\n const _TemporalCache = class _TemporalCache {\n constructor() {\n this.yearMonthDayCache = /* @__PURE__ */ new Map();\n this.yearWeekCache = /* @__PURE__ */ new Map();\n this.yearMonthCache = /* @__PURE__ */ new Map();\n this.yearCache = /* @__PURE__ */ new Map();\n }\n getYearMonthDay(s2) {\n if (!this.yearMonthDayCache.has(s2)) {\n this.yearMonthDayCache.set(s2, YearMonthDayClass.parse(s2, this));\n }\n return this.yearMonthDayCache.get(s2);\n }\n getYearMonth(s2) {\n if (!this.yearMonthCache.has(s2)) {\n this.yearMonthCache.set(s2, YearMonthClass.parse(s2, this));\n }\n return this.yearMonthCache.get(s2);\n }\n getYearWeek(s2) {\n if (!this.yearWeekCache.has(s2)) {\n this.yearWeekCache.set(s2, YearWeekClass.parse(s2, this));\n }\n return this.yearWeekCache.get(s2);\n }\n getYear(s2) {\n if (!this.yearCache.has(s2)) {\n this.yearCache.set(s2, YearClass.parse(s2, this));\n }\n return this.yearCache.get(s2);\n }\n static getInstance() {\n return this.instance;\n }\n };\n _TemporalCache.instance = new _TemporalCache();\n let TemporalCache = _TemporalCache;\n class YearMonthDayClass {\n constructor(yearNumber, monthNumber, dayNumber, cache) {\n this.yearNumber = yearNumber;\n this.monthNumber = monthNumber;\n this.dayNumber = dayNumber;\n this.cache = cache;\n this.type = "YearMonthDay";\n this.date = new Date(this.yearNumber, this.monthNumber - 1, this.dayNumber);\n this.dayjs = dayjs(this.date);\n this.dateString = this.toString();\n }\n get text() {\n return this.dayjs.format("YYYY-MM-DD");\n }\n toString() {\n return this.text;\n }\n englishName() {\n return this.dayjs.format("dddd, MMMM D, YYYY");\n }\n get firstDay() {\n return this;\n }\n get lastDay() {\n return this;\n }\n get year() {\n return this.cache.getYear(`${this.yearNumber}`);\n }\n get month() {\n return this.cache.getYearMonth(this.dayjs.format("YYYY-MM"));\n }\n get week() {\n return this.cache.getYearWeek(this.dayjs.format(FORMAT_ISO_WEEK_YEAR_WEEK));\n }\n addDays(days) {\n const date = this.dayjs.add(days, "day");\n const s2 = date.format("YYYY-MM-DD");\n return this.cache.getYearMonthDay(s2);\n }\n minus(other) {\n return this.dayjs.diff(other.dayjs, "day");\n }\n static parse(s2, cache) {\n const [year, month, day] = s2.split("-").map((s22) => parseInt(s22, 10));\n return new YearMonthDayClass(year, month, day, cache);\n }\n }\n class YearWeekClass {\n constructor(isoYearNumber, isoWeekNumber, cache) {\n this.isoYearNumber = isoYearNumber;\n this.isoWeekNumber = isoWeekNumber;\n this.cache = cache;\n this.type = "YearWeek";\n this.dateString = this.toString();\n }\n get text() {\n return this.firstDay.dayjs.format(FORMAT_ISO_WEEK_YEAR_WEEK);\n }\n toString() {\n return this.text;\n }\n englishName() {\n return `Week ${this.isoWeekNumber}, ${this.isoYearNumber}`;\n }\n get firstDay() {\n const firstDay = dayjs().year(this.isoYearNumber).month(1).date(4).isoWeek(this.isoWeekNumber).startOf("isoWeek");\n return this.cache.getYearMonthDay(firstDay.format("YYYY-MM-DD"));\n }\n get lastDay() {\n const lastDay = this.firstDay.dayjs.add(6, "days");\n return this.cache.getYearMonthDay(lastDay.format("YYYY-MM-DD"));\n }\n get year() {\n return this.cache.getYear(`${this.isoYearNumber}`);\n }\n addWeeks(weeks) {\n const date = this.firstDay.dayjs.add(weeks, "week");\n const s2 = date.format(FORMAT_ISO_WEEK_YEAR_WEEK);\n return this.cache.getYearWeek(s2);\n }\n minus(other) {\n return this.firstDay.dayjs.diff(other.firstDay.dayjs, "week");\n }\n static parse(s2, cache) {\n const [year, week] = s2.split("-W").map((s22) => parseInt(s22, 10));\n return new YearWeekClass(year, week, cache);\n }\n }\n class YearMonthClass {\n constructor(yearNumber, monthNumber, cache) {\n this.yearNumber = yearNumber;\n this.monthNumber = monthNumber;\n this.cache = cache;\n this.type = "YearMonth";\n this.dateString = this.toString();\n }\n get text() {\n return this.firstDay.dayjs.format("YYYY-MM");\n }\n toString() {\n return this.text;\n }\n englishName() {\n return `${monthName(this.monthNumber)} ${this.yearNumber}`;\n }\n get firstDay() {\n return this.cache.getYearMonthDay(dayjs(`${this.yearNumber}-${this.monthNumber}-01`).format("YYYY-MM-DD"));\n }\n get lastDay() {\n return this.cache.getYearMonthDay(\n dayjs(`${this.yearNumber}-${this.monthNumber}-01`).endOf("month").format("YYYY-MM-DD")\n );\n }\n get year() {\n return this.cache.getYear(`${this.yearNumber}`);\n }\n addMonths(months) {\n const date = this.firstDay.dayjs.add(months, "month");\n const s2 = date.format("YYYY-MM");\n return this.cache.getYearMonth(s2);\n }\n minus(other) {\n return this.firstDay.dayjs.diff(other.firstDay.dayjs, "month");\n }\n static parse(s2, cache) {\n const [year, month] = s2.split("-").map((s22) => parseInt(s22, 10));\n return new YearMonthClass(year, month, cache);\n }\n }\n class YearClass {\n constructor(year, cache) {\n this.year = year;\n this.cache = cache;\n this.type = "Year";\n this.dateString = this.toString();\n }\n get text() {\n return this.firstDay.dayjs.format("YYYY");\n }\n toString() {\n return this.text;\n }\n englishName() {\n return this.year.toString();\n }\n get firstMonth() {\n return this.cache.getYearMonth(`${this.year}-01`);\n }\n get lastMonth() {\n return this.cache.getYearMonth(`${this.year}-12`);\n }\n get firstDay() {\n return this.firstMonth.firstDay;\n }\n get lastDay() {\n return this.lastMonth.lastDay;\n }\n addYears(years) {\n const date = this.firstDay.dayjs.add(years, "year");\n const s2 = date.format("YYYY");\n return this.cache.getYear(s2);\n }\n minus(other) {\n return this.firstDay.dayjs.diff(other.firstDay.dayjs, "year");\n }\n static parse(s2, cache) {\n const year = parseInt(s2, 10);\n return new YearClass(year, cache);\n }\n }\n function monthName(month) {\n return dayjs().month(month - 1).format("MMMM");\n }\n function toTemporal(temporalClass) {\n switch (temporalClass.type) {\n case "YearMonthDay":\n return {\n type: "YearMonthDay",\n yearNumber: temporalClass.yearNumber,\n monthNumber: temporalClass.monthNumber,\n dayNumber: temporalClass.dayNumber,\n dateString: temporalClass.dateString\n };\n case "YearWeek":\n return {\n type: "YearWeek",\n isoYearNumber: temporalClass.isoYearNumber,\n isoWeekNumber: temporalClass.isoWeekNumber,\n dateString: temporalClass.dateString\n };\n case "YearMonth":\n return {\n type: "YearMonth",\n yearNumber: temporalClass.yearNumber,\n monthNumber: temporalClass.monthNumber,\n dateString: temporalClass.dateString\n };\n case "Year":\n return {\n type: "Year",\n year: temporalClass.year,\n dateString: temporalClass.dateString\n };\n }\n }\n function generateAllDaysInRange(start, end) {\n const days = [];\n const daysInBetween = end.minus(start);\n for (let i2 = 0; i2 <= daysInBetween; i2++) {\n days.push(start.addDays(i2));\n }\n return days;\n }\n function generateAllWeeksInRange(start, end) {\n const weeks = [];\n const weeksInBetween = end.minus(start);\n for (let i2 = 0; i2 <= weeksInBetween; i2++) {\n weeks.push(start.addWeeks(i2));\n }\n return weeks;\n }\n function generateAllMonthsInRange(start, end) {\n const months = [];\n const monthsInBetween = end.minus(start);\n for (let i2 = 0; i2 <= monthsInBetween; i2++) {\n months.push(start.addMonths(i2));\n }\n return months;\n }\n function generateAllYearsInRange(start, end) {\n const years = [];\n const yearsInBetween = end.minus(start);\n for (let i2 = 0; i2 <= yearsInBetween; i2++) {\n years.push(start.addYears(i2));\n }\n return years;\n }\n function generateAllInRange(start, end) {\n if (start === null || end === null) {\n return [];\n }\n if (start instanceof YearMonthDayClass && end instanceof YearMonthDayClass) {\n return generateAllDaysInRange(start, end);\n }\n if (start instanceof YearWeekClass && end instanceof YearWeekClass) {\n return generateAllWeeksInRange(start, end);\n }\n if (start instanceof YearMonthClass && end instanceof YearMonthClass) {\n return generateAllMonthsInRange(start, end);\n }\n if (start instanceof YearClass && end instanceof YearClass) {\n return generateAllYearsInRange(start, end);\n }\n throw new Error(`Invalid arguments: start and end must be of the same type: ${start}, ${end}`);\n }\n function minusTemporal(a2, b) {\n if (a2 instanceof YearMonthDayClass && b instanceof YearMonthDayClass) {\n return a2.minus(b);\n }\n if (a2 instanceof YearWeekClass && b instanceof YearWeekClass) {\n return a2.minus(b);\n }\n if (a2 instanceof YearMonthClass && b instanceof YearMonthClass) {\n return a2.minus(b);\n }\n if (a2 instanceof YearClass && b instanceof YearClass) {\n return a2.minus(b);\n }\n throw new Error(`Cannot compare ${a2} and ${b}`);\n }\n function compareTemporal(a2, b) {\n if (a2 === null) {\n return 1;\n }\n if (b === null) {\n return -1;\n }\n const diff = minusTemporal(a2, b);\n if (diff < 0) {\n return -1;\n }\n if (diff > 0) {\n return 1;\n }\n return 0;\n }\n function getMinMaxTemporal(values) {\n let min = null;\n let max = null;\n for (const value of values) {\n if (value === null) {\n continue;\n }\n if (min === null || compareTemporal(value, min) < 0) {\n min = value;\n }\n if (max === null || compareTemporal(value, max) > 0) {\n max = value;\n }\n }\n if (min === null || max === null) {\n return { min: null, max: null };\n }\n return { min, max };\n }\n function parseDateStringToTemporal(date, granularity) {\n const cache = TemporalCache.getInstance();\n const day = cache.getYearMonthDay(date);\n switch (granularity) {\n case "day":\n return day;\n case "week":\n return day.week;\n case "month":\n return day.month;\n case "year":\n return day.year;\n }\n }\n function dateRangeCompare(a2, b) {\n if (a2.dateRange === null) {\n return 1;\n }\n if (b.dateRange === null) {\n return -1;\n }\n return compareTemporal(a2.dateRange, b.dateRange);\n }\n function mapDateToGranularityRange(data, granularity) {\n return {\n dateRange: data.date === null ? null : parseDateStringToTemporal(data.date, granularity),\n count: data.count\n };\n }\n const substitutionRegex = /^((?<segment>[A-Z0-9_-]+)(?=:):)?(?<valueAtReference>[A-Z])?(?<position>\\d+)(?<substitutionValue>[A-Z.*])?$/i;\n class SubstitutionClass {\n constructor(segment, valueAtReference, substitutionValue, position) {\n this.segment = segment;\n this.valueAtReference = valueAtReference;\n this.substitutionValue = substitutionValue;\n this.position = position;\n this.type = "substitution";\n const segmentString = this.segment ? `${this.segment}:` : "";\n const valueAtReferenceString = this.valueAtReference ?? "";\n const substitutionValueString = this.substitutionValue ?? "";\n this.code = `${segmentString}${valueAtReferenceString}${this.position}${substitutionValueString}`;\n }\n equals(other) {\n if (!(other instanceof SubstitutionClass)) {\n return false;\n }\n return this.segment === other.segment && this.valueAtReference === other.valueAtReference && this.substitutionValue === other.substitutionValue && this.position === other.position;\n }\n toString() {\n return this.code;\n }\n static parse(mutationStr) {\n const match = substitutionRegex.exec(mutationStr);\n if ((match == null ? void 0 : match.groups) === void 0) {\n return null;\n }\n return new SubstitutionClass(\n match.groups.segment,\n match.groups.valueAtReference,\n match.groups.substitutionValue,\n parseInt(match.groups.position, 10)\n );\n }\n }\n const deletionRegex = /^((?<segment>[A-Z0-9_-]+)(?=:):)?(?<valueAtReference>[A-Z])?(?<position>\\d+)(-)$/i;\n class DeletionClass {\n constructor(segment, valueAtReference, position) {\n this.segment = segment;\n this.valueAtReference = valueAtReference;\n this.position = position;\n this.type = "deletion";\n const segmentString = this.segment ? `${this.segment}:` : "";\n const valueAtReferenceString = this.valueAtReference ?? "";\n this.code = `${segmentString}${valueAtReferenceString}${this.position}-`;\n }\n equals(other) {\n if (!(other instanceof DeletionClass)) {\n return false;\n }\n return this.segment === other.segment && this.valueAtReference === other.valueAtReference && this.position === other.position;\n }\n toString() {\n return this.code;\n }\n static parse(mutationStr) {\n const match = deletionRegex.exec(mutationStr);\n if ((match == null ? void 0 : match.groups) === void 0) {\n return null;\n }\n return new DeletionClass(\n match.groups.segment,\n match.groups.valueAtReference,\n parseInt(match.groups.position, 10)\n );\n }\n }\n function toSubstitutionOrDeletion(mutation) {\n switch (mutation.type) {\n case "substitution":\n return {\n type: "substitution",\n code: mutation.code,\n segment: mutation.segment,\n position: mutation.position,\n valueAtReference: mutation.valueAtReference,\n substitutionValue: mutation.substitutionValue\n };\n case "deletion":\n return {\n type: "deletion",\n code: mutation.code,\n segment: mutation.segment,\n position: mutation.position,\n valueAtReference: mutation.valueAtReference\n };\n }\n }\n class FetchSubstitutionsOrDeletionsOperator {\n constructor(filter, sequenceType, minProportion) {\n this.filter = filter;\n this.sequenceType = sequenceType;\n this.minProportion = minProportion;\n }\n async evaluate(lapis, signal) {\n const mutations = await this.fetchMutations(lapis, signal);\n const content = mutations.map(\n ({ count, proportion, mutationFrom, mutationTo, position, sequenceName }) => {\n if (mutationTo === "-") {\n return {\n type: "deletion",\n mutation: new DeletionClass(sequenceName ?? void 0, mutationFrom, position),\n count,\n proportion\n };\n }\n return {\n type: "substitution",\n mutation: new SubstitutionClass(sequenceName ?? void 0, mutationFrom, mutationTo, position),\n count,\n proportion\n };\n }\n );\n return { content };\n }\n async fetchMutations(lapis, signal) {\n const filter = {\n ...this.filter,\n minProportion: this.minProportion\n };\n return fetchSubstitutionsOrDeletions(lapis, filter, this.sequenceType, signal).then(\n (response) => response.data\n );\n }\n }\n var l$1;\n l$1 = { __e: function(n, l2, u2, t) {\n for (var i2, r2, o; l2 = l2.__; ) if ((i2 = l2.__c) && !i2.__) try {\n if ((r2 = i2.constructor) && null != r2.getDerivedStateFromError && (i2.setState(r2.getDerivedStateFromError(n)), o = i2.__d), null != i2.componentDidCatch && (i2.componentDidCatch(n, t || {}), o = i2.__d), o) return i2.__E = i2;\n } catch (l3) {\n n = l3;\n }\n throw n;\n } }, "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout;\n var r, u, i, f = [], c = l$1, e = c.__b, a = c.__r, v = c.diffed, l = c.__c, m = c.unmount, s = c.__;\n function j() {\n for (var n; n = f.shift(); ) if (n.__P && n.__H) try {\n n.__H.__h.forEach(z), n.__H.__h.forEach(B), n.__H.__h = [];\n } catch (t) {\n n.__H.__h = [], c.__e(t, n.__v);\n }\n }\n c.__b = function(n) {\n r = null, e && e(n);\n }, c.__ = function(n, t) {\n n && t.__k && t.__k.__m && (n.__m = t.__k.__m), s && s(n, t);\n }, c.__r = function(n) {\n a && a(n);\n var i2 = (r = n.__c).__H;\n i2 && (u === r ? (i2.__h = [], r.__h = [], i2.__.forEach(function(n2) {\n n2.__N && (n2.__ = n2.__N), n2.u = n2.__N = void 0;\n })) : (i2.__h.forEach(z), i2.__h.forEach(B), i2.__h = [], 0)), u = r;\n }, c.diffed = function(n) {\n v && v(n);\n var t = n.__c;\n t && t.__H && (t.__H.__h.length && (1 !== f.push(t) && i === c.requestAnimationFrame || ((i = c.requestAnimationFrame) || w)(j)), t.__H.__.forEach(function(n2) {\n n2.u && (n2.__H = n2.u), n2.u = void 0;\n })), u = r = null;\n }, c.__c = function(n, t) {\n t.some(function(n2) {\n try {\n n2.__h.forEach(z), n2.__h = n2.__h.filter(function(n3) {\n return !n3.__ || B(n3);\n });\n } catch (r2) {\n t.some(function(n3) {\n n3.__h && (n3.__h = []);\n }), t = [], c.__e(r2, n2.__v);\n }\n }), l && l(n, t);\n }, c.unmount = function(n) {\n m && m(n);\n var t, r2 = n.__c;\n r2 && r2.__H && (r2.__H.__.forEach(function(n2) {\n try {\n z(n2);\n } catch (n3) {\n t = n3;\n }\n }), r2.__H = void 0, t && c.__e(t, r2.__v));\n };\n var k = "function" == typeof requestAnimationFrame;\n function w(n) {\n var t, r2 = function() {\n clearTimeout(u2), k && cancelAnimationFrame(t), setTimeout(n);\n }, u2 = setTimeout(r2, 35);\n k && (t = requestAnimationFrame(r2));\n }\n function z(n) {\n var t = r, u2 = n.__c;\n "function" == typeof u2 && (n.__c = void 0, u2()), r = t;\n }\n function B(n) {\n var t = r;\n n.__c = n.__(), r = t;\n }\n class UserFacingError extends Error {\n constructor(headline, message) {\n super(message);\n this.headline = headline;\n this.name = "UserFacingError";\n }\n }\n class Map2dBase {\n constructor(serializeFirstAxis, serializeSecondAxis, initialContent) {\n this.serializeFirstAxis = serializeFirstAxis;\n this.serializeSecondAxis = serializeSecondAxis;\n this.data = /* @__PURE__ */ new Map();\n this.keysFirstAxis = /* @__PURE__ */ new Map();\n this.keysSecondAxis = /* @__PURE__ */ new Map();\n if (initialContent) {\n this.keysFirstAxis = new Map(initialContent.keysFirstAxis);\n this.keysSecondAxis = new Map(initialContent.keysSecondAxis);\n this.data = new Map(initialContent.data);\n }\n }\n get(keyFirstAxis, keySecondAxis) {\n var _a;\n const serializedKeyFirstAxis = this.serializeFirstAxis(keyFirstAxis);\n const serializedKeySecondAxis = this.serializeSecondAxis(keySecondAxis);\n return (_a = this.data.get(serializedKeyFirstAxis)) == null ? void 0 : _a.get(serializedKeySecondAxis);\n }\n getRow(key) {\n const serializedKeyFirstAxis = this.serializeFirstAxis(key);\n const row = this.data.get(serializedKeyFirstAxis);\n if (row === void 0) {\n return [];\n }\n return Array.from(this.keysSecondAxis.keys()).map((key2) => row.get(key2));\n }\n set(keyFirstAxis, keySecondAxis, value) {\n const serializedKeyFirstAxis = this.serializeFirstAxis(keyFirstAxis);\n const serializedKeySecondAxis = this.serializeSecondAxis(keySecondAxis);\n if (!this.data.has(serializedKeyFirstAxis)) {\n this.data.set(serializedKeyFirstAxis, /* @__PURE__ */ new Map());\n }\n this.data.get(serializedKeyFirstAxis).set(serializedKeySecondAxis, value);\n this.keysFirstAxis.set(serializedKeyFirstAxis, keyFirstAxis);\n this.keysSecondAxis.set(serializedKeySecondAxis, keySecondAxis);\n }\n deleteRow(key) {\n const serializedKeyFirstAxis = this.serializeFirstAxis(key);\n this.data.delete(serializedKeyFirstAxis);\n this.keysFirstAxis.delete(serializedKeyFirstAxis);\n }\n getFirstAxisKeys() {\n return Array.from(this.keysFirstAxis.values());\n }\n getSecondAxisKeys() {\n return Array.from(this.keysSecondAxis.values());\n }\n getAsArray() {\n return this.getFirstAxisKeys().map((firstAxisKey) => {\n return this.getSecondAxisKeys().map((secondAxisKey) => {\n return this.get(firstAxisKey, secondAxisKey);\n });\n });\n }\n getContents() {\n return {\n keysFirstAxis: this.keysFirstAxis,\n keysSecondAxis: this.keysSecondAxis,\n data: this.data\n };\n }\n }\n class BaseMutationOverTimeDataMap extends Map2dBase {\n constructor(initialContent) {\n super(serializeSubstitutionOrDeletion, serializeTemporal, initialContent);\n }\n }\n const sortSubstitutionsAndDeletions = (a2, b) => {\n if (a2.segment !== b.segment) {\n return compareSegments(a2.segment, b.segment);\n }\n if (a2.position !== b.position) {\n return comparePositions(a2.position, b.position);\n }\n const aIsDeletion = a2.type === "deletion";\n const bIsDeletion = b.type === "deletion";\n if (aIsDeletion !== bIsDeletion) {\n return aIsDeletion ? 1 : -1;\n }\n if (!aIsDeletion && !bIsDeletion) {\n if (a2.substitutionValue !== b.substitutionValue) {\n return compareSubstitutionValues(a2.substitutionValue, b.substitutionValue);\n }\n }\n return 0;\n };\n const compareSegments = (a2, b) => {\n if (a2 === void 0) {\n return -1;\n }\n if (b === void 0) {\n return 1;\n }\n return a2.localeCompare(b);\n };\n const comparePositions = (a2, b) => {\n return a2 - b;\n };\n const compareSubstitutionValues = (a2, b) => {\n if (a2 === void 0) {\n return -1;\n }\n if (b === void 0) {\n return 1;\n }\n return a2.localeCompare(b);\n };\n const MAX_NUMBER_OF_GRID_COLUMNS = 200;\n const MUTATIONS_OVER_TIME_MIN_PROPORTION = 1e-3;\n function codeToEmptyEntry(code) {\n const maybeDeletion = DeletionClass.parse(code);\n if (maybeDeletion) {\n return {\n type: "deletion",\n mutation: maybeDeletion,\n count: 0,\n proportion: 0\n };\n }\n const maybeSubstitution = SubstitutionClass.parse(code);\n if (maybeSubstitution) {\n return {\n type: "substitution",\n mutation: maybeSubstitution,\n count: 0,\n proportion: 0\n };\n }\n return null;\n }\n async function queryOverallMutationData({\n lapisFilter,\n sequenceType,\n lapis,\n granularity,\n lapisDateField,\n includeMutations,\n signal\n }) {\n const requestedDateRanges = await getDatesInDataset(lapisFilter, lapis, granularity, lapisDateField, signal);\n if (requestedDateRanges.length === 0) {\n if (includeMutations) {\n return {\n content: includeMutations.map(codeToEmptyEntry).filter((e2) => e2 !== null)\n };\n } else {\n return {\n content: []\n };\n }\n }\n const filter = {\n ...lapisFilter,\n [`${lapisDateField}From`]: requestedDateRanges[0].firstDay.toString(),\n [`${lapisDateField}To`]: requestedDateRanges[requestedDateRanges.length - 1].lastDay.toString()\n };\n let dataPromise = fetchAndPrepareSubstitutionsOrDeletions(filter, sequenceType).evaluate(lapis, signal);\n if (includeMutations) {\n dataPromise = dataPromise.then((data) => {\n return {\n content: includeMutations.map((code) => {\n const found = data.content.find((m2) => m2.mutation.code === code);\n return found ?? codeToEmptyEntry(code);\n }).filter((e2) => e2 !== null)\n };\n });\n }\n return dataPromise;\n }\n async function queryMutationsOverTimeData(query) {\n const { lapisFilter, displayMutations, sequenceType, lapis, lapisDateField, granularity, useNewEndpoint, signal } = query;\n const requestedDateRanges = await getDatesInDataset(lapisFilter, lapis, granularity, lapisDateField, signal);\n if (requestedDateRanges.length > MAX_NUMBER_OF_GRID_COLUMNS) {\n throw new UserFacingError(\n "Too many dates",\n `The dataset would contain ${requestedDateRanges.length} date intervals. Please reduce the number to below ${MAX_NUMBER_OF_GRID_COLUMNS} to display the data. You can achieve this by either narrowing the date range in the provided LAPIS filter or by selecting a larger granularity.`\n );\n }\n const overallMutationData = queryOverallMutationData({\n lapisFilter,\n sequenceType,\n lapis,\n lapisDateField,\n includeMutations: displayMutations,\n granularity\n }).then((r2) => r2.content);\n return useNewEndpoint === true ? queryMutationsOverTimeDataDirectEndpoint(requestedDateRanges, overallMutationData, query) : queryMutationsOverTimeDataMultiQuery(requestedDateRanges, overallMutationData, query);\n }\n async function queryMutationsOverTimeDataMultiQuery(allDates, overallMutationDataPromise, { lapisFilter, sequenceType, lapis, lapisDateField, signal }) {\n const subQueries = allDates.map(async (date) => {\n const dateFrom = date.firstDay.toString();\n const dateTo = date.lastDay.toString();\n const filter = {\n ...lapisFilter,\n [`${lapisDateField}From`]: dateFrom,\n [`${lapisDateField}To`]: dateTo\n };\n const [data2, totalCountQuery] = await Promise.all([\n fetchAndPrepareSubstitutionsOrDeletions(filter, sequenceType).evaluate(lapis, signal),\n getTotalNumberOfSequencesInDateRange(filter).evaluate(lapis, signal)\n ]);\n return {\n date,\n mutations: data2.content,\n totalCount: totalCountQuery.content[0].count\n };\n });\n const data = await Promise.all(subQueries);\n const overallMutationData = await overallMutationDataPromise;\n return {\n mutationOverTimeData: groupByMutation(data, overallMutationData),\n overallMutationData\n };\n }\n async function queryMutationsOverTimeDataDirectEndpoint(allDates, overallMutationDataPromise, { lapisFilter, sequenceType, lapis, lapisDateField, signal }) {\n const overallMutationData = await overallMutationDataPromise;\n overallMutationData.sort((a2, b) => sortSubstitutionsAndDeletions(a2.mutation, b.mutation));\n const totalCounts = await Promise.all(\n allDates.map(async (date) => {\n const filter = {\n ...lapisFilter,\n [`${lapisDateField}From`]: date.firstDay.toString(),\n [`${lapisDateField}To`]: date.lastDay.toString()\n };\n const totalCountQuery = await getTotalNumberOfSequencesInDateRange(filter).evaluate(lapis, signal);\n return totalCountQuery.content[0].count;\n })\n );\n const includeMutations = overallMutationData.map((value) => value.mutation.code);\n const apiResult = await fetchMutationsOverTime(\n lapis,\n {\n filters: lapisFilter,\n dateRanges: allDates.map((date) => ({\n dateFrom: date.firstDay.toString(),\n dateTo: date.lastDay.toString()\n })),\n includeMutations,\n dateField: lapisDateField\n },\n sequenceType,\n signal\n );\n const responseMutations = apiResult.data.mutations.map(parseMutationCode);\n const mutationEntries = responseMutations.map((mutation, i2) => {\n const numbers = {\n count: overallMutationData[i2].count,\n proportion: overallMutationData[i2].proportion\n };\n if (mutation.type === "deletion") {\n return {\n type: "deletion",\n mutation,\n ...numbers\n };\n } else {\n return {\n type: "substitution",\n mutation,\n ...numbers\n };\n }\n });\n const mutationOverTimeData = {\n keysFirstAxis: new Map(responseMutations.map((mutation) => [mutation.code, mutation])),\n keysSecondAxis: new Map(allDates.map((date) => [date.dateString, date])),\n data: new Map(\n responseMutations.map((mutation, i2) => [\n mutation.code,\n new Map(\n allDates.map((date, j2) => [\n date.dateString,\n {\n type: "value",\n // \'coverage\' in the API resp. is the number of seqs. that have a non-ambiguous symbol at position\n // \'count\' in the API resp. is the number of seqs with the mutation\n proportion: apiResult.data.data[i2][j2].count / apiResult.data.data[i2][j2].coverage,\n count: apiResult.data.data[i2][j2].count,\n totalCount: totalCounts[j2]\n }\n ])\n )\n ])\n )\n };\n return {\n mutationOverTimeData: new BaseMutationOverTimeDataMap(mutationOverTimeData),\n overallMutationData: mutationEntries\n };\n }\n function parseMutationCode(code) {\n const maybeDeletion = DeletionClass.parse(code);\n if (maybeDeletion) {\n return maybeDeletion;\n }\n const maybeSubstitution = SubstitutionClass.parse(code);\n if (maybeSubstitution) {\n return maybeSubstitution;\n }\n throw Error("Given code is not valid");\n }\n async function getDatesInDataset(lapisFilter, lapis, granularity, lapisDateField, signal) {\n const { dateFrom, dateTo } = getDateRangeFromFilter(lapisFilter, lapisDateField, granularity);\n if (dateFrom !== null && dateTo !== null) {\n return generateAllInRange(dateFrom, dateTo);\n }\n const { content: availableDates } = await queryAvailableDates(\n lapisFilter,\n lapis,\n granularity,\n lapisDateField,\n signal\n );\n const { min, max } = getMinMaxTemporal(availableDates);\n return generateAllInRange(dateFrom ?? min, dateTo ?? max);\n }\n function getDateRangeFromFilter(lapisFilter, lapisDateField, granularity) {\n const valueFromFilter = lapisFilter[lapisDateField];\n if (valueFromFilter) {\n return {\n dateFrom: parseDateStringToTemporal(valueFromFilter, granularity),\n dateTo: parseDateStringToTemporal(valueFromFilter, granularity)\n };\n }\n const minFromFilter = lapisFilter[`${lapisDateField}From`];\n const maxFromFilter = lapisFilter[`${lapisDateField}To`];\n return {\n dateFrom: minFromFilter ? parseDateStringToTemporal(minFromFilter, granularity) : null,\n dateTo: maxFromFilter ? parseDateStringToTemporal(maxFromFilter, granularity) : null\n };\n }\n function queryAvailableDates(lapisFilter, lapis, granularity, lapisDateField, signal) {\n return fetchAndPrepareDates(lapisFilter, granularity, lapisDateField).evaluate(lapis, signal);\n }\n function fetchAndPrepareDates(filter, granularity, lapisDateField) {\n const fetchData = new FetchAggregatedOperator(filter, [lapisDateField]);\n const dataWithFixedDateKey = new RenameFieldOperator(fetchData, lapisDateField, "date");\n const mapData = new MapOperator(dataWithFixedDateKey, (data) => mapDateToGranularityRange(data, granularity));\n const groupByData = new GroupByAndSumOperator(mapData, "dateRange", "count");\n const sortData = new SortOperator(groupByData, dateRangeCompare);\n return new MapOperator(sortData, (data) => data.dateRange);\n }\n function fetchAndPrepareSubstitutionsOrDeletions(filter, sequenceType) {\n return new FetchSubstitutionsOrDeletionsOperator(filter, sequenceType, MUTATIONS_OVER_TIME_MIN_PROPORTION);\n }\n function serializeSubstitutionOrDeletion(mutation) {\n return mutation.code;\n }\n function serializeTemporal(date) {\n return date.dateString;\n }\n function groupByMutation(data, overallMutationData) {\n const dataArray = new BaseMutationOverTimeDataMap();\n const allDates = data.map((mutationData) => mutationData.date);\n const sortedOverallMutationData = overallMutationData.sort((a2, b) => sortSubstitutionsAndDeletions(a2.mutation, b.mutation)).map((entry) => {\n return toSubstitutionOrDeletion(entry.mutation);\n });\n const sortedDates = allDates.sort((a2, b) => compareTemporal(a2, b)).map((date) => toTemporal(date));\n sortedOverallMutationData.forEach((mutationData) => {\n sortedDates.forEach((date) => {\n dataArray.set(mutationData, date, null);\n });\n });\n data.forEach((mutationData) => {\n if (mutationData.totalCount == 0) {\n return;\n }\n const date = toTemporal(mutationData.date);\n mutationData.mutations.forEach((mutationEntry) => {\n const mutation = toSubstitutionOrDeletion(mutationEntry.mutation);\n if (dataArray.get(mutation, date) !== void 0) {\n dataArray.set(mutation, date, {\n type: "value",\n count: mutationEntry.count,\n proportion: mutationEntry.proportion,\n totalCount: mutationData.totalCount\n });\n }\n });\n for (const firstAxisKey of dataArray.getFirstAxisKeys()) {\n if (dataArray.get(firstAxisKey, date) === null) {\n dataArray.set(firstAxisKey, date, {\n type: "belowThreshold",\n totalCount: mutationData.totalCount\n });\n }\n }\n });\n return dataArray;\n }\n function getTotalNumberOfSequencesInDateRange(filter) {\n return new FetchAggregatedOperator(filter);\n }\n async function workerFunction(queryFunction) {\n try {\n postMessage({ status: "loading" });\n const workerResponse = await queryFunction();\n postMessage({\n status: "success",\n data: workerResponse\n });\n } catch (error) {\n postMessage(\n error instanceof UserFacingError ? {\n status: "error",\n userFacing: true,\n headline: error.headline,\n error\n } : {\n status: "error",\n userFacing: false,\n error: error instanceof Error ? error : new Error(`${error}`)\n }\n );\n }\n }\n async function getMutationOverTimeWorkerFunction(event) {\n const mutationOverTimeData = await queryMutationsOverTimeData(event.data);\n const workerResponse = {\n overallMutationData: mutationOverTimeData.overallMutationData,\n mutationOverTimeSerialized: mutationOverTimeData.mutationOverTimeData.getContents()\n };\n return workerResponse;\n }\n self.onmessage = async function(event) {\n await workerFunction(() => getMutationOverTimeWorkerFunction(event));\n };\n})();\n//# sourceMappingURL=mutationOverTimeWorker-BJ_P2T8Y.js.map\n';
7080
+ const jsContent = '(function() {\n "use strict";\n var util;\n (function(util2) {\n util2.assertEqual = (_) => {\n };\n function assertIs(_arg) {\n }\n util2.assertIs = assertIs;\n function assertNever(_x) {\n throw new Error();\n }\n util2.assertNever = assertNever;\n util2.arrayToEnum = (items) => {\n const obj = {};\n for (const item of items) {\n obj[item] = item;\n }\n return obj;\n };\n util2.getValidEnumValues = (obj) => {\n const validKeys = util2.objectKeys(obj).filter((k2) => typeof obj[obj[k2]] !== "number");\n const filtered = {};\n for (const k2 of validKeys) {\n filtered[k2] = obj[k2];\n }\n return util2.objectValues(filtered);\n };\n util2.objectValues = (obj) => {\n return util2.objectKeys(obj).map(function(e2) {\n return obj[e2];\n });\n };\n util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {\n const keys = [];\n for (const key in object) {\n if (Object.prototype.hasOwnProperty.call(object, key)) {\n keys.push(key);\n }\n }\n return keys;\n };\n util2.find = (arr, checker) => {\n for (const item of arr) {\n if (checker(item))\n return item;\n }\n return void 0;\n };\n util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;\n function joinValues(array, separator = " | ") {\n return array.map((val) => typeof val === "string" ? `\'${val}\'` : val).join(separator);\n }\n util2.joinValues = joinValues;\n util2.jsonStringifyReplacer = (_, value) => {\n if (typeof value === "bigint") {\n return value.toString();\n }\n return value;\n };\n })(util || (util = {}));\n var objectUtil;\n (function(objectUtil2) {\n objectUtil2.mergeShapes = (first, second) => {\n return {\n ...first,\n ...second\n // second overwrites first\n };\n };\n })(objectUtil || (objectUtil = {}));\n const ZodParsedType = util.arrayToEnum([\n "string",\n "nan",\n "number",\n "integer",\n "float",\n "boolean",\n "date",\n "bigint",\n "symbol",\n "function",\n "undefined",\n "null",\n "array",\n "object",\n "unknown",\n "promise",\n "void",\n "never",\n "map",\n "set"\n ]);\n const getParsedType = (data) => {\n const t = typeof data;\n switch (t) {\n case "undefined":\n return ZodParsedType.undefined;\n case "string":\n return ZodParsedType.string;\n case "number":\n return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;\n case "boolean":\n return ZodParsedType.boolean;\n case "function":\n return ZodParsedType.function;\n case "bigint":\n return ZodParsedType.bigint;\n case "symbol":\n return ZodParsedType.symbol;\n case "object":\n if (Array.isArray(data)) {\n return ZodParsedType.array;\n }\n if (data === null) {\n return ZodParsedType.null;\n }\n if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {\n return ZodParsedType.promise;\n }\n if (typeof Map !== "undefined" && data instanceof Map) {\n return ZodParsedType.map;\n }\n if (typeof Set !== "undefined" && data instanceof Set) {\n return ZodParsedType.set;\n }\n if (typeof Date !== "undefined" && data instanceof Date) {\n return ZodParsedType.date;\n }\n return ZodParsedType.object;\n default:\n return ZodParsedType.unknown;\n }\n };\n const ZodIssueCode = util.arrayToEnum([\n "invalid_type",\n "invalid_literal",\n "custom",\n "invalid_union",\n "invalid_union_discriminator",\n "invalid_enum_value",\n "unrecognized_keys",\n "invalid_arguments",\n "invalid_return_type",\n "invalid_date",\n "invalid_string",\n "too_small",\n "too_big",\n "invalid_intersection_types",\n "not_multiple_of",\n "not_finite"\n ]);\n const quotelessJson = (obj) => {\n const json = JSON.stringify(obj, null, 2);\n return json.replace(/"([^"]+)":/g, "$1:");\n };\n class ZodError extends Error {\n get errors() {\n return this.issues;\n }\n constructor(issues) {\n super();\n this.issues = [];\n this.addIssue = (sub) => {\n this.issues = [...this.issues, sub];\n };\n this.addIssues = (subs = []) => {\n this.issues = [...this.issues, ...subs];\n };\n const actualProto = new.target.prototype;\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(this, actualProto);\n } else {\n this.__proto__ = actualProto;\n }\n this.name = "ZodError";\n this.issues = issues;\n }\n format(_mapper) {\n const mapper = _mapper || function(issue) {\n return issue.message;\n };\n const fieldErrors = { _errors: [] };\n const processError = (error) => {\n for (const issue of error.issues) {\n if (issue.code === "invalid_union") {\n issue.unionErrors.map(processError);\n } else if (issue.code === "invalid_return_type") {\n processError(issue.returnTypeError);\n } else if (issue.code === "invalid_arguments") {\n processError(issue.argumentsError);\n } else if (issue.path.length === 0) {\n fieldErrors._errors.push(mapper(issue));\n } else {\n let curr = fieldErrors;\n let i2 = 0;\n while (i2 < issue.path.length) {\n const el = issue.path[i2];\n const terminal = i2 === issue.path.length - 1;\n if (!terminal) {\n curr[el] = curr[el] || { _errors: [] };\n } else {\n curr[el] = curr[el] || { _errors: [] };\n curr[el]._errors.push(mapper(issue));\n }\n curr = curr[el];\n i2++;\n }\n }\n }\n };\n processError(this);\n return fieldErrors;\n }\n static assert(value) {\n if (!(value instanceof ZodError)) {\n throw new Error(`Not a ZodError: ${value}`);\n }\n }\n toString() {\n return this.message;\n }\n get message() {\n return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);\n }\n get isEmpty() {\n return this.issues.length === 0;\n }\n flatten(mapper = (issue) => issue.message) {\n const fieldErrors = {};\n const formErrors = [];\n for (const sub of this.issues) {\n if (sub.path.length > 0) {\n const firstEl = sub.path[0];\n fieldErrors[firstEl] = fieldErrors[firstEl] || [];\n fieldErrors[firstEl].push(mapper(sub));\n } else {\n formErrors.push(mapper(sub));\n }\n }\n return { formErrors, fieldErrors };\n }\n get formErrors() {\n return this.flatten();\n }\n }\n ZodError.create = (issues) => {\n const error = new ZodError(issues);\n return error;\n };\n const errorMap = (issue, _ctx) => {\n let message;\n switch (issue.code) {\n case ZodIssueCode.invalid_type:\n if (issue.received === ZodParsedType.undefined) {\n message = "Required";\n } else {\n message = `Expected ${issue.expected}, received ${issue.received}`;\n }\n break;\n case ZodIssueCode.invalid_literal:\n message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;\n break;\n case ZodIssueCode.unrecognized_keys:\n message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;\n break;\n case ZodIssueCode.invalid_union:\n message = `Invalid input`;\n break;\n case ZodIssueCode.invalid_union_discriminator:\n message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;\n break;\n case ZodIssueCode.invalid_enum_value:\n message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received \'${issue.received}\'`;\n break;\n case ZodIssueCode.invalid_arguments:\n message = `Invalid function arguments`;\n break;\n case ZodIssueCode.invalid_return_type:\n message = `Invalid function return type`;\n break;\n case ZodIssueCode.invalid_date:\n message = `Invalid date`;\n break;\n case ZodIssueCode.invalid_string:\n if (typeof issue.validation === "object") {\n if ("includes" in issue.validation) {\n message = `Invalid input: must include "${issue.validation.includes}"`;\n if (typeof issue.validation.position === "number") {\n message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;\n }\n } else if ("startsWith" in issue.validation) {\n message = `Invalid input: must start with "${issue.validation.startsWith}"`;\n } else if ("endsWith" in issue.validation) {\n message = `Invalid input: must end with "${issue.validation.endsWith}"`;\n } else {\n util.assertNever(issue.validation);\n }\n } else if (issue.validation !== "regex") {\n message = `Invalid ${issue.validation}`;\n } else {\n message = "Invalid";\n }\n break;\n case ZodIssueCode.too_small:\n if (issue.type === "array")\n message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;\n else if (issue.type === "string")\n message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;\n else if (issue.type === "number")\n message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;\n else if (issue.type === "bigint")\n message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;\n else if (issue.type === "date")\n message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;\n else\n message = "Invalid input";\n break;\n case ZodIssueCode.too_big:\n if (issue.type === "array")\n message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;\n else if (issue.type === "string")\n message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;\n else if (issue.type === "number")\n message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;\n else if (issue.type === "bigint")\n message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;\n else if (issue.type === "date")\n message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;\n else\n message = "Invalid input";\n break;\n case ZodIssueCode.custom:\n message = `Invalid input`;\n break;\n case ZodIssueCode.invalid_intersection_types:\n message = `Intersection results could not be merged`;\n break;\n case ZodIssueCode.not_multiple_of:\n message = `Number must be a multiple of ${issue.multipleOf}`;\n break;\n case ZodIssueCode.not_finite:\n message = "Number must be finite";\n break;\n default:\n message = _ctx.defaultError;\n util.assertNever(issue);\n }\n return { message };\n };\n let overrideErrorMap = errorMap;\n function setErrorMap(map) {\n overrideErrorMap = map;\n }\n function getErrorMap() {\n return overrideErrorMap;\n }\n const makeIssue = (params) => {\n const { data, path, errorMaps, issueData } = params;\n const fullPath = [...path, ...issueData.path || []];\n const fullIssue = {\n ...issueData,\n path: fullPath\n };\n if (issueData.message !== void 0) {\n return {\n ...issueData,\n path: fullPath,\n message: issueData.message\n };\n }\n let errorMessage = "";\n const maps = errorMaps.filter((m2) => !!m2).slice().reverse();\n for (const map of maps) {\n errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;\n }\n return {\n ...issueData,\n path: fullPath,\n message: errorMessage\n };\n };\n const EMPTY_PATH = [];\n function addIssueToContext(ctx, issueData) {\n const overrideMap = getErrorMap();\n const issue = makeIssue({\n issueData,\n data: ctx.data,\n path: ctx.path,\n errorMaps: [\n ctx.common.contextualErrorMap,\n // contextual error map is first priority\n ctx.schemaErrorMap,\n // then schema-bound map if available\n overrideMap,\n // then global override map\n overrideMap === errorMap ? void 0 : errorMap\n // then global default map\n ].filter((x) => !!x)\n });\n ctx.common.issues.push(issue);\n }\n class ParseStatus {\n constructor() {\n this.value = "valid";\n }\n dirty() {\n if (this.value === "valid")\n this.value = "dirty";\n }\n abort() {\n if (this.value !== "aborted")\n this.value = "aborted";\n }\n static mergeArray(status, results) {\n const arrayValue = [];\n for (const s2 of results) {\n if (s2.status === "aborted")\n return INVALID;\n if (s2.status === "dirty")\n status.dirty();\n arrayValue.push(s2.value);\n }\n return { status: status.value, value: arrayValue };\n }\n static async mergeObjectAsync(status, pairs) {\n const syncPairs = [];\n for (const pair of pairs) {\n const key = await pair.key;\n const value = await pair.value;\n syncPairs.push({\n key,\n value\n });\n }\n return ParseStatus.mergeObjectSync(status, syncPairs);\n }\n static mergeObjectSync(status, pairs) {\n const finalObject = {};\n for (const pair of pairs) {\n const { key, value } = pair;\n if (key.status === "aborted")\n return INVALID;\n if (value.status === "aborted")\n return INVALID;\n if (key.status === "dirty")\n status.dirty();\n if (value.status === "dirty")\n status.dirty();\n if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {\n finalObject[key.value] = value.value;\n }\n }\n return { status: status.value, value: finalObject };\n }\n }\n const INVALID = Object.freeze({\n status: "aborted"\n });\n const DIRTY = (value) => ({ status: "dirty", value });\n const OK = (value) => ({ status: "valid", value });\n const isAborted = (x) => x.status === "aborted";\n const isDirty = (x) => x.status === "dirty";\n const isValid = (x) => x.status === "valid";\n const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;\n var errorUtil;\n (function(errorUtil2) {\n errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};\n errorUtil2.toString = (message) => typeof message === "string" ? message : message == null ? void 0 : message.message;\n })(errorUtil || (errorUtil = {}));\n class ParseInputLazyPath {\n constructor(parent, value, path, key) {\n this._cachedPath = [];\n this.parent = parent;\n this.data = value;\n this._path = path;\n this._key = key;\n }\n get path() {\n if (!this._cachedPath.length) {\n if (Array.isArray(this._key)) {\n this._cachedPath.push(...this._path, ...this._key);\n } else {\n this._cachedPath.push(...this._path, this._key);\n }\n }\n return this._cachedPath;\n }\n }\n const handleResult = (ctx, result) => {\n if (isValid(result)) {\n return { success: true, data: result.value };\n } else {\n if (!ctx.common.issues.length) {\n throw new Error("Validation failed but no issues detected.");\n }\n return {\n success: false,\n get error() {\n if (this._error)\n return this._error;\n const error = new ZodError(ctx.common.issues);\n this._error = error;\n return this._error;\n }\n };\n }\n };\n function processCreateParams(params) {\n if (!params)\n return {};\n const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;\n if (errorMap2 && (invalid_type_error || required_error)) {\n throw new Error(`Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.`);\n }\n if (errorMap2)\n return { errorMap: errorMap2, description };\n const customMap = (iss, ctx) => {\n const { message } = params;\n if (iss.code === "invalid_enum_value") {\n return { message: message ?? ctx.defaultError };\n }\n if (typeof ctx.data === "undefined") {\n return { message: message ?? required_error ?? ctx.defaultError };\n }\n if (iss.code !== "invalid_type")\n return { message: ctx.defaultError };\n return { message: message ?? invalid_type_error ?? ctx.defaultError };\n };\n return { errorMap: customMap, description };\n }\n class ZodType {\n get description() {\n return this._def.description;\n }\n _getType(input) {\n return getParsedType(input.data);\n }\n _getOrReturnCtx(input, ctx) {\n return ctx || {\n common: input.parent.common,\n data: input.data,\n parsedType: getParsedType(input.data),\n schemaErrorMap: this._def.errorMap,\n path: input.path,\n parent: input.parent\n };\n }\n _processInputParams(input) {\n return {\n status: new ParseStatus(),\n ctx: {\n common: input.parent.common,\n data: input.data,\n parsedType: getParsedType(input.data),\n schemaErrorMap: this._def.errorMap,\n path: input.path,\n parent: input.parent\n }\n };\n }\n _parseSync(input) {\n const result = this._parse(input);\n if (isAsync(result)) {\n throw new Error("Synchronous parse encountered promise.");\n }\n return result;\n }\n _parseAsync(input) {\n const result = this._parse(input);\n return Promise.resolve(result);\n }\n parse(data, params) {\n const result = this.safeParse(data, params);\n if (result.success)\n return result.data;\n throw result.error;\n }\n safeParse(data, params) {\n const ctx = {\n common: {\n issues: [],\n async: (params == null ? void 0 : params.async) ?? false,\n contextualErrorMap: params == null ? void 0 : params.errorMap\n },\n path: (params == null ? void 0 : params.path) || [],\n schemaErrorMap: this._def.errorMap,\n parent: null,\n data,\n parsedType: getParsedType(data)\n };\n const result = this._parseSync({ data, path: ctx.path, parent: ctx });\n return handleResult(ctx, result);\n }\n "~validate"(data) {\n var _a, _b;\n const ctx = {\n common: {\n issues: [],\n async: !!this["~standard"].async\n },\n path: [],\n schemaErrorMap: this._def.errorMap,\n parent: null,\n data,\n parsedType: getParsedType(data)\n };\n if (!this["~standard"].async) {\n try {\n const result = this._parseSync({ data, path: [], parent: ctx });\n return isValid(result) ? {\n value: result.value\n } : {\n issues: ctx.common.issues\n };\n } catch (err) {\n if ((_b = (_a = err == null ? void 0 : err.message) == null ? void 0 : _a.toLowerCase()) == null ? void 0 : _b.includes("encountered")) {\n this["~standard"].async = true;\n }\n ctx.common = {\n issues: [],\n async: true\n };\n }\n }\n return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {\n value: result.value\n } : {\n issues: ctx.common.issues\n });\n }\n async parseAsync(data, params) {\n const result = await this.safeParseAsync(data, params);\n if (result.success)\n return result.data;\n throw result.error;\n }\n async safeParseAsync(data, params) {\n const ctx = {\n common: {\n issues: [],\n contextualErrorMap: params == null ? void 0 : params.errorMap,\n async: true\n },\n path: (params == null ? void 0 : params.path) || [],\n schemaErrorMap: this._def.errorMap,\n parent: null,\n data,\n parsedType: getParsedType(data)\n };\n const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });\n const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));\n return handleResult(ctx, result);\n }\n refine(check, message) {\n const getIssueProperties = (val) => {\n if (typeof message === "string" || typeof message === "undefined") {\n return { message };\n } else if (typeof message === "function") {\n return message(val);\n } else {\n return message;\n }\n };\n return this._refinement((val, ctx) => {\n const result = check(val);\n const setError = () => ctx.addIssue({\n code: ZodIssueCode.custom,\n ...getIssueProperties(val)\n });\n if (typeof Promise !== "undefined" && result instanceof Promise) {\n return result.then((data) => {\n if (!data) {\n setError();\n return false;\n } else {\n return true;\n }\n });\n }\n if (!result) {\n setError();\n return false;\n } else {\n return true;\n }\n });\n }\n refinement(check, refinementData) {\n return this._refinement((val, ctx) => {\n if (!check(val)) {\n ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);\n return false;\n } else {\n return true;\n }\n });\n }\n _refinement(refinement) {\n return new ZodEffects({\n schema: this,\n typeName: ZodFirstPartyTypeKind.ZodEffects,\n effect: { type: "refinement", refinement }\n });\n }\n superRefine(refinement) {\n return this._refinement(refinement);\n }\n constructor(def) {\n this.spa = this.safeParseAsync;\n this._def = def;\n this.parse = this.parse.bind(this);\n this.safeParse = this.safeParse.bind(this);\n this.parseAsync = this.parseAsync.bind(this);\n this.safeParseAsync = this.safeParseAsync.bind(this);\n this.spa = this.spa.bind(this);\n this.refine = this.refine.bind(this);\n this.refinement = this.refinement.bind(this);\n this.superRefine = this.superRefine.bind(this);\n this.optional = this.optional.bind(this);\n this.nullable = this.nullable.bind(this);\n this.nullish = this.nullish.bind(this);\n this.array = this.array.bind(this);\n this.promise = this.promise.bind(this);\n this.or = this.or.bind(this);\n this.and = this.and.bind(this);\n this.transform = this.transform.bind(this);\n this.brand = this.brand.bind(this);\n this.default = this.default.bind(this);\n this.catch = this.catch.bind(this);\n this.describe = this.describe.bind(this);\n this.pipe = this.pipe.bind(this);\n this.readonly = this.readonly.bind(this);\n this.isNullable = this.isNullable.bind(this);\n this.isOptional = this.isOptional.bind(this);\n this["~standard"] = {\n version: 1,\n vendor: "zod",\n validate: (data) => this["~validate"](data)\n };\n }\n optional() {\n return ZodOptional.create(this, this._def);\n }\n nullable() {\n return ZodNullable.create(this, this._def);\n }\n nullish() {\n return this.nullable().optional();\n }\n array() {\n return ZodArray.create(this);\n }\n promise() {\n return ZodPromise.create(this, this._def);\n }\n or(option) {\n return ZodUnion.create([this, option], this._def);\n }\n and(incoming) {\n return ZodIntersection.create(this, incoming, this._def);\n }\n transform(transform) {\n return new ZodEffects({\n ...processCreateParams(this._def),\n schema: this,\n typeName: ZodFirstPartyTypeKind.ZodEffects,\n effect: { type: "transform", transform }\n });\n }\n default(def) {\n const defaultValueFunc = typeof def === "function" ? def : () => def;\n return new ZodDefault({\n ...processCreateParams(this._def),\n innerType: this,\n defaultValue: defaultValueFunc,\n typeName: ZodFirstPartyTypeKind.ZodDefault\n });\n }\n brand() {\n return new ZodBranded({\n typeName: ZodFirstPartyTypeKind.ZodBranded,\n type: this,\n ...processCreateParams(this._def)\n });\n }\n catch(def) {\n const catchValueFunc = typeof def === "function" ? def : () => def;\n return new ZodCatch({\n ...processCreateParams(this._def),\n innerType: this,\n catchValue: catchValueFunc,\n typeName: ZodFirstPartyTypeKind.ZodCatch\n });\n }\n describe(description) {\n const This = this.constructor;\n return new This({\n ...this._def,\n description\n });\n }\n pipe(target) {\n return ZodPipeline.create(this, target);\n }\n readonly() {\n return ZodReadonly.create(this);\n }\n isOptional() {\n return this.safeParse(void 0).success;\n }\n isNullable() {\n return this.safeParse(null).success;\n }\n }\n const cuidRegex = /^c[^\\s-]{8,}$/i;\n const cuid2Regex = /^[0-9a-z]+$/;\n const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;\n 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;\n const nanoidRegex = /^[a-z0-9_-]{21}$/i;\n const jwtRegex = /^[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_]*$/;\n 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)?)??$/;\n const emailRegex = /^(?!\\.)(?!.*\\.\\.)([A-Z0-9_\'+\\-\\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\\-]*\\.)+[A-Z]{2,}$/i;\n const _emojiRegex = `^(\\\\p{Extended_Pictographic}|\\\\p{Emoji_Component})+$`;\n let emojiRegex;\n 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])$/;\n 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])$/;\n 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]))$/;\n 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])$/;\n const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;\n const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;\n 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])))`;\n const dateRegex = new RegExp(`^${dateRegexSource}$`);\n function timeRegexSource(args) {\n let secondsRegexSource = `[0-5]\\\\d`;\n if (args.precision) {\n secondsRegexSource = `${secondsRegexSource}\\\\.\\\\d{${args.precision}}`;\n } else if (args.precision == null) {\n secondsRegexSource = `${secondsRegexSource}(\\\\.\\\\d+)?`;\n }\n const secondsQuantifier = args.precision ? "+" : "?";\n return `([01]\\\\d|2[0-3]):[0-5]\\\\d(:${secondsRegexSource})${secondsQuantifier}`;\n }\n function timeRegex(args) {\n return new RegExp(`^${timeRegexSource(args)}$`);\n }\n function datetimeRegex(args) {\n let regex = `${dateRegexSource}T${timeRegexSource(args)}`;\n const opts = [];\n opts.push(args.local ? `Z?` : `Z`);\n if (args.offset)\n opts.push(`([+-]\\\\d{2}:?\\\\d{2})`);\n regex = `${regex}(${opts.join("|")})`;\n return new RegExp(`^${regex}$`);\n }\n function isValidIP(ip, version) {\n if ((version === "v4" || !version) && ipv4Regex.test(ip)) {\n return true;\n }\n if ((version === "v6" || !version) && ipv6Regex.test(ip)) {\n return true;\n }\n return false;\n }\n function isValidJWT(jwt, alg) {\n if (!jwtRegex.test(jwt))\n return false;\n try {\n const [header] = jwt.split(".");\n if (!header)\n return false;\n const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");\n const decoded = JSON.parse(atob(base64));\n if (typeof decoded !== "object" || decoded === null)\n return false;\n if ("typ" in decoded && (decoded == null ? void 0 : decoded.typ) !== "JWT")\n return false;\n if (!decoded.alg)\n return false;\n if (alg && decoded.alg !== alg)\n return false;\n return true;\n } catch {\n return false;\n }\n }\n function isValidCidr(ip, version) {\n if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {\n return true;\n }\n if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {\n return true;\n }\n return false;\n }\n class ZodString extends ZodType {\n _parse(input) {\n if (this._def.coerce) {\n input.data = String(input.data);\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.string) {\n const ctx2 = this._getOrReturnCtx(input);\n addIssueToContext(ctx2, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.string,\n received: ctx2.parsedType\n });\n return INVALID;\n }\n const status = new ParseStatus();\n let ctx = void 0;\n for (const check of this._def.checks) {\n if (check.kind === "min") {\n if (input.data.length < check.value) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: check.value,\n type: "string",\n inclusive: true,\n exact: false,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "max") {\n if (input.data.length > check.value) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: check.value,\n type: "string",\n inclusive: true,\n exact: false,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "length") {\n const tooBig = input.data.length > check.value;\n const tooSmall = input.data.length < check.value;\n if (tooBig || tooSmall) {\n ctx = this._getOrReturnCtx(input, ctx);\n if (tooBig) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: check.value,\n type: "string",\n inclusive: true,\n exact: true,\n message: check.message\n });\n } else if (tooSmall) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: check.value,\n type: "string",\n inclusive: true,\n exact: true,\n message: check.message\n });\n }\n status.dirty();\n }\n } else if (check.kind === "email") {\n if (!emailRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "email",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "emoji") {\n if (!emojiRegex) {\n emojiRegex = new RegExp(_emojiRegex, "u");\n }\n if (!emojiRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "emoji",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "uuid") {\n if (!uuidRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "uuid",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "nanoid") {\n if (!nanoidRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "nanoid",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "cuid") {\n if (!cuidRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "cuid",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "cuid2") {\n if (!cuid2Regex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "cuid2",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "ulid") {\n if (!ulidRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "ulid",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "url") {\n try {\n new URL(input.data);\n } catch {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "url",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "regex") {\n check.regex.lastIndex = 0;\n const testResult = check.regex.test(input.data);\n if (!testResult) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "regex",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "trim") {\n input.data = input.data.trim();\n } else if (check.kind === "includes") {\n if (!input.data.includes(check.value, check.position)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: { includes: check.value, position: check.position },\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "toLowerCase") {\n input.data = input.data.toLowerCase();\n } else if (check.kind === "toUpperCase") {\n input.data = input.data.toUpperCase();\n } else if (check.kind === "startsWith") {\n if (!input.data.startsWith(check.value)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: { startsWith: check.value },\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "endsWith") {\n if (!input.data.endsWith(check.value)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: { endsWith: check.value },\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "datetime") {\n const regex = datetimeRegex(check);\n if (!regex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: "datetime",\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "date") {\n const regex = dateRegex;\n if (!regex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: "date",\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "time") {\n const regex = timeRegex(check);\n if (!regex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_string,\n validation: "time",\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "duration") {\n if (!durationRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "duration",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "ip") {\n if (!isValidIP(input.data, check.version)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "ip",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "jwt") {\n if (!isValidJWT(input.data, check.alg)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "jwt",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "cidr") {\n if (!isValidCidr(input.data, check.version)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "cidr",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "base64") {\n if (!base64Regex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "base64",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "base64url") {\n if (!base64urlRegex.test(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n validation: "base64url",\n code: ZodIssueCode.invalid_string,\n message: check.message\n });\n status.dirty();\n }\n } else {\n util.assertNever(check);\n }\n }\n return { status: status.value, value: input.data };\n }\n _regex(regex, validation, message) {\n return this.refinement((data) => regex.test(data), {\n validation,\n code: ZodIssueCode.invalid_string,\n ...errorUtil.errToObj(message)\n });\n }\n _addCheck(check) {\n return new ZodString({\n ...this._def,\n checks: [...this._def.checks, check]\n });\n }\n email(message) {\n return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });\n }\n url(message) {\n return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });\n }\n emoji(message) {\n return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });\n }\n uuid(message) {\n return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });\n }\n nanoid(message) {\n return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });\n }\n cuid(message) {\n return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });\n }\n cuid2(message) {\n return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });\n }\n ulid(message) {\n return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });\n }\n base64(message) {\n return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });\n }\n base64url(message) {\n return this._addCheck({\n kind: "base64url",\n ...errorUtil.errToObj(message)\n });\n }\n jwt(options) {\n return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });\n }\n ip(options) {\n return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });\n }\n cidr(options) {\n return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });\n }\n datetime(options) {\n if (typeof options === "string") {\n return this._addCheck({\n kind: "datetime",\n precision: null,\n offset: false,\n local: false,\n message: options\n });\n }\n return this._addCheck({\n kind: "datetime",\n precision: typeof (options == null ? void 0 : options.precision) === "undefined" ? null : options == null ? void 0 : options.precision,\n offset: (options == null ? void 0 : options.offset) ?? false,\n local: (options == null ? void 0 : options.local) ?? false,\n ...errorUtil.errToObj(options == null ? void 0 : options.message)\n });\n }\n date(message) {\n return this._addCheck({ kind: "date", message });\n }\n time(options) {\n if (typeof options === "string") {\n return this._addCheck({\n kind: "time",\n precision: null,\n message: options\n });\n }\n return this._addCheck({\n kind: "time",\n precision: typeof (options == null ? void 0 : options.precision) === "undefined" ? null : options == null ? void 0 : options.precision,\n ...errorUtil.errToObj(options == null ? void 0 : options.message)\n });\n }\n duration(message) {\n return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });\n }\n regex(regex, message) {\n return this._addCheck({\n kind: "regex",\n regex,\n ...errorUtil.errToObj(message)\n });\n }\n includes(value, options) {\n return this._addCheck({\n kind: "includes",\n value,\n position: options == null ? void 0 : options.position,\n ...errorUtil.errToObj(options == null ? void 0 : options.message)\n });\n }\n startsWith(value, message) {\n return this._addCheck({\n kind: "startsWith",\n value,\n ...errorUtil.errToObj(message)\n });\n }\n endsWith(value, message) {\n return this._addCheck({\n kind: "endsWith",\n value,\n ...errorUtil.errToObj(message)\n });\n }\n min(minLength, message) {\n return this._addCheck({\n kind: "min",\n value: minLength,\n ...errorUtil.errToObj(message)\n });\n }\n max(maxLength, message) {\n return this._addCheck({\n kind: "max",\n value: maxLength,\n ...errorUtil.errToObj(message)\n });\n }\n length(len, message) {\n return this._addCheck({\n kind: "length",\n value: len,\n ...errorUtil.errToObj(message)\n });\n }\n /**\n * Equivalent to `.min(1)`\n */\n nonempty(message) {\n return this.min(1, errorUtil.errToObj(message));\n }\n trim() {\n return new ZodString({\n ...this._def,\n checks: [...this._def.checks, { kind: "trim" }]\n });\n }\n toLowerCase() {\n return new ZodString({\n ...this._def,\n checks: [...this._def.checks, { kind: "toLowerCase" }]\n });\n }\n toUpperCase() {\n return new ZodString({\n ...this._def,\n checks: [...this._def.checks, { kind: "toUpperCase" }]\n });\n }\n get isDatetime() {\n return !!this._def.checks.find((ch) => ch.kind === "datetime");\n }\n get isDate() {\n return !!this._def.checks.find((ch) => ch.kind === "date");\n }\n get isTime() {\n return !!this._def.checks.find((ch) => ch.kind === "time");\n }\n get isDuration() {\n return !!this._def.checks.find((ch) => ch.kind === "duration");\n }\n get isEmail() {\n return !!this._def.checks.find((ch) => ch.kind === "email");\n }\n get isURL() {\n return !!this._def.checks.find((ch) => ch.kind === "url");\n }\n get isEmoji() {\n return !!this._def.checks.find((ch) => ch.kind === "emoji");\n }\n get isUUID() {\n return !!this._def.checks.find((ch) => ch.kind === "uuid");\n }\n get isNANOID() {\n return !!this._def.checks.find((ch) => ch.kind === "nanoid");\n }\n get isCUID() {\n return !!this._def.checks.find((ch) => ch.kind === "cuid");\n }\n get isCUID2() {\n return !!this._def.checks.find((ch) => ch.kind === "cuid2");\n }\n get isULID() {\n return !!this._def.checks.find((ch) => ch.kind === "ulid");\n }\n get isIP() {\n return !!this._def.checks.find((ch) => ch.kind === "ip");\n }\n get isCIDR() {\n return !!this._def.checks.find((ch) => ch.kind === "cidr");\n }\n get isBase64() {\n return !!this._def.checks.find((ch) => ch.kind === "base64");\n }\n get isBase64url() {\n return !!this._def.checks.find((ch) => ch.kind === "base64url");\n }\n get minLength() {\n let min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === "min") {\n if (min === null || ch.value > min)\n min = ch.value;\n }\n }\n return min;\n }\n get maxLength() {\n let max = null;\n for (const ch of this._def.checks) {\n if (ch.kind === "max") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return max;\n }\n }\n ZodString.create = (params) => {\n return new ZodString({\n checks: [],\n typeName: ZodFirstPartyTypeKind.ZodString,\n coerce: (params == null ? void 0 : params.coerce) ?? false,\n ...processCreateParams(params)\n });\n };\n function floatSafeRemainder(val, step) {\n const valDecCount = (val.toString().split(".")[1] || "").length;\n const stepDecCount = (step.toString().split(".")[1] || "").length;\n const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;\n const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));\n const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));\n return valInt % stepInt / 10 ** decCount;\n }\n class ZodNumber extends ZodType {\n constructor() {\n super(...arguments);\n this.min = this.gte;\n this.max = this.lte;\n this.step = this.multipleOf;\n }\n _parse(input) {\n if (this._def.coerce) {\n input.data = Number(input.data);\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.number) {\n const ctx2 = this._getOrReturnCtx(input);\n addIssueToContext(ctx2, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.number,\n received: ctx2.parsedType\n });\n return INVALID;\n }\n let ctx = void 0;\n const status = new ParseStatus();\n for (const check of this._def.checks) {\n if (check.kind === "int") {\n if (!util.isInteger(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: "integer",\n received: "float",\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "min") {\n const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;\n if (tooSmall) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: check.value,\n type: "number",\n inclusive: check.inclusive,\n exact: false,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "max") {\n const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;\n if (tooBig) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: check.value,\n type: "number",\n inclusive: check.inclusive,\n exact: false,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "multipleOf") {\n if (floatSafeRemainder(input.data, check.value) !== 0) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.not_multiple_of,\n multipleOf: check.value,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "finite") {\n if (!Number.isFinite(input.data)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.not_finite,\n message: check.message\n });\n status.dirty();\n }\n } else {\n util.assertNever(check);\n }\n }\n return { status: status.value, value: input.data };\n }\n gte(value, message) {\n return this.setLimit("min", value, true, errorUtil.toString(message));\n }\n gt(value, message) {\n return this.setLimit("min", value, false, errorUtil.toString(message));\n }\n lte(value, message) {\n return this.setLimit("max", value, true, errorUtil.toString(message));\n }\n lt(value, message) {\n return this.setLimit("max", value, false, errorUtil.toString(message));\n }\n setLimit(kind, value, inclusive, message) {\n return new ZodNumber({\n ...this._def,\n checks: [\n ...this._def.checks,\n {\n kind,\n value,\n inclusive,\n message: errorUtil.toString(message)\n }\n ]\n });\n }\n _addCheck(check) {\n return new ZodNumber({\n ...this._def,\n checks: [...this._def.checks, check]\n });\n }\n int(message) {\n return this._addCheck({\n kind: "int",\n message: errorUtil.toString(message)\n });\n }\n positive(message) {\n return this._addCheck({\n kind: "min",\n value: 0,\n inclusive: false,\n message: errorUtil.toString(message)\n });\n }\n negative(message) {\n return this._addCheck({\n kind: "max",\n value: 0,\n inclusive: false,\n message: errorUtil.toString(message)\n });\n }\n nonpositive(message) {\n return this._addCheck({\n kind: "max",\n value: 0,\n inclusive: true,\n message: errorUtil.toString(message)\n });\n }\n nonnegative(message) {\n return this._addCheck({\n kind: "min",\n value: 0,\n inclusive: true,\n message: errorUtil.toString(message)\n });\n }\n multipleOf(value, message) {\n return this._addCheck({\n kind: "multipleOf",\n value,\n message: errorUtil.toString(message)\n });\n }\n finite(message) {\n return this._addCheck({\n kind: "finite",\n message: errorUtil.toString(message)\n });\n }\n safe(message) {\n return this._addCheck({\n kind: "min",\n inclusive: true,\n value: Number.MIN_SAFE_INTEGER,\n message: errorUtil.toString(message)\n })._addCheck({\n kind: "max",\n inclusive: true,\n value: Number.MAX_SAFE_INTEGER,\n message: errorUtil.toString(message)\n });\n }\n get minValue() {\n let min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === "min") {\n if (min === null || ch.value > min)\n min = ch.value;\n }\n }\n return min;\n }\n get maxValue() {\n let max = null;\n for (const ch of this._def.checks) {\n if (ch.kind === "max") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return max;\n }\n get isInt() {\n return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));\n }\n get isFinite() {\n let max = null;\n let min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {\n return true;\n } else if (ch.kind === "min") {\n if (min === null || ch.value > min)\n min = ch.value;\n } else if (ch.kind === "max") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return Number.isFinite(min) && Number.isFinite(max);\n }\n }\n ZodNumber.create = (params) => {\n return new ZodNumber({\n checks: [],\n typeName: ZodFirstPartyTypeKind.ZodNumber,\n coerce: (params == null ? void 0 : params.coerce) || false,\n ...processCreateParams(params)\n });\n };\n class ZodBigInt extends ZodType {\n constructor() {\n super(...arguments);\n this.min = this.gte;\n this.max = this.lte;\n }\n _parse(input) {\n if (this._def.coerce) {\n try {\n input.data = BigInt(input.data);\n } catch {\n return this._getInvalidInput(input);\n }\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.bigint) {\n return this._getInvalidInput(input);\n }\n let ctx = void 0;\n const status = new ParseStatus();\n for (const check of this._def.checks) {\n if (check.kind === "min") {\n const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;\n if (tooSmall) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n type: "bigint",\n minimum: check.value,\n inclusive: check.inclusive,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "max") {\n const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;\n if (tooBig) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n type: "bigint",\n maximum: check.value,\n inclusive: check.inclusive,\n message: check.message\n });\n status.dirty();\n }\n } else if (check.kind === "multipleOf") {\n if (input.data % check.value !== BigInt(0)) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.not_multiple_of,\n multipleOf: check.value,\n message: check.message\n });\n status.dirty();\n }\n } else {\n util.assertNever(check);\n }\n }\n return { status: status.value, value: input.data };\n }\n _getInvalidInput(input) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.bigint,\n received: ctx.parsedType\n });\n return INVALID;\n }\n gte(value, message) {\n return this.setLimit("min", value, true, errorUtil.toString(message));\n }\n gt(value, message) {\n return this.setLimit("min", value, false, errorUtil.toString(message));\n }\n lte(value, message) {\n return this.setLimit("max", value, true, errorUtil.toString(message));\n }\n lt(value, message) {\n return this.setLimit("max", value, false, errorUtil.toString(message));\n }\n setLimit(kind, value, inclusive, message) {\n return new ZodBigInt({\n ...this._def,\n checks: [\n ...this._def.checks,\n {\n kind,\n value,\n inclusive,\n message: errorUtil.toString(message)\n }\n ]\n });\n }\n _addCheck(check) {\n return new ZodBigInt({\n ...this._def,\n checks: [...this._def.checks, check]\n });\n }\n positive(message) {\n return this._addCheck({\n kind: "min",\n value: BigInt(0),\n inclusive: false,\n message: errorUtil.toString(message)\n });\n }\n negative(message) {\n return this._addCheck({\n kind: "max",\n value: BigInt(0),\n inclusive: false,\n message: errorUtil.toString(message)\n });\n }\n nonpositive(message) {\n return this._addCheck({\n kind: "max",\n value: BigInt(0),\n inclusive: true,\n message: errorUtil.toString(message)\n });\n }\n nonnegative(message) {\n return this._addCheck({\n kind: "min",\n value: BigInt(0),\n inclusive: true,\n message: errorUtil.toString(message)\n });\n }\n multipleOf(value, message) {\n return this._addCheck({\n kind: "multipleOf",\n value,\n message: errorUtil.toString(message)\n });\n }\n get minValue() {\n let min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === "min") {\n if (min === null || ch.value > min)\n min = ch.value;\n }\n }\n return min;\n }\n get maxValue() {\n let max = null;\n for (const ch of this._def.checks) {\n if (ch.kind === "max") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return max;\n }\n }\n ZodBigInt.create = (params) => {\n return new ZodBigInt({\n checks: [],\n typeName: ZodFirstPartyTypeKind.ZodBigInt,\n coerce: (params == null ? void 0 : params.coerce) ?? false,\n ...processCreateParams(params)\n });\n };\n class ZodBoolean extends ZodType {\n _parse(input) {\n if (this._def.coerce) {\n input.data = Boolean(input.data);\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.boolean) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.boolean,\n received: ctx.parsedType\n });\n return INVALID;\n }\n return OK(input.data);\n }\n }\n ZodBoolean.create = (params) => {\n return new ZodBoolean({\n typeName: ZodFirstPartyTypeKind.ZodBoolean,\n coerce: (params == null ? void 0 : params.coerce) || false,\n ...processCreateParams(params)\n });\n };\n class ZodDate extends ZodType {\n _parse(input) {\n if (this._def.coerce) {\n input.data = new Date(input.data);\n }\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.date) {\n const ctx2 = this._getOrReturnCtx(input);\n addIssueToContext(ctx2, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.date,\n received: ctx2.parsedType\n });\n return INVALID;\n }\n if (Number.isNaN(input.data.getTime())) {\n const ctx2 = this._getOrReturnCtx(input);\n addIssueToContext(ctx2, {\n code: ZodIssueCode.invalid_date\n });\n return INVALID;\n }\n const status = new ParseStatus();\n let ctx = void 0;\n for (const check of this._def.checks) {\n if (check.kind === "min") {\n if (input.data.getTime() < check.value) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n message: check.message,\n inclusive: true,\n exact: false,\n minimum: check.value,\n type: "date"\n });\n status.dirty();\n }\n } else if (check.kind === "max") {\n if (input.data.getTime() > check.value) {\n ctx = this._getOrReturnCtx(input, ctx);\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n message: check.message,\n inclusive: true,\n exact: false,\n maximum: check.value,\n type: "date"\n });\n status.dirty();\n }\n } else {\n util.assertNever(check);\n }\n }\n return {\n status: status.value,\n value: new Date(input.data.getTime())\n };\n }\n _addCheck(check) {\n return new ZodDate({\n ...this._def,\n checks: [...this._def.checks, check]\n });\n }\n min(minDate, message) {\n return this._addCheck({\n kind: "min",\n value: minDate.getTime(),\n message: errorUtil.toString(message)\n });\n }\n max(maxDate, message) {\n return this._addCheck({\n kind: "max",\n value: maxDate.getTime(),\n message: errorUtil.toString(message)\n });\n }\n get minDate() {\n let min = null;\n for (const ch of this._def.checks) {\n if (ch.kind === "min") {\n if (min === null || ch.value > min)\n min = ch.value;\n }\n }\n return min != null ? new Date(min) : null;\n }\n get maxDate() {\n let max = null;\n for (const ch of this._def.checks) {\n if (ch.kind === "max") {\n if (max === null || ch.value < max)\n max = ch.value;\n }\n }\n return max != null ? new Date(max) : null;\n }\n }\n ZodDate.create = (params) => {\n return new ZodDate({\n checks: [],\n coerce: (params == null ? void 0 : params.coerce) || false,\n typeName: ZodFirstPartyTypeKind.ZodDate,\n ...processCreateParams(params)\n });\n };\n class ZodSymbol extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.symbol) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.symbol,\n received: ctx.parsedType\n });\n return INVALID;\n }\n return OK(input.data);\n }\n }\n ZodSymbol.create = (params) => {\n return new ZodSymbol({\n typeName: ZodFirstPartyTypeKind.ZodSymbol,\n ...processCreateParams(params)\n });\n };\n class ZodUndefined extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.undefined) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.undefined,\n received: ctx.parsedType\n });\n return INVALID;\n }\n return OK(input.data);\n }\n }\n ZodUndefined.create = (params) => {\n return new ZodUndefined({\n typeName: ZodFirstPartyTypeKind.ZodUndefined,\n ...processCreateParams(params)\n });\n };\n class ZodNull extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.null) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.null,\n received: ctx.parsedType\n });\n return INVALID;\n }\n return OK(input.data);\n }\n }\n ZodNull.create = (params) => {\n return new ZodNull({\n typeName: ZodFirstPartyTypeKind.ZodNull,\n ...processCreateParams(params)\n });\n };\n class ZodAny extends ZodType {\n constructor() {\n super(...arguments);\n this._any = true;\n }\n _parse(input) {\n return OK(input.data);\n }\n }\n ZodAny.create = (params) => {\n return new ZodAny({\n typeName: ZodFirstPartyTypeKind.ZodAny,\n ...processCreateParams(params)\n });\n };\n class ZodUnknown extends ZodType {\n constructor() {\n super(...arguments);\n this._unknown = true;\n }\n _parse(input) {\n return OK(input.data);\n }\n }\n ZodUnknown.create = (params) => {\n return new ZodUnknown({\n typeName: ZodFirstPartyTypeKind.ZodUnknown,\n ...processCreateParams(params)\n });\n };\n class ZodNever extends ZodType {\n _parse(input) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.never,\n received: ctx.parsedType\n });\n return INVALID;\n }\n }\n ZodNever.create = (params) => {\n return new ZodNever({\n typeName: ZodFirstPartyTypeKind.ZodNever,\n ...processCreateParams(params)\n });\n };\n class ZodVoid extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.undefined) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.void,\n received: ctx.parsedType\n });\n return INVALID;\n }\n return OK(input.data);\n }\n }\n ZodVoid.create = (params) => {\n return new ZodVoid({\n typeName: ZodFirstPartyTypeKind.ZodVoid,\n ...processCreateParams(params)\n });\n };\n class ZodArray extends ZodType {\n _parse(input) {\n const { ctx, status } = this._processInputParams(input);\n const def = this._def;\n if (ctx.parsedType !== ZodParsedType.array) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.array,\n received: ctx.parsedType\n });\n return INVALID;\n }\n if (def.exactLength !== null) {\n const tooBig = ctx.data.length > def.exactLength.value;\n const tooSmall = ctx.data.length < def.exactLength.value;\n if (tooBig || tooSmall) {\n addIssueToContext(ctx, {\n code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,\n minimum: tooSmall ? def.exactLength.value : void 0,\n maximum: tooBig ? def.exactLength.value : void 0,\n type: "array",\n inclusive: true,\n exact: true,\n message: def.exactLength.message\n });\n status.dirty();\n }\n }\n if (def.minLength !== null) {\n if (ctx.data.length < def.minLength.value) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: def.minLength.value,\n type: "array",\n inclusive: true,\n exact: false,\n message: def.minLength.message\n });\n status.dirty();\n }\n }\n if (def.maxLength !== null) {\n if (ctx.data.length > def.maxLength.value) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: def.maxLength.value,\n type: "array",\n inclusive: true,\n exact: false,\n message: def.maxLength.message\n });\n status.dirty();\n }\n }\n if (ctx.common.async) {\n return Promise.all([...ctx.data].map((item, i2) => {\n return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i2));\n })).then((result2) => {\n return ParseStatus.mergeArray(status, result2);\n });\n }\n const result = [...ctx.data].map((item, i2) => {\n return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i2));\n });\n return ParseStatus.mergeArray(status, result);\n }\n get element() {\n return this._def.type;\n }\n min(minLength, message) {\n return new ZodArray({\n ...this._def,\n minLength: { value: minLength, message: errorUtil.toString(message) }\n });\n }\n max(maxLength, message) {\n return new ZodArray({\n ...this._def,\n maxLength: { value: maxLength, message: errorUtil.toString(message) }\n });\n }\n length(len, message) {\n return new ZodArray({\n ...this._def,\n exactLength: { value: len, message: errorUtil.toString(message) }\n });\n }\n nonempty(message) {\n return this.min(1, message);\n }\n }\n ZodArray.create = (schema, params) => {\n return new ZodArray({\n type: schema,\n minLength: null,\n maxLength: null,\n exactLength: null,\n typeName: ZodFirstPartyTypeKind.ZodArray,\n ...processCreateParams(params)\n });\n };\n function deepPartialify(schema) {\n if (schema instanceof ZodObject) {\n const newShape = {};\n for (const key in schema.shape) {\n const fieldSchema = schema.shape[key];\n newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));\n }\n return new ZodObject({\n ...schema._def,\n shape: () => newShape\n });\n } else if (schema instanceof ZodArray) {\n return new ZodArray({\n ...schema._def,\n type: deepPartialify(schema.element)\n });\n } else if (schema instanceof ZodOptional) {\n return ZodOptional.create(deepPartialify(schema.unwrap()));\n } else if (schema instanceof ZodNullable) {\n return ZodNullable.create(deepPartialify(schema.unwrap()));\n } else if (schema instanceof ZodTuple) {\n return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));\n } else {\n return schema;\n }\n }\n class ZodObject extends ZodType {\n constructor() {\n super(...arguments);\n this._cached = null;\n this.nonstrict = this.passthrough;\n this.augment = this.extend;\n }\n _getCached() {\n if (this._cached !== null)\n return this._cached;\n const shape = this._def.shape();\n const keys = util.objectKeys(shape);\n this._cached = { shape, keys };\n return this._cached;\n }\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.object) {\n const ctx2 = this._getOrReturnCtx(input);\n addIssueToContext(ctx2, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.object,\n received: ctx2.parsedType\n });\n return INVALID;\n }\n const { status, ctx } = this._processInputParams(input);\n const { shape, keys: shapeKeys } = this._getCached();\n const extraKeys = [];\n if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {\n for (const key in ctx.data) {\n if (!shapeKeys.includes(key)) {\n extraKeys.push(key);\n }\n }\n }\n const pairs = [];\n for (const key of shapeKeys) {\n const keyValidator = shape[key];\n const value = ctx.data[key];\n pairs.push({\n key: { status: "valid", value: key },\n value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),\n alwaysSet: key in ctx.data\n });\n }\n if (this._def.catchall instanceof ZodNever) {\n const unknownKeys = this._def.unknownKeys;\n if (unknownKeys === "passthrough") {\n for (const key of extraKeys) {\n pairs.push({\n key: { status: "valid", value: key },\n value: { status: "valid", value: ctx.data[key] }\n });\n }\n } else if (unknownKeys === "strict") {\n if (extraKeys.length > 0) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.unrecognized_keys,\n keys: extraKeys\n });\n status.dirty();\n }\n } else if (unknownKeys === "strip") ;\n else {\n throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);\n }\n } else {\n const catchall = this._def.catchall;\n for (const key of extraKeys) {\n const value = ctx.data[key];\n pairs.push({\n key: { status: "valid", value: key },\n value: catchall._parse(\n new ParseInputLazyPath(ctx, value, ctx.path, key)\n //, ctx.child(key), value, getParsedType(value)\n ),\n alwaysSet: key in ctx.data\n });\n }\n }\n if (ctx.common.async) {\n return Promise.resolve().then(async () => {\n const syncPairs = [];\n for (const pair of pairs) {\n const key = await pair.key;\n const value = await pair.value;\n syncPairs.push({\n key,\n value,\n alwaysSet: pair.alwaysSet\n });\n }\n return syncPairs;\n }).then((syncPairs) => {\n return ParseStatus.mergeObjectSync(status, syncPairs);\n });\n } else {\n return ParseStatus.mergeObjectSync(status, pairs);\n }\n }\n get shape() {\n return this._def.shape();\n }\n strict(message) {\n errorUtil.errToObj;\n return new ZodObject({\n ...this._def,\n unknownKeys: "strict",\n ...message !== void 0 ? {\n errorMap: (issue, ctx) => {\n var _a, _b;\n const defaultError = ((_b = (_a = this._def).errorMap) == null ? void 0 : _b.call(_a, issue, ctx).message) ?? ctx.defaultError;\n if (issue.code === "unrecognized_keys")\n return {\n message: errorUtil.errToObj(message).message ?? defaultError\n };\n return {\n message: defaultError\n };\n }\n } : {}\n });\n }\n strip() {\n return new ZodObject({\n ...this._def,\n unknownKeys: "strip"\n });\n }\n passthrough() {\n return new ZodObject({\n ...this._def,\n unknownKeys: "passthrough"\n });\n }\n // const AugmentFactory =\n // <Def extends ZodObjectDef>(def: Def) =>\n // <Augmentation extends ZodRawShape>(\n // augmentation: Augmentation\n // ): ZodObject<\n // extendShape<ReturnType<Def["shape"]>, Augmentation>,\n // Def["unknownKeys"],\n // Def["catchall"]\n // > => {\n // return new ZodObject({\n // ...def,\n // shape: () => ({\n // ...def.shape(),\n // ...augmentation,\n // }),\n // }) as any;\n // };\n extend(augmentation) {\n return new ZodObject({\n ...this._def,\n shape: () => ({\n ...this._def.shape(),\n ...augmentation\n })\n });\n }\n /**\n * Prior to zod@1.0.12 there was a bug in the\n * inferred type of merged objects. Please\n * upgrade if you are experiencing issues.\n */\n merge(merging) {\n const merged = new ZodObject({\n unknownKeys: merging._def.unknownKeys,\n catchall: merging._def.catchall,\n shape: () => ({\n ...this._def.shape(),\n ...merging._def.shape()\n }),\n typeName: ZodFirstPartyTypeKind.ZodObject\n });\n return merged;\n }\n // merge<\n // Incoming extends AnyZodObject,\n // Augmentation extends Incoming["shape"],\n // NewOutput extends {\n // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation\n // ? Augmentation[k]["_output"]\n // : k extends keyof Output\n // ? Output[k]\n // : never;\n // },\n // NewInput extends {\n // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation\n // ? Augmentation[k]["_input"]\n // : k extends keyof Input\n // ? Input[k]\n // : never;\n // }\n // >(\n // merging: Incoming\n // ): ZodObject<\n // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,\n // Incoming["_def"]["unknownKeys"],\n // Incoming["_def"]["catchall"],\n // NewOutput,\n // NewInput\n // > {\n // const merged: any = new ZodObject({\n // unknownKeys: merging._def.unknownKeys,\n // catchall: merging._def.catchall,\n // shape: () =>\n // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),\n // typeName: ZodFirstPartyTypeKind.ZodObject,\n // }) as any;\n // return merged;\n // }\n setKey(key, schema) {\n return this.augment({ [key]: schema });\n }\n // merge<Incoming extends AnyZodObject>(\n // merging: Incoming\n // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {\n // ZodObject<\n // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,\n // Incoming["_def"]["unknownKeys"],\n // Incoming["_def"]["catchall"]\n // > {\n // // const mergedShape = objectUtil.mergeShapes(\n // // this._def.shape(),\n // // merging._def.shape()\n // // );\n // const merged: any = new ZodObject({\n // unknownKeys: merging._def.unknownKeys,\n // catchall: merging._def.catchall,\n // shape: () =>\n // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),\n // typeName: ZodFirstPartyTypeKind.ZodObject,\n // }) as any;\n // return merged;\n // }\n catchall(index) {\n return new ZodObject({\n ...this._def,\n catchall: index\n });\n }\n pick(mask) {\n const shape = {};\n for (const key of util.objectKeys(mask)) {\n if (mask[key] && this.shape[key]) {\n shape[key] = this.shape[key];\n }\n }\n return new ZodObject({\n ...this._def,\n shape: () => shape\n });\n }\n omit(mask) {\n const shape = {};\n for (const key of util.objectKeys(this.shape)) {\n if (!mask[key]) {\n shape[key] = this.shape[key];\n }\n }\n return new ZodObject({\n ...this._def,\n shape: () => shape\n });\n }\n /**\n * @deprecated\n */\n deepPartial() {\n return deepPartialify(this);\n }\n partial(mask) {\n const newShape = {};\n for (const key of util.objectKeys(this.shape)) {\n const fieldSchema = this.shape[key];\n if (mask && !mask[key]) {\n newShape[key] = fieldSchema;\n } else {\n newShape[key] = fieldSchema.optional();\n }\n }\n return new ZodObject({\n ...this._def,\n shape: () => newShape\n });\n }\n required(mask) {\n const newShape = {};\n for (const key of util.objectKeys(this.shape)) {\n if (mask && !mask[key]) {\n newShape[key] = this.shape[key];\n } else {\n const fieldSchema = this.shape[key];\n let newField = fieldSchema;\n while (newField instanceof ZodOptional) {\n newField = newField._def.innerType;\n }\n newShape[key] = newField;\n }\n }\n return new ZodObject({\n ...this._def,\n shape: () => newShape\n });\n }\n keyof() {\n return createZodEnum(util.objectKeys(this.shape));\n }\n }\n ZodObject.create = (shape, params) => {\n return new ZodObject({\n shape: () => shape,\n unknownKeys: "strip",\n catchall: ZodNever.create(),\n typeName: ZodFirstPartyTypeKind.ZodObject,\n ...processCreateParams(params)\n });\n };\n ZodObject.strictCreate = (shape, params) => {\n return new ZodObject({\n shape: () => shape,\n unknownKeys: "strict",\n catchall: ZodNever.create(),\n typeName: ZodFirstPartyTypeKind.ZodObject,\n ...processCreateParams(params)\n });\n };\n ZodObject.lazycreate = (shape, params) => {\n return new ZodObject({\n shape,\n unknownKeys: "strip",\n catchall: ZodNever.create(),\n typeName: ZodFirstPartyTypeKind.ZodObject,\n ...processCreateParams(params)\n });\n };\n class ZodUnion extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n const options = this._def.options;\n function handleResults(results) {\n for (const result of results) {\n if (result.result.status === "valid") {\n return result.result;\n }\n }\n for (const result of results) {\n if (result.result.status === "dirty") {\n ctx.common.issues.push(...result.ctx.common.issues);\n return result.result;\n }\n }\n const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_union,\n unionErrors\n });\n return INVALID;\n }\n if (ctx.common.async) {\n return Promise.all(options.map(async (option) => {\n const childCtx = {\n ...ctx,\n common: {\n ...ctx.common,\n issues: []\n },\n parent: null\n };\n return {\n result: await option._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: childCtx\n }),\n ctx: childCtx\n };\n })).then(handleResults);\n } else {\n let dirty = void 0;\n const issues = [];\n for (const option of options) {\n const childCtx = {\n ...ctx,\n common: {\n ...ctx.common,\n issues: []\n },\n parent: null\n };\n const result = option._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: childCtx\n });\n if (result.status === "valid") {\n return result;\n } else if (result.status === "dirty" && !dirty) {\n dirty = { result, ctx: childCtx };\n }\n if (childCtx.common.issues.length) {\n issues.push(childCtx.common.issues);\n }\n }\n if (dirty) {\n ctx.common.issues.push(...dirty.ctx.common.issues);\n return dirty.result;\n }\n const unionErrors = issues.map((issues2) => new ZodError(issues2));\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_union,\n unionErrors\n });\n return INVALID;\n }\n }\n get options() {\n return this._def.options;\n }\n }\n ZodUnion.create = (types, params) => {\n return new ZodUnion({\n options: types,\n typeName: ZodFirstPartyTypeKind.ZodUnion,\n ...processCreateParams(params)\n });\n };\n const getDiscriminator = (type) => {\n if (type instanceof ZodLazy) {\n return getDiscriminator(type.schema);\n } else if (type instanceof ZodEffects) {\n return getDiscriminator(type.innerType());\n } else if (type instanceof ZodLiteral) {\n return [type.value];\n } else if (type instanceof ZodEnum) {\n return type.options;\n } else if (type instanceof ZodNativeEnum) {\n return util.objectValues(type.enum);\n } else if (type instanceof ZodDefault) {\n return getDiscriminator(type._def.innerType);\n } else if (type instanceof ZodUndefined) {\n return [void 0];\n } else if (type instanceof ZodNull) {\n return [null];\n } else if (type instanceof ZodOptional) {\n return [void 0, ...getDiscriminator(type.unwrap())];\n } else if (type instanceof ZodNullable) {\n return [null, ...getDiscriminator(type.unwrap())];\n } else if (type instanceof ZodBranded) {\n return getDiscriminator(type.unwrap());\n } else if (type instanceof ZodReadonly) {\n return getDiscriminator(type.unwrap());\n } else if (type instanceof ZodCatch) {\n return getDiscriminator(type._def.innerType);\n } else {\n return [];\n }\n };\n class ZodDiscriminatedUnion extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.object) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.object,\n received: ctx.parsedType\n });\n return INVALID;\n }\n const discriminator = this.discriminator;\n const discriminatorValue = ctx.data[discriminator];\n const option = this.optionsMap.get(discriminatorValue);\n if (!option) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_union_discriminator,\n options: Array.from(this.optionsMap.keys()),\n path: [discriminator]\n });\n return INVALID;\n }\n if (ctx.common.async) {\n return option._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n });\n } else {\n return option._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n });\n }\n }\n get discriminator() {\n return this._def.discriminator;\n }\n get options() {\n return this._def.options;\n }\n get optionsMap() {\n return this._def.optionsMap;\n }\n /**\n * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.\n * However, it only allows a union of objects, all of which need to share a discriminator property. This property must\n * have a different value for each object in the union.\n * @param discriminator the name of the discriminator property\n * @param types an array of object schemas\n * @param params\n */\n static create(discriminator, options, params) {\n const optionsMap = /* @__PURE__ */ new Map();\n for (const type of options) {\n const discriminatorValues = getDiscriminator(type.shape[discriminator]);\n if (!discriminatorValues.length) {\n throw new Error(`A discriminator value for key \\`${discriminator}\\` could not be extracted from all schema options`);\n }\n for (const value of discriminatorValues) {\n if (optionsMap.has(value)) {\n throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);\n }\n optionsMap.set(value, type);\n }\n }\n return new ZodDiscriminatedUnion({\n typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,\n discriminator,\n options,\n optionsMap,\n ...processCreateParams(params)\n });\n }\n }\n function mergeValues(a2, b) {\n const aType = getParsedType(a2);\n const bType = getParsedType(b);\n if (a2 === b) {\n return { valid: true, data: a2 };\n } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {\n const bKeys = util.objectKeys(b);\n const sharedKeys = util.objectKeys(a2).filter((key) => bKeys.indexOf(key) !== -1);\n const newObj = { ...a2, ...b };\n for (const key of sharedKeys) {\n const sharedValue = mergeValues(a2[key], b[key]);\n if (!sharedValue.valid) {\n return { valid: false };\n }\n newObj[key] = sharedValue.data;\n }\n return { valid: true, data: newObj };\n } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {\n if (a2.length !== b.length) {\n return { valid: false };\n }\n const newArray = [];\n for (let index = 0; index < a2.length; index++) {\n const itemA = a2[index];\n const itemB = b[index];\n const sharedValue = mergeValues(itemA, itemB);\n if (!sharedValue.valid) {\n return { valid: false };\n }\n newArray.push(sharedValue.data);\n }\n return { valid: true, data: newArray };\n } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a2 === +b) {\n return { valid: true, data: a2 };\n } else {\n return { valid: false };\n }\n }\n class ZodIntersection extends ZodType {\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n const handleParsed = (parsedLeft, parsedRight) => {\n if (isAborted(parsedLeft) || isAborted(parsedRight)) {\n return INVALID;\n }\n const merged = mergeValues(parsedLeft.value, parsedRight.value);\n if (!merged.valid) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_intersection_types\n });\n return INVALID;\n }\n if (isDirty(parsedLeft) || isDirty(parsedRight)) {\n status.dirty();\n }\n return { status: status.value, value: merged.data };\n };\n if (ctx.common.async) {\n return Promise.all([\n this._def.left._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n }),\n this._def.right._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n })\n ]).then(([left, right]) => handleParsed(left, right));\n } else {\n return handleParsed(this._def.left._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n }), this._def.right._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n }));\n }\n }\n }\n ZodIntersection.create = (left, right, params) => {\n return new ZodIntersection({\n left,\n right,\n typeName: ZodFirstPartyTypeKind.ZodIntersection,\n ...processCreateParams(params)\n });\n };\n class ZodTuple extends ZodType {\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.array) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.array,\n received: ctx.parsedType\n });\n return INVALID;\n }\n if (ctx.data.length < this._def.items.length) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: this._def.items.length,\n inclusive: true,\n exact: false,\n type: "array"\n });\n return INVALID;\n }\n const rest = this._def.rest;\n if (!rest && ctx.data.length > this._def.items.length) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: this._def.items.length,\n inclusive: true,\n exact: false,\n type: "array"\n });\n status.dirty();\n }\n const items = [...ctx.data].map((item, itemIndex) => {\n const schema = this._def.items[itemIndex] || this._def.rest;\n if (!schema)\n return null;\n return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));\n }).filter((x) => !!x);\n if (ctx.common.async) {\n return Promise.all(items).then((results) => {\n return ParseStatus.mergeArray(status, results);\n });\n } else {\n return ParseStatus.mergeArray(status, items);\n }\n }\n get items() {\n return this._def.items;\n }\n rest(rest) {\n return new ZodTuple({\n ...this._def,\n rest\n });\n }\n }\n ZodTuple.create = (schemas, params) => {\n if (!Array.isArray(schemas)) {\n throw new Error("You must pass an array of schemas to z.tuple([ ... ])");\n }\n return new ZodTuple({\n items: schemas,\n typeName: ZodFirstPartyTypeKind.ZodTuple,\n rest: null,\n ...processCreateParams(params)\n });\n };\n class ZodRecord extends ZodType {\n get keySchema() {\n return this._def.keyType;\n }\n get valueSchema() {\n return this._def.valueType;\n }\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.object) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.object,\n received: ctx.parsedType\n });\n return INVALID;\n }\n const pairs = [];\n const keyType = this._def.keyType;\n const valueType = this._def.valueType;\n for (const key in ctx.data) {\n pairs.push({\n key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),\n value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),\n alwaysSet: key in ctx.data\n });\n }\n if (ctx.common.async) {\n return ParseStatus.mergeObjectAsync(status, pairs);\n } else {\n return ParseStatus.mergeObjectSync(status, pairs);\n }\n }\n get element() {\n return this._def.valueType;\n }\n static create(first, second, third) {\n if (second instanceof ZodType) {\n return new ZodRecord({\n keyType: first,\n valueType: second,\n typeName: ZodFirstPartyTypeKind.ZodRecord,\n ...processCreateParams(third)\n });\n }\n return new ZodRecord({\n keyType: ZodString.create(),\n valueType: first,\n typeName: ZodFirstPartyTypeKind.ZodRecord,\n ...processCreateParams(second)\n });\n }\n }\n class ZodMap extends ZodType {\n get keySchema() {\n return this._def.keyType;\n }\n get valueSchema() {\n return this._def.valueType;\n }\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.map) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.map,\n received: ctx.parsedType\n });\n return INVALID;\n }\n const keyType = this._def.keyType;\n const valueType = this._def.valueType;\n const pairs = [...ctx.data.entries()].map(([key, value], index) => {\n return {\n key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),\n value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))\n };\n });\n if (ctx.common.async) {\n const finalMap = /* @__PURE__ */ new Map();\n return Promise.resolve().then(async () => {\n for (const pair of pairs) {\n const key = await pair.key;\n const value = await pair.value;\n if (key.status === "aborted" || value.status === "aborted") {\n return INVALID;\n }\n if (key.status === "dirty" || value.status === "dirty") {\n status.dirty();\n }\n finalMap.set(key.value, value.value);\n }\n return { status: status.value, value: finalMap };\n });\n } else {\n const finalMap = /* @__PURE__ */ new Map();\n for (const pair of pairs) {\n const key = pair.key;\n const value = pair.value;\n if (key.status === "aborted" || value.status === "aborted") {\n return INVALID;\n }\n if (key.status === "dirty" || value.status === "dirty") {\n status.dirty();\n }\n finalMap.set(key.value, value.value);\n }\n return { status: status.value, value: finalMap };\n }\n }\n }\n ZodMap.create = (keyType, valueType, params) => {\n return new ZodMap({\n valueType,\n keyType,\n typeName: ZodFirstPartyTypeKind.ZodMap,\n ...processCreateParams(params)\n });\n };\n class ZodSet extends ZodType {\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.set) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.set,\n received: ctx.parsedType\n });\n return INVALID;\n }\n const def = this._def;\n if (def.minSize !== null) {\n if (ctx.data.size < def.minSize.value) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_small,\n minimum: def.minSize.value,\n type: "set",\n inclusive: true,\n exact: false,\n message: def.minSize.message\n });\n status.dirty();\n }\n }\n if (def.maxSize !== null) {\n if (ctx.data.size > def.maxSize.value) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.too_big,\n maximum: def.maxSize.value,\n type: "set",\n inclusive: true,\n exact: false,\n message: def.maxSize.message\n });\n status.dirty();\n }\n }\n const valueType = this._def.valueType;\n function finalizeSet(elements2) {\n const parsedSet = /* @__PURE__ */ new Set();\n for (const element of elements2) {\n if (element.status === "aborted")\n return INVALID;\n if (element.status === "dirty")\n status.dirty();\n parsedSet.add(element.value);\n }\n return { status: status.value, value: parsedSet };\n }\n const elements = [...ctx.data.values()].map((item, i2) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i2)));\n if (ctx.common.async) {\n return Promise.all(elements).then((elements2) => finalizeSet(elements2));\n } else {\n return finalizeSet(elements);\n }\n }\n min(minSize, message) {\n return new ZodSet({\n ...this._def,\n minSize: { value: minSize, message: errorUtil.toString(message) }\n });\n }\n max(maxSize, message) {\n return new ZodSet({\n ...this._def,\n maxSize: { value: maxSize, message: errorUtil.toString(message) }\n });\n }\n size(size, message) {\n return this.min(size, message).max(size, message);\n }\n nonempty(message) {\n return this.min(1, message);\n }\n }\n ZodSet.create = (valueType, params) => {\n return new ZodSet({\n valueType,\n minSize: null,\n maxSize: null,\n typeName: ZodFirstPartyTypeKind.ZodSet,\n ...processCreateParams(params)\n });\n };\n class ZodFunction extends ZodType {\n constructor() {\n super(...arguments);\n this.validate = this.implement;\n }\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.function) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.function,\n received: ctx.parsedType\n });\n return INVALID;\n }\n function makeArgsIssue(args, error) {\n return makeIssue({\n data: args,\n path: ctx.path,\n errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), errorMap].filter((x) => !!x),\n issueData: {\n code: ZodIssueCode.invalid_arguments,\n argumentsError: error\n }\n });\n }\n function makeReturnsIssue(returns, error) {\n return makeIssue({\n data: returns,\n path: ctx.path,\n errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), errorMap].filter((x) => !!x),\n issueData: {\n code: ZodIssueCode.invalid_return_type,\n returnTypeError: error\n }\n });\n }\n const params = { errorMap: ctx.common.contextualErrorMap };\n const fn = ctx.data;\n if (this._def.returns instanceof ZodPromise) {\n const me = this;\n return OK(async function(...args) {\n const error = new ZodError([]);\n const parsedArgs = await me._def.args.parseAsync(args, params).catch((e2) => {\n error.addIssue(makeArgsIssue(args, e2));\n throw error;\n });\n const result = await Reflect.apply(fn, this, parsedArgs);\n const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e2) => {\n error.addIssue(makeReturnsIssue(result, e2));\n throw error;\n });\n return parsedReturns;\n });\n } else {\n const me = this;\n return OK(function(...args) {\n const parsedArgs = me._def.args.safeParse(args, params);\n if (!parsedArgs.success) {\n throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);\n }\n const result = Reflect.apply(fn, this, parsedArgs.data);\n const parsedReturns = me._def.returns.safeParse(result, params);\n if (!parsedReturns.success) {\n throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);\n }\n return parsedReturns.data;\n });\n }\n }\n parameters() {\n return this._def.args;\n }\n returnType() {\n return this._def.returns;\n }\n args(...items) {\n return new ZodFunction({\n ...this._def,\n args: ZodTuple.create(items).rest(ZodUnknown.create())\n });\n }\n returns(returnType) {\n return new ZodFunction({\n ...this._def,\n returns: returnType\n });\n }\n implement(func) {\n const validatedFunc = this.parse(func);\n return validatedFunc;\n }\n strictImplement(func) {\n const validatedFunc = this.parse(func);\n return validatedFunc;\n }\n static create(args, returns, params) {\n return new ZodFunction({\n args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),\n returns: returns || ZodUnknown.create(),\n typeName: ZodFirstPartyTypeKind.ZodFunction,\n ...processCreateParams(params)\n });\n }\n }\n class ZodLazy extends ZodType {\n get schema() {\n return this._def.getter();\n }\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n const lazySchema = this._def.getter();\n return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });\n }\n }\n ZodLazy.create = (getter, params) => {\n return new ZodLazy({\n getter,\n typeName: ZodFirstPartyTypeKind.ZodLazy,\n ...processCreateParams(params)\n });\n };\n class ZodLiteral extends ZodType {\n _parse(input) {\n if (input.data !== this._def.value) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n received: ctx.data,\n code: ZodIssueCode.invalid_literal,\n expected: this._def.value\n });\n return INVALID;\n }\n return { status: "valid", value: input.data };\n }\n get value() {\n return this._def.value;\n }\n }\n ZodLiteral.create = (value, params) => {\n return new ZodLiteral({\n value,\n typeName: ZodFirstPartyTypeKind.ZodLiteral,\n ...processCreateParams(params)\n });\n };\n function createZodEnum(values, params) {\n return new ZodEnum({\n values,\n typeName: ZodFirstPartyTypeKind.ZodEnum,\n ...processCreateParams(params)\n });\n }\n class ZodEnum extends ZodType {\n _parse(input) {\n if (typeof input.data !== "string") {\n const ctx = this._getOrReturnCtx(input);\n const expectedValues = this._def.values;\n addIssueToContext(ctx, {\n expected: util.joinValues(expectedValues),\n received: ctx.parsedType,\n code: ZodIssueCode.invalid_type\n });\n return INVALID;\n }\n if (!this._cache) {\n this._cache = new Set(this._def.values);\n }\n if (!this._cache.has(input.data)) {\n const ctx = this._getOrReturnCtx(input);\n const expectedValues = this._def.values;\n addIssueToContext(ctx, {\n received: ctx.data,\n code: ZodIssueCode.invalid_enum_value,\n options: expectedValues\n });\n return INVALID;\n }\n return OK(input.data);\n }\n get options() {\n return this._def.values;\n }\n get enum() {\n const enumValues = {};\n for (const val of this._def.values) {\n enumValues[val] = val;\n }\n return enumValues;\n }\n get Values() {\n const enumValues = {};\n for (const val of this._def.values) {\n enumValues[val] = val;\n }\n return enumValues;\n }\n get Enum() {\n const enumValues = {};\n for (const val of this._def.values) {\n enumValues[val] = val;\n }\n return enumValues;\n }\n extract(values, newDef = this._def) {\n return ZodEnum.create(values, {\n ...this._def,\n ...newDef\n });\n }\n exclude(values, newDef = this._def) {\n return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {\n ...this._def,\n ...newDef\n });\n }\n }\n ZodEnum.create = createZodEnum;\n class ZodNativeEnum extends ZodType {\n _parse(input) {\n const nativeEnumValues = util.getValidEnumValues(this._def.values);\n const ctx = this._getOrReturnCtx(input);\n if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {\n const expectedValues = util.objectValues(nativeEnumValues);\n addIssueToContext(ctx, {\n expected: util.joinValues(expectedValues),\n received: ctx.parsedType,\n code: ZodIssueCode.invalid_type\n });\n return INVALID;\n }\n if (!this._cache) {\n this._cache = new Set(util.getValidEnumValues(this._def.values));\n }\n if (!this._cache.has(input.data)) {\n const expectedValues = util.objectValues(nativeEnumValues);\n addIssueToContext(ctx, {\n received: ctx.data,\n code: ZodIssueCode.invalid_enum_value,\n options: expectedValues\n });\n return INVALID;\n }\n return OK(input.data);\n }\n get enum() {\n return this._def.values;\n }\n }\n ZodNativeEnum.create = (values, params) => {\n return new ZodNativeEnum({\n values,\n typeName: ZodFirstPartyTypeKind.ZodNativeEnum,\n ...processCreateParams(params)\n });\n };\n class ZodPromise extends ZodType {\n unwrap() {\n return this._def.type;\n }\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.promise,\n received: ctx.parsedType\n });\n return INVALID;\n }\n const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);\n return OK(promisified.then((data) => {\n return this._def.type.parseAsync(data, {\n path: ctx.path,\n errorMap: ctx.common.contextualErrorMap\n });\n }));\n }\n }\n ZodPromise.create = (schema, params) => {\n return new ZodPromise({\n type: schema,\n typeName: ZodFirstPartyTypeKind.ZodPromise,\n ...processCreateParams(params)\n });\n };\n class ZodEffects extends ZodType {\n innerType() {\n return this._def.schema;\n }\n sourceType() {\n return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;\n }\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n const effect = this._def.effect || null;\n const checkCtx = {\n addIssue: (arg) => {\n addIssueToContext(ctx, arg);\n if (arg.fatal) {\n status.abort();\n } else {\n status.dirty();\n }\n },\n get path() {\n return ctx.path;\n }\n };\n checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);\n if (effect.type === "preprocess") {\n const processed = effect.transform(ctx.data, checkCtx);\n if (ctx.common.async) {\n return Promise.resolve(processed).then(async (processed2) => {\n if (status.value === "aborted")\n return INVALID;\n const result = await this._def.schema._parseAsync({\n data: processed2,\n path: ctx.path,\n parent: ctx\n });\n if (result.status === "aborted")\n return INVALID;\n if (result.status === "dirty")\n return DIRTY(result.value);\n if (status.value === "dirty")\n return DIRTY(result.value);\n return result;\n });\n } else {\n if (status.value === "aborted")\n return INVALID;\n const result = this._def.schema._parseSync({\n data: processed,\n path: ctx.path,\n parent: ctx\n });\n if (result.status === "aborted")\n return INVALID;\n if (result.status === "dirty")\n return DIRTY(result.value);\n if (status.value === "dirty")\n return DIRTY(result.value);\n return result;\n }\n }\n if (effect.type === "refinement") {\n const executeRefinement = (acc) => {\n const result = effect.refinement(acc, checkCtx);\n if (ctx.common.async) {\n return Promise.resolve(result);\n }\n if (result instanceof Promise) {\n throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");\n }\n return acc;\n };\n if (ctx.common.async === false) {\n const inner = this._def.schema._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n });\n if (inner.status === "aborted")\n return INVALID;\n if (inner.status === "dirty")\n status.dirty();\n executeRefinement(inner.value);\n return { status: status.value, value: inner.value };\n } else {\n return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {\n if (inner.status === "aborted")\n return INVALID;\n if (inner.status === "dirty")\n status.dirty();\n return executeRefinement(inner.value).then(() => {\n return { status: status.value, value: inner.value };\n });\n });\n }\n }\n if (effect.type === "transform") {\n if (ctx.common.async === false) {\n const base = this._def.schema._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n });\n if (!isValid(base))\n return INVALID;\n const result = effect.transform(base.value, checkCtx);\n if (result instanceof Promise) {\n throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);\n }\n return { status: status.value, value: result };\n } else {\n return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {\n if (!isValid(base))\n return INVALID;\n return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({\n status: status.value,\n value: result\n }));\n });\n }\n }\n util.assertNever(effect);\n }\n }\n ZodEffects.create = (schema, effect, params) => {\n return new ZodEffects({\n schema,\n typeName: ZodFirstPartyTypeKind.ZodEffects,\n effect,\n ...processCreateParams(params)\n });\n };\n ZodEffects.createWithPreprocess = (preprocess, schema, params) => {\n return new ZodEffects({\n schema,\n effect: { type: "preprocess", transform: preprocess },\n typeName: ZodFirstPartyTypeKind.ZodEffects,\n ...processCreateParams(params)\n });\n };\n class ZodOptional extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType === ZodParsedType.undefined) {\n return OK(void 0);\n }\n return this._def.innerType._parse(input);\n }\n unwrap() {\n return this._def.innerType;\n }\n }\n ZodOptional.create = (type, params) => {\n return new ZodOptional({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodOptional,\n ...processCreateParams(params)\n });\n };\n class ZodNullable extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType === ZodParsedType.null) {\n return OK(null);\n }\n return this._def.innerType._parse(input);\n }\n unwrap() {\n return this._def.innerType;\n }\n }\n ZodNullable.create = (type, params) => {\n return new ZodNullable({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodNullable,\n ...processCreateParams(params)\n });\n };\n class ZodDefault extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n let data = ctx.data;\n if (ctx.parsedType === ZodParsedType.undefined) {\n data = this._def.defaultValue();\n }\n return this._def.innerType._parse({\n data,\n path: ctx.path,\n parent: ctx\n });\n }\n removeDefault() {\n return this._def.innerType;\n }\n }\n ZodDefault.create = (type, params) => {\n return new ZodDefault({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodDefault,\n defaultValue: typeof params.default === "function" ? params.default : () => params.default,\n ...processCreateParams(params)\n });\n };\n class ZodCatch extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n const newCtx = {\n ...ctx,\n common: {\n ...ctx.common,\n issues: []\n }\n };\n const result = this._def.innerType._parse({\n data: newCtx.data,\n path: newCtx.path,\n parent: {\n ...newCtx\n }\n });\n if (isAsync(result)) {\n return result.then((result2) => {\n return {\n status: "valid",\n value: result2.status === "valid" ? result2.value : this._def.catchValue({\n get error() {\n return new ZodError(newCtx.common.issues);\n },\n input: newCtx.data\n })\n };\n });\n } else {\n return {\n status: "valid",\n value: result.status === "valid" ? result.value : this._def.catchValue({\n get error() {\n return new ZodError(newCtx.common.issues);\n },\n input: newCtx.data\n })\n };\n }\n }\n removeCatch() {\n return this._def.innerType;\n }\n }\n ZodCatch.create = (type, params) => {\n return new ZodCatch({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodCatch,\n catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,\n ...processCreateParams(params)\n });\n };\n class ZodNaN extends ZodType {\n _parse(input) {\n const parsedType = this._getType(input);\n if (parsedType !== ZodParsedType.nan) {\n const ctx = this._getOrReturnCtx(input);\n addIssueToContext(ctx, {\n code: ZodIssueCode.invalid_type,\n expected: ZodParsedType.nan,\n received: ctx.parsedType\n });\n return INVALID;\n }\n return { status: "valid", value: input.data };\n }\n }\n ZodNaN.create = (params) => {\n return new ZodNaN({\n typeName: ZodFirstPartyTypeKind.ZodNaN,\n ...processCreateParams(params)\n });\n };\n const BRAND = Symbol("zod_brand");\n class ZodBranded extends ZodType {\n _parse(input) {\n const { ctx } = this._processInputParams(input);\n const data = ctx.data;\n return this._def.type._parse({\n data,\n path: ctx.path,\n parent: ctx\n });\n }\n unwrap() {\n return this._def.type;\n }\n }\n class ZodPipeline extends ZodType {\n _parse(input) {\n const { status, ctx } = this._processInputParams(input);\n if (ctx.common.async) {\n const handleAsync = async () => {\n const inResult = await this._def.in._parseAsync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n });\n if (inResult.status === "aborted")\n return INVALID;\n if (inResult.status === "dirty") {\n status.dirty();\n return DIRTY(inResult.value);\n } else {\n return this._def.out._parseAsync({\n data: inResult.value,\n path: ctx.path,\n parent: ctx\n });\n }\n };\n return handleAsync();\n } else {\n const inResult = this._def.in._parseSync({\n data: ctx.data,\n path: ctx.path,\n parent: ctx\n });\n if (inResult.status === "aborted")\n return INVALID;\n if (inResult.status === "dirty") {\n status.dirty();\n return {\n status: "dirty",\n value: inResult.value\n };\n } else {\n return this._def.out._parseSync({\n data: inResult.value,\n path: ctx.path,\n parent: ctx\n });\n }\n }\n }\n static create(a2, b) {\n return new ZodPipeline({\n in: a2,\n out: b,\n typeName: ZodFirstPartyTypeKind.ZodPipeline\n });\n }\n }\n class ZodReadonly extends ZodType {\n _parse(input) {\n const result = this._def.innerType._parse(input);\n const freeze = (data) => {\n if (isValid(data)) {\n data.value = Object.freeze(data.value);\n }\n return data;\n };\n return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);\n }\n unwrap() {\n return this._def.innerType;\n }\n }\n ZodReadonly.create = (type, params) => {\n return new ZodReadonly({\n innerType: type,\n typeName: ZodFirstPartyTypeKind.ZodReadonly,\n ...processCreateParams(params)\n });\n };\n function cleanParams(params, data) {\n const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;\n const p2 = typeof p === "string" ? { message: p } : p;\n return p2;\n }\n function custom(check, _params = {}, fatal) {\n if (check)\n return ZodAny.create().superRefine((data, ctx) => {\n const r2 = check(data);\n if (r2 instanceof Promise) {\n return r2.then((r3) => {\n if (!r3) {\n const params = cleanParams(_params, data);\n const _fatal = params.fatal ?? fatal ?? true;\n ctx.addIssue({ code: "custom", ...params, fatal: _fatal });\n }\n });\n }\n if (!r2) {\n const params = cleanParams(_params, data);\n const _fatal = params.fatal ?? fatal ?? true;\n ctx.addIssue({ code: "custom", ...params, fatal: _fatal });\n }\n return;\n });\n return ZodAny.create();\n }\n const late = {\n object: ZodObject.lazycreate\n };\n var ZodFirstPartyTypeKind;\n (function(ZodFirstPartyTypeKind2) {\n ZodFirstPartyTypeKind2["ZodString"] = "ZodString";\n ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";\n ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";\n ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";\n ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";\n ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";\n ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";\n ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";\n ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";\n ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";\n ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";\n ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";\n ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";\n ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";\n ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";\n ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";\n ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";\n ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";\n ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";\n ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";\n ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";\n ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";\n ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";\n ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";\n ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";\n ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";\n ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";\n ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";\n ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";\n ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";\n ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";\n ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";\n ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";\n ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";\n ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";\n ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";\n })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));\n const instanceOfType = (cls, params = {\n message: `Input not instance of ${cls.name}`\n }) => custom((data) => data instanceof cls, params);\n const stringType = ZodString.create;\n const numberType = ZodNumber.create;\n const nanType = ZodNaN.create;\n const bigIntType = ZodBigInt.create;\n const booleanType = ZodBoolean.create;\n const dateType = ZodDate.create;\n const symbolType = ZodSymbol.create;\n const undefinedType = ZodUndefined.create;\n const nullType = ZodNull.create;\n const anyType = ZodAny.create;\n const unknownType = ZodUnknown.create;\n const neverType = ZodNever.create;\n const voidType = ZodVoid.create;\n const arrayType = ZodArray.create;\n const objectType = ZodObject.create;\n const strictObjectType = ZodObject.strictCreate;\n const unionType = ZodUnion.create;\n const discriminatedUnionType = ZodDiscriminatedUnion.create;\n const intersectionType = ZodIntersection.create;\n const tupleType = ZodTuple.create;\n const recordType = ZodRecord.create;\n const mapType = ZodMap.create;\n const setType = ZodSet.create;\n const functionType = ZodFunction.create;\n const lazyType = ZodLazy.create;\n const literalType = ZodLiteral.create;\n const enumType = ZodEnum.create;\n const nativeEnumType = ZodNativeEnum.create;\n const promiseType = ZodPromise.create;\n const effectsType = ZodEffects.create;\n const optionalType = ZodOptional.create;\n const nullableType = ZodNullable.create;\n const preprocessType = ZodEffects.createWithPreprocess;\n const pipelineType = ZodPipeline.create;\n const ostring = () => stringType().optional();\n const onumber = () => numberType().optional();\n const oboolean = () => booleanType().optional();\n const coerce = {\n string: (arg) => ZodString.create({ ...arg, coerce: true }),\n number: (arg) => ZodNumber.create({ ...arg, coerce: true }),\n boolean: (arg) => ZodBoolean.create({\n ...arg,\n coerce: true\n }),\n bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),\n date: (arg) => ZodDate.create({ ...arg, coerce: true })\n };\n const NEVER = INVALID;\n var z$1 = /* @__PURE__ */ Object.freeze({\n __proto__: null,\n BRAND,\n DIRTY,\n EMPTY_PATH,\n INVALID,\n NEVER,\n OK,\n ParseStatus,\n Schema: ZodType,\n ZodAny,\n ZodArray,\n ZodBigInt,\n ZodBoolean,\n ZodBranded,\n ZodCatch,\n ZodDate,\n ZodDefault,\n ZodDiscriminatedUnion,\n ZodEffects,\n ZodEnum,\n ZodError,\n get ZodFirstPartyTypeKind() {\n return ZodFirstPartyTypeKind;\n },\n ZodFunction,\n ZodIntersection,\n ZodIssueCode,\n ZodLazy,\n ZodLiteral,\n ZodMap,\n ZodNaN,\n ZodNativeEnum,\n ZodNever,\n ZodNull,\n ZodNullable,\n ZodNumber,\n ZodObject,\n ZodOptional,\n ZodParsedType,\n ZodPipeline,\n ZodPromise,\n ZodReadonly,\n ZodRecord,\n ZodSchema: ZodType,\n ZodSet,\n ZodString,\n ZodSymbol,\n ZodTransformer: ZodEffects,\n ZodTuple,\n ZodType,\n ZodUndefined,\n ZodUnion,\n ZodUnknown,\n ZodVoid,\n addIssueToContext,\n any: anyType,\n array: arrayType,\n bigint: bigIntType,\n boolean: booleanType,\n coerce,\n custom,\n date: dateType,\n datetimeRegex,\n defaultErrorMap: errorMap,\n discriminatedUnion: discriminatedUnionType,\n effect: effectsType,\n enum: enumType,\n function: functionType,\n getErrorMap,\n getParsedType,\n instanceof: instanceOfType,\n intersection: intersectionType,\n isAborted,\n isAsync,\n isDirty,\n isValid,\n late,\n lazy: lazyType,\n literal: literalType,\n makeIssue,\n map: mapType,\n nan: nanType,\n nativeEnum: nativeEnumType,\n never: neverType,\n null: nullType,\n nullable: nullableType,\n number: numberType,\n object: objectType,\n get objectUtil() {\n return objectUtil;\n },\n oboolean,\n onumber,\n optional: optionalType,\n ostring,\n pipeline: pipelineType,\n preprocess: preprocessType,\n promise: promiseType,\n quotelessJson,\n record: recordType,\n set: setType,\n setErrorMap,\n strictObject: strictObjectType,\n string: stringType,\n symbol: symbolType,\n transformer: effectsType,\n tuple: tupleType,\n undefined: undefinedType,\n union: unionType,\n unknown: unknownType,\n get util() {\n return util;\n },\n void: voidType\n });\n z$1.object({\n nucleotideSequences: z$1.array(\n z$1.object({\n name: z$1.string(),\n sequence: z$1.string()\n })\n ),\n genes: z$1.array(\n z$1.object({\n name: z$1.string(),\n sequence: z$1.string()\n })\n )\n });\n const orderByType = z$1.enum(["ascending", "descending"]);\n const orderBy = z$1.object({\n field: z$1.string(),\n type: orderByType\n });\n const filterValue = z$1.union([z$1.string(), z$1.number(), z$1.boolean(), z$1.null(), z$1.undefined(), z$1.array(z$1.string())]);\n const dateRange = z$1.object({\n dateFrom: z$1.string(),\n dateTo: z$1.string()\n });\n const lapisBaseRequest = z$1.object({\n limit: z$1.number().optional(),\n offset: z$1.number().optional(),\n fields: z$1.array(z$1.string()).optional(),\n orderBy: z$1.array(orderBy).optional()\n }).catchall(filterValue);\n lapisBaseRequest.extend({ minProportion: z$1.number().optional() });\n const mutationProportionCount = z$1.object({\n mutation: z$1.string(),\n proportion: z$1.number(),\n count: z$1.number(),\n sequenceName: z$1.union([z$1.string(), z$1.null()]),\n mutationFrom: z$1.string(),\n mutationTo: z$1.string(),\n position: z$1.number()\n });\n const mutationsResponse = makeLapisResponse(z$1.array(mutationProportionCount));\n z$1.object({\n filters: z$1.record(filterValue),\n downloadAsFile: z$1.boolean().optional(),\n downloadFileBasename: z$1.string().optional(),\n compression: z$1.enum(["gzip", "none"]).optional(),\n includeMutations: z$1.array(z$1.string()).optional(),\n dateRanges: z$1.array(dateRange).optional(),\n dateField: z$1.string().optional()\n });\n const mutationsOverTimeResponse = makeLapisResponse(\n z$1.object({\n mutations: z$1.array(z$1.string()),\n dateRanges: z$1.array(dateRange),\n data: z$1.array(\n z$1.array(\n z$1.object({\n count: z$1.number(),\n coverage: z$1.number()\n })\n )\n )\n })\n );\n const insertionCount = z$1.object({\n insertion: z$1.string(),\n count: z$1.number(),\n insertedSymbols: z$1.string(),\n position: z$1.number(),\n sequenceName: z$1.union([z$1.string(), z$1.null()])\n });\n makeLapisResponse(z$1.array(insertionCount));\n const baseResponseValueSchema = z$1.union([z$1.string(), z$1.number(), z$1.boolean(), z$1.null()]);\n const aggregatedItem = z$1.object({ count: z$1.number() }).catchall(baseResponseValueSchema);\n const aggregatedResponse = makeLapisResponse(z$1.array(aggregatedItem));\n const detailsItem = z$1.object({}).catchall(baseResponseValueSchema);\n makeLapisResponse(z$1.array(detailsItem));\n function makeLapisResponse(data) {\n return z$1.object({\n data\n });\n }\n const problemDetail = z$1.object({\n title: z$1.string().optional(),\n status: z$1.number(),\n detail: z$1.string().optional(),\n type: z$1.string(),\n instance: z$1.string().optional()\n });\n const lapisError = z$1.object({\n error: problemDetail\n });\n const lineage = z$1.object({\n parents: z$1.array(z$1.string()).optional(),\n aliases: z$1.array(z$1.string()).optional()\n });\n z$1.record(lineage);\n class UnknownLapisError extends Error {\n constructor(message, status, requestedData) {\n super(message);\n this.status = status;\n this.requestedData = requestedData;\n this.name = "UnknownLapisError";\n }\n }\n class LapisError extends Error {\n constructor(message, status, problemDetail2, requestedData) {\n super(message);\n this.status = status;\n this.problemDetail = problemDetail2;\n this.requestedData = requestedData;\n this.name = "LapisError";\n }\n }\n async function fetchAggregated(lapisUrl, body, signal) {\n const response = await callLapis(\n aggregatedEndpoint(lapisUrl),\n {\n method: "POST",\n headers: {\n "Content-Type": "application/json"\n },\n body: JSON.stringify(body),\n signal\n },\n "aggregated data"\n );\n return aggregatedResponse.parse(await response.json());\n }\n async function fetchSubstitutionsOrDeletions(lapisUrl, body, sequenceType, signal) {\n const response = await callLapis(\n substitutionsOrDeletionsEndpoint(lapisUrl, sequenceType),\n {\n method: "POST",\n headers: {\n "Content-Type": "application/json"\n },\n body: JSON.stringify(body),\n signal\n },\n `${sequenceType} mutations`\n );\n return mutationsResponse.parse(await response.json());\n }\n async function fetchMutationsOverTime(lapisUrl, body, sequenceType, signal) {\n const response = await callLapis(\n mutationsOverTimeEndpoint(lapisUrl, sequenceType),\n {\n method: "POST",\n headers: {\n "Content-Type": "application/json"\n },\n body: JSON.stringify(body),\n signal\n },\n `${sequenceType} mutations over time`\n );\n return mutationsOverTimeResponse.parse(await response.json());\n }\n async function callLapis(input, init, requestedDataName) {\n try {\n const response = await fetch(input, init);\n await handleErrors(response, requestedDataName);\n return response;\n } catch (error) {\n const message = error instanceof Error ? error.message : `${error}`;\n throw new UnknownLapisError(`Failed to connect to LAPIS: ${message}`, 500, requestedDataName);\n }\n }\n const handleErrors = async (response, requestedData) => {\n if (!response.ok) {\n if (response.status >= 400 && response.status < 500) {\n const json = await response.json();\n const lapisErrorResult = lapisError.safeParse(json);\n if (lapisErrorResult.success) {\n throw new LapisError(\n response.statusText + (lapisErrorResult.data.error.detail ?? ""),\n response.status,\n lapisErrorResult.data.error,\n requestedData\n );\n }\n const problemDetailResult = problemDetail.safeParse(json);\n if (problemDetailResult.success) {\n throw new LapisError(\n response.statusText + (problemDetailResult.data.detail ?? ""),\n response.status,\n problemDetailResult.data,\n requestedData\n );\n }\n throw new UnknownLapisError(\n `${response.statusText}: ${JSON.stringify(json)}`,\n response.status,\n requestedData\n );\n }\n throw new UnknownLapisError(`${response.statusText}: ${response.status}`, response.status, requestedData);\n }\n };\n const aggregatedEndpoint = (lapisUrl) => `${lapisUrl}/sample/aggregated`;\n const substitutionsOrDeletionsEndpoint = (lapisUrl, sequenceType) => {\n return sequenceType === "amino acid" ? `${lapisUrl}/sample/aminoAcidMutations` : `${lapisUrl}/sample/nucleotideMutations`;\n };\n const mutationsOverTimeEndpoint = (lapisUrl, sequenceType) => {\n return sequenceType === "amino acid" ? `${lapisUrl}/component/aminoAcidMutationsOverTime` : `${lapisUrl}/component/nucleotideMutationsOverTime`;\n };\n class FetchAggregatedOperator {\n constructor(filter, fields = []) {\n this.filter = filter;\n this.fields = fields;\n }\n async evaluate(lapisUrl, signal) {\n const aggregatedResponse2 = (await fetchAggregated(\n lapisUrl,\n {\n ...this.filter,\n fields: this.fields\n },\n signal\n )).data;\n if (isFieldsArrayWithCount(aggregatedResponse2)) {\n return {\n content: aggregatedResponse2\n };\n }\n throw new Error("Aggregated response does not have count");\n }\n }\n function isFieldsArrayWithCount(data) {\n return data.every((item) => typeof item === "object" && "count" in item && typeof item.count === "number");\n }\n class GroupByOperator {\n constructor(child, field, aggregate) {\n this.child = child;\n this.field = field;\n this.aggregate = aggregate;\n }\n async evaluate(lapis, signal) {\n const childEvaluated = await this.child.evaluate(lapis, signal);\n const grouped = /* @__PURE__ */ new Map();\n for (const row of childEvaluated.content) {\n const key = row[this.field];\n if (!grouped.has(key)) {\n grouped.set(key, []);\n }\n grouped.get(key).push(row);\n }\n const result = new Array();\n for (const [, values] of grouped) {\n result.push(this.aggregate(values));\n }\n return {\n content: result\n };\n }\n }\n class GroupByAndSumOperator extends GroupByOperator {\n constructor(child, groupByField, sumField) {\n super(child, groupByField, (values) => {\n let n = 0;\n for (const value of values) {\n n += value[sumField];\n }\n return {\n [groupByField]: values[0][groupByField],\n [sumField]: n\n };\n });\n }\n }\n class MapOperator {\n constructor(child, func) {\n this.child = child;\n this.func = func;\n }\n async evaluate(lapis, signal) {\n const childEvaluated = await this.child.evaluate(lapis, signal);\n return {\n content: childEvaluated.content.map(this.func)\n };\n }\n }\n class RenameFieldOperator extends MapOperator {\n constructor(child, oldFieldName, newFieldName) {\n super(\n child,\n (value) => ({\n ...value,\n [newFieldName]: value[oldFieldName]\n })\n );\n }\n }\n class SortOperator {\n constructor(child, compareFn) {\n this.child = child;\n this.compareFn = compareFn;\n }\n async evaluate(lapis, signal) {\n const childEvaluated = await this.child.evaluate(lapis, signal);\n return {\n content: childEvaluated.content.sort(this.compareFn)\n };\n }\n }\n var SECONDS_A_MINUTE = 60;\n var SECONDS_A_HOUR = SECONDS_A_MINUTE * 60;\n var SECONDS_A_DAY = SECONDS_A_HOUR * 24;\n var SECONDS_A_WEEK = SECONDS_A_DAY * 7;\n var MILLISECONDS_A_SECOND = 1e3;\n var MILLISECONDS_A_MINUTE = SECONDS_A_MINUTE * MILLISECONDS_A_SECOND;\n var MILLISECONDS_A_HOUR = SECONDS_A_HOUR * MILLISECONDS_A_SECOND;\n var MILLISECONDS_A_DAY = SECONDS_A_DAY * MILLISECONDS_A_SECOND;\n var MILLISECONDS_A_WEEK = SECONDS_A_WEEK * MILLISECONDS_A_SECOND;\n var MS = "millisecond";\n var S = "second";\n var MIN = "minute";\n var H = "hour";\n var D = "day";\n var W = "week";\n var M = "month";\n var Q = "quarter";\n var Y = "year";\n var DATE = "date";\n var FORMAT_DEFAULT = "YYYY-MM-DDTHH:mm:ssZ";\n var INVALID_DATE_STRING = "Invalid Date";\n var REGEX_PARSE = /^(\\d{4})[-/]?(\\d{1,2})?[-/]?(\\d{0,2})[Tt\\s]*(\\d{1,2})?:?(\\d{1,2})?:?(\\d{1,2})?[.:]?(\\d+)?$/;\n var REGEX_FORMAT = /\\[([^\\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g;\n var en = {\n name: "en",\n weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),\n months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),\n ordinal: function ordinal(n) {\n var s2 = ["th", "st", "nd", "rd"];\n var v2 = n % 100;\n return "[" + n + (s2[(v2 - 20) % 10] || s2[v2] || s2[0]) + "]";\n }\n };\n var padStart = function padStart2(string, length, pad) {\n var s2 = String(string);\n if (!s2 || s2.length >= length) return string;\n return "" + Array(length + 1 - s2.length).join(pad) + string;\n };\n var padZoneStr = function padZoneStr2(instance) {\n var negMinutes = -instance.utcOffset();\n var minutes = Math.abs(negMinutes);\n var hourOffset = Math.floor(minutes / 60);\n var minuteOffset = minutes % 60;\n return (negMinutes <= 0 ? "+" : "-") + padStart(hourOffset, 2, "0") + ":" + padStart(minuteOffset, 2, "0");\n };\n var monthDiff = function monthDiff2(a2, b) {\n if (a2.date() < b.date()) return -monthDiff2(b, a2);\n var wholeMonthDiff = (b.year() - a2.year()) * 12 + (b.month() - a2.month());\n var anchor = a2.clone().add(wholeMonthDiff, M);\n var c2 = b - anchor < 0;\n var anchor2 = a2.clone().add(wholeMonthDiff + (c2 ? -1 : 1), M);\n return +(-(wholeMonthDiff + (b - anchor) / (c2 ? anchor - anchor2 : anchor2 - anchor)) || 0);\n };\n var absFloor = function absFloor2(n) {\n return n < 0 ? Math.ceil(n) || 0 : Math.floor(n);\n };\n var prettyUnit = function prettyUnit2(u2) {\n var special = {\n M,\n y: Y,\n w: W,\n d: D,\n D: DATE,\n h: H,\n m: MIN,\n s: S,\n ms: MS,\n Q\n };\n return special[u2] || String(u2 || "").toLowerCase().replace(/s$/, "");\n };\n var isUndefined = function isUndefined2(s2) {\n return s2 === void 0;\n };\n var U = {\n s: padStart,\n z: padZoneStr,\n m: monthDiff,\n a: absFloor,\n p: prettyUnit,\n u: isUndefined\n };\n var L = "en";\n var Ls = {};\n Ls[L] = en;\n var IS_DAYJS = "$isDayjsObject";\n var isDayjs = function isDayjs2(d) {\n return d instanceof Dayjs || !!(d && d[IS_DAYJS]);\n };\n var parseLocale = function parseLocale2(preset, object, isLocal) {\n var l2;\n if (!preset) return L;\n if (typeof preset === "string") {\n var presetLower = preset.toLowerCase();\n if (Ls[presetLower]) {\n l2 = presetLower;\n }\n if (object) {\n Ls[presetLower] = object;\n l2 = presetLower;\n }\n var presetSplit = preset.split("-");\n if (!l2 && presetSplit.length > 1) {\n return parseLocale2(presetSplit[0]);\n }\n } else {\n var name = preset.name;\n Ls[name] = preset;\n l2 = name;\n }\n if (!isLocal && l2) L = l2;\n return l2 || !isLocal && L;\n };\n var dayjs = function dayjs2(date, c2) {\n if (isDayjs(date)) {\n return date.clone();\n }\n var cfg = typeof c2 === "object" ? c2 : {};\n cfg.date = date;\n cfg.args = arguments;\n return new Dayjs(cfg);\n };\n var wrapper = function wrapper2(date, instance) {\n return dayjs(date, {\n locale: instance.$L,\n utc: instance.$u,\n x: instance.$x,\n $offset: instance.$offset\n // todo: refactor; do not use this.$offset in you code\n });\n };\n var Utils = U;\n Utils.l = parseLocale;\n Utils.i = isDayjs;\n Utils.w = wrapper;\n var parseDate = function parseDate2(cfg) {\n var date = cfg.date, utc = cfg.utc;\n if (date === null) return /* @__PURE__ */ new Date(NaN);\n if (Utils.u(date)) return /* @__PURE__ */ new Date();\n if (date instanceof Date) return new Date(date);\n if (typeof date === "string" && !/Z$/i.test(date)) {\n var d = date.match(REGEX_PARSE);\n if (d) {\n var m2 = d[2] - 1 || 0;\n var ms = (d[7] || "0").substring(0, 3);\n if (utc) {\n return new Date(Date.UTC(d[1], m2, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms));\n }\n return new Date(d[1], m2, d[3] || 1, d[4] || 0, d[5] || 0, d[6] || 0, ms);\n }\n }\n return new Date(date);\n };\n var Dayjs = /* @__PURE__ */ function() {\n function Dayjs2(cfg) {\n this.$L = parseLocale(cfg.locale, null, true);\n this.parse(cfg);\n this.$x = this.$x || cfg.x || {};\n this[IS_DAYJS] = true;\n }\n var _proto = Dayjs2.prototype;\n _proto.parse = function parse(cfg) {\n this.$d = parseDate(cfg);\n this.init();\n };\n _proto.init = function init() {\n var $d = this.$d;\n this.$y = $d.getFullYear();\n this.$M = $d.getMonth();\n this.$D = $d.getDate();\n this.$W = $d.getDay();\n this.$H = $d.getHours();\n this.$m = $d.getMinutes();\n this.$s = $d.getSeconds();\n this.$ms = $d.getMilliseconds();\n };\n _proto.$utils = function $utils() {\n return Utils;\n };\n _proto.isValid = function isValid2() {\n return !(this.$d.toString() === INVALID_DATE_STRING);\n };\n _proto.isSame = function isSame(that, units) {\n var other = dayjs(that);\n return this.startOf(units) <= other && other <= this.endOf(units);\n };\n _proto.isAfter = function isAfter(that, units) {\n return dayjs(that) < this.startOf(units);\n };\n _proto.isBefore = function isBefore(that, units) {\n return this.endOf(units) < dayjs(that);\n };\n _proto.$g = function $g(input, get, set) {\n if (Utils.u(input)) return this[get];\n return this.set(set, input);\n };\n _proto.unix = function unix() {\n return Math.floor(this.valueOf() / 1e3);\n };\n _proto.valueOf = function valueOf() {\n return this.$d.getTime();\n };\n _proto.startOf = function startOf(units, _startOf) {\n var _this = this;\n var isStartOf = !Utils.u(_startOf) ? _startOf : true;\n var unit = Utils.p(units);\n var instanceFactory = function instanceFactory2(d, m2) {\n var ins = Utils.w(_this.$u ? Date.UTC(_this.$y, m2, d) : new Date(_this.$y, m2, d), _this);\n return isStartOf ? ins : ins.endOf(D);\n };\n var instanceFactorySet = function instanceFactorySet2(method, slice) {\n var argumentStart = [0, 0, 0, 0];\n var argumentEnd = [23, 59, 59, 999];\n return Utils.w(_this.toDate()[method].apply(\n // eslint-disable-line prefer-spread\n _this.toDate("s"),\n (isStartOf ? argumentStart : argumentEnd).slice(slice)\n ), _this);\n };\n var $W = this.$W, $M = this.$M, $D = this.$D;\n var utcPad = "set" + (this.$u ? "UTC" : "");\n switch (unit) {\n case Y:\n return isStartOf ? instanceFactory(1, 0) : instanceFactory(31, 11);\n case M:\n return isStartOf ? instanceFactory(1, $M) : instanceFactory(0, $M + 1);\n case W: {\n var weekStart = this.$locale().weekStart || 0;\n var gap = ($W < weekStart ? $W + 7 : $W) - weekStart;\n return instanceFactory(isStartOf ? $D - gap : $D + (6 - gap), $M);\n }\n case D:\n case DATE:\n return instanceFactorySet(utcPad + "Hours", 0);\n case H:\n return instanceFactorySet(utcPad + "Minutes", 1);\n case MIN:\n return instanceFactorySet(utcPad + "Seconds", 2);\n case S:\n return instanceFactorySet(utcPad + "Milliseconds", 3);\n default:\n return this.clone();\n }\n };\n _proto.endOf = function endOf(arg) {\n return this.startOf(arg, false);\n };\n _proto.$set = function $set(units, _int) {\n var _C$D$C$DATE$C$M$C$Y$C;\n var unit = Utils.p(units);\n var utcPad = "set" + (this.$u ? "UTC" : "");\n var name = (_C$D$C$DATE$C$M$C$Y$C = {}, _C$D$C$DATE$C$M$C$Y$C[D] = utcPad + "Date", _C$D$C$DATE$C$M$C$Y$C[DATE] = utcPad + "Date", _C$D$C$DATE$C$M$C$Y$C[M] = utcPad + "Month", _C$D$C$DATE$C$M$C$Y$C[Y] = utcPad + "FullYear", _C$D$C$DATE$C$M$C$Y$C[H] = utcPad + "Hours", _C$D$C$DATE$C$M$C$Y$C[MIN] = utcPad + "Minutes", _C$D$C$DATE$C$M$C$Y$C[S] = utcPad + "Seconds", _C$D$C$DATE$C$M$C$Y$C[MS] = utcPad + "Milliseconds", _C$D$C$DATE$C$M$C$Y$C)[unit];\n var arg = unit === D ? this.$D + (_int - this.$W) : _int;\n if (unit === M || unit === Y) {\n var date = this.clone().set(DATE, 1);\n date.$d[name](arg);\n date.init();\n this.$d = date.set(DATE, Math.min(this.$D, date.daysInMonth())).$d;\n } else if (name) this.$d[name](arg);\n this.init();\n return this;\n };\n _proto.set = function set(string, _int2) {\n return this.clone().$set(string, _int2);\n };\n _proto.get = function get(unit) {\n return this[Utils.p(unit)]();\n };\n _proto.add = function add(number, units) {\n var _this2 = this, _C$MIN$C$H$C$S$unit;\n number = Number(number);\n var unit = Utils.p(units);\n var instanceFactorySet = function instanceFactorySet2(n) {\n var d = dayjs(_this2);\n return Utils.w(d.date(d.date() + Math.round(n * number)), _this2);\n };\n if (unit === M) {\n return this.set(M, this.$M + number);\n }\n if (unit === Y) {\n return this.set(Y, this.$y + number);\n }\n if (unit === D) {\n return instanceFactorySet(1);\n }\n if (unit === W) {\n return instanceFactorySet(7);\n }\n var step = (_C$MIN$C$H$C$S$unit = {}, _C$MIN$C$H$C$S$unit[MIN] = MILLISECONDS_A_MINUTE, _C$MIN$C$H$C$S$unit[H] = MILLISECONDS_A_HOUR, _C$MIN$C$H$C$S$unit[S] = MILLISECONDS_A_SECOND, _C$MIN$C$H$C$S$unit)[unit] || 1;\n var nextTimeStamp = this.$d.getTime() + number * step;\n return Utils.w(nextTimeStamp, this);\n };\n _proto.subtract = function subtract(number, string) {\n return this.add(number * -1, string);\n };\n _proto.format = function format(formatStr) {\n var _this3 = this;\n var locale = this.$locale();\n if (!this.isValid()) return locale.invalidDate || INVALID_DATE_STRING;\n var str = formatStr || FORMAT_DEFAULT;\n var zoneStr = Utils.z(this);\n var $H = this.$H, $m = this.$m, $M = this.$M;\n var weekdays = locale.weekdays, months = locale.months, meridiem = locale.meridiem;\n var getShort = function getShort2(arr, index, full, length) {\n return arr && (arr[index] || arr(_this3, str)) || full[index].slice(0, length);\n };\n var get$H = function get$H2(num) {\n return Utils.s($H % 12 || 12, num, "0");\n };\n var meridiemFunc = meridiem || function(hour, minute, isLowercase) {\n var m2 = hour < 12 ? "AM" : "PM";\n return isLowercase ? m2.toLowerCase() : m2;\n };\n var matches = function matches2(match) {\n switch (match) {\n case "YY":\n return String(_this3.$y).slice(-2);\n case "YYYY":\n return Utils.s(_this3.$y, 4, "0");\n case "M":\n return $M + 1;\n case "MM":\n return Utils.s($M + 1, 2, "0");\n case "MMM":\n return getShort(locale.monthsShort, $M, months, 3);\n case "MMMM":\n return getShort(months, $M);\n case "D":\n return _this3.$D;\n case "DD":\n return Utils.s(_this3.$D, 2, "0");\n case "d":\n return String(_this3.$W);\n case "dd":\n return getShort(locale.weekdaysMin, _this3.$W, weekdays, 2);\n case "ddd":\n return getShort(locale.weekdaysShort, _this3.$W, weekdays, 3);\n case "dddd":\n return weekdays[_this3.$W];\n case "H":\n return String($H);\n case "HH":\n return Utils.s($H, 2, "0");\n case "h":\n return get$H(1);\n case "hh":\n return get$H(2);\n case "a":\n return meridiemFunc($H, $m, true);\n case "A":\n return meridiemFunc($H, $m, false);\n case "m":\n return String($m);\n case "mm":\n return Utils.s($m, 2, "0");\n case "s":\n return String(_this3.$s);\n case "ss":\n return Utils.s(_this3.$s, 2, "0");\n case "SSS":\n return Utils.s(_this3.$ms, 3, "0");\n case "Z":\n return zoneStr;\n }\n return null;\n };\n return str.replace(REGEX_FORMAT, function(match, $1) {\n return $1 || matches(match) || zoneStr.replace(":", "");\n });\n };\n _proto.utcOffset = function utcOffset() {\n return -Math.round(this.$d.getTimezoneOffset() / 15) * 15;\n };\n _proto.diff = function diff(input, units, _float) {\n var _this4 = this;\n var unit = Utils.p(units);\n var that = dayjs(input);\n var zoneDelta = (that.utcOffset() - this.utcOffset()) * MILLISECONDS_A_MINUTE;\n var diff2 = this - that;\n var getMonth = function getMonth2() {\n return Utils.m(_this4, that);\n };\n var result;\n switch (unit) {\n case Y:\n result = getMonth() / 12;\n break;\n case M:\n result = getMonth();\n break;\n case Q:\n result = getMonth() / 3;\n break;\n case W:\n result = (diff2 - zoneDelta) / MILLISECONDS_A_WEEK;\n break;\n case D:\n result = (diff2 - zoneDelta) / MILLISECONDS_A_DAY;\n break;\n case H:\n result = diff2 / MILLISECONDS_A_HOUR;\n break;\n case MIN:\n result = diff2 / MILLISECONDS_A_MINUTE;\n break;\n case S:\n result = diff2 / MILLISECONDS_A_SECOND;\n break;\n default:\n result = diff2;\n break;\n }\n return _float ? result : Utils.a(result);\n };\n _proto.daysInMonth = function daysInMonth() {\n return this.endOf(M).$D;\n };\n _proto.$locale = function $locale() {\n return Ls[this.$L];\n };\n _proto.locale = function locale(preset, object) {\n if (!preset) return this.$L;\n var that = this.clone();\n var nextLocaleName = parseLocale(preset, object, true);\n if (nextLocaleName) that.$L = nextLocaleName;\n return that;\n };\n _proto.clone = function clone() {\n return Utils.w(this.$d, this);\n };\n _proto.toDate = function toDate() {\n return new Date(this.valueOf());\n };\n _proto.toJSON = function toJSON() {\n return this.isValid() ? this.toISOString() : null;\n };\n _proto.toISOString = function toISOString() {\n return this.$d.toISOString();\n };\n _proto.toString = function toString() {\n return this.$d.toUTCString();\n };\n return Dayjs2;\n }();\n var proto = Dayjs.prototype;\n dayjs.prototype = proto;\n [["$ms", MS], ["$s", S], ["$m", MIN], ["$H", H], ["$W", D], ["$M", M], ["$y", Y], ["$D", DATE]].forEach(function(g) {\n proto[g[1]] = function(input) {\n return this.$g(input, g[0], g[1]);\n };\n });\n dayjs.extend = function(plugin, option) {\n if (!plugin.$i) {\n plugin(option, Dayjs, dayjs);\n plugin.$i = true;\n }\n return dayjs;\n };\n dayjs.locale = parseLocale;\n dayjs.isDayjs = isDayjs;\n dayjs.unix = function(timestamp) {\n return dayjs(timestamp * 1e3);\n };\n dayjs.en = Ls[L];\n dayjs.Ls = Ls;\n dayjs.p = {};\n var advancedFormat = function(o, c2) {\n var proto2 = c2.prototype;\n var oldFormat = proto2.format;\n proto2.format = function(formatStr) {\n var _this = this;\n var locale = this.$locale();\n if (!this.isValid()) {\n return oldFormat.bind(this)(formatStr);\n }\n var utils = this.$utils();\n var str = formatStr || FORMAT_DEFAULT;\n var result = str.replace(/\\[([^\\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g, function(match) {\n switch (match) {\n case "Q":\n return Math.ceil((_this.$M + 1) / 3);\n case "Do":\n return locale.ordinal(_this.$D);\n case "gggg":\n return _this.weekYear();\n case "GGGG":\n return _this.isoWeekYear();\n case "wo":\n return locale.ordinal(_this.week(), "W");\n // W for week\n case "w":\n case "ww":\n return utils.s(_this.week(), match === "w" ? 1 : 2, "0");\n case "W":\n case "WW":\n return utils.s(_this.isoWeek(), match === "W" ? 1 : 2, "0");\n case "k":\n case "kk":\n return utils.s(String(_this.$H === 0 ? 24 : _this.$H), match === "k" ? 1 : 2, "0");\n case "X":\n return Math.floor(_this.$d.getTime() / 1e3);\n case "x":\n return _this.$d.getTime();\n case "z":\n return "[" + _this.offsetName() + "]";\n case "zzz":\n return "[" + _this.offsetName("long") + "]";\n default:\n return match;\n }\n });\n return oldFormat.bind(this)(result);\n };\n };\n var isoWeekPrettyUnit = "isoweek";\n var isoWeek = function(o, c2, d) {\n var getYearFirstThursday = function getYearFirstThursday2(year, isUtc) {\n var yearFirstDay = (isUtc ? d.utc : d)().year(year).startOf(Y);\n var addDiffDays = 4 - yearFirstDay.isoWeekday();\n if (yearFirstDay.isoWeekday() > 4) {\n addDiffDays += 7;\n }\n return yearFirstDay.add(addDiffDays, D);\n };\n var getCurrentWeekThursday = function getCurrentWeekThursday2(ins) {\n return ins.add(4 - ins.isoWeekday(), D);\n };\n var proto2 = c2.prototype;\n proto2.isoWeekYear = function() {\n var nowWeekThursday = getCurrentWeekThursday(this);\n return nowWeekThursday.year();\n };\n proto2.isoWeek = function(week) {\n if (!this.$utils().u(week)) {\n return this.add((week - this.isoWeek()) * 7, D);\n }\n var nowWeekThursday = getCurrentWeekThursday(this);\n var diffWeekThursday = getYearFirstThursday(this.isoWeekYear(), this.$u);\n return nowWeekThursday.diff(diffWeekThursday, W) + 1;\n };\n proto2.isoWeekday = function(week) {\n if (!this.$utils().u(week)) {\n return this.day(this.day() % 7 ? week : week - 7);\n }\n return this.day() || 7;\n };\n var oldStartOf = proto2.startOf;\n proto2.startOf = function(units, startOf) {\n var utils = this.$utils();\n var isStartOf = !utils.u(startOf) ? startOf : true;\n var unit = utils.p(units);\n if (unit === isoWeekPrettyUnit) {\n return isStartOf ? this.date(this.date() - (this.isoWeekday() - 1)).startOf("day") : this.date(this.date() - 1 - (this.isoWeekday() - 1) + 7).endOf("day");\n }\n return oldStartOf.bind(this)(units, startOf);\n };\n };\n dayjs.extend(isoWeek);\n dayjs.extend(advancedFormat);\n const FORMAT_ISO_WEEK_YEAR_WEEK = "GGGG-[W]WW";\n const _TemporalCache = class _TemporalCache {\n constructor() {\n this.yearMonthDayCache = /* @__PURE__ */ new Map();\n this.yearWeekCache = /* @__PURE__ */ new Map();\n this.yearMonthCache = /* @__PURE__ */ new Map();\n this.yearCache = /* @__PURE__ */ new Map();\n }\n getYearMonthDay(s2) {\n if (!this.yearMonthDayCache.has(s2)) {\n this.yearMonthDayCache.set(s2, YearMonthDayClass.parse(s2, this));\n }\n return this.yearMonthDayCache.get(s2);\n }\n getYearMonth(s2) {\n if (!this.yearMonthCache.has(s2)) {\n this.yearMonthCache.set(s2, YearMonthClass.parse(s2, this));\n }\n return this.yearMonthCache.get(s2);\n }\n getYearWeek(s2) {\n if (!this.yearWeekCache.has(s2)) {\n this.yearWeekCache.set(s2, YearWeekClass.parse(s2, this));\n }\n return this.yearWeekCache.get(s2);\n }\n getYear(s2) {\n if (!this.yearCache.has(s2)) {\n this.yearCache.set(s2, YearClass.parse(s2, this));\n }\n return this.yearCache.get(s2);\n }\n static getInstance() {\n return this.instance;\n }\n };\n _TemporalCache.instance = new _TemporalCache();\n let TemporalCache = _TemporalCache;\n class YearMonthDayClass {\n constructor(yearNumber, monthNumber, dayNumber, cache) {\n this.yearNumber = yearNumber;\n this.monthNumber = monthNumber;\n this.dayNumber = dayNumber;\n this.cache = cache;\n this.type = "YearMonthDay";\n this.date = new Date(this.yearNumber, this.monthNumber - 1, this.dayNumber);\n this.dayjs = dayjs(this.date);\n this.dateString = this.toString();\n }\n get text() {\n return this.dayjs.format("YYYY-MM-DD");\n }\n toString() {\n return this.text;\n }\n englishName() {\n return this.dayjs.format("dddd, MMMM D, YYYY");\n }\n get firstDay() {\n return this;\n }\n get lastDay() {\n return this;\n }\n get year() {\n return this.cache.getYear(`${this.yearNumber}`);\n }\n get month() {\n return this.cache.getYearMonth(this.dayjs.format("YYYY-MM"));\n }\n get week() {\n return this.cache.getYearWeek(this.dayjs.format(FORMAT_ISO_WEEK_YEAR_WEEK));\n }\n addDays(days) {\n const date = this.dayjs.add(days, "day");\n const s2 = date.format("YYYY-MM-DD");\n return this.cache.getYearMonthDay(s2);\n }\n minus(other) {\n return this.dayjs.diff(other.dayjs, "day");\n }\n static parse(s2, cache) {\n const [year, month, day] = s2.split("-").map((s22) => parseInt(s22, 10));\n return new YearMonthDayClass(year, month, day, cache);\n }\n }\n class YearWeekClass {\n constructor(isoYearNumber, isoWeekNumber, cache) {\n this.isoYearNumber = isoYearNumber;\n this.isoWeekNumber = isoWeekNumber;\n this.cache = cache;\n this.type = "YearWeek";\n this.dateString = this.toString();\n }\n get text() {\n return this.firstDay.dayjs.format(FORMAT_ISO_WEEK_YEAR_WEEK);\n }\n toString() {\n return this.text;\n }\n englishName() {\n return `Week ${this.isoWeekNumber}, ${this.isoYearNumber}`;\n }\n get firstDay() {\n const firstDay = dayjs().year(this.isoYearNumber).month(1).date(4).isoWeek(this.isoWeekNumber).startOf("isoWeek");\n return this.cache.getYearMonthDay(firstDay.format("YYYY-MM-DD"));\n }\n get lastDay() {\n const lastDay = this.firstDay.dayjs.add(6, "days");\n return this.cache.getYearMonthDay(lastDay.format("YYYY-MM-DD"));\n }\n get year() {\n return this.cache.getYear(`${this.isoYearNumber}`);\n }\n addWeeks(weeks) {\n const date = this.firstDay.dayjs.add(weeks, "week");\n const s2 = date.format(FORMAT_ISO_WEEK_YEAR_WEEK);\n return this.cache.getYearWeek(s2);\n }\n minus(other) {\n return this.firstDay.dayjs.diff(other.firstDay.dayjs, "week");\n }\n static parse(s2, cache) {\n const [year, week] = s2.split("-W").map((s22) => parseInt(s22, 10));\n return new YearWeekClass(year, week, cache);\n }\n }\n class YearMonthClass {\n constructor(yearNumber, monthNumber, cache) {\n this.yearNumber = yearNumber;\n this.monthNumber = monthNumber;\n this.cache = cache;\n this.type = "YearMonth";\n this.dateString = this.toString();\n }\n get text() {\n return this.firstDay.dayjs.format("YYYY-MM");\n }\n toString() {\n return this.text;\n }\n englishName() {\n return `${monthName(this.monthNumber)} ${this.yearNumber}`;\n }\n get firstDay() {\n return this.cache.getYearMonthDay(dayjs(`${this.yearNumber}-${this.monthNumber}-01`).format("YYYY-MM-DD"));\n }\n get lastDay() {\n return this.cache.getYearMonthDay(\n dayjs(`${this.yearNumber}-${this.monthNumber}-01`).endOf("month").format("YYYY-MM-DD")\n );\n }\n get year() {\n return this.cache.getYear(`${this.yearNumber}`);\n }\n addMonths(months) {\n const date = this.firstDay.dayjs.add(months, "month");\n const s2 = date.format("YYYY-MM");\n return this.cache.getYearMonth(s2);\n }\n minus(other) {\n return this.firstDay.dayjs.diff(other.firstDay.dayjs, "month");\n }\n static parse(s2, cache) {\n const [year, month] = s2.split("-").map((s22) => parseInt(s22, 10));\n return new YearMonthClass(year, month, cache);\n }\n }\n class YearClass {\n constructor(year, cache) {\n this.year = year;\n this.cache = cache;\n this.type = "Year";\n this.dateString = this.toString();\n }\n get text() {\n return this.firstDay.dayjs.format("YYYY");\n }\n toString() {\n return this.text;\n }\n englishName() {\n return this.year.toString();\n }\n get firstMonth() {\n return this.cache.getYearMonth(`${this.year}-01`);\n }\n get lastMonth() {\n return this.cache.getYearMonth(`${this.year}-12`);\n }\n get firstDay() {\n return this.firstMonth.firstDay;\n }\n get lastDay() {\n return this.lastMonth.lastDay;\n }\n addYears(years) {\n const date = this.firstDay.dayjs.add(years, "year");\n const s2 = date.format("YYYY");\n return this.cache.getYear(s2);\n }\n minus(other) {\n return this.firstDay.dayjs.diff(other.firstDay.dayjs, "year");\n }\n static parse(s2, cache) {\n const year = parseInt(s2, 10);\n return new YearClass(year, cache);\n }\n }\n function monthName(month) {\n return dayjs().month(month - 1).format("MMMM");\n }\n function toTemporal(temporalClass) {\n switch (temporalClass.type) {\n case "YearMonthDay":\n return {\n type: "YearMonthDay",\n yearNumber: temporalClass.yearNumber,\n monthNumber: temporalClass.monthNumber,\n dayNumber: temporalClass.dayNumber,\n dateString: temporalClass.dateString\n };\n case "YearWeek":\n return {\n type: "YearWeek",\n isoYearNumber: temporalClass.isoYearNumber,\n isoWeekNumber: temporalClass.isoWeekNumber,\n dateString: temporalClass.dateString\n };\n case "YearMonth":\n return {\n type: "YearMonth",\n yearNumber: temporalClass.yearNumber,\n monthNumber: temporalClass.monthNumber,\n dateString: temporalClass.dateString\n };\n case "Year":\n return {\n type: "Year",\n year: temporalClass.year,\n dateString: temporalClass.dateString\n };\n }\n }\n function generateAllDaysInRange(start, end) {\n const days = [];\n const daysInBetween = end.minus(start);\n for (let i2 = 0; i2 <= daysInBetween; i2++) {\n days.push(start.addDays(i2));\n }\n return days;\n }\n function generateAllWeeksInRange(start, end) {\n const weeks = [];\n const weeksInBetween = end.minus(start);\n for (let i2 = 0; i2 <= weeksInBetween; i2++) {\n weeks.push(start.addWeeks(i2));\n }\n return weeks;\n }\n function generateAllMonthsInRange(start, end) {\n const months = [];\n const monthsInBetween = end.minus(start);\n for (let i2 = 0; i2 <= monthsInBetween; i2++) {\n months.push(start.addMonths(i2));\n }\n return months;\n }\n function generateAllYearsInRange(start, end) {\n const years = [];\n const yearsInBetween = end.minus(start);\n for (let i2 = 0; i2 <= yearsInBetween; i2++) {\n years.push(start.addYears(i2));\n }\n return years;\n }\n function generateAllInRange(start, end) {\n if (start === null || end === null) {\n return [];\n }\n if (start instanceof YearMonthDayClass && end instanceof YearMonthDayClass) {\n return generateAllDaysInRange(start, end);\n }\n if (start instanceof YearWeekClass && end instanceof YearWeekClass) {\n return generateAllWeeksInRange(start, end);\n }\n if (start instanceof YearMonthClass && end instanceof YearMonthClass) {\n return generateAllMonthsInRange(start, end);\n }\n if (start instanceof YearClass && end instanceof YearClass) {\n return generateAllYearsInRange(start, end);\n }\n throw new Error(`Invalid arguments: start and end must be of the same type: ${start}, ${end}`);\n }\n function minusTemporal(a2, b) {\n if (a2 instanceof YearMonthDayClass && b instanceof YearMonthDayClass) {\n return a2.minus(b);\n }\n if (a2 instanceof YearWeekClass && b instanceof YearWeekClass) {\n return a2.minus(b);\n }\n if (a2 instanceof YearMonthClass && b instanceof YearMonthClass) {\n return a2.minus(b);\n }\n if (a2 instanceof YearClass && b instanceof YearClass) {\n return a2.minus(b);\n }\n throw new Error(`Cannot compare ${a2} and ${b}`);\n }\n function compareTemporal(a2, b) {\n if (a2 === null) {\n return 1;\n }\n if (b === null) {\n return -1;\n }\n const diff = minusTemporal(a2, b);\n if (diff < 0) {\n return -1;\n }\n if (diff > 0) {\n return 1;\n }\n return 0;\n }\n function getMinMaxTemporal(values) {\n let min = null;\n let max = null;\n for (const value of values) {\n if (value === null) {\n continue;\n }\n if (min === null || compareTemporal(value, min) < 0) {\n min = value;\n }\n if (max === null || compareTemporal(value, max) > 0) {\n max = value;\n }\n }\n if (min === null || max === null) {\n return { min: null, max: null };\n }\n return { min, max };\n }\n function parseDateStringToTemporal(date, granularity) {\n const cache = TemporalCache.getInstance();\n const day = cache.getYearMonthDay(date);\n switch (granularity) {\n case "day":\n return day;\n case "week":\n return day.week;\n case "month":\n return day.month;\n case "year":\n return day.year;\n }\n }\n function dateRangeCompare(a2, b) {\n if (a2.dateRange === null) {\n return 1;\n }\n if (b.dateRange === null) {\n return -1;\n }\n return compareTemporal(a2.dateRange, b.dateRange);\n }\n function mapDateToGranularityRange(data, granularity) {\n return {\n dateRange: data.date === null ? null : parseDateStringToTemporal(data.date, granularity),\n count: data.count\n };\n }\n const nucleotideChars = "ACGTRYKMSWBDHVN";\n const aminoAcidChars = "ACDEFGHIKLMNPQRSTVWY";\n function segmentPart(type) {\n return type === "aminoAcid" ? `(?<segment>[A-Z0-9_-]+):` : `((?<segment>[A-Z0-9_-]+)(?=:):)?`;\n }\n function buildSubstitutionRegex(type) {\n const chars = type === "nucleotide" ? nucleotideChars : aminoAcidChars;\n return new RegExp(\n `^${segmentPart(type)}(?<valueAtReference>[${chars}*])?(?<position>\\\\d+)(?<substitutionValue>[${chars}.*])?$`,\n "i"\n );\n }\n const nucleotideSubstitutionRegex = buildSubstitutionRegex("nucleotide");\n const aminoAcidSubstitutionRegex = buildSubstitutionRegex("aminoAcid");\n class SubstitutionClass {\n constructor(segment, valueAtReference, substitutionValue, position) {\n this.segment = segment;\n this.valueAtReference = valueAtReference;\n this.substitutionValue = substitutionValue;\n this.position = position;\n this.type = "substitution";\n const segmentString = this.segment ? `${this.segment}:` : "";\n const valueAtReferenceString = this.valueAtReference ?? "";\n const substitutionValueString = this.substitutionValue ?? "";\n this.code = `${segmentString}${valueAtReferenceString}${this.position}${substitutionValueString}`;\n }\n equals(other) {\n if (!(other instanceof SubstitutionClass)) {\n return false;\n }\n return this.segment === other.segment && this.valueAtReference === other.valueAtReference && this.substitutionValue === other.substitutionValue && this.position === other.position;\n }\n toString() {\n return this.code;\n }\n static parse(mutationStr) {\n const matchNucleotide = nucleotideSubstitutionRegex.exec(mutationStr);\n const matchAminoAcid = aminoAcidSubstitutionRegex.exec(mutationStr);\n const match = matchNucleotide ?? matchAminoAcid;\n if ((match == null ? void 0 : match.groups) === void 0) {\n return null;\n }\n return new SubstitutionClass(\n match.groups.segment,\n match.groups.valueAtReference,\n match.groups.substitutionValue,\n parseInt(match.groups.position, 10)\n );\n }\n }\n function buildDeletionRegex(type) {\n const chars = type === "nucleotide" ? nucleotideChars : aminoAcidChars;\n return new RegExp(\n `^${segmentPart(type)}(?<valueAtReference>[${chars}*])?(?<position>\\\\d+)(-)$`,\n "i"\n );\n }\n const nucleotideDeletionRegex = buildDeletionRegex("nucleotide");\n const aminoAcidDeletionRegex = buildDeletionRegex("aminoAcid");\n class DeletionClass {\n constructor(segment, valueAtReference, position) {\n this.segment = segment;\n this.valueAtReference = valueAtReference;\n this.position = position;\n this.type = "deletion";\n const segmentString = this.segment ? `${this.segment}:` : "";\n const valueAtReferenceString = this.valueAtReference ?? "";\n this.code = `${segmentString}${valueAtReferenceString}${this.position}-`;\n }\n equals(other) {\n if (!(other instanceof DeletionClass)) {\n return false;\n }\n return this.segment === other.segment && this.valueAtReference === other.valueAtReference && this.position === other.position;\n }\n toString() {\n return this.code;\n }\n static parse(mutationStr) {\n const matchNucleotide = nucleotideDeletionRegex.exec(mutationStr);\n const matchAminoAcid = aminoAcidDeletionRegex.exec(mutationStr);\n const match = matchNucleotide ?? matchAminoAcid;\n if ((match == null ? void 0 : match.groups) === void 0) {\n return null;\n }\n return new DeletionClass(\n match.groups.segment,\n match.groups.valueAtReference,\n parseInt(match.groups.position, 10)\n );\n }\n }\n function toSubstitutionOrDeletion(mutation) {\n switch (mutation.type) {\n case "substitution":\n return {\n type: "substitution",\n code: mutation.code,\n segment: mutation.segment,\n position: mutation.position,\n valueAtReference: mutation.valueAtReference,\n substitutionValue: mutation.substitutionValue\n };\n case "deletion":\n return {\n type: "deletion",\n code: mutation.code,\n segment: mutation.segment,\n position: mutation.position,\n valueAtReference: mutation.valueAtReference\n };\n }\n }\n class FetchSubstitutionsOrDeletionsOperator {\n constructor(filter, sequenceType, minProportion) {\n this.filter = filter;\n this.sequenceType = sequenceType;\n this.minProportion = minProportion;\n }\n async evaluate(lapis, signal) {\n const mutations = await this.fetchMutations(lapis, signal);\n const content = mutations.map(\n ({ count, proportion, mutationFrom, mutationTo, position, sequenceName }) => {\n if (mutationTo === "-") {\n return {\n type: "deletion",\n mutation: new DeletionClass(sequenceName ?? void 0, mutationFrom, position),\n count,\n proportion\n };\n }\n return {\n type: "substitution",\n mutation: new SubstitutionClass(sequenceName ?? void 0, mutationFrom, mutationTo, position),\n count,\n proportion\n };\n }\n );\n return { content };\n }\n async fetchMutations(lapis, signal) {\n const filter = {\n ...this.filter,\n minProportion: this.minProportion\n };\n return fetchSubstitutionsOrDeletions(lapis, filter, this.sequenceType, signal).then(\n (response) => response.data\n );\n }\n }\n var l$1;\n l$1 = { __e: function(n, l2, u2, t) {\n for (var i2, r2, o; l2 = l2.__; ) if ((i2 = l2.__c) && !i2.__) try {\n if ((r2 = i2.constructor) && null != r2.getDerivedStateFromError && (i2.setState(r2.getDerivedStateFromError(n)), o = i2.__d), null != i2.componentDidCatch && (i2.componentDidCatch(n, t || {}), o = i2.__d), o) return i2.__E = i2;\n } catch (l3) {\n n = l3;\n }\n throw n;\n } }, "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout;\n var r, u, i, f = [], c = l$1, e = c.__b, a = c.__r, v = c.diffed, l = c.__c, m = c.unmount, s = c.__;\n function j() {\n for (var n; n = f.shift(); ) if (n.__P && n.__H) try {\n n.__H.__h.forEach(z), n.__H.__h.forEach(B), n.__H.__h = [];\n } catch (t) {\n n.__H.__h = [], c.__e(t, n.__v);\n }\n }\n c.__b = function(n) {\n r = null, e && e(n);\n }, c.__ = function(n, t) {\n n && t.__k && t.__k.__m && (n.__m = t.__k.__m), s && s(n, t);\n }, c.__r = function(n) {\n a && a(n);\n var i2 = (r = n.__c).__H;\n i2 && (u === r ? (i2.__h = [], r.__h = [], i2.__.forEach(function(n2) {\n n2.__N && (n2.__ = n2.__N), n2.u = n2.__N = void 0;\n })) : (i2.__h.forEach(z), i2.__h.forEach(B), i2.__h = [], 0)), u = r;\n }, c.diffed = function(n) {\n v && v(n);\n var t = n.__c;\n t && t.__H && (t.__H.__h.length && (1 !== f.push(t) && i === c.requestAnimationFrame || ((i = c.requestAnimationFrame) || w)(j)), t.__H.__.forEach(function(n2) {\n n2.u && (n2.__H = n2.u), n2.u = void 0;\n })), u = r = null;\n }, c.__c = function(n, t) {\n t.some(function(n2) {\n try {\n n2.__h.forEach(z), n2.__h = n2.__h.filter(function(n3) {\n return !n3.__ || B(n3);\n });\n } catch (r2) {\n t.some(function(n3) {\n n3.__h && (n3.__h = []);\n }), t = [], c.__e(r2, n2.__v);\n }\n }), l && l(n, t);\n }, c.unmount = function(n) {\n m && m(n);\n var t, r2 = n.__c;\n r2 && r2.__H && (r2.__H.__.forEach(function(n2) {\n try {\n z(n2);\n } catch (n3) {\n t = n3;\n }\n }), r2.__H = void 0, t && c.__e(t, r2.__v));\n };\n var k = "function" == typeof requestAnimationFrame;\n function w(n) {\n var t, r2 = function() {\n clearTimeout(u2), k && cancelAnimationFrame(t), setTimeout(n);\n }, u2 = setTimeout(r2, 35);\n k && (t = requestAnimationFrame(r2));\n }\n function z(n) {\n var t = r, u2 = n.__c;\n "function" == typeof u2 && (n.__c = void 0, u2()), r = t;\n }\n function B(n) {\n var t = r;\n n.__c = n.__(), r = t;\n }\n class UserFacingError extends Error {\n constructor(headline, message) {\n super(message);\n this.headline = headline;\n this.name = "UserFacingError";\n }\n }\n class Map2dBase {\n constructor(serializeFirstAxis, serializeSecondAxis, initialContent) {\n this.serializeFirstAxis = serializeFirstAxis;\n this.serializeSecondAxis = serializeSecondAxis;\n this.data = /* @__PURE__ */ new Map();\n this.keysFirstAxis = /* @__PURE__ */ new Map();\n this.keysSecondAxis = /* @__PURE__ */ new Map();\n if (initialContent) {\n this.keysFirstAxis = new Map(initialContent.keysFirstAxis);\n this.keysSecondAxis = new Map(initialContent.keysSecondAxis);\n this.data = new Map(initialContent.data);\n }\n }\n get(keyFirstAxis, keySecondAxis) {\n var _a;\n const serializedKeyFirstAxis = this.serializeFirstAxis(keyFirstAxis);\n const serializedKeySecondAxis = this.serializeSecondAxis(keySecondAxis);\n return (_a = this.data.get(serializedKeyFirstAxis)) == null ? void 0 : _a.get(serializedKeySecondAxis);\n }\n getRow(key) {\n const serializedKeyFirstAxis = this.serializeFirstAxis(key);\n const row = this.data.get(serializedKeyFirstAxis);\n if (row === void 0) {\n return [];\n }\n return Array.from(this.keysSecondAxis.keys()).map((key2) => row.get(key2));\n }\n set(keyFirstAxis, keySecondAxis, value) {\n const serializedKeyFirstAxis = this.serializeFirstAxis(keyFirstAxis);\n const serializedKeySecondAxis = this.serializeSecondAxis(keySecondAxis);\n if (!this.data.has(serializedKeyFirstAxis)) {\n this.data.set(serializedKeyFirstAxis, /* @__PURE__ */ new Map());\n }\n this.data.get(serializedKeyFirstAxis).set(serializedKeySecondAxis, value);\n this.keysFirstAxis.set(serializedKeyFirstAxis, keyFirstAxis);\n this.keysSecondAxis.set(serializedKeySecondAxis, keySecondAxis);\n }\n deleteRow(key) {\n const serializedKeyFirstAxis = this.serializeFirstAxis(key);\n this.data.delete(serializedKeyFirstAxis);\n this.keysFirstAxis.delete(serializedKeyFirstAxis);\n }\n getFirstAxisKeys() {\n return Array.from(this.keysFirstAxis.values());\n }\n getSecondAxisKeys() {\n return Array.from(this.keysSecondAxis.values());\n }\n getAsArray() {\n return this.getFirstAxisKeys().map((firstAxisKey) => {\n return this.getSecondAxisKeys().map((secondAxisKey) => {\n return this.get(firstAxisKey, secondAxisKey);\n });\n });\n }\n getContents() {\n return {\n keysFirstAxis: this.keysFirstAxis,\n keysSecondAxis: this.keysSecondAxis,\n data: this.data\n };\n }\n }\n class BaseMutationOverTimeDataMap extends Map2dBase {\n constructor(initialContent) {\n super(serializeSubstitutionOrDeletion, serializeTemporal, initialContent);\n }\n }\n const sortSubstitutionsAndDeletions = (a2, b) => {\n if (a2.segment !== b.segment) {\n return compareSegments(a2.segment, b.segment);\n }\n if (a2.position !== b.position) {\n return comparePositions(a2.position, b.position);\n }\n const aIsDeletion = a2.type === "deletion";\n const bIsDeletion = b.type === "deletion";\n if (aIsDeletion !== bIsDeletion) {\n return aIsDeletion ? 1 : -1;\n }\n if (!aIsDeletion && !bIsDeletion) {\n if (a2.substitutionValue !== b.substitutionValue) {\n return compareSubstitutionValues(a2.substitutionValue, b.substitutionValue);\n }\n }\n return 0;\n };\n const compareSegments = (a2, b) => {\n if (a2 === void 0) {\n return -1;\n }\n if (b === void 0) {\n return 1;\n }\n return a2.localeCompare(b);\n };\n const comparePositions = (a2, b) => {\n return a2 - b;\n };\n const compareSubstitutionValues = (a2, b) => {\n if (a2 === void 0) {\n return -1;\n }\n if (b === void 0) {\n return 1;\n }\n return a2.localeCompare(b);\n };\n const MAX_NUMBER_OF_GRID_COLUMNS = 200;\n const MUTATIONS_OVER_TIME_MIN_PROPORTION = 1e-3;\n function codeToEmptyEntry(code) {\n const maybeDeletion = DeletionClass.parse(code);\n if (maybeDeletion) {\n return {\n type: "deletion",\n mutation: maybeDeletion,\n count: 0,\n proportion: 0\n };\n }\n const maybeSubstitution = SubstitutionClass.parse(code);\n if (maybeSubstitution) {\n return {\n type: "substitution",\n mutation: maybeSubstitution,\n count: 0,\n proportion: 0\n };\n }\n return null;\n }\n async function queryOverallMutationData({\n lapisFilter,\n sequenceType,\n lapis,\n granularity,\n lapisDateField,\n includeMutations,\n signal\n }) {\n const requestedDateRanges = await getDatesInDataset(lapisFilter, lapis, granularity, lapisDateField, signal);\n if (requestedDateRanges.length === 0) {\n if (includeMutations) {\n return {\n content: includeMutations.map(codeToEmptyEntry).filter((e2) => e2 !== null)\n };\n } else {\n return {\n content: []\n };\n }\n }\n const filter = {\n ...lapisFilter,\n [`${lapisDateField}From`]: requestedDateRanges[0].firstDay.toString(),\n [`${lapisDateField}To`]: requestedDateRanges[requestedDateRanges.length - 1].lastDay.toString()\n };\n let dataPromise = fetchAndPrepareSubstitutionsOrDeletions(filter, sequenceType).evaluate(lapis, signal);\n if (includeMutations) {\n dataPromise = dataPromise.then((data) => {\n return {\n content: includeMutations.map((code) => {\n const found = data.content.find((m2) => m2.mutation.code === code);\n return found ?? codeToEmptyEntry(code);\n }).filter((e2) => e2 !== null)\n };\n });\n }\n return dataPromise;\n }\n async function queryMutationsOverTimeData(query) {\n const { lapisFilter, displayMutations, sequenceType, lapis, lapisDateField, granularity, useNewEndpoint, signal } = query;\n const requestedDateRanges = await getDatesInDataset(lapisFilter, lapis, granularity, lapisDateField, signal);\n if (requestedDateRanges.length > MAX_NUMBER_OF_GRID_COLUMNS) {\n throw new UserFacingError(\n "Too many dates",\n `The dataset would contain ${requestedDateRanges.length} date intervals. Please reduce the number to below ${MAX_NUMBER_OF_GRID_COLUMNS} to display the data. You can achieve this by either narrowing the date range in the provided LAPIS filter or by selecting a larger granularity.`\n );\n }\n const overallMutationData = queryOverallMutationData({\n lapisFilter,\n sequenceType,\n lapis,\n lapisDateField,\n includeMutations: displayMutations,\n granularity\n }).then((r2) => r2.content);\n return useNewEndpoint === true ? queryMutationsOverTimeDataDirectEndpoint(requestedDateRanges, overallMutationData, query) : queryMutationsOverTimeDataMultiQuery(requestedDateRanges, overallMutationData, query);\n }\n async function queryMutationsOverTimeDataMultiQuery(allDates, overallMutationDataPromise, { lapisFilter, sequenceType, lapis, lapisDateField, signal }) {\n const subQueries = allDates.map(async (date) => {\n const dateFrom = date.firstDay.toString();\n const dateTo = date.lastDay.toString();\n const filter = {\n ...lapisFilter,\n [`${lapisDateField}From`]: dateFrom,\n [`${lapisDateField}To`]: dateTo\n };\n const [data2, totalCountQuery] = await Promise.all([\n fetchAndPrepareSubstitutionsOrDeletions(filter, sequenceType).evaluate(lapis, signal),\n getTotalNumberOfSequencesInDateRange(filter).evaluate(lapis, signal)\n ]);\n return {\n date,\n mutations: data2.content,\n totalCount: totalCountQuery.content[0].count\n };\n });\n const data = await Promise.all(subQueries);\n const overallMutationData = await overallMutationDataPromise;\n return {\n mutationOverTimeData: groupByMutation(data, overallMutationData),\n overallMutationData\n };\n }\n async function queryMutationsOverTimeDataDirectEndpoint(allDates, overallMutationDataPromise, { lapisFilter, sequenceType, lapis, lapisDateField, signal }) {\n const overallMutationData = await overallMutationDataPromise;\n overallMutationData.sort((a2, b) => sortSubstitutionsAndDeletions(a2.mutation, b.mutation));\n const totalCounts = await Promise.all(\n allDates.map(async (date) => {\n const filter = {\n ...lapisFilter,\n [`${lapisDateField}From`]: date.firstDay.toString(),\n [`${lapisDateField}To`]: date.lastDay.toString()\n };\n const totalCountQuery = await getTotalNumberOfSequencesInDateRange(filter).evaluate(lapis, signal);\n return totalCountQuery.content[0].count;\n })\n );\n const includeMutations = overallMutationData.map((value) => value.mutation.code);\n const apiResult = await fetchMutationsOverTime(\n lapis,\n {\n filters: lapisFilter,\n dateRanges: allDates.map((date) => ({\n dateFrom: date.firstDay.toString(),\n dateTo: date.lastDay.toString()\n })),\n includeMutations,\n dateField: lapisDateField\n },\n sequenceType,\n signal\n );\n const responseMutations = apiResult.data.mutations.map(parseMutationCode);\n const mutationEntries = responseMutations.map((mutation, i2) => {\n const numbers = {\n count: overallMutationData[i2].count,\n proportion: overallMutationData[i2].proportion\n };\n if (mutation.type === "deletion") {\n return {\n type: "deletion",\n mutation,\n ...numbers\n };\n } else {\n return {\n type: "substitution",\n mutation,\n ...numbers\n };\n }\n });\n const mutationOverTimeData = {\n keysFirstAxis: new Map(responseMutations.map((mutation) => [mutation.code, mutation])),\n keysSecondAxis: new Map(allDates.map((date) => [date.dateString, date])),\n data: new Map(\n responseMutations.map((mutation, i2) => [\n mutation.code,\n new Map(\n allDates.map((date, j2) => [\n date.dateString,\n {\n type: "value",\n // \'coverage\' in the API resp. is the number of seqs. that have a non-ambiguous symbol at position\n // \'count\' in the API resp. is the number of seqs with the mutation\n proportion: apiResult.data.data[i2][j2].count / apiResult.data.data[i2][j2].coverage,\n count: apiResult.data.data[i2][j2].count,\n totalCount: totalCounts[j2]\n }\n ])\n )\n ])\n )\n };\n return {\n mutationOverTimeData: new BaseMutationOverTimeDataMap(mutationOverTimeData),\n overallMutationData: mutationEntries\n };\n }\n function parseMutationCode(code) {\n const maybeDeletion = DeletionClass.parse(code);\n if (maybeDeletion) {\n return maybeDeletion;\n }\n const maybeSubstitution = SubstitutionClass.parse(code);\n if (maybeSubstitution) {\n return maybeSubstitution;\n }\n throw Error(`Given code is not valid: ${code}`);\n }\n async function getDatesInDataset(lapisFilter, lapis, granularity, lapisDateField, signal) {\n const { dateFrom, dateTo } = getDateRangeFromFilter(lapisFilter, lapisDateField, granularity);\n if (dateFrom !== null && dateTo !== null) {\n return generateAllInRange(dateFrom, dateTo);\n }\n const { content: availableDates } = await queryAvailableDates(\n lapisFilter,\n lapis,\n granularity,\n lapisDateField,\n signal\n );\n const { min, max } = getMinMaxTemporal(availableDates);\n return generateAllInRange(dateFrom ?? min, dateTo ?? max);\n }\n function getDateRangeFromFilter(lapisFilter, lapisDateField, granularity) {\n const valueFromFilter = lapisFilter[lapisDateField];\n if (valueFromFilter) {\n return {\n dateFrom: parseDateStringToTemporal(valueFromFilter, granularity),\n dateTo: parseDateStringToTemporal(valueFromFilter, granularity)\n };\n }\n const minFromFilter = lapisFilter[`${lapisDateField}From`];\n const maxFromFilter = lapisFilter[`${lapisDateField}To`];\n return {\n dateFrom: minFromFilter ? parseDateStringToTemporal(minFromFilter, granularity) : null,\n dateTo: maxFromFilter ? parseDateStringToTemporal(maxFromFilter, granularity) : null\n };\n }\n function queryAvailableDates(lapisFilter, lapis, granularity, lapisDateField, signal) {\n return fetchAndPrepareDates(lapisFilter, granularity, lapisDateField).evaluate(lapis, signal);\n }\n function fetchAndPrepareDates(filter, granularity, lapisDateField) {\n const fetchData = new FetchAggregatedOperator(filter, [lapisDateField]);\n const dataWithFixedDateKey = new RenameFieldOperator(fetchData, lapisDateField, "date");\n const mapData = new MapOperator(dataWithFixedDateKey, (data) => mapDateToGranularityRange(data, granularity));\n const groupByData = new GroupByAndSumOperator(mapData, "dateRange", "count");\n const sortData = new SortOperator(groupByData, dateRangeCompare);\n return new MapOperator(sortData, (data) => data.dateRange);\n }\n function fetchAndPrepareSubstitutionsOrDeletions(filter, sequenceType) {\n return new FetchSubstitutionsOrDeletionsOperator(filter, sequenceType, MUTATIONS_OVER_TIME_MIN_PROPORTION);\n }\n function serializeSubstitutionOrDeletion(mutation) {\n return mutation.code;\n }\n function serializeTemporal(date) {\n return date.dateString;\n }\n function groupByMutation(data, overallMutationData) {\n const dataArray = new BaseMutationOverTimeDataMap();\n const allDates = data.map((mutationData) => mutationData.date);\n const sortedOverallMutationData = overallMutationData.sort((a2, b) => sortSubstitutionsAndDeletions(a2.mutation, b.mutation)).map((entry) => {\n return toSubstitutionOrDeletion(entry.mutation);\n });\n const sortedDates = allDates.sort((a2, b) => compareTemporal(a2, b)).map((date) => toTemporal(date));\n sortedOverallMutationData.forEach((mutationData) => {\n sortedDates.forEach((date) => {\n dataArray.set(mutationData, date, null);\n });\n });\n data.forEach((mutationData) => {\n if (mutationData.totalCount == 0) {\n return;\n }\n const date = toTemporal(mutationData.date);\n mutationData.mutations.forEach((mutationEntry) => {\n const mutation = toSubstitutionOrDeletion(mutationEntry.mutation);\n if (dataArray.get(mutation, date) !== void 0) {\n dataArray.set(mutation, date, {\n type: "value",\n count: mutationEntry.count,\n proportion: mutationEntry.proportion,\n totalCount: mutationData.totalCount\n });\n }\n });\n for (const firstAxisKey of dataArray.getFirstAxisKeys()) {\n if (dataArray.get(firstAxisKey, date) === null) {\n dataArray.set(firstAxisKey, date, {\n type: "belowThreshold",\n totalCount: mutationData.totalCount\n });\n }\n }\n });\n return dataArray;\n }\n function getTotalNumberOfSequencesInDateRange(filter) {\n return new FetchAggregatedOperator(filter);\n }\n async function workerFunction(queryFunction) {\n try {\n postMessage({ status: "loading" });\n const workerResponse = await queryFunction();\n postMessage({\n status: "success",\n data: workerResponse\n });\n } catch (error) {\n postMessage(\n error instanceof UserFacingError ? {\n status: "error",\n userFacing: true,\n headline: error.headline,\n error\n } : {\n status: "error",\n userFacing: false,\n error: error instanceof Error ? error : new Error(`${error}`)\n }\n );\n }\n }\n async function getMutationOverTimeWorkerFunction(event) {\n const mutationOverTimeData = await queryMutationsOverTimeData(event.data);\n const workerResponse = {\n overallMutationData: mutationOverTimeData.overallMutationData,\n mutationOverTimeSerialized: mutationOverTimeData.mutationOverTimeData.getContents()\n };\n return workerResponse;\n }\n self.onmessage = async function(event) {\n await workerFunction(() => getMutationOverTimeWorkerFunction(event));\n };\n})();\n//# sourceMappingURL=mutationOverTimeWorker-DPS3tmOd.js.map\n';
7029
7081
  const blob = typeof self !== "undefined" && self.Blob && new Blob([jsContent], { type: "text/javascript;charset=utf-8" });
7030
7082
  function WorkerWrapper(options2) {
7031
7083
  let objURL;
@@ -7236,7 +7288,7 @@ function getFilteredMutationOverTimeData$1({
7236
7288
  return true;
7237
7289
  }
7238
7290
  return displayedMutationTypes.some(
7239
- (mutationType) => mutationType.type === entry.mutation.type && !mutationType.checked
7291
+ (mutationType2) => mutationType2.type === entry.mutation.type && !mutationType2.checked
7240
7292
  );
7241
7293
  });
7242
7294
  mutationsToFilterOut.forEach((entry) => {
@@ -7844,6 +7896,10 @@ function useWebWorker(messageToWorker, WorkerConstructor) {
7844
7896
  return { data, error, isLoading };
7845
7897
  }
7846
7898
  const mutationsOverTimeViewSchema = z$2.literal(views.grid);
7899
+ const meanProportionIntervalSchema = z$2.object({
7900
+ min: z$2.number().min(0).max(1),
7901
+ max: z$2.number().min(0).max(1)
7902
+ });
7847
7903
  const mutationOverTimeSchema = z$2.object({
7848
7904
  lapisFilter: lapisFilterSchema,
7849
7905
  sequenceType: sequenceTypeSchema,
@@ -7852,10 +7908,7 @@ const mutationOverTimeSchema = z$2.object({
7852
7908
  lapisDateField: z$2.string().min(1),
7853
7909
  useNewEndpoint: z$2.boolean().optional(),
7854
7910
  displayMutations: displayMutationsSchema.optional(),
7855
- initialMeanProportionInterval: z$2.object({
7856
- min: z$2.number().min(0).max(1),
7857
- max: z$2.number().min(0).max(1)
7858
- }),
7911
+ initialMeanProportionInterval: meanProportionIntervalSchema,
7859
7912
  hideGaps: z$2.boolean().optional(),
7860
7913
  width: z$2.string(),
7861
7914
  height: z$2.string().optional(),
@@ -14374,18 +14427,18 @@ const ReferenceGenomesAwaiter = ({ children }) => {
14374
14427
  }
14375
14428
  return /* @__PURE__ */ u$1(Fragment, { children });
14376
14429
  };
14377
- const ExampleMutation = ({ sequenceType, mutationType }) => {
14430
+ const ExampleMutation = ({ sequenceType, mutationType: mutationType2 }) => {
14378
14431
  const referenceGenome = x$1(ReferenceGenomeContext);
14379
- return /* @__PURE__ */ u$1("b", { children: getExampleMutation(referenceGenome, sequenceType, mutationType) });
14432
+ return /* @__PURE__ */ u$1("b", { children: getExampleMutation(referenceGenome, sequenceType, mutationType2) });
14380
14433
  };
14381
- function getExampleMutation(referenceGenome, sequenceType, mutationType) {
14434
+ function getExampleMutation(referenceGenome, sequenceType, mutationType2) {
14382
14435
  switch (sequenceType) {
14383
14436
  case "amino acid": {
14384
14437
  if (referenceGenome.genes.length === 0) {
14385
14438
  return "";
14386
14439
  }
14387
14440
  const firstGene = referenceGenome.genes[0].name;
14388
- switch (mutationType) {
14441
+ switch (mutationType2) {
14389
14442
  case "substitution":
14390
14443
  return `${firstGene}:57Q`;
14391
14444
  case "insertion":
@@ -14400,7 +14453,7 @@ function getExampleMutation(referenceGenome, sequenceType, mutationType) {
14400
14453
  return "";
14401
14454
  }
14402
14455
  case 1: {
14403
- switch (mutationType) {
14456
+ switch (mutationType2) {
14404
14457
  case "substitution":
14405
14458
  return "23T";
14406
14459
  case "insertion":
@@ -14411,7 +14464,7 @@ function getExampleMutation(referenceGenome, sequenceType, mutationType) {
14411
14464
  // eslint-disable-next-line no-fallthrough
14412
14465
  default: {
14413
14466
  const firstSegment = referenceGenome.nucleotideSequences[0].name;
14414
- switch (mutationType) {
14467
+ switch (mutationType2) {
14415
14468
  case "substitution":
14416
14469
  return `${firstSegment}:23T`;
14417
14470
  case "insertion":
@@ -14596,11 +14649,13 @@ const AminoAcidMutationsInfo = () => {
14596
14649
  ". A ",
14597
14650
  /* @__PURE__ */ u$1("b", { children: "<base>" }),
14598
14651
  " can be one of the 20 amino acid codes. It can also be ",
14652
+ /* @__PURE__ */ u$1("b", { children: "*" }),
14653
+ " for a stop codon, ",
14599
14654
  /* @__PURE__ */ u$1("b", { children: "-" }),
14600
14655
  " for deletion and ",
14601
14656
  /* @__PURE__ */ u$1("b", { children: "X" }),
14602
- " for unknown. Example:",
14603
14657
  " ",
14658
+ "for unknown. Example: ",
14604
14659
  /* @__PURE__ */ u$1(ExampleMutation, { mutationType: "substitution", sequenceType: "amino acid" }),
14605
14660
  "."
14606
14661
  ] }),
@@ -14757,11 +14812,11 @@ const parseAndValidateMutation = (value, referenceGenome) => {
14757
14812
  };
14758
14813
  const getSequenceType = (type) => {
14759
14814
  switch (type) {
14760
- case "nucleotideInsertions":
14761
- case "nucleotideMutations":
14815
+ case mutationType.nucleotideInsertions:
14816
+ case mutationType.nucleotideMutations:
14762
14817
  return "nucleotide";
14763
- case "aminoAcidInsertions":
14764
- case "aminoAcidMutations":
14818
+ case mutationType.aminoAcidInsertions:
14819
+ case mutationType.aminoAcidMutations:
14765
14820
  return "amino acid";
14766
14821
  }
14767
14822
  };
@@ -14771,10 +14826,10 @@ const parseMutation = (value, referenceGenome) => {
14771
14826
  const sequenceType = sequenceTypeFromSegment(possibleInsertion.segment, referenceGenome);
14772
14827
  switch (sequenceType) {
14773
14828
  case "nucleotide": {
14774
- return { type: "nucleotideInsertions", value: possibleInsertion };
14829
+ return { type: mutationType.nucleotideInsertions, value: possibleInsertion };
14775
14830
  }
14776
14831
  case "amino acid":
14777
- return { type: "aminoAcidInsertions", value: possibleInsertion };
14832
+ return { type: mutationType.aminoAcidInsertions, value: possibleInsertion };
14778
14833
  case void 0:
14779
14834
  return null;
14780
14835
  }
@@ -14784,9 +14839,9 @@ const parseMutation = (value, referenceGenome) => {
14784
14839
  const sequenceType = sequenceTypeFromSegment(possibleDeletion.segment, referenceGenome);
14785
14840
  switch (sequenceType) {
14786
14841
  case "nucleotide":
14787
- return { type: "nucleotideMutations", value: possibleDeletion };
14842
+ return { type: mutationType.nucleotideMutations, value: possibleDeletion };
14788
14843
  case "amino acid":
14789
- return { type: "aminoAcidMutations", value: possibleDeletion };
14844
+ return { type: mutationType.aminoAcidMutations, value: possibleDeletion };
14790
14845
  case void 0:
14791
14846
  return null;
14792
14847
  }
@@ -14796,10 +14851,10 @@ const parseMutation = (value, referenceGenome) => {
14796
14851
  const sequenceType = sequenceTypeFromSegment(possibleSubstitution.segment, referenceGenome);
14797
14852
  switch (sequenceType) {
14798
14853
  case "nucleotide": {
14799
- return { type: "nucleotideMutations", value: possibleSubstitution };
14854
+ return { type: mutationType.nucleotideMutations, value: possibleSubstitution };
14800
14855
  }
14801
14856
  case "amino acid": {
14802
- return { type: "aminoAcidMutations", value: possibleSubstitution };
14857
+ return { type: mutationType.aminoAcidMutations, value: possibleSubstitution };
14803
14858
  }
14804
14859
  case void 0:
14805
14860
  return null;
@@ -14831,13 +14886,14 @@ function getLengthOfSegment(segment, referenceGenome, sequenceType) {
14831
14886
  }
14832
14887
  }
14833
14888
  const mutationFilterInnerPropsSchema = z$2.object({
14834
- initialValue: z$2.union([mutationsFilterSchema.optional(), z$2.array(z$2.string()), z$2.undefined()])
14889
+ initialValue: z$2.union([mutationsFilterSchema.optional(), z$2.array(z$2.string()), z$2.undefined()]),
14890
+ enabledMutationTypes: z$2.array(mutationTypeSchema).optional()
14835
14891
  });
14836
14892
  const mutationFilterPropsSchema = mutationFilterInnerPropsSchema.extend({
14837
14893
  width: z$2.string()
14838
14894
  });
14839
14895
  const MutationFilter = (props) => {
14840
- const { width, initialValue } = props;
14896
+ const { width, initialValue, enabledMutationTypes } = props;
14841
14897
  return /* @__PURE__ */ u$1(
14842
14898
  ErrorBoundary,
14843
14899
  {
@@ -14845,22 +14901,30 @@ const MutationFilter = (props) => {
14845
14901
  layout: "horizontal",
14846
14902
  schema: mutationFilterPropsSchema,
14847
14903
  componentProps: props,
14848
- children: /* @__PURE__ */ u$1("div", { style: { width }, children: /* @__PURE__ */ u$1(MutationFilterInner, { initialValue }) })
14904
+ children: /* @__PURE__ */ u$1("div", { style: { width }, children: /* @__PURE__ */ u$1(MutationFilterInner, { initialValue, enabledMutationTypes }) })
14849
14905
  }
14850
14906
  );
14851
14907
  };
14852
- function MutationFilterInner({ initialValue }) {
14908
+ function MutationFilterInner({
14909
+ initialValue,
14910
+ enabledMutationTypes = Object.values(mutationType)
14911
+ }) {
14853
14912
  var _a;
14854
14913
  const referenceGenome = x$1(ReferenceGenomeContext);
14855
14914
  const filterRef = A$1(null);
14856
14915
  const [inputValue, setInputValue] = d("");
14857
14916
  const initialState = T$1(() => {
14858
- return getInitialState(initialValue, referenceGenome);
14859
- }, [initialValue, referenceGenome]);
14917
+ return getInitialState(initialValue, referenceGenome, enabledMutationTypes);
14918
+ }, [initialValue, referenceGenome, enabledMutationTypes]);
14860
14919
  const [selectedItems, setSelectedItems] = d(initialState);
14861
14920
  const [itemCandidate, setItemCandidate] = d(null);
14862
14921
  const [showErrorIndicator, setShowErrorIndicator] = d(false);
14863
14922
  const items = itemCandidate ? [itemCandidate] : [];
14923
+ y2(() => {
14924
+ setSelectedItems(
14925
+ (prevSelectedItems) => prevSelectedItems.filter((mutFilterItem) => enabledMutationTypes.includes(mutFilterItem.type))
14926
+ );
14927
+ }, [enabledMutationTypes, selectedItems]);
14864
14928
  const fireChangeEvent = (selectedFilters) => {
14865
14929
  var _a2;
14866
14930
  const detail = mapToMutationFilterStrings(selectedFilters);
@@ -14890,11 +14954,20 @@ function MutationFilterInner({ initialValue }) {
14890
14954
  const values = newInputValue.split(",").map((value) => {
14891
14955
  return { value, parsedValue: parseAndValidateMutation(value.trim(), referenceGenome) };
14892
14956
  });
14893
- const validEntries = values.map((value) => value.parsedValue).filter((value) => value !== null);
14894
- const invalidInput = values.filter((value) => value.parsedValue === null).map((value) => value.value.trim()).join(",");
14957
+ const validEntries = [];
14958
+ const rejected = [];
14959
+ for (const v2 of values) {
14960
+ if (v2.parsedValue === null) {
14961
+ rejected.push(v2.value.trim());
14962
+ } else if (enabledMutationTypes.includes(v2.parsedValue.type)) {
14963
+ validEntries.push(v2.parsedValue);
14964
+ } else {
14965
+ rejected.push(v2.parsedValue.value.code);
14966
+ }
14967
+ }
14895
14968
  const selectedItemCandidates = [...selectedItems, ...validEntries];
14896
14969
  handleSelectedItemsChanged(extractUniqueValues(selectedItemCandidates));
14897
- setInputValue(invalidInput);
14970
+ setInputValue(rejected.join(","));
14898
14971
  setItemCandidate(null);
14899
14972
  } else {
14900
14973
  setInputValue(newInputValue ?? "");
@@ -14903,7 +14976,8 @@ function MutationFilterInner({ initialValue }) {
14903
14976
  const alreadyExists = selectedItems.find(
14904
14977
  (selectedItem2) => selectedItem2.value.code === (candidate == null ? void 0 : candidate.value.code)
14905
14978
  );
14906
- if (!alreadyExists) {
14979
+ const allowedType = candidate !== null && enabledMutationTypes.includes(candidate.type);
14980
+ if (!alreadyExists && allowedType) {
14907
14981
  setItemCandidate(candidate);
14908
14982
  }
14909
14983
  }
@@ -14972,7 +15046,7 @@ function MutationFilterInner({ initialValue }) {
14972
15046
  /* @__PURE__ */ u$1(
14973
15047
  "input",
14974
15048
  {
14975
- placeholder: getPlaceholder(referenceGenome),
15049
+ placeholder: getPlaceholder(referenceGenome, enabledMutationTypes),
14976
15050
  className: "w-full focus:outline-none min-w-8",
14977
15051
  ...getInputProps(getDropdownProps({ preventKeyAction: isOpen })),
14978
15052
  onBlur: () => {
@@ -15014,30 +15088,39 @@ function extractUniqueValues(newSelectedItems) {
15014
15088
  }
15015
15089
  return Array.from(uniqueMutationsMap.values());
15016
15090
  }
15017
- function getInitialState(initialValue, referenceGenome) {
15091
+ function getInitialState(initialValue, referenceGenome, enabledMutationTypes) {
15018
15092
  if (initialValue === void 0) {
15019
15093
  return [];
15020
15094
  }
15021
15095
  const values = Array.isArray(initialValue) ? initialValue : Object.values(initialValue).flatMap((it) => it);
15022
- return values.map((value) => parseAndValidateMutation(value, referenceGenome)).filter((parsedMutation) => parsedMutation !== null);
15023
- }
15024
- function getPlaceholder(referenceGenome) {
15025
- const nucleotideSubstitution = getExampleMutation(referenceGenome, "nucleotide", "substitution");
15026
- const nucleotideInsertion = getExampleMutation(referenceGenome, "nucleotide", "insertion");
15027
- const aminoAcidSubstitution = getExampleMutation(referenceGenome, "amino acid", "substitution");
15028
- const aminoAcidInsertion = getExampleMutation(referenceGenome, "amino acid", "insertion");
15029
- const exampleMutations = [nucleotideSubstitution, nucleotideInsertion, aminoAcidSubstitution, aminoAcidInsertion].filter((example) => example !== "").join(", ");
15096
+ return values.map((value) => parseAndValidateMutation(value, referenceGenome)).filter((parsedMutation) => parsedMutation !== null).filter((mutation) => enabledMutationTypes.includes(mutation.type));
15097
+ }
15098
+ function getPlaceholder(referenceGenome, enabledMutationTypes) {
15099
+ const exampleMutationList = [];
15100
+ if (enabledMutationTypes.includes(mutationType.nucleotideMutations)) {
15101
+ exampleMutationList.push(getExampleMutation(referenceGenome, "nucleotide", "substitution"));
15102
+ }
15103
+ if (enabledMutationTypes.includes(mutationType.nucleotideInsertions)) {
15104
+ exampleMutationList.push(getExampleMutation(referenceGenome, "nucleotide", "insertion"));
15105
+ }
15106
+ if (enabledMutationTypes.includes(mutationType.aminoAcidMutations)) {
15107
+ exampleMutationList.push(getExampleMutation(referenceGenome, "amino acid", "substitution"));
15108
+ }
15109
+ if (enabledMutationTypes.includes(mutationType.aminoAcidInsertions)) {
15110
+ exampleMutationList.push(getExampleMutation(referenceGenome, "amino acid", "insertion"));
15111
+ }
15112
+ const exampleMutations = exampleMutationList.filter((example) => example !== "").join(", ");
15030
15113
  return `Enter a mutation (e.g. ${exampleMutations})`;
15031
15114
  }
15032
15115
  const backgroundColorMap = (data, alpha = 0.4) => {
15033
15116
  switch (data.type) {
15034
- case "nucleotideMutations":
15117
+ case mutationType.nucleotideMutations:
15035
15118
  return singleGraphColorRGBByName("green", alpha);
15036
- case "aminoAcidMutations":
15119
+ case mutationType.aminoAcidMutations:
15037
15120
  return singleGraphColorRGBByName("teal", alpha);
15038
- case "nucleotideInsertions":
15121
+ case mutationType.nucleotideInsertions:
15039
15122
  return singleGraphColorRGBByName("indigo", alpha);
15040
- case "aminoAcidInsertions":
15123
+ case mutationType.aminoAcidInsertions:
15041
15124
  return singleGraphColorRGBByName("purple", alpha);
15042
15125
  }
15043
15126
  };
@@ -15069,13 +15152,13 @@ function mapToMutationFilterStrings(selectedFilters) {
15069
15152
  return selectedFilters.reduce(
15070
15153
  (acc, filter) => {
15071
15154
  switch (filter.type) {
15072
- case "nucleotideMutations":
15155
+ case mutationType.nucleotideMutations:
15073
15156
  return { ...acc, nucleotideMutations: [...acc.nucleotideMutations, filter.value.toString()] };
15074
- case "aminoAcidMutations":
15157
+ case mutationType.aminoAcidMutations:
15075
15158
  return { ...acc, aminoAcidMutations: [...acc.aminoAcidMutations, filter.value.toString()] };
15076
- case "nucleotideInsertions":
15159
+ case mutationType.nucleotideInsertions:
15077
15160
  return { ...acc, nucleotideInsertions: [...acc.nucleotideInsertions, filter.value.toString()] };
15078
- case "aminoAcidInsertions":
15161
+ case mutationType.aminoAcidInsertions:
15079
15162
  return { ...acc, aminoAcidInsertions: [...acc.aminoAcidInsertions, filter.value.toString()] };
15080
15163
  }
15081
15164
  },
@@ -15102,9 +15185,17 @@ let MutationFilterComponent = class extends PreactLitAdapter {
15102
15185
  super(...arguments);
15103
15186
  this.initialValue = void 0;
15104
15187
  this.width = "100%";
15188
+ this.enabledMutationTypes = void 0;
15105
15189
  }
15106
15190
  render() {
15107
- return /* @__PURE__ */ u$1(ReferenceGenomesAwaiter, { children: /* @__PURE__ */ u$1(MutationFilter, { initialValue: this.initialValue, width: this.width }) });
15191
+ return /* @__PURE__ */ u$1(ReferenceGenomesAwaiter, { children: /* @__PURE__ */ u$1(
15192
+ MutationFilter,
15193
+ {
15194
+ initialValue: this.initialValue,
15195
+ width: this.width,
15196
+ enabledMutationTypes: this.enabledMutationTypes
15197
+ }
15198
+ ) });
15108
15199
  }
15109
15200
  };
15110
15201
  __decorateClass$2([
@@ -15113,6 +15204,9 @@ __decorateClass$2([
15113
15204
  __decorateClass$2([
15114
15205
  n$1({ type: String })
15115
15206
  ], MutationFilterComponent.prototype, "width", 2);
15207
+ __decorateClass$2([
15208
+ n$1({ type: Object })
15209
+ ], MutationFilterComponent.prototype, "enabledMutationTypes", 2);
15116
15210
  MutationFilterComponent = __decorateClass$2([
15117
15211
  t$3("gs-mutation-filter")
15118
15212
  ], MutationFilterComponent);