@luzmo/embed 5.1.2 → 5.1.3-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,7 +43,8 @@ var __decorateClass = (decorators, target, key, kind) => {
43
43
  var src_exports2 = {};
44
44
  __export(src_exports2, {
45
45
  LuzmoDashboard: () => LuzmoDashboard2,
46
- LuzmoEmbedDashboard: () => LuzmoEmbedDashboard
46
+ LuzmoEmbedDashboard: () => LuzmoEmbedDashboard,
47
+ LuzmoVizItem: () => LuzmoVizItem
47
48
  });
48
49
  module.exports = __toCommonJS(src_exports2);
49
50
 
@@ -625,7 +626,7 @@ var formatDashboardList = (dashboards, integrationId, user, dashboardComponent)
625
626
  }
626
627
  return treatedDashboards;
627
628
  };
628
- var VERSION = "0.0.0-shared-luzmo";
629
+ var VERSION = "0.0.0-unknown-luzmo";
629
630
  var sanitizeUrl = (url) => {
630
631
  const invalidPrototcolRegex = /^(%20|\s)*(javascript|data)/im;
631
632
  const ctrlCharactersRegex = /[^\u0020-\u007E]/gim;
@@ -738,7 +739,7 @@ var createIframeUrl = (dashboardContent) => {
738
739
  searchString.push("editMode=" + editMode);
739
740
  }
740
741
  const keyTokenUrlAnchor = key && token ? "#" + key + ":" + token : "";
741
- searchString.push("version=" + (dashboardContent.VERSION || VERSION));
742
+ searchString.push("version=" + (dashboardContent.libVersion || VERSION));
742
743
  const iframeUrl = itemEmbedding ? `${appServer}i/${dashboardId || dashboardSlug}/${itemId}?${encodeURIComponent(
743
744
  searchString.join("&")
744
745
  )}${keyTokenUrlAnchor}` : `${appServer}i/${dashboardId || dashboardSlug}?${encodeURIComponent(
@@ -891,7 +892,7 @@ var exportDashboard = (dashboardComponent, iframe, format) => {
891
892
  {
892
893
  action: "exportDashboard",
893
894
  format: format || "png",
894
- _version: dashboardComponent.VERSION,
895
+ _version: dashboardComponent.libVersion,
895
896
  requestId
896
897
  },
897
898
  "*"
@@ -1029,7 +1030,7 @@ var getData = (dashboardComponent, iframe, itemId) => {
1029
1030
  {
1030
1031
  action: "getData",
1031
1032
  id: itemId,
1032
- _version: dashboardComponent.VERSION,
1033
+ _version: dashboardComponent.libVersion,
1033
1034
  requestId
1034
1035
  },
1035
1036
  "*"
@@ -1055,7 +1056,7 @@ var getFilters = (dashboardComponent, iframe) => {
1055
1056
  if (iframe?.contentWindow) {
1056
1057
  const requestId = uuidv4();
1057
1058
  iframe.contentWindow.postMessage(
1058
- { action: "getFilters", _version: dashboardComponent.VERSION, requestId },
1059
+ { action: "getFilters", _version: dashboardComponent.libVersion, requestId },
1059
1060
  "*"
1060
1061
  );
1061
1062
  return new Promise((resolve, reject) => {
@@ -1081,7 +1082,7 @@ var refreshData = (dashboardComponent, iframe, itemId) => {
1081
1082
  {
1082
1083
  action: "refreshData",
1083
1084
  id: itemId ?? null,
1084
- _version: dashboardComponent.VERSION
1085
+ _version: dashboardComponent.libVersion
1085
1086
  },
1086
1087
  "*"
1087
1088
  );
@@ -1094,7 +1095,7 @@ var refreshData = (dashboardComponent, iframe, itemId) => {
1094
1095
  var reloadDashboard = (dashboardComponent, iframe) => {
1095
1096
  if (iframe) {
1096
1097
  iframe.contentWindow.postMessage(
1097
- { action: "reloadDashboard", _version: dashboardComponent.VERSION },
1098
+ { action: "reloadDashboard", _version: dashboardComponent.libVersion },
1098
1099
  "*"
1099
1100
  );
1100
1101
  return Promise.resolve();
@@ -1110,7 +1111,7 @@ var setAuthorization = (dashboardComponent, iframe, key, token) => {
1110
1111
  action: "setAuthorization",
1111
1112
  key,
1112
1113
  token,
1113
- _version: dashboardComponent.VERSION
1114
+ _version: dashboardComponent.libVersion
1114
1115
  },
1115
1116
  "*"
1116
1117
  );
@@ -1138,7 +1139,7 @@ var setEditMode = (dashboardComponent, iframe, editMode) => {
1138
1139
  {
1139
1140
  action: "setEditMode",
1140
1141
  editMode,
1141
- _version: dashboardComponent.VERSION,
1142
+ _version: dashboardComponent.libVersion,
1142
1143
  requestId
1143
1144
  },
1144
1145
  "*"
@@ -1159,7 +1160,7 @@ var setFilters = (dashboardComponent, iframe, itemId, filters) => {
1159
1160
  action: "setFilters",
1160
1161
  itemId,
1161
1162
  filters,
1162
- _version: dashboardComponent.VERSION,
1163
+ _version: dashboardComponent.libVersion,
1163
1164
  requestId
1164
1165
  },
1165
1166
  "*"
@@ -1189,7 +1190,7 @@ var setPreview = (dashboardComponent, iframe, preview) => {
1189
1190
  action: "setPreview",
1190
1191
  preview,
1191
1192
  requestId,
1192
- _version: dashboardComponent.VERSION
1193
+ _version: dashboardComponent.libVersion
1193
1194
  },
1194
1195
  "*"
1195
1196
  );
@@ -1490,6 +1491,4053 @@ var _extendAndValidate = (dashboardContent) => {
1490
1491
  }
1491
1492
  };
1492
1493
 
1494
+ // node_modules/zod/lib/index.mjs
1495
+ var util;
1496
+ (function(util2) {
1497
+ util2.assertEqual = (val) => val;
1498
+ function assertIs(_arg) {
1499
+ }
1500
+ util2.assertIs = assertIs;
1501
+ function assertNever(_x) {
1502
+ throw new Error();
1503
+ }
1504
+ util2.assertNever = assertNever;
1505
+ util2.arrayToEnum = (items) => {
1506
+ const obj = {};
1507
+ for (const item of items) {
1508
+ obj[item] = item;
1509
+ }
1510
+ return obj;
1511
+ };
1512
+ util2.getValidEnumValues = (obj) => {
1513
+ const validKeys = util2.objectKeys(obj).filter((k2) => typeof obj[obj[k2]] !== "number");
1514
+ const filtered = {};
1515
+ for (const k2 of validKeys) {
1516
+ filtered[k2] = obj[k2];
1517
+ }
1518
+ return util2.objectValues(filtered);
1519
+ };
1520
+ util2.objectValues = (obj) => {
1521
+ return util2.objectKeys(obj).map(function(e7) {
1522
+ return obj[e7];
1523
+ });
1524
+ };
1525
+ util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
1526
+ const keys = [];
1527
+ for (const key in object) {
1528
+ if (Object.prototype.hasOwnProperty.call(object, key)) {
1529
+ keys.push(key);
1530
+ }
1531
+ }
1532
+ return keys;
1533
+ };
1534
+ util2.find = (arr, checker) => {
1535
+ for (const item of arr) {
1536
+ if (checker(item))
1537
+ return item;
1538
+ }
1539
+ return void 0;
1540
+ };
1541
+ util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
1542
+ function joinValues(array, separator = " | ") {
1543
+ return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
1544
+ }
1545
+ util2.joinValues = joinValues;
1546
+ util2.jsonStringifyReplacer = (_2, value) => {
1547
+ if (typeof value === "bigint") {
1548
+ return value.toString();
1549
+ }
1550
+ return value;
1551
+ };
1552
+ })(util || (util = {}));
1553
+ var objectUtil;
1554
+ (function(objectUtil2) {
1555
+ objectUtil2.mergeShapes = (first, second) => {
1556
+ return {
1557
+ ...first,
1558
+ ...second
1559
+ // second overwrites first
1560
+ };
1561
+ };
1562
+ })(objectUtil || (objectUtil = {}));
1563
+ var ZodParsedType = util.arrayToEnum([
1564
+ "string",
1565
+ "nan",
1566
+ "number",
1567
+ "integer",
1568
+ "float",
1569
+ "boolean",
1570
+ "date",
1571
+ "bigint",
1572
+ "symbol",
1573
+ "function",
1574
+ "undefined",
1575
+ "null",
1576
+ "array",
1577
+ "object",
1578
+ "unknown",
1579
+ "promise",
1580
+ "void",
1581
+ "never",
1582
+ "map",
1583
+ "set"
1584
+ ]);
1585
+ var getParsedType = (data) => {
1586
+ const t5 = typeof data;
1587
+ switch (t5) {
1588
+ case "undefined":
1589
+ return ZodParsedType.undefined;
1590
+ case "string":
1591
+ return ZodParsedType.string;
1592
+ case "number":
1593
+ return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
1594
+ case "boolean":
1595
+ return ZodParsedType.boolean;
1596
+ case "function":
1597
+ return ZodParsedType.function;
1598
+ case "bigint":
1599
+ return ZodParsedType.bigint;
1600
+ case "symbol":
1601
+ return ZodParsedType.symbol;
1602
+ case "object":
1603
+ if (Array.isArray(data)) {
1604
+ return ZodParsedType.array;
1605
+ }
1606
+ if (data === null) {
1607
+ return ZodParsedType.null;
1608
+ }
1609
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
1610
+ return ZodParsedType.promise;
1611
+ }
1612
+ if (typeof Map !== "undefined" && data instanceof Map) {
1613
+ return ZodParsedType.map;
1614
+ }
1615
+ if (typeof Set !== "undefined" && data instanceof Set) {
1616
+ return ZodParsedType.set;
1617
+ }
1618
+ if (typeof Date !== "undefined" && data instanceof Date) {
1619
+ return ZodParsedType.date;
1620
+ }
1621
+ return ZodParsedType.object;
1622
+ default:
1623
+ return ZodParsedType.unknown;
1624
+ }
1625
+ };
1626
+ var ZodIssueCode = util.arrayToEnum([
1627
+ "invalid_type",
1628
+ "invalid_literal",
1629
+ "custom",
1630
+ "invalid_union",
1631
+ "invalid_union_discriminator",
1632
+ "invalid_enum_value",
1633
+ "unrecognized_keys",
1634
+ "invalid_arguments",
1635
+ "invalid_return_type",
1636
+ "invalid_date",
1637
+ "invalid_string",
1638
+ "too_small",
1639
+ "too_big",
1640
+ "invalid_intersection_types",
1641
+ "not_multiple_of",
1642
+ "not_finite"
1643
+ ]);
1644
+ var quotelessJson = (obj) => {
1645
+ const json = JSON.stringify(obj, null, 2);
1646
+ return json.replace(/"([^"]+)":/g, "$1:");
1647
+ };
1648
+ var ZodError = class _ZodError extends Error {
1649
+ constructor(issues) {
1650
+ super();
1651
+ this.issues = [];
1652
+ this.addIssue = (sub) => {
1653
+ this.issues = [...this.issues, sub];
1654
+ };
1655
+ this.addIssues = (subs = []) => {
1656
+ this.issues = [...this.issues, ...subs];
1657
+ };
1658
+ const actualProto = new.target.prototype;
1659
+ if (Object.setPrototypeOf) {
1660
+ Object.setPrototypeOf(this, actualProto);
1661
+ } else {
1662
+ this.__proto__ = actualProto;
1663
+ }
1664
+ this.name = "ZodError";
1665
+ this.issues = issues;
1666
+ }
1667
+ get errors() {
1668
+ return this.issues;
1669
+ }
1670
+ format(_mapper) {
1671
+ const mapper = _mapper || function(issue) {
1672
+ return issue.message;
1673
+ };
1674
+ const fieldErrors = { _errors: [] };
1675
+ const processError = (error) => {
1676
+ for (const issue of error.issues) {
1677
+ if (issue.code === "invalid_union") {
1678
+ issue.unionErrors.map(processError);
1679
+ } else if (issue.code === "invalid_return_type") {
1680
+ processError(issue.returnTypeError);
1681
+ } else if (issue.code === "invalid_arguments") {
1682
+ processError(issue.argumentsError);
1683
+ } else if (issue.path.length === 0) {
1684
+ fieldErrors._errors.push(mapper(issue));
1685
+ } else {
1686
+ let curr = fieldErrors;
1687
+ let i6 = 0;
1688
+ while (i6 < issue.path.length) {
1689
+ const el = issue.path[i6];
1690
+ const terminal = i6 === issue.path.length - 1;
1691
+ if (!terminal) {
1692
+ curr[el] = curr[el] || { _errors: [] };
1693
+ } else {
1694
+ curr[el] = curr[el] || { _errors: [] };
1695
+ curr[el]._errors.push(mapper(issue));
1696
+ }
1697
+ curr = curr[el];
1698
+ i6++;
1699
+ }
1700
+ }
1701
+ }
1702
+ };
1703
+ processError(this);
1704
+ return fieldErrors;
1705
+ }
1706
+ static assert(value) {
1707
+ if (!(value instanceof _ZodError)) {
1708
+ throw new Error(`Not a ZodError: ${value}`);
1709
+ }
1710
+ }
1711
+ toString() {
1712
+ return this.message;
1713
+ }
1714
+ get message() {
1715
+ return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
1716
+ }
1717
+ get isEmpty() {
1718
+ return this.issues.length === 0;
1719
+ }
1720
+ flatten(mapper = (issue) => issue.message) {
1721
+ const fieldErrors = {};
1722
+ const formErrors = [];
1723
+ for (const sub of this.issues) {
1724
+ if (sub.path.length > 0) {
1725
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
1726
+ fieldErrors[sub.path[0]].push(mapper(sub));
1727
+ } else {
1728
+ formErrors.push(mapper(sub));
1729
+ }
1730
+ }
1731
+ return { formErrors, fieldErrors };
1732
+ }
1733
+ get formErrors() {
1734
+ return this.flatten();
1735
+ }
1736
+ };
1737
+ ZodError.create = (issues) => {
1738
+ const error = new ZodError(issues);
1739
+ return error;
1740
+ };
1741
+ var errorMap = (issue, _ctx) => {
1742
+ let message;
1743
+ switch (issue.code) {
1744
+ case ZodIssueCode.invalid_type:
1745
+ if (issue.received === ZodParsedType.undefined) {
1746
+ message = "Required";
1747
+ } else {
1748
+ message = `Expected ${issue.expected}, received ${issue.received}`;
1749
+ }
1750
+ break;
1751
+ case ZodIssueCode.invalid_literal:
1752
+ message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
1753
+ break;
1754
+ case ZodIssueCode.unrecognized_keys:
1755
+ message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
1756
+ break;
1757
+ case ZodIssueCode.invalid_union:
1758
+ message = `Invalid input`;
1759
+ break;
1760
+ case ZodIssueCode.invalid_union_discriminator:
1761
+ message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
1762
+ break;
1763
+ case ZodIssueCode.invalid_enum_value:
1764
+ message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
1765
+ break;
1766
+ case ZodIssueCode.invalid_arguments:
1767
+ message = `Invalid function arguments`;
1768
+ break;
1769
+ case ZodIssueCode.invalid_return_type:
1770
+ message = `Invalid function return type`;
1771
+ break;
1772
+ case ZodIssueCode.invalid_date:
1773
+ message = `Invalid date`;
1774
+ break;
1775
+ case ZodIssueCode.invalid_string:
1776
+ if (typeof issue.validation === "object") {
1777
+ if ("includes" in issue.validation) {
1778
+ message = `Invalid input: must include "${issue.validation.includes}"`;
1779
+ if (typeof issue.validation.position === "number") {
1780
+ message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
1781
+ }
1782
+ } else if ("startsWith" in issue.validation) {
1783
+ message = `Invalid input: must start with "${issue.validation.startsWith}"`;
1784
+ } else if ("endsWith" in issue.validation) {
1785
+ message = `Invalid input: must end with "${issue.validation.endsWith}"`;
1786
+ } else {
1787
+ util.assertNever(issue.validation);
1788
+ }
1789
+ } else if (issue.validation !== "regex") {
1790
+ message = `Invalid ${issue.validation}`;
1791
+ } else {
1792
+ message = "Invalid";
1793
+ }
1794
+ break;
1795
+ case ZodIssueCode.too_small:
1796
+ if (issue.type === "array")
1797
+ message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
1798
+ else if (issue.type === "string")
1799
+ message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
1800
+ else if (issue.type === "number")
1801
+ message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
1802
+ else if (issue.type === "date")
1803
+ message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
1804
+ else
1805
+ message = "Invalid input";
1806
+ break;
1807
+ case ZodIssueCode.too_big:
1808
+ if (issue.type === "array")
1809
+ message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
1810
+ else if (issue.type === "string")
1811
+ message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
1812
+ else if (issue.type === "number")
1813
+ message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1814
+ else if (issue.type === "bigint")
1815
+ message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
1816
+ else if (issue.type === "date")
1817
+ message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
1818
+ else
1819
+ message = "Invalid input";
1820
+ break;
1821
+ case ZodIssueCode.custom:
1822
+ message = `Invalid input`;
1823
+ break;
1824
+ case ZodIssueCode.invalid_intersection_types:
1825
+ message = `Intersection results could not be merged`;
1826
+ break;
1827
+ case ZodIssueCode.not_multiple_of:
1828
+ message = `Number must be a multiple of ${issue.multipleOf}`;
1829
+ break;
1830
+ case ZodIssueCode.not_finite:
1831
+ message = "Number must be finite";
1832
+ break;
1833
+ default:
1834
+ message = _ctx.defaultError;
1835
+ util.assertNever(issue);
1836
+ }
1837
+ return { message };
1838
+ };
1839
+ var overrideErrorMap = errorMap;
1840
+ function setErrorMap(map) {
1841
+ overrideErrorMap = map;
1842
+ }
1843
+ function getErrorMap() {
1844
+ return overrideErrorMap;
1845
+ }
1846
+ var makeIssue = (params) => {
1847
+ const { data, path, errorMaps, issueData } = params;
1848
+ const fullPath = [...path, ...issueData.path || []];
1849
+ const fullIssue = {
1850
+ ...issueData,
1851
+ path: fullPath
1852
+ };
1853
+ if (issueData.message !== void 0) {
1854
+ return {
1855
+ ...issueData,
1856
+ path: fullPath,
1857
+ message: issueData.message
1858
+ };
1859
+ }
1860
+ let errorMessage = "";
1861
+ const maps = errorMaps.filter((m2) => !!m2).slice().reverse();
1862
+ for (const map of maps) {
1863
+ errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
1864
+ }
1865
+ return {
1866
+ ...issueData,
1867
+ path: fullPath,
1868
+ message: errorMessage
1869
+ };
1870
+ };
1871
+ var EMPTY_PATH = [];
1872
+ function addIssueToContext(ctx, issueData) {
1873
+ const overrideMap = getErrorMap();
1874
+ const issue = makeIssue({
1875
+ issueData,
1876
+ data: ctx.data,
1877
+ path: ctx.path,
1878
+ errorMaps: [
1879
+ ctx.common.contextualErrorMap,
1880
+ ctx.schemaErrorMap,
1881
+ overrideMap,
1882
+ overrideMap === errorMap ? void 0 : errorMap
1883
+ // then global default map
1884
+ ].filter((x2) => !!x2)
1885
+ });
1886
+ ctx.common.issues.push(issue);
1887
+ }
1888
+ var ParseStatus = class _ParseStatus {
1889
+ constructor() {
1890
+ this.value = "valid";
1891
+ }
1892
+ dirty() {
1893
+ if (this.value === "valid")
1894
+ this.value = "dirty";
1895
+ }
1896
+ abort() {
1897
+ if (this.value !== "aborted")
1898
+ this.value = "aborted";
1899
+ }
1900
+ static mergeArray(status, results) {
1901
+ const arrayValue = [];
1902
+ for (const s4 of results) {
1903
+ if (s4.status === "aborted")
1904
+ return INVALID;
1905
+ if (s4.status === "dirty")
1906
+ status.dirty();
1907
+ arrayValue.push(s4.value);
1908
+ }
1909
+ return { status: status.value, value: arrayValue };
1910
+ }
1911
+ static async mergeObjectAsync(status, pairs) {
1912
+ const syncPairs = [];
1913
+ for (const pair of pairs) {
1914
+ const key = await pair.key;
1915
+ const value = await pair.value;
1916
+ syncPairs.push({
1917
+ key,
1918
+ value
1919
+ });
1920
+ }
1921
+ return _ParseStatus.mergeObjectSync(status, syncPairs);
1922
+ }
1923
+ static mergeObjectSync(status, pairs) {
1924
+ const finalObject = {};
1925
+ for (const pair of pairs) {
1926
+ const { key, value } = pair;
1927
+ if (key.status === "aborted")
1928
+ return INVALID;
1929
+ if (value.status === "aborted")
1930
+ return INVALID;
1931
+ if (key.status === "dirty")
1932
+ status.dirty();
1933
+ if (value.status === "dirty")
1934
+ status.dirty();
1935
+ if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
1936
+ finalObject[key.value] = value.value;
1937
+ }
1938
+ }
1939
+ return { status: status.value, value: finalObject };
1940
+ }
1941
+ };
1942
+ var INVALID = Object.freeze({
1943
+ status: "aborted"
1944
+ });
1945
+ var DIRTY = (value) => ({ status: "dirty", value });
1946
+ var OK = (value) => ({ status: "valid", value });
1947
+ var isAborted = (x2) => x2.status === "aborted";
1948
+ var isDirty = (x2) => x2.status === "dirty";
1949
+ var isValid = (x2) => x2.status === "valid";
1950
+ var isAsync = (x2) => typeof Promise !== "undefined" && x2 instanceof Promise;
1951
+ function __classPrivateFieldGet(receiver, state, kind, f3) {
1952
+ if (kind === "a" && !f3)
1953
+ throw new TypeError("Private accessor was defined without a getter");
1954
+ if (typeof state === "function" ? receiver !== state || !f3 : !state.has(receiver))
1955
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
1956
+ return kind === "m" ? f3 : kind === "a" ? f3.call(receiver) : f3 ? f3.value : state.get(receiver);
1957
+ }
1958
+ function __classPrivateFieldSet(receiver, state, value, kind, f3) {
1959
+ if (kind === "m")
1960
+ throw new TypeError("Private method is not writable");
1961
+ if (kind === "a" && !f3)
1962
+ throw new TypeError("Private accessor was defined without a setter");
1963
+ if (typeof state === "function" ? receiver !== state || !f3 : !state.has(receiver))
1964
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
1965
+ return kind === "a" ? f3.call(receiver, value) : f3 ? f3.value = value : state.set(receiver, value), value;
1966
+ }
1967
+ var errorUtil;
1968
+ (function(errorUtil2) {
1969
+ errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
1970
+ errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
1971
+ })(errorUtil || (errorUtil = {}));
1972
+ var _ZodEnum_cache;
1973
+ var _ZodNativeEnum_cache;
1974
+ var ParseInputLazyPath = class {
1975
+ constructor(parent, value, path, key) {
1976
+ this._cachedPath = [];
1977
+ this.parent = parent;
1978
+ this.data = value;
1979
+ this._path = path;
1980
+ this._key = key;
1981
+ }
1982
+ get path() {
1983
+ if (!this._cachedPath.length) {
1984
+ if (this._key instanceof Array) {
1985
+ this._cachedPath.push(...this._path, ...this._key);
1986
+ } else {
1987
+ this._cachedPath.push(...this._path, this._key);
1988
+ }
1989
+ }
1990
+ return this._cachedPath;
1991
+ }
1992
+ };
1993
+ var handleResult = (ctx, result) => {
1994
+ if (isValid(result)) {
1995
+ return { success: true, data: result.value };
1996
+ } else {
1997
+ if (!ctx.common.issues.length) {
1998
+ throw new Error("Validation failed but no issues detected.");
1999
+ }
2000
+ return {
2001
+ success: false,
2002
+ get error() {
2003
+ if (this._error)
2004
+ return this._error;
2005
+ const error = new ZodError(ctx.common.issues);
2006
+ this._error = error;
2007
+ return this._error;
2008
+ }
2009
+ };
2010
+ }
2011
+ };
2012
+ function processCreateParams(params) {
2013
+ if (!params)
2014
+ return {};
2015
+ const { errorMap: errorMap2, invalid_type_error, required_error, description } = params;
2016
+ if (errorMap2 && (invalid_type_error || required_error)) {
2017
+ throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
2018
+ }
2019
+ if (errorMap2)
2020
+ return { errorMap: errorMap2, description };
2021
+ const customMap = (iss, ctx) => {
2022
+ var _a, _b;
2023
+ const { message } = params;
2024
+ if (iss.code === "invalid_enum_value") {
2025
+ return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
2026
+ }
2027
+ if (typeof ctx.data === "undefined") {
2028
+ return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
2029
+ }
2030
+ if (iss.code !== "invalid_type")
2031
+ return { message: ctx.defaultError };
2032
+ return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
2033
+ };
2034
+ return { errorMap: customMap, description };
2035
+ }
2036
+ var ZodType = class {
2037
+ constructor(def) {
2038
+ this.spa = this.safeParseAsync;
2039
+ this._def = def;
2040
+ this.parse = this.parse.bind(this);
2041
+ this.safeParse = this.safeParse.bind(this);
2042
+ this.parseAsync = this.parseAsync.bind(this);
2043
+ this.safeParseAsync = this.safeParseAsync.bind(this);
2044
+ this.spa = this.spa.bind(this);
2045
+ this.refine = this.refine.bind(this);
2046
+ this.refinement = this.refinement.bind(this);
2047
+ this.superRefine = this.superRefine.bind(this);
2048
+ this.optional = this.optional.bind(this);
2049
+ this.nullable = this.nullable.bind(this);
2050
+ this.nullish = this.nullish.bind(this);
2051
+ this.array = this.array.bind(this);
2052
+ this.promise = this.promise.bind(this);
2053
+ this.or = this.or.bind(this);
2054
+ this.and = this.and.bind(this);
2055
+ this.transform = this.transform.bind(this);
2056
+ this.brand = this.brand.bind(this);
2057
+ this.default = this.default.bind(this);
2058
+ this.catch = this.catch.bind(this);
2059
+ this.describe = this.describe.bind(this);
2060
+ this.pipe = this.pipe.bind(this);
2061
+ this.readonly = this.readonly.bind(this);
2062
+ this.isNullable = this.isNullable.bind(this);
2063
+ this.isOptional = this.isOptional.bind(this);
2064
+ }
2065
+ get description() {
2066
+ return this._def.description;
2067
+ }
2068
+ _getType(input) {
2069
+ return getParsedType(input.data);
2070
+ }
2071
+ _getOrReturnCtx(input, ctx) {
2072
+ return ctx || {
2073
+ common: input.parent.common,
2074
+ data: input.data,
2075
+ parsedType: getParsedType(input.data),
2076
+ schemaErrorMap: this._def.errorMap,
2077
+ path: input.path,
2078
+ parent: input.parent
2079
+ };
2080
+ }
2081
+ _processInputParams(input) {
2082
+ return {
2083
+ status: new ParseStatus(),
2084
+ ctx: {
2085
+ common: input.parent.common,
2086
+ data: input.data,
2087
+ parsedType: getParsedType(input.data),
2088
+ schemaErrorMap: this._def.errorMap,
2089
+ path: input.path,
2090
+ parent: input.parent
2091
+ }
2092
+ };
2093
+ }
2094
+ _parseSync(input) {
2095
+ const result = this._parse(input);
2096
+ if (isAsync(result)) {
2097
+ throw new Error("Synchronous parse encountered promise.");
2098
+ }
2099
+ return result;
2100
+ }
2101
+ _parseAsync(input) {
2102
+ const result = this._parse(input);
2103
+ return Promise.resolve(result);
2104
+ }
2105
+ parse(data, params) {
2106
+ const result = this.safeParse(data, params);
2107
+ if (result.success)
2108
+ return result.data;
2109
+ throw result.error;
2110
+ }
2111
+ safeParse(data, params) {
2112
+ var _a;
2113
+ const ctx = {
2114
+ common: {
2115
+ issues: [],
2116
+ async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false,
2117
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
2118
+ },
2119
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
2120
+ schemaErrorMap: this._def.errorMap,
2121
+ parent: null,
2122
+ data,
2123
+ parsedType: getParsedType(data)
2124
+ };
2125
+ const result = this._parseSync({ data, path: ctx.path, parent: ctx });
2126
+ return handleResult(ctx, result);
2127
+ }
2128
+ async parseAsync(data, params) {
2129
+ const result = await this.safeParseAsync(data, params);
2130
+ if (result.success)
2131
+ return result.data;
2132
+ throw result.error;
2133
+ }
2134
+ async safeParseAsync(data, params) {
2135
+ const ctx = {
2136
+ common: {
2137
+ issues: [],
2138
+ contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
2139
+ async: true
2140
+ },
2141
+ path: (params === null || params === void 0 ? void 0 : params.path) || [],
2142
+ schemaErrorMap: this._def.errorMap,
2143
+ parent: null,
2144
+ data,
2145
+ parsedType: getParsedType(data)
2146
+ };
2147
+ const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
2148
+ const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
2149
+ return handleResult(ctx, result);
2150
+ }
2151
+ refine(check, message) {
2152
+ const getIssueProperties = (val) => {
2153
+ if (typeof message === "string" || typeof message === "undefined") {
2154
+ return { message };
2155
+ } else if (typeof message === "function") {
2156
+ return message(val);
2157
+ } else {
2158
+ return message;
2159
+ }
2160
+ };
2161
+ return this._refinement((val, ctx) => {
2162
+ const result = check(val);
2163
+ const setError = () => ctx.addIssue({
2164
+ code: ZodIssueCode.custom,
2165
+ ...getIssueProperties(val)
2166
+ });
2167
+ if (typeof Promise !== "undefined" && result instanceof Promise) {
2168
+ return result.then((data) => {
2169
+ if (!data) {
2170
+ setError();
2171
+ return false;
2172
+ } else {
2173
+ return true;
2174
+ }
2175
+ });
2176
+ }
2177
+ if (!result) {
2178
+ setError();
2179
+ return false;
2180
+ } else {
2181
+ return true;
2182
+ }
2183
+ });
2184
+ }
2185
+ refinement(check, refinementData) {
2186
+ return this._refinement((val, ctx) => {
2187
+ if (!check(val)) {
2188
+ ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
2189
+ return false;
2190
+ } else {
2191
+ return true;
2192
+ }
2193
+ });
2194
+ }
2195
+ _refinement(refinement) {
2196
+ return new ZodEffects({
2197
+ schema: this,
2198
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
2199
+ effect: { type: "refinement", refinement }
2200
+ });
2201
+ }
2202
+ superRefine(refinement) {
2203
+ return this._refinement(refinement);
2204
+ }
2205
+ optional() {
2206
+ return ZodOptional.create(this, this._def);
2207
+ }
2208
+ nullable() {
2209
+ return ZodNullable.create(this, this._def);
2210
+ }
2211
+ nullish() {
2212
+ return this.nullable().optional();
2213
+ }
2214
+ array() {
2215
+ return ZodArray.create(this, this._def);
2216
+ }
2217
+ promise() {
2218
+ return ZodPromise.create(this, this._def);
2219
+ }
2220
+ or(option) {
2221
+ return ZodUnion.create([this, option], this._def);
2222
+ }
2223
+ and(incoming) {
2224
+ return ZodIntersection.create(this, incoming, this._def);
2225
+ }
2226
+ transform(transform) {
2227
+ return new ZodEffects({
2228
+ ...processCreateParams(this._def),
2229
+ schema: this,
2230
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
2231
+ effect: { type: "transform", transform }
2232
+ });
2233
+ }
2234
+ default(def) {
2235
+ const defaultValueFunc = typeof def === "function" ? def : () => def;
2236
+ return new ZodDefault({
2237
+ ...processCreateParams(this._def),
2238
+ innerType: this,
2239
+ defaultValue: defaultValueFunc,
2240
+ typeName: ZodFirstPartyTypeKind.ZodDefault
2241
+ });
2242
+ }
2243
+ brand() {
2244
+ return new ZodBranded({
2245
+ typeName: ZodFirstPartyTypeKind.ZodBranded,
2246
+ type: this,
2247
+ ...processCreateParams(this._def)
2248
+ });
2249
+ }
2250
+ catch(def) {
2251
+ const catchValueFunc = typeof def === "function" ? def : () => def;
2252
+ return new ZodCatch({
2253
+ ...processCreateParams(this._def),
2254
+ innerType: this,
2255
+ catchValue: catchValueFunc,
2256
+ typeName: ZodFirstPartyTypeKind.ZodCatch
2257
+ });
2258
+ }
2259
+ describe(description) {
2260
+ const This = this.constructor;
2261
+ return new This({
2262
+ ...this._def,
2263
+ description
2264
+ });
2265
+ }
2266
+ pipe(target) {
2267
+ return ZodPipeline.create(this, target);
2268
+ }
2269
+ readonly() {
2270
+ return ZodReadonly.create(this);
2271
+ }
2272
+ isOptional() {
2273
+ return this.safeParse(void 0).success;
2274
+ }
2275
+ isNullable() {
2276
+ return this.safeParse(null).success;
2277
+ }
2278
+ };
2279
+ var cuidRegex = /^c[^\s-]{8,}$/i;
2280
+ var cuid2Regex = /^[0-9a-z]+$/;
2281
+ var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
2282
+ var 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;
2283
+ var nanoidRegex = /^[a-z0-9_-]{21}$/i;
2284
+ var 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)?)??$/;
2285
+ var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
2286
+ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
2287
+ var emojiRegex;
2288
+ var 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])$/;
2289
+ var ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
2290
+ var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
2291
+ var 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])))`;
2292
+ var dateRegex = new RegExp(`^${dateRegexSource}$`);
2293
+ function timeRegexSource(args) {
2294
+ let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
2295
+ if (args.precision) {
2296
+ regex = `${regex}\\.\\d{${args.precision}}`;
2297
+ } else if (args.precision == null) {
2298
+ regex = `${regex}(\\.\\d+)?`;
2299
+ }
2300
+ return regex;
2301
+ }
2302
+ function timeRegex(args) {
2303
+ return new RegExp(`^${timeRegexSource(args)}$`);
2304
+ }
2305
+ function datetimeRegex(args) {
2306
+ let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
2307
+ const opts = [];
2308
+ opts.push(args.local ? `Z?` : `Z`);
2309
+ if (args.offset)
2310
+ opts.push(`([+-]\\d{2}:?\\d{2})`);
2311
+ regex = `${regex}(${opts.join("|")})`;
2312
+ return new RegExp(`^${regex}$`);
2313
+ }
2314
+ function isValidIP(ip, version2) {
2315
+ if ((version2 === "v4" || !version2) && ipv4Regex.test(ip)) {
2316
+ return true;
2317
+ }
2318
+ if ((version2 === "v6" || !version2) && ipv6Regex.test(ip)) {
2319
+ return true;
2320
+ }
2321
+ return false;
2322
+ }
2323
+ var ZodString = class _ZodString extends ZodType {
2324
+ _parse(input) {
2325
+ if (this._def.coerce) {
2326
+ input.data = String(input.data);
2327
+ }
2328
+ const parsedType = this._getType(input);
2329
+ if (parsedType !== ZodParsedType.string) {
2330
+ const ctx2 = this._getOrReturnCtx(input);
2331
+ addIssueToContext(ctx2, {
2332
+ code: ZodIssueCode.invalid_type,
2333
+ expected: ZodParsedType.string,
2334
+ received: ctx2.parsedType
2335
+ });
2336
+ return INVALID;
2337
+ }
2338
+ const status = new ParseStatus();
2339
+ let ctx = void 0;
2340
+ for (const check of this._def.checks) {
2341
+ if (check.kind === "min") {
2342
+ if (input.data.length < check.value) {
2343
+ ctx = this._getOrReturnCtx(input, ctx);
2344
+ addIssueToContext(ctx, {
2345
+ code: ZodIssueCode.too_small,
2346
+ minimum: check.value,
2347
+ type: "string",
2348
+ inclusive: true,
2349
+ exact: false,
2350
+ message: check.message
2351
+ });
2352
+ status.dirty();
2353
+ }
2354
+ } else if (check.kind === "max") {
2355
+ if (input.data.length > check.value) {
2356
+ ctx = this._getOrReturnCtx(input, ctx);
2357
+ addIssueToContext(ctx, {
2358
+ code: ZodIssueCode.too_big,
2359
+ maximum: check.value,
2360
+ type: "string",
2361
+ inclusive: true,
2362
+ exact: false,
2363
+ message: check.message
2364
+ });
2365
+ status.dirty();
2366
+ }
2367
+ } else if (check.kind === "length") {
2368
+ const tooBig = input.data.length > check.value;
2369
+ const tooSmall = input.data.length < check.value;
2370
+ if (tooBig || tooSmall) {
2371
+ ctx = this._getOrReturnCtx(input, ctx);
2372
+ if (tooBig) {
2373
+ addIssueToContext(ctx, {
2374
+ code: ZodIssueCode.too_big,
2375
+ maximum: check.value,
2376
+ type: "string",
2377
+ inclusive: true,
2378
+ exact: true,
2379
+ message: check.message
2380
+ });
2381
+ } else if (tooSmall) {
2382
+ addIssueToContext(ctx, {
2383
+ code: ZodIssueCode.too_small,
2384
+ minimum: check.value,
2385
+ type: "string",
2386
+ inclusive: true,
2387
+ exact: true,
2388
+ message: check.message
2389
+ });
2390
+ }
2391
+ status.dirty();
2392
+ }
2393
+ } else if (check.kind === "email") {
2394
+ if (!emailRegex.test(input.data)) {
2395
+ ctx = this._getOrReturnCtx(input, ctx);
2396
+ addIssueToContext(ctx, {
2397
+ validation: "email",
2398
+ code: ZodIssueCode.invalid_string,
2399
+ message: check.message
2400
+ });
2401
+ status.dirty();
2402
+ }
2403
+ } else if (check.kind === "emoji") {
2404
+ if (!emojiRegex) {
2405
+ emojiRegex = new RegExp(_emojiRegex, "u");
2406
+ }
2407
+ if (!emojiRegex.test(input.data)) {
2408
+ ctx = this._getOrReturnCtx(input, ctx);
2409
+ addIssueToContext(ctx, {
2410
+ validation: "emoji",
2411
+ code: ZodIssueCode.invalid_string,
2412
+ message: check.message
2413
+ });
2414
+ status.dirty();
2415
+ }
2416
+ } else if (check.kind === "uuid") {
2417
+ if (!uuidRegex.test(input.data)) {
2418
+ ctx = this._getOrReturnCtx(input, ctx);
2419
+ addIssueToContext(ctx, {
2420
+ validation: "uuid",
2421
+ code: ZodIssueCode.invalid_string,
2422
+ message: check.message
2423
+ });
2424
+ status.dirty();
2425
+ }
2426
+ } else if (check.kind === "nanoid") {
2427
+ if (!nanoidRegex.test(input.data)) {
2428
+ ctx = this._getOrReturnCtx(input, ctx);
2429
+ addIssueToContext(ctx, {
2430
+ validation: "nanoid",
2431
+ code: ZodIssueCode.invalid_string,
2432
+ message: check.message
2433
+ });
2434
+ status.dirty();
2435
+ }
2436
+ } else if (check.kind === "cuid") {
2437
+ if (!cuidRegex.test(input.data)) {
2438
+ ctx = this._getOrReturnCtx(input, ctx);
2439
+ addIssueToContext(ctx, {
2440
+ validation: "cuid",
2441
+ code: ZodIssueCode.invalid_string,
2442
+ message: check.message
2443
+ });
2444
+ status.dirty();
2445
+ }
2446
+ } else if (check.kind === "cuid2") {
2447
+ if (!cuid2Regex.test(input.data)) {
2448
+ ctx = this._getOrReturnCtx(input, ctx);
2449
+ addIssueToContext(ctx, {
2450
+ validation: "cuid2",
2451
+ code: ZodIssueCode.invalid_string,
2452
+ message: check.message
2453
+ });
2454
+ status.dirty();
2455
+ }
2456
+ } else if (check.kind === "ulid") {
2457
+ if (!ulidRegex.test(input.data)) {
2458
+ ctx = this._getOrReturnCtx(input, ctx);
2459
+ addIssueToContext(ctx, {
2460
+ validation: "ulid",
2461
+ code: ZodIssueCode.invalid_string,
2462
+ message: check.message
2463
+ });
2464
+ status.dirty();
2465
+ }
2466
+ } else if (check.kind === "url") {
2467
+ try {
2468
+ new URL(input.data);
2469
+ } catch (_a) {
2470
+ ctx = this._getOrReturnCtx(input, ctx);
2471
+ addIssueToContext(ctx, {
2472
+ validation: "url",
2473
+ code: ZodIssueCode.invalid_string,
2474
+ message: check.message
2475
+ });
2476
+ status.dirty();
2477
+ }
2478
+ } else if (check.kind === "regex") {
2479
+ check.regex.lastIndex = 0;
2480
+ const testResult = check.regex.test(input.data);
2481
+ if (!testResult) {
2482
+ ctx = this._getOrReturnCtx(input, ctx);
2483
+ addIssueToContext(ctx, {
2484
+ validation: "regex",
2485
+ code: ZodIssueCode.invalid_string,
2486
+ message: check.message
2487
+ });
2488
+ status.dirty();
2489
+ }
2490
+ } else if (check.kind === "trim") {
2491
+ input.data = input.data.trim();
2492
+ } else if (check.kind === "includes") {
2493
+ if (!input.data.includes(check.value, check.position)) {
2494
+ ctx = this._getOrReturnCtx(input, ctx);
2495
+ addIssueToContext(ctx, {
2496
+ code: ZodIssueCode.invalid_string,
2497
+ validation: { includes: check.value, position: check.position },
2498
+ message: check.message
2499
+ });
2500
+ status.dirty();
2501
+ }
2502
+ } else if (check.kind === "toLowerCase") {
2503
+ input.data = input.data.toLowerCase();
2504
+ } else if (check.kind === "toUpperCase") {
2505
+ input.data = input.data.toUpperCase();
2506
+ } else if (check.kind === "startsWith") {
2507
+ if (!input.data.startsWith(check.value)) {
2508
+ ctx = this._getOrReturnCtx(input, ctx);
2509
+ addIssueToContext(ctx, {
2510
+ code: ZodIssueCode.invalid_string,
2511
+ validation: { startsWith: check.value },
2512
+ message: check.message
2513
+ });
2514
+ status.dirty();
2515
+ }
2516
+ } else if (check.kind === "endsWith") {
2517
+ if (!input.data.endsWith(check.value)) {
2518
+ ctx = this._getOrReturnCtx(input, ctx);
2519
+ addIssueToContext(ctx, {
2520
+ code: ZodIssueCode.invalid_string,
2521
+ validation: { endsWith: check.value },
2522
+ message: check.message
2523
+ });
2524
+ status.dirty();
2525
+ }
2526
+ } else if (check.kind === "datetime") {
2527
+ const regex = datetimeRegex(check);
2528
+ if (!regex.test(input.data)) {
2529
+ ctx = this._getOrReturnCtx(input, ctx);
2530
+ addIssueToContext(ctx, {
2531
+ code: ZodIssueCode.invalid_string,
2532
+ validation: "datetime",
2533
+ message: check.message
2534
+ });
2535
+ status.dirty();
2536
+ }
2537
+ } else if (check.kind === "date") {
2538
+ const regex = dateRegex;
2539
+ if (!regex.test(input.data)) {
2540
+ ctx = this._getOrReturnCtx(input, ctx);
2541
+ addIssueToContext(ctx, {
2542
+ code: ZodIssueCode.invalid_string,
2543
+ validation: "date",
2544
+ message: check.message
2545
+ });
2546
+ status.dirty();
2547
+ }
2548
+ } else if (check.kind === "time") {
2549
+ const regex = timeRegex(check);
2550
+ if (!regex.test(input.data)) {
2551
+ ctx = this._getOrReturnCtx(input, ctx);
2552
+ addIssueToContext(ctx, {
2553
+ code: ZodIssueCode.invalid_string,
2554
+ validation: "time",
2555
+ message: check.message
2556
+ });
2557
+ status.dirty();
2558
+ }
2559
+ } else if (check.kind === "duration") {
2560
+ if (!durationRegex.test(input.data)) {
2561
+ ctx = this._getOrReturnCtx(input, ctx);
2562
+ addIssueToContext(ctx, {
2563
+ validation: "duration",
2564
+ code: ZodIssueCode.invalid_string,
2565
+ message: check.message
2566
+ });
2567
+ status.dirty();
2568
+ }
2569
+ } else if (check.kind === "ip") {
2570
+ if (!isValidIP(input.data, check.version)) {
2571
+ ctx = this._getOrReturnCtx(input, ctx);
2572
+ addIssueToContext(ctx, {
2573
+ validation: "ip",
2574
+ code: ZodIssueCode.invalid_string,
2575
+ message: check.message
2576
+ });
2577
+ status.dirty();
2578
+ }
2579
+ } else if (check.kind === "base64") {
2580
+ if (!base64Regex.test(input.data)) {
2581
+ ctx = this._getOrReturnCtx(input, ctx);
2582
+ addIssueToContext(ctx, {
2583
+ validation: "base64",
2584
+ code: ZodIssueCode.invalid_string,
2585
+ message: check.message
2586
+ });
2587
+ status.dirty();
2588
+ }
2589
+ } else {
2590
+ util.assertNever(check);
2591
+ }
2592
+ }
2593
+ return { status: status.value, value: input.data };
2594
+ }
2595
+ _regex(regex, validation, message) {
2596
+ return this.refinement((data) => regex.test(data), {
2597
+ validation,
2598
+ code: ZodIssueCode.invalid_string,
2599
+ ...errorUtil.errToObj(message)
2600
+ });
2601
+ }
2602
+ _addCheck(check) {
2603
+ return new _ZodString({
2604
+ ...this._def,
2605
+ checks: [...this._def.checks, check]
2606
+ });
2607
+ }
2608
+ email(message) {
2609
+ return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) });
2610
+ }
2611
+ url(message) {
2612
+ return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) });
2613
+ }
2614
+ emoji(message) {
2615
+ return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) });
2616
+ }
2617
+ uuid(message) {
2618
+ return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) });
2619
+ }
2620
+ nanoid(message) {
2621
+ return this._addCheck({ kind: "nanoid", ...errorUtil.errToObj(message) });
2622
+ }
2623
+ cuid(message) {
2624
+ return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) });
2625
+ }
2626
+ cuid2(message) {
2627
+ return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) });
2628
+ }
2629
+ ulid(message) {
2630
+ return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) });
2631
+ }
2632
+ base64(message) {
2633
+ return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
2634
+ }
2635
+ ip(options) {
2636
+ return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
2637
+ }
2638
+ datetime(options) {
2639
+ var _a, _b;
2640
+ if (typeof options === "string") {
2641
+ return this._addCheck({
2642
+ kind: "datetime",
2643
+ precision: null,
2644
+ offset: false,
2645
+ local: false,
2646
+ message: options
2647
+ });
2648
+ }
2649
+ return this._addCheck({
2650
+ kind: "datetime",
2651
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
2652
+ offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
2653
+ local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false,
2654
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2655
+ });
2656
+ }
2657
+ date(message) {
2658
+ return this._addCheck({ kind: "date", message });
2659
+ }
2660
+ time(options) {
2661
+ if (typeof options === "string") {
2662
+ return this._addCheck({
2663
+ kind: "time",
2664
+ precision: null,
2665
+ message: options
2666
+ });
2667
+ }
2668
+ return this._addCheck({
2669
+ kind: "time",
2670
+ precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
2671
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2672
+ });
2673
+ }
2674
+ duration(message) {
2675
+ return this._addCheck({ kind: "duration", ...errorUtil.errToObj(message) });
2676
+ }
2677
+ regex(regex, message) {
2678
+ return this._addCheck({
2679
+ kind: "regex",
2680
+ regex,
2681
+ ...errorUtil.errToObj(message)
2682
+ });
2683
+ }
2684
+ includes(value, options) {
2685
+ return this._addCheck({
2686
+ kind: "includes",
2687
+ value,
2688
+ position: options === null || options === void 0 ? void 0 : options.position,
2689
+ ...errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)
2690
+ });
2691
+ }
2692
+ startsWith(value, message) {
2693
+ return this._addCheck({
2694
+ kind: "startsWith",
2695
+ value,
2696
+ ...errorUtil.errToObj(message)
2697
+ });
2698
+ }
2699
+ endsWith(value, message) {
2700
+ return this._addCheck({
2701
+ kind: "endsWith",
2702
+ value,
2703
+ ...errorUtil.errToObj(message)
2704
+ });
2705
+ }
2706
+ min(minLength, message) {
2707
+ return this._addCheck({
2708
+ kind: "min",
2709
+ value: minLength,
2710
+ ...errorUtil.errToObj(message)
2711
+ });
2712
+ }
2713
+ max(maxLength, message) {
2714
+ return this._addCheck({
2715
+ kind: "max",
2716
+ value: maxLength,
2717
+ ...errorUtil.errToObj(message)
2718
+ });
2719
+ }
2720
+ length(len, message) {
2721
+ return this._addCheck({
2722
+ kind: "length",
2723
+ value: len,
2724
+ ...errorUtil.errToObj(message)
2725
+ });
2726
+ }
2727
+ /**
2728
+ * @deprecated Use z.string().min(1) instead.
2729
+ * @see {@link ZodString.min}
2730
+ */
2731
+ nonempty(message) {
2732
+ return this.min(1, errorUtil.errToObj(message));
2733
+ }
2734
+ trim() {
2735
+ return new _ZodString({
2736
+ ...this._def,
2737
+ checks: [...this._def.checks, { kind: "trim" }]
2738
+ });
2739
+ }
2740
+ toLowerCase() {
2741
+ return new _ZodString({
2742
+ ...this._def,
2743
+ checks: [...this._def.checks, { kind: "toLowerCase" }]
2744
+ });
2745
+ }
2746
+ toUpperCase() {
2747
+ return new _ZodString({
2748
+ ...this._def,
2749
+ checks: [...this._def.checks, { kind: "toUpperCase" }]
2750
+ });
2751
+ }
2752
+ get isDatetime() {
2753
+ return !!this._def.checks.find((ch) => ch.kind === "datetime");
2754
+ }
2755
+ get isDate() {
2756
+ return !!this._def.checks.find((ch) => ch.kind === "date");
2757
+ }
2758
+ get isTime() {
2759
+ return !!this._def.checks.find((ch) => ch.kind === "time");
2760
+ }
2761
+ get isDuration() {
2762
+ return !!this._def.checks.find((ch) => ch.kind === "duration");
2763
+ }
2764
+ get isEmail() {
2765
+ return !!this._def.checks.find((ch) => ch.kind === "email");
2766
+ }
2767
+ get isURL() {
2768
+ return !!this._def.checks.find((ch) => ch.kind === "url");
2769
+ }
2770
+ get isEmoji() {
2771
+ return !!this._def.checks.find((ch) => ch.kind === "emoji");
2772
+ }
2773
+ get isUUID() {
2774
+ return !!this._def.checks.find((ch) => ch.kind === "uuid");
2775
+ }
2776
+ get isNANOID() {
2777
+ return !!this._def.checks.find((ch) => ch.kind === "nanoid");
2778
+ }
2779
+ get isCUID() {
2780
+ return !!this._def.checks.find((ch) => ch.kind === "cuid");
2781
+ }
2782
+ get isCUID2() {
2783
+ return !!this._def.checks.find((ch) => ch.kind === "cuid2");
2784
+ }
2785
+ get isULID() {
2786
+ return !!this._def.checks.find((ch) => ch.kind === "ulid");
2787
+ }
2788
+ get isIP() {
2789
+ return !!this._def.checks.find((ch) => ch.kind === "ip");
2790
+ }
2791
+ get isBase64() {
2792
+ return !!this._def.checks.find((ch) => ch.kind === "base64");
2793
+ }
2794
+ get minLength() {
2795
+ let min = null;
2796
+ for (const ch of this._def.checks) {
2797
+ if (ch.kind === "min") {
2798
+ if (min === null || ch.value > min)
2799
+ min = ch.value;
2800
+ }
2801
+ }
2802
+ return min;
2803
+ }
2804
+ get maxLength() {
2805
+ let max = null;
2806
+ for (const ch of this._def.checks) {
2807
+ if (ch.kind === "max") {
2808
+ if (max === null || ch.value < max)
2809
+ max = ch.value;
2810
+ }
2811
+ }
2812
+ return max;
2813
+ }
2814
+ };
2815
+ ZodString.create = (params) => {
2816
+ var _a;
2817
+ return new ZodString({
2818
+ checks: [],
2819
+ typeName: ZodFirstPartyTypeKind.ZodString,
2820
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
2821
+ ...processCreateParams(params)
2822
+ });
2823
+ };
2824
+ function floatSafeRemainder(val, step) {
2825
+ const valDecCount = (val.toString().split(".")[1] || "").length;
2826
+ const stepDecCount = (step.toString().split(".")[1] || "").length;
2827
+ const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
2828
+ const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
2829
+ const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
2830
+ return valInt % stepInt / Math.pow(10, decCount);
2831
+ }
2832
+ var ZodNumber = class _ZodNumber extends ZodType {
2833
+ constructor() {
2834
+ super(...arguments);
2835
+ this.min = this.gte;
2836
+ this.max = this.lte;
2837
+ this.step = this.multipleOf;
2838
+ }
2839
+ _parse(input) {
2840
+ if (this._def.coerce) {
2841
+ input.data = Number(input.data);
2842
+ }
2843
+ const parsedType = this._getType(input);
2844
+ if (parsedType !== ZodParsedType.number) {
2845
+ const ctx2 = this._getOrReturnCtx(input);
2846
+ addIssueToContext(ctx2, {
2847
+ code: ZodIssueCode.invalid_type,
2848
+ expected: ZodParsedType.number,
2849
+ received: ctx2.parsedType
2850
+ });
2851
+ return INVALID;
2852
+ }
2853
+ let ctx = void 0;
2854
+ const status = new ParseStatus();
2855
+ for (const check of this._def.checks) {
2856
+ if (check.kind === "int") {
2857
+ if (!util.isInteger(input.data)) {
2858
+ ctx = this._getOrReturnCtx(input, ctx);
2859
+ addIssueToContext(ctx, {
2860
+ code: ZodIssueCode.invalid_type,
2861
+ expected: "integer",
2862
+ received: "float",
2863
+ message: check.message
2864
+ });
2865
+ status.dirty();
2866
+ }
2867
+ } else if (check.kind === "min") {
2868
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
2869
+ if (tooSmall) {
2870
+ ctx = this._getOrReturnCtx(input, ctx);
2871
+ addIssueToContext(ctx, {
2872
+ code: ZodIssueCode.too_small,
2873
+ minimum: check.value,
2874
+ type: "number",
2875
+ inclusive: check.inclusive,
2876
+ exact: false,
2877
+ message: check.message
2878
+ });
2879
+ status.dirty();
2880
+ }
2881
+ } else if (check.kind === "max") {
2882
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
2883
+ if (tooBig) {
2884
+ ctx = this._getOrReturnCtx(input, ctx);
2885
+ addIssueToContext(ctx, {
2886
+ code: ZodIssueCode.too_big,
2887
+ maximum: check.value,
2888
+ type: "number",
2889
+ inclusive: check.inclusive,
2890
+ exact: false,
2891
+ message: check.message
2892
+ });
2893
+ status.dirty();
2894
+ }
2895
+ } else if (check.kind === "multipleOf") {
2896
+ if (floatSafeRemainder(input.data, check.value) !== 0) {
2897
+ ctx = this._getOrReturnCtx(input, ctx);
2898
+ addIssueToContext(ctx, {
2899
+ code: ZodIssueCode.not_multiple_of,
2900
+ multipleOf: check.value,
2901
+ message: check.message
2902
+ });
2903
+ status.dirty();
2904
+ }
2905
+ } else if (check.kind === "finite") {
2906
+ if (!Number.isFinite(input.data)) {
2907
+ ctx = this._getOrReturnCtx(input, ctx);
2908
+ addIssueToContext(ctx, {
2909
+ code: ZodIssueCode.not_finite,
2910
+ message: check.message
2911
+ });
2912
+ status.dirty();
2913
+ }
2914
+ } else {
2915
+ util.assertNever(check);
2916
+ }
2917
+ }
2918
+ return { status: status.value, value: input.data };
2919
+ }
2920
+ gte(value, message) {
2921
+ return this.setLimit("min", value, true, errorUtil.toString(message));
2922
+ }
2923
+ gt(value, message) {
2924
+ return this.setLimit("min", value, false, errorUtil.toString(message));
2925
+ }
2926
+ lte(value, message) {
2927
+ return this.setLimit("max", value, true, errorUtil.toString(message));
2928
+ }
2929
+ lt(value, message) {
2930
+ return this.setLimit("max", value, false, errorUtil.toString(message));
2931
+ }
2932
+ setLimit(kind, value, inclusive, message) {
2933
+ return new _ZodNumber({
2934
+ ...this._def,
2935
+ checks: [
2936
+ ...this._def.checks,
2937
+ {
2938
+ kind,
2939
+ value,
2940
+ inclusive,
2941
+ message: errorUtil.toString(message)
2942
+ }
2943
+ ]
2944
+ });
2945
+ }
2946
+ _addCheck(check) {
2947
+ return new _ZodNumber({
2948
+ ...this._def,
2949
+ checks: [...this._def.checks, check]
2950
+ });
2951
+ }
2952
+ int(message) {
2953
+ return this._addCheck({
2954
+ kind: "int",
2955
+ message: errorUtil.toString(message)
2956
+ });
2957
+ }
2958
+ positive(message) {
2959
+ return this._addCheck({
2960
+ kind: "min",
2961
+ value: 0,
2962
+ inclusive: false,
2963
+ message: errorUtil.toString(message)
2964
+ });
2965
+ }
2966
+ negative(message) {
2967
+ return this._addCheck({
2968
+ kind: "max",
2969
+ value: 0,
2970
+ inclusive: false,
2971
+ message: errorUtil.toString(message)
2972
+ });
2973
+ }
2974
+ nonpositive(message) {
2975
+ return this._addCheck({
2976
+ kind: "max",
2977
+ value: 0,
2978
+ inclusive: true,
2979
+ message: errorUtil.toString(message)
2980
+ });
2981
+ }
2982
+ nonnegative(message) {
2983
+ return this._addCheck({
2984
+ kind: "min",
2985
+ value: 0,
2986
+ inclusive: true,
2987
+ message: errorUtil.toString(message)
2988
+ });
2989
+ }
2990
+ multipleOf(value, message) {
2991
+ return this._addCheck({
2992
+ kind: "multipleOf",
2993
+ value,
2994
+ message: errorUtil.toString(message)
2995
+ });
2996
+ }
2997
+ finite(message) {
2998
+ return this._addCheck({
2999
+ kind: "finite",
3000
+ message: errorUtil.toString(message)
3001
+ });
3002
+ }
3003
+ safe(message) {
3004
+ return this._addCheck({
3005
+ kind: "min",
3006
+ inclusive: true,
3007
+ value: Number.MIN_SAFE_INTEGER,
3008
+ message: errorUtil.toString(message)
3009
+ })._addCheck({
3010
+ kind: "max",
3011
+ inclusive: true,
3012
+ value: Number.MAX_SAFE_INTEGER,
3013
+ message: errorUtil.toString(message)
3014
+ });
3015
+ }
3016
+ get minValue() {
3017
+ let min = null;
3018
+ for (const ch of this._def.checks) {
3019
+ if (ch.kind === "min") {
3020
+ if (min === null || ch.value > min)
3021
+ min = ch.value;
3022
+ }
3023
+ }
3024
+ return min;
3025
+ }
3026
+ get maxValue() {
3027
+ let max = null;
3028
+ for (const ch of this._def.checks) {
3029
+ if (ch.kind === "max") {
3030
+ if (max === null || ch.value < max)
3031
+ max = ch.value;
3032
+ }
3033
+ }
3034
+ return max;
3035
+ }
3036
+ get isInt() {
3037
+ return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
3038
+ }
3039
+ get isFinite() {
3040
+ let max = null, min = null;
3041
+ for (const ch of this._def.checks) {
3042
+ if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
3043
+ return true;
3044
+ } else if (ch.kind === "min") {
3045
+ if (min === null || ch.value > min)
3046
+ min = ch.value;
3047
+ } else if (ch.kind === "max") {
3048
+ if (max === null || ch.value < max)
3049
+ max = ch.value;
3050
+ }
3051
+ }
3052
+ return Number.isFinite(min) && Number.isFinite(max);
3053
+ }
3054
+ };
3055
+ ZodNumber.create = (params) => {
3056
+ return new ZodNumber({
3057
+ checks: [],
3058
+ typeName: ZodFirstPartyTypeKind.ZodNumber,
3059
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
3060
+ ...processCreateParams(params)
3061
+ });
3062
+ };
3063
+ var ZodBigInt = class _ZodBigInt extends ZodType {
3064
+ constructor() {
3065
+ super(...arguments);
3066
+ this.min = this.gte;
3067
+ this.max = this.lte;
3068
+ }
3069
+ _parse(input) {
3070
+ if (this._def.coerce) {
3071
+ input.data = BigInt(input.data);
3072
+ }
3073
+ const parsedType = this._getType(input);
3074
+ if (parsedType !== ZodParsedType.bigint) {
3075
+ const ctx2 = this._getOrReturnCtx(input);
3076
+ addIssueToContext(ctx2, {
3077
+ code: ZodIssueCode.invalid_type,
3078
+ expected: ZodParsedType.bigint,
3079
+ received: ctx2.parsedType
3080
+ });
3081
+ return INVALID;
3082
+ }
3083
+ let ctx = void 0;
3084
+ const status = new ParseStatus();
3085
+ for (const check of this._def.checks) {
3086
+ if (check.kind === "min") {
3087
+ const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
3088
+ if (tooSmall) {
3089
+ ctx = this._getOrReturnCtx(input, ctx);
3090
+ addIssueToContext(ctx, {
3091
+ code: ZodIssueCode.too_small,
3092
+ type: "bigint",
3093
+ minimum: check.value,
3094
+ inclusive: check.inclusive,
3095
+ message: check.message
3096
+ });
3097
+ status.dirty();
3098
+ }
3099
+ } else if (check.kind === "max") {
3100
+ const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
3101
+ if (tooBig) {
3102
+ ctx = this._getOrReturnCtx(input, ctx);
3103
+ addIssueToContext(ctx, {
3104
+ code: ZodIssueCode.too_big,
3105
+ type: "bigint",
3106
+ maximum: check.value,
3107
+ inclusive: check.inclusive,
3108
+ message: check.message
3109
+ });
3110
+ status.dirty();
3111
+ }
3112
+ } else if (check.kind === "multipleOf") {
3113
+ if (input.data % check.value !== BigInt(0)) {
3114
+ ctx = this._getOrReturnCtx(input, ctx);
3115
+ addIssueToContext(ctx, {
3116
+ code: ZodIssueCode.not_multiple_of,
3117
+ multipleOf: check.value,
3118
+ message: check.message
3119
+ });
3120
+ status.dirty();
3121
+ }
3122
+ } else {
3123
+ util.assertNever(check);
3124
+ }
3125
+ }
3126
+ return { status: status.value, value: input.data };
3127
+ }
3128
+ gte(value, message) {
3129
+ return this.setLimit("min", value, true, errorUtil.toString(message));
3130
+ }
3131
+ gt(value, message) {
3132
+ return this.setLimit("min", value, false, errorUtil.toString(message));
3133
+ }
3134
+ lte(value, message) {
3135
+ return this.setLimit("max", value, true, errorUtil.toString(message));
3136
+ }
3137
+ lt(value, message) {
3138
+ return this.setLimit("max", value, false, errorUtil.toString(message));
3139
+ }
3140
+ setLimit(kind, value, inclusive, message) {
3141
+ return new _ZodBigInt({
3142
+ ...this._def,
3143
+ checks: [
3144
+ ...this._def.checks,
3145
+ {
3146
+ kind,
3147
+ value,
3148
+ inclusive,
3149
+ message: errorUtil.toString(message)
3150
+ }
3151
+ ]
3152
+ });
3153
+ }
3154
+ _addCheck(check) {
3155
+ return new _ZodBigInt({
3156
+ ...this._def,
3157
+ checks: [...this._def.checks, check]
3158
+ });
3159
+ }
3160
+ positive(message) {
3161
+ return this._addCheck({
3162
+ kind: "min",
3163
+ value: BigInt(0),
3164
+ inclusive: false,
3165
+ message: errorUtil.toString(message)
3166
+ });
3167
+ }
3168
+ negative(message) {
3169
+ return this._addCheck({
3170
+ kind: "max",
3171
+ value: BigInt(0),
3172
+ inclusive: false,
3173
+ message: errorUtil.toString(message)
3174
+ });
3175
+ }
3176
+ nonpositive(message) {
3177
+ return this._addCheck({
3178
+ kind: "max",
3179
+ value: BigInt(0),
3180
+ inclusive: true,
3181
+ message: errorUtil.toString(message)
3182
+ });
3183
+ }
3184
+ nonnegative(message) {
3185
+ return this._addCheck({
3186
+ kind: "min",
3187
+ value: BigInt(0),
3188
+ inclusive: true,
3189
+ message: errorUtil.toString(message)
3190
+ });
3191
+ }
3192
+ multipleOf(value, message) {
3193
+ return this._addCheck({
3194
+ kind: "multipleOf",
3195
+ value,
3196
+ message: errorUtil.toString(message)
3197
+ });
3198
+ }
3199
+ get minValue() {
3200
+ let min = null;
3201
+ for (const ch of this._def.checks) {
3202
+ if (ch.kind === "min") {
3203
+ if (min === null || ch.value > min)
3204
+ min = ch.value;
3205
+ }
3206
+ }
3207
+ return min;
3208
+ }
3209
+ get maxValue() {
3210
+ let max = null;
3211
+ for (const ch of this._def.checks) {
3212
+ if (ch.kind === "max") {
3213
+ if (max === null || ch.value < max)
3214
+ max = ch.value;
3215
+ }
3216
+ }
3217
+ return max;
3218
+ }
3219
+ };
3220
+ ZodBigInt.create = (params) => {
3221
+ var _a;
3222
+ return new ZodBigInt({
3223
+ checks: [],
3224
+ typeName: ZodFirstPartyTypeKind.ZodBigInt,
3225
+ coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false,
3226
+ ...processCreateParams(params)
3227
+ });
3228
+ };
3229
+ var ZodBoolean = class extends ZodType {
3230
+ _parse(input) {
3231
+ if (this._def.coerce) {
3232
+ input.data = Boolean(input.data);
3233
+ }
3234
+ const parsedType = this._getType(input);
3235
+ if (parsedType !== ZodParsedType.boolean) {
3236
+ const ctx = this._getOrReturnCtx(input);
3237
+ addIssueToContext(ctx, {
3238
+ code: ZodIssueCode.invalid_type,
3239
+ expected: ZodParsedType.boolean,
3240
+ received: ctx.parsedType
3241
+ });
3242
+ return INVALID;
3243
+ }
3244
+ return OK(input.data);
3245
+ }
3246
+ };
3247
+ ZodBoolean.create = (params) => {
3248
+ return new ZodBoolean({
3249
+ typeName: ZodFirstPartyTypeKind.ZodBoolean,
3250
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
3251
+ ...processCreateParams(params)
3252
+ });
3253
+ };
3254
+ var ZodDate = class _ZodDate extends ZodType {
3255
+ _parse(input) {
3256
+ if (this._def.coerce) {
3257
+ input.data = new Date(input.data);
3258
+ }
3259
+ const parsedType = this._getType(input);
3260
+ if (parsedType !== ZodParsedType.date) {
3261
+ const ctx2 = this._getOrReturnCtx(input);
3262
+ addIssueToContext(ctx2, {
3263
+ code: ZodIssueCode.invalid_type,
3264
+ expected: ZodParsedType.date,
3265
+ received: ctx2.parsedType
3266
+ });
3267
+ return INVALID;
3268
+ }
3269
+ if (isNaN(input.data.getTime())) {
3270
+ const ctx2 = this._getOrReturnCtx(input);
3271
+ addIssueToContext(ctx2, {
3272
+ code: ZodIssueCode.invalid_date
3273
+ });
3274
+ return INVALID;
3275
+ }
3276
+ const status = new ParseStatus();
3277
+ let ctx = void 0;
3278
+ for (const check of this._def.checks) {
3279
+ if (check.kind === "min") {
3280
+ if (input.data.getTime() < check.value) {
3281
+ ctx = this._getOrReturnCtx(input, ctx);
3282
+ addIssueToContext(ctx, {
3283
+ code: ZodIssueCode.too_small,
3284
+ message: check.message,
3285
+ inclusive: true,
3286
+ exact: false,
3287
+ minimum: check.value,
3288
+ type: "date"
3289
+ });
3290
+ status.dirty();
3291
+ }
3292
+ } else if (check.kind === "max") {
3293
+ if (input.data.getTime() > check.value) {
3294
+ ctx = this._getOrReturnCtx(input, ctx);
3295
+ addIssueToContext(ctx, {
3296
+ code: ZodIssueCode.too_big,
3297
+ message: check.message,
3298
+ inclusive: true,
3299
+ exact: false,
3300
+ maximum: check.value,
3301
+ type: "date"
3302
+ });
3303
+ status.dirty();
3304
+ }
3305
+ } else {
3306
+ util.assertNever(check);
3307
+ }
3308
+ }
3309
+ return {
3310
+ status: status.value,
3311
+ value: new Date(input.data.getTime())
3312
+ };
3313
+ }
3314
+ _addCheck(check) {
3315
+ return new _ZodDate({
3316
+ ...this._def,
3317
+ checks: [...this._def.checks, check]
3318
+ });
3319
+ }
3320
+ min(minDate, message) {
3321
+ return this._addCheck({
3322
+ kind: "min",
3323
+ value: minDate.getTime(),
3324
+ message: errorUtil.toString(message)
3325
+ });
3326
+ }
3327
+ max(maxDate, message) {
3328
+ return this._addCheck({
3329
+ kind: "max",
3330
+ value: maxDate.getTime(),
3331
+ message: errorUtil.toString(message)
3332
+ });
3333
+ }
3334
+ get minDate() {
3335
+ let min = null;
3336
+ for (const ch of this._def.checks) {
3337
+ if (ch.kind === "min") {
3338
+ if (min === null || ch.value > min)
3339
+ min = ch.value;
3340
+ }
3341
+ }
3342
+ return min != null ? new Date(min) : null;
3343
+ }
3344
+ get maxDate() {
3345
+ let max = null;
3346
+ for (const ch of this._def.checks) {
3347
+ if (ch.kind === "max") {
3348
+ if (max === null || ch.value < max)
3349
+ max = ch.value;
3350
+ }
3351
+ }
3352
+ return max != null ? new Date(max) : null;
3353
+ }
3354
+ };
3355
+ ZodDate.create = (params) => {
3356
+ return new ZodDate({
3357
+ checks: [],
3358
+ coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false,
3359
+ typeName: ZodFirstPartyTypeKind.ZodDate,
3360
+ ...processCreateParams(params)
3361
+ });
3362
+ };
3363
+ var ZodSymbol = class extends ZodType {
3364
+ _parse(input) {
3365
+ const parsedType = this._getType(input);
3366
+ if (parsedType !== ZodParsedType.symbol) {
3367
+ const ctx = this._getOrReturnCtx(input);
3368
+ addIssueToContext(ctx, {
3369
+ code: ZodIssueCode.invalid_type,
3370
+ expected: ZodParsedType.symbol,
3371
+ received: ctx.parsedType
3372
+ });
3373
+ return INVALID;
3374
+ }
3375
+ return OK(input.data);
3376
+ }
3377
+ };
3378
+ ZodSymbol.create = (params) => {
3379
+ return new ZodSymbol({
3380
+ typeName: ZodFirstPartyTypeKind.ZodSymbol,
3381
+ ...processCreateParams(params)
3382
+ });
3383
+ };
3384
+ var ZodUndefined = class extends ZodType {
3385
+ _parse(input) {
3386
+ const parsedType = this._getType(input);
3387
+ if (parsedType !== ZodParsedType.undefined) {
3388
+ const ctx = this._getOrReturnCtx(input);
3389
+ addIssueToContext(ctx, {
3390
+ code: ZodIssueCode.invalid_type,
3391
+ expected: ZodParsedType.undefined,
3392
+ received: ctx.parsedType
3393
+ });
3394
+ return INVALID;
3395
+ }
3396
+ return OK(input.data);
3397
+ }
3398
+ };
3399
+ ZodUndefined.create = (params) => {
3400
+ return new ZodUndefined({
3401
+ typeName: ZodFirstPartyTypeKind.ZodUndefined,
3402
+ ...processCreateParams(params)
3403
+ });
3404
+ };
3405
+ var ZodNull = class extends ZodType {
3406
+ _parse(input) {
3407
+ const parsedType = this._getType(input);
3408
+ if (parsedType !== ZodParsedType.null) {
3409
+ const ctx = this._getOrReturnCtx(input);
3410
+ addIssueToContext(ctx, {
3411
+ code: ZodIssueCode.invalid_type,
3412
+ expected: ZodParsedType.null,
3413
+ received: ctx.parsedType
3414
+ });
3415
+ return INVALID;
3416
+ }
3417
+ return OK(input.data);
3418
+ }
3419
+ };
3420
+ ZodNull.create = (params) => {
3421
+ return new ZodNull({
3422
+ typeName: ZodFirstPartyTypeKind.ZodNull,
3423
+ ...processCreateParams(params)
3424
+ });
3425
+ };
3426
+ var ZodAny = class extends ZodType {
3427
+ constructor() {
3428
+ super(...arguments);
3429
+ this._any = true;
3430
+ }
3431
+ _parse(input) {
3432
+ return OK(input.data);
3433
+ }
3434
+ };
3435
+ ZodAny.create = (params) => {
3436
+ return new ZodAny({
3437
+ typeName: ZodFirstPartyTypeKind.ZodAny,
3438
+ ...processCreateParams(params)
3439
+ });
3440
+ };
3441
+ var ZodUnknown = class extends ZodType {
3442
+ constructor() {
3443
+ super(...arguments);
3444
+ this._unknown = true;
3445
+ }
3446
+ _parse(input) {
3447
+ return OK(input.data);
3448
+ }
3449
+ };
3450
+ ZodUnknown.create = (params) => {
3451
+ return new ZodUnknown({
3452
+ typeName: ZodFirstPartyTypeKind.ZodUnknown,
3453
+ ...processCreateParams(params)
3454
+ });
3455
+ };
3456
+ var ZodNever = class extends ZodType {
3457
+ _parse(input) {
3458
+ const ctx = this._getOrReturnCtx(input);
3459
+ addIssueToContext(ctx, {
3460
+ code: ZodIssueCode.invalid_type,
3461
+ expected: ZodParsedType.never,
3462
+ received: ctx.parsedType
3463
+ });
3464
+ return INVALID;
3465
+ }
3466
+ };
3467
+ ZodNever.create = (params) => {
3468
+ return new ZodNever({
3469
+ typeName: ZodFirstPartyTypeKind.ZodNever,
3470
+ ...processCreateParams(params)
3471
+ });
3472
+ };
3473
+ var ZodVoid = class extends ZodType {
3474
+ _parse(input) {
3475
+ const parsedType = this._getType(input);
3476
+ if (parsedType !== ZodParsedType.undefined) {
3477
+ const ctx = this._getOrReturnCtx(input);
3478
+ addIssueToContext(ctx, {
3479
+ code: ZodIssueCode.invalid_type,
3480
+ expected: ZodParsedType.void,
3481
+ received: ctx.parsedType
3482
+ });
3483
+ return INVALID;
3484
+ }
3485
+ return OK(input.data);
3486
+ }
3487
+ };
3488
+ ZodVoid.create = (params) => {
3489
+ return new ZodVoid({
3490
+ typeName: ZodFirstPartyTypeKind.ZodVoid,
3491
+ ...processCreateParams(params)
3492
+ });
3493
+ };
3494
+ var ZodArray = class _ZodArray extends ZodType {
3495
+ _parse(input) {
3496
+ const { ctx, status } = this._processInputParams(input);
3497
+ const def = this._def;
3498
+ if (ctx.parsedType !== ZodParsedType.array) {
3499
+ addIssueToContext(ctx, {
3500
+ code: ZodIssueCode.invalid_type,
3501
+ expected: ZodParsedType.array,
3502
+ received: ctx.parsedType
3503
+ });
3504
+ return INVALID;
3505
+ }
3506
+ if (def.exactLength !== null) {
3507
+ const tooBig = ctx.data.length > def.exactLength.value;
3508
+ const tooSmall = ctx.data.length < def.exactLength.value;
3509
+ if (tooBig || tooSmall) {
3510
+ addIssueToContext(ctx, {
3511
+ code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
3512
+ minimum: tooSmall ? def.exactLength.value : void 0,
3513
+ maximum: tooBig ? def.exactLength.value : void 0,
3514
+ type: "array",
3515
+ inclusive: true,
3516
+ exact: true,
3517
+ message: def.exactLength.message
3518
+ });
3519
+ status.dirty();
3520
+ }
3521
+ }
3522
+ if (def.minLength !== null) {
3523
+ if (ctx.data.length < def.minLength.value) {
3524
+ addIssueToContext(ctx, {
3525
+ code: ZodIssueCode.too_small,
3526
+ minimum: def.minLength.value,
3527
+ type: "array",
3528
+ inclusive: true,
3529
+ exact: false,
3530
+ message: def.minLength.message
3531
+ });
3532
+ status.dirty();
3533
+ }
3534
+ }
3535
+ if (def.maxLength !== null) {
3536
+ if (ctx.data.length > def.maxLength.value) {
3537
+ addIssueToContext(ctx, {
3538
+ code: ZodIssueCode.too_big,
3539
+ maximum: def.maxLength.value,
3540
+ type: "array",
3541
+ inclusive: true,
3542
+ exact: false,
3543
+ message: def.maxLength.message
3544
+ });
3545
+ status.dirty();
3546
+ }
3547
+ }
3548
+ if (ctx.common.async) {
3549
+ return Promise.all([...ctx.data].map((item, i6) => {
3550
+ return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i6));
3551
+ })).then((result2) => {
3552
+ return ParseStatus.mergeArray(status, result2);
3553
+ });
3554
+ }
3555
+ const result = [...ctx.data].map((item, i6) => {
3556
+ return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i6));
3557
+ });
3558
+ return ParseStatus.mergeArray(status, result);
3559
+ }
3560
+ get element() {
3561
+ return this._def.type;
3562
+ }
3563
+ min(minLength, message) {
3564
+ return new _ZodArray({
3565
+ ...this._def,
3566
+ minLength: { value: minLength, message: errorUtil.toString(message) }
3567
+ });
3568
+ }
3569
+ max(maxLength, message) {
3570
+ return new _ZodArray({
3571
+ ...this._def,
3572
+ maxLength: { value: maxLength, message: errorUtil.toString(message) }
3573
+ });
3574
+ }
3575
+ length(len, message) {
3576
+ return new _ZodArray({
3577
+ ...this._def,
3578
+ exactLength: { value: len, message: errorUtil.toString(message) }
3579
+ });
3580
+ }
3581
+ nonempty(message) {
3582
+ return this.min(1, message);
3583
+ }
3584
+ };
3585
+ ZodArray.create = (schema, params) => {
3586
+ return new ZodArray({
3587
+ type: schema,
3588
+ minLength: null,
3589
+ maxLength: null,
3590
+ exactLength: null,
3591
+ typeName: ZodFirstPartyTypeKind.ZodArray,
3592
+ ...processCreateParams(params)
3593
+ });
3594
+ };
3595
+ function deepPartialify(schema) {
3596
+ if (schema instanceof ZodObject) {
3597
+ const newShape = {};
3598
+ for (const key in schema.shape) {
3599
+ const fieldSchema = schema.shape[key];
3600
+ newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
3601
+ }
3602
+ return new ZodObject({
3603
+ ...schema._def,
3604
+ shape: () => newShape
3605
+ });
3606
+ } else if (schema instanceof ZodArray) {
3607
+ return new ZodArray({
3608
+ ...schema._def,
3609
+ type: deepPartialify(schema.element)
3610
+ });
3611
+ } else if (schema instanceof ZodOptional) {
3612
+ return ZodOptional.create(deepPartialify(schema.unwrap()));
3613
+ } else if (schema instanceof ZodNullable) {
3614
+ return ZodNullable.create(deepPartialify(schema.unwrap()));
3615
+ } else if (schema instanceof ZodTuple) {
3616
+ return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
3617
+ } else {
3618
+ return schema;
3619
+ }
3620
+ }
3621
+ var ZodObject = class _ZodObject extends ZodType {
3622
+ constructor() {
3623
+ super(...arguments);
3624
+ this._cached = null;
3625
+ this.nonstrict = this.passthrough;
3626
+ this.augment = this.extend;
3627
+ }
3628
+ _getCached() {
3629
+ if (this._cached !== null)
3630
+ return this._cached;
3631
+ const shape = this._def.shape();
3632
+ const keys = util.objectKeys(shape);
3633
+ return this._cached = { shape, keys };
3634
+ }
3635
+ _parse(input) {
3636
+ const parsedType = this._getType(input);
3637
+ if (parsedType !== ZodParsedType.object) {
3638
+ const ctx2 = this._getOrReturnCtx(input);
3639
+ addIssueToContext(ctx2, {
3640
+ code: ZodIssueCode.invalid_type,
3641
+ expected: ZodParsedType.object,
3642
+ received: ctx2.parsedType
3643
+ });
3644
+ return INVALID;
3645
+ }
3646
+ const { status, ctx } = this._processInputParams(input);
3647
+ const { shape, keys: shapeKeys } = this._getCached();
3648
+ const extraKeys = [];
3649
+ if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
3650
+ for (const key in ctx.data) {
3651
+ if (!shapeKeys.includes(key)) {
3652
+ extraKeys.push(key);
3653
+ }
3654
+ }
3655
+ }
3656
+ const pairs = [];
3657
+ for (const key of shapeKeys) {
3658
+ const keyValidator = shape[key];
3659
+ const value = ctx.data[key];
3660
+ pairs.push({
3661
+ key: { status: "valid", value: key },
3662
+ value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
3663
+ alwaysSet: key in ctx.data
3664
+ });
3665
+ }
3666
+ if (this._def.catchall instanceof ZodNever) {
3667
+ const unknownKeys = this._def.unknownKeys;
3668
+ if (unknownKeys === "passthrough") {
3669
+ for (const key of extraKeys) {
3670
+ pairs.push({
3671
+ key: { status: "valid", value: key },
3672
+ value: { status: "valid", value: ctx.data[key] }
3673
+ });
3674
+ }
3675
+ } else if (unknownKeys === "strict") {
3676
+ if (extraKeys.length > 0) {
3677
+ addIssueToContext(ctx, {
3678
+ code: ZodIssueCode.unrecognized_keys,
3679
+ keys: extraKeys
3680
+ });
3681
+ status.dirty();
3682
+ }
3683
+ } else if (unknownKeys === "strip")
3684
+ ;
3685
+ else {
3686
+ throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
3687
+ }
3688
+ } else {
3689
+ const catchall = this._def.catchall;
3690
+ for (const key of extraKeys) {
3691
+ const value = ctx.data[key];
3692
+ pairs.push({
3693
+ key: { status: "valid", value: key },
3694
+ value: catchall._parse(
3695
+ new ParseInputLazyPath(ctx, value, ctx.path, key)
3696
+ //, ctx.child(key), value, getParsedType(value)
3697
+ ),
3698
+ alwaysSet: key in ctx.data
3699
+ });
3700
+ }
3701
+ }
3702
+ if (ctx.common.async) {
3703
+ return Promise.resolve().then(async () => {
3704
+ const syncPairs = [];
3705
+ for (const pair of pairs) {
3706
+ const key = await pair.key;
3707
+ const value = await pair.value;
3708
+ syncPairs.push({
3709
+ key,
3710
+ value,
3711
+ alwaysSet: pair.alwaysSet
3712
+ });
3713
+ }
3714
+ return syncPairs;
3715
+ }).then((syncPairs) => {
3716
+ return ParseStatus.mergeObjectSync(status, syncPairs);
3717
+ });
3718
+ } else {
3719
+ return ParseStatus.mergeObjectSync(status, pairs);
3720
+ }
3721
+ }
3722
+ get shape() {
3723
+ return this._def.shape();
3724
+ }
3725
+ strict(message) {
3726
+ errorUtil.errToObj;
3727
+ return new _ZodObject({
3728
+ ...this._def,
3729
+ unknownKeys: "strict",
3730
+ ...message !== void 0 ? {
3731
+ errorMap: (issue, ctx) => {
3732
+ var _a, _b, _c, _d;
3733
+ const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
3734
+ if (issue.code === "unrecognized_keys")
3735
+ return {
3736
+ message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
3737
+ };
3738
+ return {
3739
+ message: defaultError
3740
+ };
3741
+ }
3742
+ } : {}
3743
+ });
3744
+ }
3745
+ strip() {
3746
+ return new _ZodObject({
3747
+ ...this._def,
3748
+ unknownKeys: "strip"
3749
+ });
3750
+ }
3751
+ passthrough() {
3752
+ return new _ZodObject({
3753
+ ...this._def,
3754
+ unknownKeys: "passthrough"
3755
+ });
3756
+ }
3757
+ // const AugmentFactory =
3758
+ // <Def extends ZodObjectDef>(def: Def) =>
3759
+ // <Augmentation extends ZodRawShape>(
3760
+ // augmentation: Augmentation
3761
+ // ): ZodObject<
3762
+ // extendShape<ReturnType<Def["shape"]>, Augmentation>,
3763
+ // Def["unknownKeys"],
3764
+ // Def["catchall"]
3765
+ // > => {
3766
+ // return new ZodObject({
3767
+ // ...def,
3768
+ // shape: () => ({
3769
+ // ...def.shape(),
3770
+ // ...augmentation,
3771
+ // }),
3772
+ // }) as any;
3773
+ // };
3774
+ extend(augmentation) {
3775
+ return new _ZodObject({
3776
+ ...this._def,
3777
+ shape: () => ({
3778
+ ...this._def.shape(),
3779
+ ...augmentation
3780
+ })
3781
+ });
3782
+ }
3783
+ /**
3784
+ * Prior to zod@1.0.12 there was a bug in the
3785
+ * inferred type of merged objects. Please
3786
+ * upgrade if you are experiencing issues.
3787
+ */
3788
+ merge(merging) {
3789
+ const merged = new _ZodObject({
3790
+ unknownKeys: merging._def.unknownKeys,
3791
+ catchall: merging._def.catchall,
3792
+ shape: () => ({
3793
+ ...this._def.shape(),
3794
+ ...merging._def.shape()
3795
+ }),
3796
+ typeName: ZodFirstPartyTypeKind.ZodObject
3797
+ });
3798
+ return merged;
3799
+ }
3800
+ // merge<
3801
+ // Incoming extends AnyZodObject,
3802
+ // Augmentation extends Incoming["shape"],
3803
+ // NewOutput extends {
3804
+ // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
3805
+ // ? Augmentation[k]["_output"]
3806
+ // : k extends keyof Output
3807
+ // ? Output[k]
3808
+ // : never;
3809
+ // },
3810
+ // NewInput extends {
3811
+ // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
3812
+ // ? Augmentation[k]["_input"]
3813
+ // : k extends keyof Input
3814
+ // ? Input[k]
3815
+ // : never;
3816
+ // }
3817
+ // >(
3818
+ // merging: Incoming
3819
+ // ): ZodObject<
3820
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
3821
+ // Incoming["_def"]["unknownKeys"],
3822
+ // Incoming["_def"]["catchall"],
3823
+ // NewOutput,
3824
+ // NewInput
3825
+ // > {
3826
+ // const merged: any = new ZodObject({
3827
+ // unknownKeys: merging._def.unknownKeys,
3828
+ // catchall: merging._def.catchall,
3829
+ // shape: () =>
3830
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3831
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
3832
+ // }) as any;
3833
+ // return merged;
3834
+ // }
3835
+ setKey(key, schema) {
3836
+ return this.augment({ [key]: schema });
3837
+ }
3838
+ // merge<Incoming extends AnyZodObject>(
3839
+ // merging: Incoming
3840
+ // ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
3841
+ // ZodObject<
3842
+ // extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
3843
+ // Incoming["_def"]["unknownKeys"],
3844
+ // Incoming["_def"]["catchall"]
3845
+ // > {
3846
+ // // const mergedShape = objectUtil.mergeShapes(
3847
+ // // this._def.shape(),
3848
+ // // merging._def.shape()
3849
+ // // );
3850
+ // const merged: any = new ZodObject({
3851
+ // unknownKeys: merging._def.unknownKeys,
3852
+ // catchall: merging._def.catchall,
3853
+ // shape: () =>
3854
+ // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
3855
+ // typeName: ZodFirstPartyTypeKind.ZodObject,
3856
+ // }) as any;
3857
+ // return merged;
3858
+ // }
3859
+ catchall(index) {
3860
+ return new _ZodObject({
3861
+ ...this._def,
3862
+ catchall: index
3863
+ });
3864
+ }
3865
+ pick(mask) {
3866
+ const shape = {};
3867
+ util.objectKeys(mask).forEach((key) => {
3868
+ if (mask[key] && this.shape[key]) {
3869
+ shape[key] = this.shape[key];
3870
+ }
3871
+ });
3872
+ return new _ZodObject({
3873
+ ...this._def,
3874
+ shape: () => shape
3875
+ });
3876
+ }
3877
+ omit(mask) {
3878
+ const shape = {};
3879
+ util.objectKeys(this.shape).forEach((key) => {
3880
+ if (!mask[key]) {
3881
+ shape[key] = this.shape[key];
3882
+ }
3883
+ });
3884
+ return new _ZodObject({
3885
+ ...this._def,
3886
+ shape: () => shape
3887
+ });
3888
+ }
3889
+ /**
3890
+ * @deprecated
3891
+ */
3892
+ deepPartial() {
3893
+ return deepPartialify(this);
3894
+ }
3895
+ partial(mask) {
3896
+ const newShape = {};
3897
+ util.objectKeys(this.shape).forEach((key) => {
3898
+ const fieldSchema = this.shape[key];
3899
+ if (mask && !mask[key]) {
3900
+ newShape[key] = fieldSchema;
3901
+ } else {
3902
+ newShape[key] = fieldSchema.optional();
3903
+ }
3904
+ });
3905
+ return new _ZodObject({
3906
+ ...this._def,
3907
+ shape: () => newShape
3908
+ });
3909
+ }
3910
+ required(mask) {
3911
+ const newShape = {};
3912
+ util.objectKeys(this.shape).forEach((key) => {
3913
+ if (mask && !mask[key]) {
3914
+ newShape[key] = this.shape[key];
3915
+ } else {
3916
+ const fieldSchema = this.shape[key];
3917
+ let newField = fieldSchema;
3918
+ while (newField instanceof ZodOptional) {
3919
+ newField = newField._def.innerType;
3920
+ }
3921
+ newShape[key] = newField;
3922
+ }
3923
+ });
3924
+ return new _ZodObject({
3925
+ ...this._def,
3926
+ shape: () => newShape
3927
+ });
3928
+ }
3929
+ keyof() {
3930
+ return createZodEnum(util.objectKeys(this.shape));
3931
+ }
3932
+ };
3933
+ ZodObject.create = (shape, params) => {
3934
+ return new ZodObject({
3935
+ shape: () => shape,
3936
+ unknownKeys: "strip",
3937
+ catchall: ZodNever.create(),
3938
+ typeName: ZodFirstPartyTypeKind.ZodObject,
3939
+ ...processCreateParams(params)
3940
+ });
3941
+ };
3942
+ ZodObject.strictCreate = (shape, params) => {
3943
+ return new ZodObject({
3944
+ shape: () => shape,
3945
+ unknownKeys: "strict",
3946
+ catchall: ZodNever.create(),
3947
+ typeName: ZodFirstPartyTypeKind.ZodObject,
3948
+ ...processCreateParams(params)
3949
+ });
3950
+ };
3951
+ ZodObject.lazycreate = (shape, params) => {
3952
+ return new ZodObject({
3953
+ shape,
3954
+ unknownKeys: "strip",
3955
+ catchall: ZodNever.create(),
3956
+ typeName: ZodFirstPartyTypeKind.ZodObject,
3957
+ ...processCreateParams(params)
3958
+ });
3959
+ };
3960
+ var ZodUnion = class extends ZodType {
3961
+ _parse(input) {
3962
+ const { ctx } = this._processInputParams(input);
3963
+ const options = this._def.options;
3964
+ function handleResults(results) {
3965
+ for (const result of results) {
3966
+ if (result.result.status === "valid") {
3967
+ return result.result;
3968
+ }
3969
+ }
3970
+ for (const result of results) {
3971
+ if (result.result.status === "dirty") {
3972
+ ctx.common.issues.push(...result.ctx.common.issues);
3973
+ return result.result;
3974
+ }
3975
+ }
3976
+ const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
3977
+ addIssueToContext(ctx, {
3978
+ code: ZodIssueCode.invalid_union,
3979
+ unionErrors
3980
+ });
3981
+ return INVALID;
3982
+ }
3983
+ if (ctx.common.async) {
3984
+ return Promise.all(options.map(async (option) => {
3985
+ const childCtx = {
3986
+ ...ctx,
3987
+ common: {
3988
+ ...ctx.common,
3989
+ issues: []
3990
+ },
3991
+ parent: null
3992
+ };
3993
+ return {
3994
+ result: await option._parseAsync({
3995
+ data: ctx.data,
3996
+ path: ctx.path,
3997
+ parent: childCtx
3998
+ }),
3999
+ ctx: childCtx
4000
+ };
4001
+ })).then(handleResults);
4002
+ } else {
4003
+ let dirty = void 0;
4004
+ const issues = [];
4005
+ for (const option of options) {
4006
+ const childCtx = {
4007
+ ...ctx,
4008
+ common: {
4009
+ ...ctx.common,
4010
+ issues: []
4011
+ },
4012
+ parent: null
4013
+ };
4014
+ const result = option._parseSync({
4015
+ data: ctx.data,
4016
+ path: ctx.path,
4017
+ parent: childCtx
4018
+ });
4019
+ if (result.status === "valid") {
4020
+ return result;
4021
+ } else if (result.status === "dirty" && !dirty) {
4022
+ dirty = { result, ctx: childCtx };
4023
+ }
4024
+ if (childCtx.common.issues.length) {
4025
+ issues.push(childCtx.common.issues);
4026
+ }
4027
+ }
4028
+ if (dirty) {
4029
+ ctx.common.issues.push(...dirty.ctx.common.issues);
4030
+ return dirty.result;
4031
+ }
4032
+ const unionErrors = issues.map((issues2) => new ZodError(issues2));
4033
+ addIssueToContext(ctx, {
4034
+ code: ZodIssueCode.invalid_union,
4035
+ unionErrors
4036
+ });
4037
+ return INVALID;
4038
+ }
4039
+ }
4040
+ get options() {
4041
+ return this._def.options;
4042
+ }
4043
+ };
4044
+ ZodUnion.create = (types, params) => {
4045
+ return new ZodUnion({
4046
+ options: types,
4047
+ typeName: ZodFirstPartyTypeKind.ZodUnion,
4048
+ ...processCreateParams(params)
4049
+ });
4050
+ };
4051
+ var getDiscriminator = (type) => {
4052
+ if (type instanceof ZodLazy) {
4053
+ return getDiscriminator(type.schema);
4054
+ } else if (type instanceof ZodEffects) {
4055
+ return getDiscriminator(type.innerType());
4056
+ } else if (type instanceof ZodLiteral) {
4057
+ return [type.value];
4058
+ } else if (type instanceof ZodEnum) {
4059
+ return type.options;
4060
+ } else if (type instanceof ZodNativeEnum) {
4061
+ return util.objectValues(type.enum);
4062
+ } else if (type instanceof ZodDefault) {
4063
+ return getDiscriminator(type._def.innerType);
4064
+ } else if (type instanceof ZodUndefined) {
4065
+ return [void 0];
4066
+ } else if (type instanceof ZodNull) {
4067
+ return [null];
4068
+ } else if (type instanceof ZodOptional) {
4069
+ return [void 0, ...getDiscriminator(type.unwrap())];
4070
+ } else if (type instanceof ZodNullable) {
4071
+ return [null, ...getDiscriminator(type.unwrap())];
4072
+ } else if (type instanceof ZodBranded) {
4073
+ return getDiscriminator(type.unwrap());
4074
+ } else if (type instanceof ZodReadonly) {
4075
+ return getDiscriminator(type.unwrap());
4076
+ } else if (type instanceof ZodCatch) {
4077
+ return getDiscriminator(type._def.innerType);
4078
+ } else {
4079
+ return [];
4080
+ }
4081
+ };
4082
+ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
4083
+ _parse(input) {
4084
+ const { ctx } = this._processInputParams(input);
4085
+ if (ctx.parsedType !== ZodParsedType.object) {
4086
+ addIssueToContext(ctx, {
4087
+ code: ZodIssueCode.invalid_type,
4088
+ expected: ZodParsedType.object,
4089
+ received: ctx.parsedType
4090
+ });
4091
+ return INVALID;
4092
+ }
4093
+ const discriminator = this.discriminator;
4094
+ const discriminatorValue = ctx.data[discriminator];
4095
+ const option = this.optionsMap.get(discriminatorValue);
4096
+ if (!option) {
4097
+ addIssueToContext(ctx, {
4098
+ code: ZodIssueCode.invalid_union_discriminator,
4099
+ options: Array.from(this.optionsMap.keys()),
4100
+ path: [discriminator]
4101
+ });
4102
+ return INVALID;
4103
+ }
4104
+ if (ctx.common.async) {
4105
+ return option._parseAsync({
4106
+ data: ctx.data,
4107
+ path: ctx.path,
4108
+ parent: ctx
4109
+ });
4110
+ } else {
4111
+ return option._parseSync({
4112
+ data: ctx.data,
4113
+ path: ctx.path,
4114
+ parent: ctx
4115
+ });
4116
+ }
4117
+ }
4118
+ get discriminator() {
4119
+ return this._def.discriminator;
4120
+ }
4121
+ get options() {
4122
+ return this._def.options;
4123
+ }
4124
+ get optionsMap() {
4125
+ return this._def.optionsMap;
4126
+ }
4127
+ /**
4128
+ * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
4129
+ * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
4130
+ * have a different value for each object in the union.
4131
+ * @param discriminator the name of the discriminator property
4132
+ * @param types an array of object schemas
4133
+ * @param params
4134
+ */
4135
+ static create(discriminator, options, params) {
4136
+ const optionsMap = /* @__PURE__ */ new Map();
4137
+ for (const type of options) {
4138
+ const discriminatorValues = getDiscriminator(type.shape[discriminator]);
4139
+ if (!discriminatorValues.length) {
4140
+ throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
4141
+ }
4142
+ for (const value of discriminatorValues) {
4143
+ if (optionsMap.has(value)) {
4144
+ throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
4145
+ }
4146
+ optionsMap.set(value, type);
4147
+ }
4148
+ }
4149
+ return new _ZodDiscriminatedUnion({
4150
+ typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
4151
+ discriminator,
4152
+ options,
4153
+ optionsMap,
4154
+ ...processCreateParams(params)
4155
+ });
4156
+ }
4157
+ };
4158
+ function mergeValues(a3, b3) {
4159
+ const aType = getParsedType(a3);
4160
+ const bType = getParsedType(b3);
4161
+ if (a3 === b3) {
4162
+ return { valid: true, data: a3 };
4163
+ } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
4164
+ const bKeys = util.objectKeys(b3);
4165
+ const sharedKeys = util.objectKeys(a3).filter((key) => bKeys.indexOf(key) !== -1);
4166
+ const newObj = { ...a3, ...b3 };
4167
+ for (const key of sharedKeys) {
4168
+ const sharedValue = mergeValues(a3[key], b3[key]);
4169
+ if (!sharedValue.valid) {
4170
+ return { valid: false };
4171
+ }
4172
+ newObj[key] = sharedValue.data;
4173
+ }
4174
+ return { valid: true, data: newObj };
4175
+ } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
4176
+ if (a3.length !== b3.length) {
4177
+ return { valid: false };
4178
+ }
4179
+ const newArray = [];
4180
+ for (let index = 0; index < a3.length; index++) {
4181
+ const itemA = a3[index];
4182
+ const itemB = b3[index];
4183
+ const sharedValue = mergeValues(itemA, itemB);
4184
+ if (!sharedValue.valid) {
4185
+ return { valid: false };
4186
+ }
4187
+ newArray.push(sharedValue.data);
4188
+ }
4189
+ return { valid: true, data: newArray };
4190
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a3 === +b3) {
4191
+ return { valid: true, data: a3 };
4192
+ } else {
4193
+ return { valid: false };
4194
+ }
4195
+ }
4196
+ var ZodIntersection = class extends ZodType {
4197
+ _parse(input) {
4198
+ const { status, ctx } = this._processInputParams(input);
4199
+ const handleParsed = (parsedLeft, parsedRight) => {
4200
+ if (isAborted(parsedLeft) || isAborted(parsedRight)) {
4201
+ return INVALID;
4202
+ }
4203
+ const merged = mergeValues(parsedLeft.value, parsedRight.value);
4204
+ if (!merged.valid) {
4205
+ addIssueToContext(ctx, {
4206
+ code: ZodIssueCode.invalid_intersection_types
4207
+ });
4208
+ return INVALID;
4209
+ }
4210
+ if (isDirty(parsedLeft) || isDirty(parsedRight)) {
4211
+ status.dirty();
4212
+ }
4213
+ return { status: status.value, value: merged.data };
4214
+ };
4215
+ if (ctx.common.async) {
4216
+ return Promise.all([
4217
+ this._def.left._parseAsync({
4218
+ data: ctx.data,
4219
+ path: ctx.path,
4220
+ parent: ctx
4221
+ }),
4222
+ this._def.right._parseAsync({
4223
+ data: ctx.data,
4224
+ path: ctx.path,
4225
+ parent: ctx
4226
+ })
4227
+ ]).then(([left, right]) => handleParsed(left, right));
4228
+ } else {
4229
+ return handleParsed(this._def.left._parseSync({
4230
+ data: ctx.data,
4231
+ path: ctx.path,
4232
+ parent: ctx
4233
+ }), this._def.right._parseSync({
4234
+ data: ctx.data,
4235
+ path: ctx.path,
4236
+ parent: ctx
4237
+ }));
4238
+ }
4239
+ }
4240
+ };
4241
+ ZodIntersection.create = (left, right, params) => {
4242
+ return new ZodIntersection({
4243
+ left,
4244
+ right,
4245
+ typeName: ZodFirstPartyTypeKind.ZodIntersection,
4246
+ ...processCreateParams(params)
4247
+ });
4248
+ };
4249
+ var ZodTuple = class _ZodTuple extends ZodType {
4250
+ _parse(input) {
4251
+ const { status, ctx } = this._processInputParams(input);
4252
+ if (ctx.parsedType !== ZodParsedType.array) {
4253
+ addIssueToContext(ctx, {
4254
+ code: ZodIssueCode.invalid_type,
4255
+ expected: ZodParsedType.array,
4256
+ received: ctx.parsedType
4257
+ });
4258
+ return INVALID;
4259
+ }
4260
+ if (ctx.data.length < this._def.items.length) {
4261
+ addIssueToContext(ctx, {
4262
+ code: ZodIssueCode.too_small,
4263
+ minimum: this._def.items.length,
4264
+ inclusive: true,
4265
+ exact: false,
4266
+ type: "array"
4267
+ });
4268
+ return INVALID;
4269
+ }
4270
+ const rest = this._def.rest;
4271
+ if (!rest && ctx.data.length > this._def.items.length) {
4272
+ addIssueToContext(ctx, {
4273
+ code: ZodIssueCode.too_big,
4274
+ maximum: this._def.items.length,
4275
+ inclusive: true,
4276
+ exact: false,
4277
+ type: "array"
4278
+ });
4279
+ status.dirty();
4280
+ }
4281
+ const items = [...ctx.data].map((item, itemIndex) => {
4282
+ const schema = this._def.items[itemIndex] || this._def.rest;
4283
+ if (!schema)
4284
+ return null;
4285
+ return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
4286
+ }).filter((x2) => !!x2);
4287
+ if (ctx.common.async) {
4288
+ return Promise.all(items).then((results) => {
4289
+ return ParseStatus.mergeArray(status, results);
4290
+ });
4291
+ } else {
4292
+ return ParseStatus.mergeArray(status, items);
4293
+ }
4294
+ }
4295
+ get items() {
4296
+ return this._def.items;
4297
+ }
4298
+ rest(rest) {
4299
+ return new _ZodTuple({
4300
+ ...this._def,
4301
+ rest
4302
+ });
4303
+ }
4304
+ };
4305
+ ZodTuple.create = (schemas, params) => {
4306
+ if (!Array.isArray(schemas)) {
4307
+ throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
4308
+ }
4309
+ return new ZodTuple({
4310
+ items: schemas,
4311
+ typeName: ZodFirstPartyTypeKind.ZodTuple,
4312
+ rest: null,
4313
+ ...processCreateParams(params)
4314
+ });
4315
+ };
4316
+ var ZodRecord = class _ZodRecord extends ZodType {
4317
+ get keySchema() {
4318
+ return this._def.keyType;
4319
+ }
4320
+ get valueSchema() {
4321
+ return this._def.valueType;
4322
+ }
4323
+ _parse(input) {
4324
+ const { status, ctx } = this._processInputParams(input);
4325
+ if (ctx.parsedType !== ZodParsedType.object) {
4326
+ addIssueToContext(ctx, {
4327
+ code: ZodIssueCode.invalid_type,
4328
+ expected: ZodParsedType.object,
4329
+ received: ctx.parsedType
4330
+ });
4331
+ return INVALID;
4332
+ }
4333
+ const pairs = [];
4334
+ const keyType = this._def.keyType;
4335
+ const valueType = this._def.valueType;
4336
+ for (const key in ctx.data) {
4337
+ pairs.push({
4338
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
4339
+ value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
4340
+ alwaysSet: key in ctx.data
4341
+ });
4342
+ }
4343
+ if (ctx.common.async) {
4344
+ return ParseStatus.mergeObjectAsync(status, pairs);
4345
+ } else {
4346
+ return ParseStatus.mergeObjectSync(status, pairs);
4347
+ }
4348
+ }
4349
+ get element() {
4350
+ return this._def.valueType;
4351
+ }
4352
+ static create(first, second, third) {
4353
+ if (second instanceof ZodType) {
4354
+ return new _ZodRecord({
4355
+ keyType: first,
4356
+ valueType: second,
4357
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
4358
+ ...processCreateParams(third)
4359
+ });
4360
+ }
4361
+ return new _ZodRecord({
4362
+ keyType: ZodString.create(),
4363
+ valueType: first,
4364
+ typeName: ZodFirstPartyTypeKind.ZodRecord,
4365
+ ...processCreateParams(second)
4366
+ });
4367
+ }
4368
+ };
4369
+ var ZodMap = class extends ZodType {
4370
+ get keySchema() {
4371
+ return this._def.keyType;
4372
+ }
4373
+ get valueSchema() {
4374
+ return this._def.valueType;
4375
+ }
4376
+ _parse(input) {
4377
+ const { status, ctx } = this._processInputParams(input);
4378
+ if (ctx.parsedType !== ZodParsedType.map) {
4379
+ addIssueToContext(ctx, {
4380
+ code: ZodIssueCode.invalid_type,
4381
+ expected: ZodParsedType.map,
4382
+ received: ctx.parsedType
4383
+ });
4384
+ return INVALID;
4385
+ }
4386
+ const keyType = this._def.keyType;
4387
+ const valueType = this._def.valueType;
4388
+ const pairs = [...ctx.data.entries()].map(([key, value], index) => {
4389
+ return {
4390
+ key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
4391
+ value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
4392
+ };
4393
+ });
4394
+ if (ctx.common.async) {
4395
+ const finalMap = /* @__PURE__ */ new Map();
4396
+ return Promise.resolve().then(async () => {
4397
+ for (const pair of pairs) {
4398
+ const key = await pair.key;
4399
+ const value = await pair.value;
4400
+ if (key.status === "aborted" || value.status === "aborted") {
4401
+ return INVALID;
4402
+ }
4403
+ if (key.status === "dirty" || value.status === "dirty") {
4404
+ status.dirty();
4405
+ }
4406
+ finalMap.set(key.value, value.value);
4407
+ }
4408
+ return { status: status.value, value: finalMap };
4409
+ });
4410
+ } else {
4411
+ const finalMap = /* @__PURE__ */ new Map();
4412
+ for (const pair of pairs) {
4413
+ const key = pair.key;
4414
+ const value = pair.value;
4415
+ if (key.status === "aborted" || value.status === "aborted") {
4416
+ return INVALID;
4417
+ }
4418
+ if (key.status === "dirty" || value.status === "dirty") {
4419
+ status.dirty();
4420
+ }
4421
+ finalMap.set(key.value, value.value);
4422
+ }
4423
+ return { status: status.value, value: finalMap };
4424
+ }
4425
+ }
4426
+ };
4427
+ ZodMap.create = (keyType, valueType, params) => {
4428
+ return new ZodMap({
4429
+ valueType,
4430
+ keyType,
4431
+ typeName: ZodFirstPartyTypeKind.ZodMap,
4432
+ ...processCreateParams(params)
4433
+ });
4434
+ };
4435
+ var ZodSet = class _ZodSet extends ZodType {
4436
+ _parse(input) {
4437
+ const { status, ctx } = this._processInputParams(input);
4438
+ if (ctx.parsedType !== ZodParsedType.set) {
4439
+ addIssueToContext(ctx, {
4440
+ code: ZodIssueCode.invalid_type,
4441
+ expected: ZodParsedType.set,
4442
+ received: ctx.parsedType
4443
+ });
4444
+ return INVALID;
4445
+ }
4446
+ const def = this._def;
4447
+ if (def.minSize !== null) {
4448
+ if (ctx.data.size < def.minSize.value) {
4449
+ addIssueToContext(ctx, {
4450
+ code: ZodIssueCode.too_small,
4451
+ minimum: def.minSize.value,
4452
+ type: "set",
4453
+ inclusive: true,
4454
+ exact: false,
4455
+ message: def.minSize.message
4456
+ });
4457
+ status.dirty();
4458
+ }
4459
+ }
4460
+ if (def.maxSize !== null) {
4461
+ if (ctx.data.size > def.maxSize.value) {
4462
+ addIssueToContext(ctx, {
4463
+ code: ZodIssueCode.too_big,
4464
+ maximum: def.maxSize.value,
4465
+ type: "set",
4466
+ inclusive: true,
4467
+ exact: false,
4468
+ message: def.maxSize.message
4469
+ });
4470
+ status.dirty();
4471
+ }
4472
+ }
4473
+ const valueType = this._def.valueType;
4474
+ function finalizeSet(elements2) {
4475
+ const parsedSet = /* @__PURE__ */ new Set();
4476
+ for (const element of elements2) {
4477
+ if (element.status === "aborted")
4478
+ return INVALID;
4479
+ if (element.status === "dirty")
4480
+ status.dirty();
4481
+ parsedSet.add(element.value);
4482
+ }
4483
+ return { status: status.value, value: parsedSet };
4484
+ }
4485
+ const elements = [...ctx.data.values()].map((item, i6) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i6)));
4486
+ if (ctx.common.async) {
4487
+ return Promise.all(elements).then((elements2) => finalizeSet(elements2));
4488
+ } else {
4489
+ return finalizeSet(elements);
4490
+ }
4491
+ }
4492
+ min(minSize, message) {
4493
+ return new _ZodSet({
4494
+ ...this._def,
4495
+ minSize: { value: minSize, message: errorUtil.toString(message) }
4496
+ });
4497
+ }
4498
+ max(maxSize, message) {
4499
+ return new _ZodSet({
4500
+ ...this._def,
4501
+ maxSize: { value: maxSize, message: errorUtil.toString(message) }
4502
+ });
4503
+ }
4504
+ size(size, message) {
4505
+ return this.min(size, message).max(size, message);
4506
+ }
4507
+ nonempty(message) {
4508
+ return this.min(1, message);
4509
+ }
4510
+ };
4511
+ ZodSet.create = (valueType, params) => {
4512
+ return new ZodSet({
4513
+ valueType,
4514
+ minSize: null,
4515
+ maxSize: null,
4516
+ typeName: ZodFirstPartyTypeKind.ZodSet,
4517
+ ...processCreateParams(params)
4518
+ });
4519
+ };
4520
+ var ZodFunction = class _ZodFunction extends ZodType {
4521
+ constructor() {
4522
+ super(...arguments);
4523
+ this.validate = this.implement;
4524
+ }
4525
+ _parse(input) {
4526
+ const { ctx } = this._processInputParams(input);
4527
+ if (ctx.parsedType !== ZodParsedType.function) {
4528
+ addIssueToContext(ctx, {
4529
+ code: ZodIssueCode.invalid_type,
4530
+ expected: ZodParsedType.function,
4531
+ received: ctx.parsedType
4532
+ });
4533
+ return INVALID;
4534
+ }
4535
+ function makeArgsIssue(args, error) {
4536
+ return makeIssue({
4537
+ data: args,
4538
+ path: ctx.path,
4539
+ errorMaps: [
4540
+ ctx.common.contextualErrorMap,
4541
+ ctx.schemaErrorMap,
4542
+ getErrorMap(),
4543
+ errorMap
4544
+ ].filter((x2) => !!x2),
4545
+ issueData: {
4546
+ code: ZodIssueCode.invalid_arguments,
4547
+ argumentsError: error
4548
+ }
4549
+ });
4550
+ }
4551
+ function makeReturnsIssue(returns, error) {
4552
+ return makeIssue({
4553
+ data: returns,
4554
+ path: ctx.path,
4555
+ errorMaps: [
4556
+ ctx.common.contextualErrorMap,
4557
+ ctx.schemaErrorMap,
4558
+ getErrorMap(),
4559
+ errorMap
4560
+ ].filter((x2) => !!x2),
4561
+ issueData: {
4562
+ code: ZodIssueCode.invalid_return_type,
4563
+ returnTypeError: error
4564
+ }
4565
+ });
4566
+ }
4567
+ const params = { errorMap: ctx.common.contextualErrorMap };
4568
+ const fn = ctx.data;
4569
+ if (this._def.returns instanceof ZodPromise) {
4570
+ const me = this;
4571
+ return OK(async function(...args) {
4572
+ const error = new ZodError([]);
4573
+ const parsedArgs = await me._def.args.parseAsync(args, params).catch((e7) => {
4574
+ error.addIssue(makeArgsIssue(args, e7));
4575
+ throw error;
4576
+ });
4577
+ const result = await Reflect.apply(fn, this, parsedArgs);
4578
+ const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e7) => {
4579
+ error.addIssue(makeReturnsIssue(result, e7));
4580
+ throw error;
4581
+ });
4582
+ return parsedReturns;
4583
+ });
4584
+ } else {
4585
+ const me = this;
4586
+ return OK(function(...args) {
4587
+ const parsedArgs = me._def.args.safeParse(args, params);
4588
+ if (!parsedArgs.success) {
4589
+ throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
4590
+ }
4591
+ const result = Reflect.apply(fn, this, parsedArgs.data);
4592
+ const parsedReturns = me._def.returns.safeParse(result, params);
4593
+ if (!parsedReturns.success) {
4594
+ throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
4595
+ }
4596
+ return parsedReturns.data;
4597
+ });
4598
+ }
4599
+ }
4600
+ parameters() {
4601
+ return this._def.args;
4602
+ }
4603
+ returnType() {
4604
+ return this._def.returns;
4605
+ }
4606
+ args(...items) {
4607
+ return new _ZodFunction({
4608
+ ...this._def,
4609
+ args: ZodTuple.create(items).rest(ZodUnknown.create())
4610
+ });
4611
+ }
4612
+ returns(returnType) {
4613
+ return new _ZodFunction({
4614
+ ...this._def,
4615
+ returns: returnType
4616
+ });
4617
+ }
4618
+ implement(func) {
4619
+ const validatedFunc = this.parse(func);
4620
+ return validatedFunc;
4621
+ }
4622
+ strictImplement(func) {
4623
+ const validatedFunc = this.parse(func);
4624
+ return validatedFunc;
4625
+ }
4626
+ static create(args, returns, params) {
4627
+ return new _ZodFunction({
4628
+ args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
4629
+ returns: returns || ZodUnknown.create(),
4630
+ typeName: ZodFirstPartyTypeKind.ZodFunction,
4631
+ ...processCreateParams(params)
4632
+ });
4633
+ }
4634
+ };
4635
+ var ZodLazy = class extends ZodType {
4636
+ get schema() {
4637
+ return this._def.getter();
4638
+ }
4639
+ _parse(input) {
4640
+ const { ctx } = this._processInputParams(input);
4641
+ const lazySchema = this._def.getter();
4642
+ return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
4643
+ }
4644
+ };
4645
+ ZodLazy.create = (getter, params) => {
4646
+ return new ZodLazy({
4647
+ getter,
4648
+ typeName: ZodFirstPartyTypeKind.ZodLazy,
4649
+ ...processCreateParams(params)
4650
+ });
4651
+ };
4652
+ var ZodLiteral = class extends ZodType {
4653
+ _parse(input) {
4654
+ if (input.data !== this._def.value) {
4655
+ const ctx = this._getOrReturnCtx(input);
4656
+ addIssueToContext(ctx, {
4657
+ received: ctx.data,
4658
+ code: ZodIssueCode.invalid_literal,
4659
+ expected: this._def.value
4660
+ });
4661
+ return INVALID;
4662
+ }
4663
+ return { status: "valid", value: input.data };
4664
+ }
4665
+ get value() {
4666
+ return this._def.value;
4667
+ }
4668
+ };
4669
+ ZodLiteral.create = (value, params) => {
4670
+ return new ZodLiteral({
4671
+ value,
4672
+ typeName: ZodFirstPartyTypeKind.ZodLiteral,
4673
+ ...processCreateParams(params)
4674
+ });
4675
+ };
4676
+ function createZodEnum(values, params) {
4677
+ return new ZodEnum({
4678
+ values,
4679
+ typeName: ZodFirstPartyTypeKind.ZodEnum,
4680
+ ...processCreateParams(params)
4681
+ });
4682
+ }
4683
+ var ZodEnum = class _ZodEnum extends ZodType {
4684
+ constructor() {
4685
+ super(...arguments);
4686
+ _ZodEnum_cache.set(this, void 0);
4687
+ }
4688
+ _parse(input) {
4689
+ if (typeof input.data !== "string") {
4690
+ const ctx = this._getOrReturnCtx(input);
4691
+ const expectedValues = this._def.values;
4692
+ addIssueToContext(ctx, {
4693
+ expected: util.joinValues(expectedValues),
4694
+ received: ctx.parsedType,
4695
+ code: ZodIssueCode.invalid_type
4696
+ });
4697
+ return INVALID;
4698
+ }
4699
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
4700
+ __classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
4701
+ }
4702
+ if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
4703
+ const ctx = this._getOrReturnCtx(input);
4704
+ const expectedValues = this._def.values;
4705
+ addIssueToContext(ctx, {
4706
+ received: ctx.data,
4707
+ code: ZodIssueCode.invalid_enum_value,
4708
+ options: expectedValues
4709
+ });
4710
+ return INVALID;
4711
+ }
4712
+ return OK(input.data);
4713
+ }
4714
+ get options() {
4715
+ return this._def.values;
4716
+ }
4717
+ get enum() {
4718
+ const enumValues = {};
4719
+ for (const val of this._def.values) {
4720
+ enumValues[val] = val;
4721
+ }
4722
+ return enumValues;
4723
+ }
4724
+ get Values() {
4725
+ const enumValues = {};
4726
+ for (const val of this._def.values) {
4727
+ enumValues[val] = val;
4728
+ }
4729
+ return enumValues;
4730
+ }
4731
+ get Enum() {
4732
+ const enumValues = {};
4733
+ for (const val of this._def.values) {
4734
+ enumValues[val] = val;
4735
+ }
4736
+ return enumValues;
4737
+ }
4738
+ extract(values, newDef = this._def) {
4739
+ return _ZodEnum.create(values, {
4740
+ ...this._def,
4741
+ ...newDef
4742
+ });
4743
+ }
4744
+ exclude(values, newDef = this._def) {
4745
+ return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), {
4746
+ ...this._def,
4747
+ ...newDef
4748
+ });
4749
+ }
4750
+ };
4751
+ _ZodEnum_cache = /* @__PURE__ */ new WeakMap();
4752
+ ZodEnum.create = createZodEnum;
4753
+ var ZodNativeEnum = class extends ZodType {
4754
+ constructor() {
4755
+ super(...arguments);
4756
+ _ZodNativeEnum_cache.set(this, void 0);
4757
+ }
4758
+ _parse(input) {
4759
+ const nativeEnumValues = util.getValidEnumValues(this._def.values);
4760
+ const ctx = this._getOrReturnCtx(input);
4761
+ if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
4762
+ const expectedValues = util.objectValues(nativeEnumValues);
4763
+ addIssueToContext(ctx, {
4764
+ expected: util.joinValues(expectedValues),
4765
+ received: ctx.parsedType,
4766
+ code: ZodIssueCode.invalid_type
4767
+ });
4768
+ return INVALID;
4769
+ }
4770
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
4771
+ __classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
4772
+ }
4773
+ if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
4774
+ const expectedValues = util.objectValues(nativeEnumValues);
4775
+ addIssueToContext(ctx, {
4776
+ received: ctx.data,
4777
+ code: ZodIssueCode.invalid_enum_value,
4778
+ options: expectedValues
4779
+ });
4780
+ return INVALID;
4781
+ }
4782
+ return OK(input.data);
4783
+ }
4784
+ get enum() {
4785
+ return this._def.values;
4786
+ }
4787
+ };
4788
+ _ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
4789
+ ZodNativeEnum.create = (values, params) => {
4790
+ return new ZodNativeEnum({
4791
+ values,
4792
+ typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
4793
+ ...processCreateParams(params)
4794
+ });
4795
+ };
4796
+ var ZodPromise = class extends ZodType {
4797
+ unwrap() {
4798
+ return this._def.type;
4799
+ }
4800
+ _parse(input) {
4801
+ const { ctx } = this._processInputParams(input);
4802
+ if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
4803
+ addIssueToContext(ctx, {
4804
+ code: ZodIssueCode.invalid_type,
4805
+ expected: ZodParsedType.promise,
4806
+ received: ctx.parsedType
4807
+ });
4808
+ return INVALID;
4809
+ }
4810
+ const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
4811
+ return OK(promisified.then((data) => {
4812
+ return this._def.type.parseAsync(data, {
4813
+ path: ctx.path,
4814
+ errorMap: ctx.common.contextualErrorMap
4815
+ });
4816
+ }));
4817
+ }
4818
+ };
4819
+ ZodPromise.create = (schema, params) => {
4820
+ return new ZodPromise({
4821
+ type: schema,
4822
+ typeName: ZodFirstPartyTypeKind.ZodPromise,
4823
+ ...processCreateParams(params)
4824
+ });
4825
+ };
4826
+ var ZodEffects = class extends ZodType {
4827
+ innerType() {
4828
+ return this._def.schema;
4829
+ }
4830
+ sourceType() {
4831
+ return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
4832
+ }
4833
+ _parse(input) {
4834
+ const { status, ctx } = this._processInputParams(input);
4835
+ const effect = this._def.effect || null;
4836
+ const checkCtx = {
4837
+ addIssue: (arg) => {
4838
+ addIssueToContext(ctx, arg);
4839
+ if (arg.fatal) {
4840
+ status.abort();
4841
+ } else {
4842
+ status.dirty();
4843
+ }
4844
+ },
4845
+ get path() {
4846
+ return ctx.path;
4847
+ }
4848
+ };
4849
+ checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
4850
+ if (effect.type === "preprocess") {
4851
+ const processed = effect.transform(ctx.data, checkCtx);
4852
+ if (ctx.common.async) {
4853
+ return Promise.resolve(processed).then(async (processed2) => {
4854
+ if (status.value === "aborted")
4855
+ return INVALID;
4856
+ const result = await this._def.schema._parseAsync({
4857
+ data: processed2,
4858
+ path: ctx.path,
4859
+ parent: ctx
4860
+ });
4861
+ if (result.status === "aborted")
4862
+ return INVALID;
4863
+ if (result.status === "dirty")
4864
+ return DIRTY(result.value);
4865
+ if (status.value === "dirty")
4866
+ return DIRTY(result.value);
4867
+ return result;
4868
+ });
4869
+ } else {
4870
+ if (status.value === "aborted")
4871
+ return INVALID;
4872
+ const result = this._def.schema._parseSync({
4873
+ data: processed,
4874
+ path: ctx.path,
4875
+ parent: ctx
4876
+ });
4877
+ if (result.status === "aborted")
4878
+ return INVALID;
4879
+ if (result.status === "dirty")
4880
+ return DIRTY(result.value);
4881
+ if (status.value === "dirty")
4882
+ return DIRTY(result.value);
4883
+ return result;
4884
+ }
4885
+ }
4886
+ if (effect.type === "refinement") {
4887
+ const executeRefinement = (acc) => {
4888
+ const result = effect.refinement(acc, checkCtx);
4889
+ if (ctx.common.async) {
4890
+ return Promise.resolve(result);
4891
+ }
4892
+ if (result instanceof Promise) {
4893
+ throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
4894
+ }
4895
+ return acc;
4896
+ };
4897
+ if (ctx.common.async === false) {
4898
+ const inner = this._def.schema._parseSync({
4899
+ data: ctx.data,
4900
+ path: ctx.path,
4901
+ parent: ctx
4902
+ });
4903
+ if (inner.status === "aborted")
4904
+ return INVALID;
4905
+ if (inner.status === "dirty")
4906
+ status.dirty();
4907
+ executeRefinement(inner.value);
4908
+ return { status: status.value, value: inner.value };
4909
+ } else {
4910
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
4911
+ if (inner.status === "aborted")
4912
+ return INVALID;
4913
+ if (inner.status === "dirty")
4914
+ status.dirty();
4915
+ return executeRefinement(inner.value).then(() => {
4916
+ return { status: status.value, value: inner.value };
4917
+ });
4918
+ });
4919
+ }
4920
+ }
4921
+ if (effect.type === "transform") {
4922
+ if (ctx.common.async === false) {
4923
+ const base = this._def.schema._parseSync({
4924
+ data: ctx.data,
4925
+ path: ctx.path,
4926
+ parent: ctx
4927
+ });
4928
+ if (!isValid(base))
4929
+ return base;
4930
+ const result = effect.transform(base.value, checkCtx);
4931
+ if (result instanceof Promise) {
4932
+ throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
4933
+ }
4934
+ return { status: status.value, value: result };
4935
+ } else {
4936
+ return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
4937
+ if (!isValid(base))
4938
+ return base;
4939
+ return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
4940
+ });
4941
+ }
4942
+ }
4943
+ util.assertNever(effect);
4944
+ }
4945
+ };
4946
+ ZodEffects.create = (schema, effect, params) => {
4947
+ return new ZodEffects({
4948
+ schema,
4949
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
4950
+ effect,
4951
+ ...processCreateParams(params)
4952
+ });
4953
+ };
4954
+ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
4955
+ return new ZodEffects({
4956
+ schema,
4957
+ effect: { type: "preprocess", transform: preprocess },
4958
+ typeName: ZodFirstPartyTypeKind.ZodEffects,
4959
+ ...processCreateParams(params)
4960
+ });
4961
+ };
4962
+ var ZodOptional = class extends ZodType {
4963
+ _parse(input) {
4964
+ const parsedType = this._getType(input);
4965
+ if (parsedType === ZodParsedType.undefined) {
4966
+ return OK(void 0);
4967
+ }
4968
+ return this._def.innerType._parse(input);
4969
+ }
4970
+ unwrap() {
4971
+ return this._def.innerType;
4972
+ }
4973
+ };
4974
+ ZodOptional.create = (type, params) => {
4975
+ return new ZodOptional({
4976
+ innerType: type,
4977
+ typeName: ZodFirstPartyTypeKind.ZodOptional,
4978
+ ...processCreateParams(params)
4979
+ });
4980
+ };
4981
+ var ZodNullable = class extends ZodType {
4982
+ _parse(input) {
4983
+ const parsedType = this._getType(input);
4984
+ if (parsedType === ZodParsedType.null) {
4985
+ return OK(null);
4986
+ }
4987
+ return this._def.innerType._parse(input);
4988
+ }
4989
+ unwrap() {
4990
+ return this._def.innerType;
4991
+ }
4992
+ };
4993
+ ZodNullable.create = (type, params) => {
4994
+ return new ZodNullable({
4995
+ innerType: type,
4996
+ typeName: ZodFirstPartyTypeKind.ZodNullable,
4997
+ ...processCreateParams(params)
4998
+ });
4999
+ };
5000
+ var ZodDefault = class extends ZodType {
5001
+ _parse(input) {
5002
+ const { ctx } = this._processInputParams(input);
5003
+ let data = ctx.data;
5004
+ if (ctx.parsedType === ZodParsedType.undefined) {
5005
+ data = this._def.defaultValue();
5006
+ }
5007
+ return this._def.innerType._parse({
5008
+ data,
5009
+ path: ctx.path,
5010
+ parent: ctx
5011
+ });
5012
+ }
5013
+ removeDefault() {
5014
+ return this._def.innerType;
5015
+ }
5016
+ };
5017
+ ZodDefault.create = (type, params) => {
5018
+ return new ZodDefault({
5019
+ innerType: type,
5020
+ typeName: ZodFirstPartyTypeKind.ZodDefault,
5021
+ defaultValue: typeof params.default === "function" ? params.default : () => params.default,
5022
+ ...processCreateParams(params)
5023
+ });
5024
+ };
5025
+ var ZodCatch = class extends ZodType {
5026
+ _parse(input) {
5027
+ const { ctx } = this._processInputParams(input);
5028
+ const newCtx = {
5029
+ ...ctx,
5030
+ common: {
5031
+ ...ctx.common,
5032
+ issues: []
5033
+ }
5034
+ };
5035
+ const result = this._def.innerType._parse({
5036
+ data: newCtx.data,
5037
+ path: newCtx.path,
5038
+ parent: {
5039
+ ...newCtx
5040
+ }
5041
+ });
5042
+ if (isAsync(result)) {
5043
+ return result.then((result2) => {
5044
+ return {
5045
+ status: "valid",
5046
+ value: result2.status === "valid" ? result2.value : this._def.catchValue({
5047
+ get error() {
5048
+ return new ZodError(newCtx.common.issues);
5049
+ },
5050
+ input: newCtx.data
5051
+ })
5052
+ };
5053
+ });
5054
+ } else {
5055
+ return {
5056
+ status: "valid",
5057
+ value: result.status === "valid" ? result.value : this._def.catchValue({
5058
+ get error() {
5059
+ return new ZodError(newCtx.common.issues);
5060
+ },
5061
+ input: newCtx.data
5062
+ })
5063
+ };
5064
+ }
5065
+ }
5066
+ removeCatch() {
5067
+ return this._def.innerType;
5068
+ }
5069
+ };
5070
+ ZodCatch.create = (type, params) => {
5071
+ return new ZodCatch({
5072
+ innerType: type,
5073
+ typeName: ZodFirstPartyTypeKind.ZodCatch,
5074
+ catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
5075
+ ...processCreateParams(params)
5076
+ });
5077
+ };
5078
+ var ZodNaN = class extends ZodType {
5079
+ _parse(input) {
5080
+ const parsedType = this._getType(input);
5081
+ if (parsedType !== ZodParsedType.nan) {
5082
+ const ctx = this._getOrReturnCtx(input);
5083
+ addIssueToContext(ctx, {
5084
+ code: ZodIssueCode.invalid_type,
5085
+ expected: ZodParsedType.nan,
5086
+ received: ctx.parsedType
5087
+ });
5088
+ return INVALID;
5089
+ }
5090
+ return { status: "valid", value: input.data };
5091
+ }
5092
+ };
5093
+ ZodNaN.create = (params) => {
5094
+ return new ZodNaN({
5095
+ typeName: ZodFirstPartyTypeKind.ZodNaN,
5096
+ ...processCreateParams(params)
5097
+ });
5098
+ };
5099
+ var BRAND = Symbol("zod_brand");
5100
+ var ZodBranded = class extends ZodType {
5101
+ _parse(input) {
5102
+ const { ctx } = this._processInputParams(input);
5103
+ const data = ctx.data;
5104
+ return this._def.type._parse({
5105
+ data,
5106
+ path: ctx.path,
5107
+ parent: ctx
5108
+ });
5109
+ }
5110
+ unwrap() {
5111
+ return this._def.type;
5112
+ }
5113
+ };
5114
+ var ZodPipeline = class _ZodPipeline extends ZodType {
5115
+ _parse(input) {
5116
+ const { status, ctx } = this._processInputParams(input);
5117
+ if (ctx.common.async) {
5118
+ const handleAsync = async () => {
5119
+ const inResult = await this._def.in._parseAsync({
5120
+ data: ctx.data,
5121
+ path: ctx.path,
5122
+ parent: ctx
5123
+ });
5124
+ if (inResult.status === "aborted")
5125
+ return INVALID;
5126
+ if (inResult.status === "dirty") {
5127
+ status.dirty();
5128
+ return DIRTY(inResult.value);
5129
+ } else {
5130
+ return this._def.out._parseAsync({
5131
+ data: inResult.value,
5132
+ path: ctx.path,
5133
+ parent: ctx
5134
+ });
5135
+ }
5136
+ };
5137
+ return handleAsync();
5138
+ } else {
5139
+ const inResult = this._def.in._parseSync({
5140
+ data: ctx.data,
5141
+ path: ctx.path,
5142
+ parent: ctx
5143
+ });
5144
+ if (inResult.status === "aborted")
5145
+ return INVALID;
5146
+ if (inResult.status === "dirty") {
5147
+ status.dirty();
5148
+ return {
5149
+ status: "dirty",
5150
+ value: inResult.value
5151
+ };
5152
+ } else {
5153
+ return this._def.out._parseSync({
5154
+ data: inResult.value,
5155
+ path: ctx.path,
5156
+ parent: ctx
5157
+ });
5158
+ }
5159
+ }
5160
+ }
5161
+ static create(a3, b3) {
5162
+ return new _ZodPipeline({
5163
+ in: a3,
5164
+ out: b3,
5165
+ typeName: ZodFirstPartyTypeKind.ZodPipeline
5166
+ });
5167
+ }
5168
+ };
5169
+ var ZodReadonly = class extends ZodType {
5170
+ _parse(input) {
5171
+ const result = this._def.innerType._parse(input);
5172
+ const freeze = (data) => {
5173
+ if (isValid(data)) {
5174
+ data.value = Object.freeze(data.value);
5175
+ }
5176
+ return data;
5177
+ };
5178
+ return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
5179
+ }
5180
+ unwrap() {
5181
+ return this._def.innerType;
5182
+ }
5183
+ };
5184
+ ZodReadonly.create = (type, params) => {
5185
+ return new ZodReadonly({
5186
+ innerType: type,
5187
+ typeName: ZodFirstPartyTypeKind.ZodReadonly,
5188
+ ...processCreateParams(params)
5189
+ });
5190
+ };
5191
+ function custom(check, params = {}, fatal) {
5192
+ if (check)
5193
+ return ZodAny.create().superRefine((data, ctx) => {
5194
+ var _a, _b;
5195
+ if (!check(data)) {
5196
+ const p3 = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
5197
+ const _fatal = (_b = (_a = p3.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
5198
+ const p22 = typeof p3 === "string" ? { message: p3 } : p3;
5199
+ ctx.addIssue({ code: "custom", ...p22, fatal: _fatal });
5200
+ }
5201
+ });
5202
+ return ZodAny.create();
5203
+ }
5204
+ var late = {
5205
+ object: ZodObject.lazycreate
5206
+ };
5207
+ var ZodFirstPartyTypeKind;
5208
+ (function(ZodFirstPartyTypeKind2) {
5209
+ ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
5210
+ ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
5211
+ ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
5212
+ ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
5213
+ ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
5214
+ ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
5215
+ ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol";
5216
+ ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
5217
+ ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
5218
+ ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
5219
+ ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
5220
+ ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
5221
+ ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
5222
+ ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
5223
+ ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
5224
+ ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
5225
+ ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
5226
+ ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
5227
+ ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
5228
+ ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
5229
+ ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
5230
+ ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
5231
+ ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
5232
+ ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
5233
+ ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
5234
+ ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
5235
+ ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
5236
+ ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
5237
+ ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
5238
+ ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
5239
+ ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
5240
+ ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch";
5241
+ ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
5242
+ ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded";
5243
+ ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
5244
+ ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
5245
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
5246
+ var instanceOfType = (cls, params = {
5247
+ message: `Input not instance of ${cls.name}`
5248
+ }) => custom((data) => data instanceof cls, params);
5249
+ var stringType = ZodString.create;
5250
+ var numberType = ZodNumber.create;
5251
+ var nanType = ZodNaN.create;
5252
+ var bigIntType = ZodBigInt.create;
5253
+ var booleanType = ZodBoolean.create;
5254
+ var dateType = ZodDate.create;
5255
+ var symbolType = ZodSymbol.create;
5256
+ var undefinedType = ZodUndefined.create;
5257
+ var nullType = ZodNull.create;
5258
+ var anyType = ZodAny.create;
5259
+ var unknownType = ZodUnknown.create;
5260
+ var neverType = ZodNever.create;
5261
+ var voidType = ZodVoid.create;
5262
+ var arrayType = ZodArray.create;
5263
+ var objectType = ZodObject.create;
5264
+ var strictObjectType = ZodObject.strictCreate;
5265
+ var unionType = ZodUnion.create;
5266
+ var discriminatedUnionType = ZodDiscriminatedUnion.create;
5267
+ var intersectionType = ZodIntersection.create;
5268
+ var tupleType = ZodTuple.create;
5269
+ var recordType = ZodRecord.create;
5270
+ var mapType = ZodMap.create;
5271
+ var setType = ZodSet.create;
5272
+ var functionType = ZodFunction.create;
5273
+ var lazyType = ZodLazy.create;
5274
+ var literalType = ZodLiteral.create;
5275
+ var enumType = ZodEnum.create;
5276
+ var nativeEnumType = ZodNativeEnum.create;
5277
+ var promiseType = ZodPromise.create;
5278
+ var effectsType = ZodEffects.create;
5279
+ var optionalType = ZodOptional.create;
5280
+ var nullableType = ZodNullable.create;
5281
+ var preprocessType = ZodEffects.createWithPreprocess;
5282
+ var pipelineType = ZodPipeline.create;
5283
+ var ostring = () => stringType().optional();
5284
+ var onumber = () => numberType().optional();
5285
+ var oboolean = () => booleanType().optional();
5286
+ var coerce = {
5287
+ string: (arg) => ZodString.create({ ...arg, coerce: true }),
5288
+ number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
5289
+ boolean: (arg) => ZodBoolean.create({
5290
+ ...arg,
5291
+ coerce: true
5292
+ }),
5293
+ bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
5294
+ date: (arg) => ZodDate.create({ ...arg, coerce: true })
5295
+ };
5296
+ var NEVER = INVALID;
5297
+ var z = /* @__PURE__ */ Object.freeze({
5298
+ __proto__: null,
5299
+ defaultErrorMap: errorMap,
5300
+ setErrorMap,
5301
+ getErrorMap,
5302
+ makeIssue,
5303
+ EMPTY_PATH,
5304
+ addIssueToContext,
5305
+ ParseStatus,
5306
+ INVALID,
5307
+ DIRTY,
5308
+ OK,
5309
+ isAborted,
5310
+ isDirty,
5311
+ isValid,
5312
+ isAsync,
5313
+ get util() {
5314
+ return util;
5315
+ },
5316
+ get objectUtil() {
5317
+ return objectUtil;
5318
+ },
5319
+ ZodParsedType,
5320
+ getParsedType,
5321
+ ZodType,
5322
+ datetimeRegex,
5323
+ ZodString,
5324
+ ZodNumber,
5325
+ ZodBigInt,
5326
+ ZodBoolean,
5327
+ ZodDate,
5328
+ ZodSymbol,
5329
+ ZodUndefined,
5330
+ ZodNull,
5331
+ ZodAny,
5332
+ ZodUnknown,
5333
+ ZodNever,
5334
+ ZodVoid,
5335
+ ZodArray,
5336
+ ZodObject,
5337
+ ZodUnion,
5338
+ ZodDiscriminatedUnion,
5339
+ ZodIntersection,
5340
+ ZodTuple,
5341
+ ZodRecord,
5342
+ ZodMap,
5343
+ ZodSet,
5344
+ ZodFunction,
5345
+ ZodLazy,
5346
+ ZodLiteral,
5347
+ ZodEnum,
5348
+ ZodNativeEnum,
5349
+ ZodPromise,
5350
+ ZodEffects,
5351
+ ZodTransformer: ZodEffects,
5352
+ ZodOptional,
5353
+ ZodNullable,
5354
+ ZodDefault,
5355
+ ZodCatch,
5356
+ ZodNaN,
5357
+ BRAND,
5358
+ ZodBranded,
5359
+ ZodPipeline,
5360
+ ZodReadonly,
5361
+ custom,
5362
+ Schema: ZodType,
5363
+ ZodSchema: ZodType,
5364
+ late,
5365
+ get ZodFirstPartyTypeKind() {
5366
+ return ZodFirstPartyTypeKind;
5367
+ },
5368
+ coerce,
5369
+ any: anyType,
5370
+ array: arrayType,
5371
+ bigint: bigIntType,
5372
+ boolean: booleanType,
5373
+ date: dateType,
5374
+ discriminatedUnion: discriminatedUnionType,
5375
+ effect: effectsType,
5376
+ "enum": enumType,
5377
+ "function": functionType,
5378
+ "instanceof": instanceOfType,
5379
+ intersection: intersectionType,
5380
+ lazy: lazyType,
5381
+ literal: literalType,
5382
+ map: mapType,
5383
+ nan: nanType,
5384
+ nativeEnum: nativeEnumType,
5385
+ never: neverType,
5386
+ "null": nullType,
5387
+ nullable: nullableType,
5388
+ number: numberType,
5389
+ object: objectType,
5390
+ oboolean,
5391
+ onumber,
5392
+ optional: optionalType,
5393
+ ostring,
5394
+ pipeline: pipelineType,
5395
+ preprocess: preprocessType,
5396
+ promise: promiseType,
5397
+ record: recordType,
5398
+ set: setType,
5399
+ strictObject: strictObjectType,
5400
+ string: stringType,
5401
+ symbol: symbolType,
5402
+ transformer: effectsType,
5403
+ tuple: tupleType,
5404
+ "undefined": undefinedType,
5405
+ union: unionType,
5406
+ unknown: unknownType,
5407
+ "void": voidType,
5408
+ NEVER,
5409
+ ZodIssueCode,
5410
+ quotelessJson,
5411
+ ZodError
5412
+ });
5413
+
5414
+ // libs/embed-libs/shared-embed/src/lib/models/viz-item.model.ts
5415
+ var slotsNameParser = z.enum([
5416
+ "y-axis",
5417
+ "measure",
5418
+ "legend",
5419
+ "x-axis",
5420
+ "evolution",
5421
+ "row",
5422
+ "column",
5423
+ "columns",
5424
+ "category",
5425
+ "target",
5426
+ "color",
5427
+ "geo",
5428
+ "route",
5429
+ "order",
5430
+ "source",
5431
+ "destination",
5432
+ "size",
5433
+ "name",
5434
+ "levels",
5435
+ "open",
5436
+ "high",
5437
+ "low",
5438
+ "close",
5439
+ "coordinates",
5440
+ "identifier"
5441
+ ]);
5442
+ var slotParser = z.object({
5443
+ name: slotsNameParser,
5444
+ content: z.array(
5445
+ z.object({
5446
+ type: z.enum(["numeric", "hierarchy", "datetime", "spatial"]),
5447
+ format: z.string().optional(),
5448
+ label: z.union([z.string(), z.record(z.string())]).optional(),
5449
+ column: z.string().uuid().optional(),
5450
+ set: z.string().uuid().optional(),
5451
+ aggregationFunc: z.string().optional(),
5452
+ subtype: z.string().optional(),
5453
+ level: z.number().optional(),
5454
+ lowestLevel: z.number().optional(),
5455
+ currency: z.string().optional(),
5456
+ id: z.string().optional(),
5457
+ bins: z.object({
5458
+ enabled: z.boolean(),
5459
+ // eslint-disable-next-line id-blacklist
5460
+ number: z.number()
5461
+ }).optional()
5462
+ })
5463
+ )
5464
+ });
5465
+ var itemTypeParser = z.enum([
5466
+ "bar-chart",
5467
+ "column-chart",
5468
+ "area-chart",
5469
+ "one-number",
5470
+ "pivot-table",
5471
+ "textobject",
5472
+ "regular-table",
5473
+ "donut",
5474
+ "line-chart",
5475
+ "imageobject",
5476
+ "number-conditional",
5477
+ "combination-chart",
5478
+ "spacer",
5479
+ "boxplot",
5480
+ "circle-gauge",
5481
+ "treemap",
5482
+ "choropleth",
5483
+ "symbolmap",
5484
+ "routemap",
5485
+ "markermap",
5486
+ "hexbinmap",
5487
+ "heatmap",
5488
+ "spikemap",
5489
+ "heattable",
5490
+ "bullet",
5491
+ "funnel",
5492
+ "sunburst",
5493
+ "bubble-chart",
5494
+ "sankey",
5495
+ "scatter-plot",
5496
+ "speedometer",
5497
+ "circle-pack",
5498
+ "radar-chart",
5499
+ "pyramid",
5500
+ "parallel-coord",
5501
+ "ohlc",
5502
+ "strip-plot",
5503
+ "wordcloud",
5504
+ "videoobject",
5505
+ "venn-diagram"
5506
+ ]);
5507
+ var slotsParser = z.array(slotParser);
5508
+ var vizItemOptionsParser = z.object({
5509
+ title: z.union([z.boolean(), z.record(z.string())]).optional(),
5510
+ theme: z.union([z.string(), z.record(z.any())]).optional(),
5511
+ locale: z.string().optional(),
5512
+ html: z.record(z.string()).optional(),
5513
+ slices: z.record(z.any()).optional(),
5514
+ mode: z.string().optional(),
5515
+ url: z.string().optional(),
5516
+ bars: z.record(z.any()).optional(),
5517
+ manualValues: z.record(z.any()).optional(),
5518
+ measures: z.array(z.record(z.any())).optional(),
5519
+ classification: z.string().optional(),
5520
+ numberClasses: z.number().optional(),
5521
+ tileProvider: z.record(z.any()).optional(),
5522
+ vectorTileProvider: z.record(z.any()).optional(),
5523
+ sources: z.record(z.any()).optional(),
5524
+ display: z.union([z.record(z.any()), z.object({ title: z.boolean() })]).optional()
5525
+ });
5526
+ var canFilterParser = z.union([z.array(z.string()), z.literal("all")]);
5527
+ var libraryTypeToWebComponentTypeMapping = {
5528
+ type: "type",
5529
+ theme: "theme",
5530
+ slots: "slots",
5531
+ options: "options",
5532
+ appServer: "app-server",
5533
+ apiHost: "api-host",
5534
+ authKey: "auth-key",
5535
+ authToken: "auth-token",
5536
+ contextId: "context-id",
5537
+ canFilter: "can-filter",
5538
+ filters: "filters"
5539
+ };
5540
+
1493
5541
  // libs/embed-libs/shared-embed/src/lib/constants/class-constants.ts
1494
5542
  var luzmoEmbedContainerClass = "luzmo-embed-container";
1495
5543
 
@@ -1557,6 +5605,21 @@ function __federationMethodWrapDefault(module2, need) {
1557
5605
  async function __federationMethodGetRemote(remoteName, componentName) {
1558
5606
  return __federationMethodEnsure(remoteName).then((remote) => remote.get(componentName).then((factory) => factory()));
1559
5607
  }
5608
+ async function loadLibrary(appServer, componentName = "DashboardApp") {
5609
+ if (remotesMap[appServer]) {
5610
+ return remotesMap[appServer].module;
5611
+ }
5612
+ remotesMap[appServer] = {
5613
+ url: appServer?.startsWith("http://localhost") ? `${removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`,
5614
+ format: "esm",
5615
+ from: "vite",
5616
+ module: void 0
5617
+ };
5618
+ const module2 = await __federationMethodGetRemote(appServer, `./${componentName}`);
5619
+ const wrappedModule = __federationMethodWrapDefault(module2, true);
5620
+ remotesMap[appServer].module = wrappedModule;
5621
+ return wrappedModule;
5622
+ }
1560
5623
 
1561
5624
  // node_modules/lit-html/lit-html.js
1562
5625
  var t3 = globalThis;
@@ -1907,7 +5970,7 @@ var o5 = e6(class extends i4 {
1907
5970
  });
1908
5971
 
1909
5972
  // libs/embed-libs/embed/package.json
1910
- var version = "5.1.2";
5973
+ var version = "5.1.3-beta.1";
1911
5974
 
1912
5975
  // libs/embed-libs/embed/src/lib/luzmo-service.ts
1913
5976
  var LuzmoService = class {
@@ -2111,10 +6174,6 @@ var dashboardStyles = i`
2111
6174
  border: 0;
2112
6175
  }
2113
6176
 
2114
- .luzmo-embed-dashboard-ede {
2115
- min-height: 100vh;
2116
- }
2117
-
2118
6177
  .luzmo-embed-container-ede {
2119
6178
  width: 100%;
2120
6179
  height: 100%;
@@ -2191,7 +6250,7 @@ var dashboardStyles = i`
2191
6250
 
2192
6251
  // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-base.ts
2193
6252
  var LuzmoDashboard = class extends s3 {
2194
- constructor(inputParameters) {
6253
+ constructor() {
2195
6254
  super();
2196
6255
  this.language = "auto";
2197
6256
  this.screenMode = "auto";
@@ -2210,10 +6269,11 @@ var LuzmoDashboard = class extends s3 {
2210
6269
  this.browserErrorMsg = "";
2211
6270
  this.dashboardError = false;
2212
6271
  this.browserNotSupported = [];
2213
- this.VERSION = version + "-wc-luzmo";
6272
+ this.libVersion = version + "-wc-luzmo";
2214
6273
  this.isLibraryLoaded = false;
2215
6274
  this.currentAuthKey = null;
2216
6275
  this.currentAuthToken = null;
6276
+ this.isInitCalled = false;
2217
6277
  this.attributesMap = {
2218
6278
  dashboardId: "dashboard-id",
2219
6279
  dashboardSlug: "dashboard-slug",
@@ -2243,7 +6303,6 @@ var LuzmoDashboard = class extends s3 {
2243
6303
  this._iframeId = `luzmo-dashboard-${this._containerId}`;
2244
6304
  this.iframeLoaded = false;
2245
6305
  this.promises = {};
2246
- this.setInputParameters(inputParameters);
2247
6306
  this.params = this._setOptions();
2248
6307
  this._onResize = () => {
2249
6308
  if (this.shadowRoot?.querySelector(".dashboard-container")) {
@@ -2274,60 +6333,6 @@ var LuzmoDashboard = class extends s3 {
2274
6333
  });
2275
6334
  });
2276
6335
  }
2277
- loadLibrary(appServer) {
2278
- if (remotesMap[appServer]) {
2279
- return Promise.resolve(remotesMap[appServer].module);
2280
- }
2281
- remotesMap[appServer] = {
2282
- url: appServer?.startsWith("http://localhost") ? `${removeTrailingSlash(appServer)}/remoteEntry.mjs` : `${removeTrailingSlash(appServer)}/dashboard-app/remoteEntry.mjs`,
2283
- format: "esm",
2284
- from: "vite",
2285
- module: void 0
2286
- };
2287
- return __federationMethodGetRemote(appServer, "./DashboardApp").then((module2) => {
2288
- const wrappedModule = __federationMethodWrapDefault(module2, true);
2289
- remotesMap[appServer].module = wrappedModule;
2290
- return wrappedModule;
2291
- });
2292
- }
2293
- setInputParameters(inputParameters) {
2294
- if (!inputParameters) {
2295
- return;
2296
- }
2297
- const params = [
2298
- "dashboardId",
2299
- "dashboardSlug",
2300
- "itemId",
2301
- "language",
2302
- "qeVersion",
2303
- "screenMode",
2304
- "switchScreenModeOnResize",
2305
- "accentColor",
2306
- "mainColor",
2307
- "authToken",
2308
- "authKey",
2309
- "editMode",
2310
- "loaderBackground",
2311
- "loaderFontColor",
2312
- "loaderSpinnerColor",
2313
- "loaderSpinnerBackground",
2314
- "timezoneId",
2315
- "itemDimensions",
2316
- "apiHost"
2317
- ];
2318
- for (const key of params) {
2319
- const value = inputParameters[key];
2320
- if (value) {
2321
- this[key] = value;
2322
- }
2323
- }
2324
- if (inputParameters.experimental) {
2325
- this.experimental = inputParameters.experimental;
2326
- }
2327
- if (inputParameters.appServer) {
2328
- this.appServer = addTrailingSlash(inputParameters.appServer);
2329
- }
2330
- }
2331
6336
  // Set resize event listener
2332
6337
  connectedCallback() {
2333
6338
  super.connectedCallback();
@@ -2346,7 +6351,6 @@ var LuzmoDashboard = class extends s3 {
2346
6351
  this._loaderMsg = getLoader(this)?.loadingMsg;
2347
6352
  this._loaderStyles();
2348
6353
  luzmo_service_default._components.push(this);
2349
- this.initComponent();
2350
6354
  if (this.luzmoEmbedContainer) {
2351
6355
  this._resizeObserver.observe(this.luzmoEmbedContainer);
2352
6356
  }
@@ -2354,7 +6358,7 @@ var LuzmoDashboard = class extends s3 {
2354
6358
  initComponent() {
2355
6359
  this.params = this._setOptions();
2356
6360
  if (this.getIsViewMode()) {
2357
- this.loadLibrary(this.params.appServer).then(async () => {
6361
+ loadLibrary(this.params.appServer).then(async () => {
2358
6362
  this.isLibraryLoaded = true;
2359
6363
  await this.updateComplete;
2360
6364
  const oldReference = this.renderRoot.querySelector("dashboard-component");
@@ -2426,11 +6430,21 @@ var LuzmoDashboard = class extends s3 {
2426
6430
  "timezoneId",
2427
6431
  "itemDimensions"
2428
6432
  ]);
6433
+ const conditionsToCheck = ["dashboardId", "dashboardSlug", "itemId"];
6434
+ let callInitComponent = false;
6435
+ for (const condition of conditionsToCheck) {
6436
+ callInitComponent = callInitComponent || changedProperties.get(condition) === void 0 && this[condition];
6437
+ }
6438
+ if (callInitComponent && !this.isInitCalled) {
6439
+ this.initComponent();
6440
+ this.isInitCalled = true;
6441
+ return;
6442
+ }
2429
6443
  if (this.getIsViewMode()) {
2430
6444
  if (this.dashboardReference) {
2431
6445
  for (const [propertyName] of changedProperties.entries()) {
2432
6446
  if (propertyName === "appSever") {
2433
- this.loadLibrary(changedProperties[propertyName]).then(async () => {
6447
+ loadLibrary(changedProperties[propertyName]).then(async () => {
2434
6448
  this.isLibraryLoaded = true;
2435
6449
  await this.updateComplete;
2436
6450
  this.dashboardReference = this.renderRoot.querySelector("dashboard-component");
@@ -2638,7 +6652,7 @@ var LuzmoDashboard = class extends s3 {
2638
6652
  ${this.dashboardId || this.dashboardSlug ? x`
2639
6653
  ${loader}
2640
6654
  <iframe
2641
- class="luzmo-embed-dashboard ${!this.getIsViewMode() ? `luzmo-embed-dashboard-ede` : ""}"
6655
+ class="luzmo-embed-dashboard"
2642
6656
  id="${this._iframeId}"
2643
6657
  name="${this._iframeId}"
2644
6658
  style=${o5(this.iframeStyle)}
@@ -2929,7 +6943,7 @@ __decorateClass([
2929
6943
  ], LuzmoDashboard.prototype, "browserNotSupported", 2);
2930
6944
  __decorateClass([
2931
6945
  n3()
2932
- ], LuzmoDashboard.prototype, "VERSION", 2);
6946
+ ], LuzmoDashboard.prototype, "libVersion", 2);
2933
6947
  __decorateClass([
2934
6948
  r4()
2935
6949
  ], LuzmoDashboard.prototype, "isLibraryLoaded", 2);
@@ -2942,6 +6956,9 @@ __decorateClass([
2942
6956
  __decorateClass([
2943
6957
  r4()
2944
6958
  ], LuzmoDashboard.prototype, "currentAuthToken", 2);
6959
+ __decorateClass([
6960
+ r4()
6961
+ ], LuzmoDashboard.prototype, "isInitCalled", 2);
2945
6962
 
2946
6963
  // libs/embed-libs/embed/src/lib/dashboard-component/dashboard-component.ts
2947
6964
  var LuzmoDashboard2 = class extends LuzmoDashboard {
@@ -2954,6 +6971,303 @@ var LuzmoEmbedDashboard = class extends LuzmoDashboard {
2954
6971
  LuzmoEmbedDashboard = __decorateClass([
2955
6972
  t("luzmo-embed-dashboard")
2956
6973
  ], LuzmoEmbedDashboard);
6974
+
6975
+ // node_modules/zod-validation-error/dist/index.mjs
6976
+ var ValidationError = class extends Error {
6977
+ name;
6978
+ details;
6979
+ constructor(message, options) {
6980
+ super(message, options);
6981
+ this.name = "ZodValidationError";
6982
+ this.details = getIssuesFromErrorOptions(options);
6983
+ }
6984
+ toString() {
6985
+ return this.message;
6986
+ }
6987
+ };
6988
+ function getIssuesFromErrorOptions(options) {
6989
+ if (options) {
6990
+ const cause = options.cause;
6991
+ if (cause instanceof ZodError) {
6992
+ return cause.issues;
6993
+ }
6994
+ }
6995
+ return [];
6996
+ }
6997
+ var ISSUE_SEPARATOR = "; ";
6998
+ var MAX_ISSUES_IN_MESSAGE = 99;
6999
+ var PREFIX = "Validation error";
7000
+ var PREFIX_SEPARATOR = ": ";
7001
+ var UNION_SEPARATOR = ", or ";
7002
+ function prefixMessage(message, prefix, prefixSeparator) {
7003
+ if (prefix !== null) {
7004
+ if (message.length > 0) {
7005
+ return [prefix, message].join(prefixSeparator);
7006
+ }
7007
+ return prefix;
7008
+ }
7009
+ if (message.length > 0) {
7010
+ return message;
7011
+ }
7012
+ return PREFIX;
7013
+ }
7014
+ var identifierRegex = /[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*/u;
7015
+ function joinPath(path) {
7016
+ if (path.length === 1) {
7017
+ return path[0].toString();
7018
+ }
7019
+ return path.reduce((acc, item) => {
7020
+ if (typeof item === "number") {
7021
+ return acc + "[" + item.toString() + "]";
7022
+ }
7023
+ if (item.includes('"')) {
7024
+ return acc + '["' + escapeQuotes(item) + '"]';
7025
+ }
7026
+ if (!identifierRegex.test(item)) {
7027
+ return acc + '["' + item + '"]';
7028
+ }
7029
+ const separator = acc.length === 0 ? "" : ".";
7030
+ return acc + separator + item;
7031
+ }, "");
7032
+ }
7033
+ function escapeQuotes(str) {
7034
+ return str.replace(/"/g, '\\"');
7035
+ }
7036
+ function isNonEmptyArray(value) {
7037
+ return value.length !== 0;
7038
+ }
7039
+ function getMessageFromZodIssue(props) {
7040
+ const { issue, issueSeparator, unionSeparator, includePath } = props;
7041
+ if (issue.code === "invalid_union") {
7042
+ return issue.unionErrors.reduce((acc, zodError) => {
7043
+ const newIssues = zodError.issues.map(
7044
+ (issue2) => getMessageFromZodIssue({
7045
+ issue: issue2,
7046
+ issueSeparator,
7047
+ unionSeparator,
7048
+ includePath
7049
+ })
7050
+ ).join(issueSeparator);
7051
+ if (!acc.includes(newIssues)) {
7052
+ acc.push(newIssues);
7053
+ }
7054
+ return acc;
7055
+ }, []).join(unionSeparator);
7056
+ }
7057
+ if (issue.code === "invalid_arguments") {
7058
+ return [
7059
+ issue.message,
7060
+ ...issue.argumentsError.issues.map(
7061
+ (issue2) => getMessageFromZodIssue({
7062
+ issue: issue2,
7063
+ issueSeparator,
7064
+ unionSeparator,
7065
+ includePath
7066
+ })
7067
+ )
7068
+ ].join(issueSeparator);
7069
+ }
7070
+ if (issue.code === "invalid_return_type") {
7071
+ return [
7072
+ issue.message,
7073
+ ...issue.returnTypeError.issues.map(
7074
+ (issue2) => getMessageFromZodIssue({
7075
+ issue: issue2,
7076
+ issueSeparator,
7077
+ unionSeparator,
7078
+ includePath
7079
+ })
7080
+ )
7081
+ ].join(issueSeparator);
7082
+ }
7083
+ if (includePath && isNonEmptyArray(issue.path)) {
7084
+ if (issue.path.length === 1) {
7085
+ const identifier = issue.path[0];
7086
+ if (typeof identifier === "number") {
7087
+ return `${issue.message} at index ${identifier}`;
7088
+ }
7089
+ }
7090
+ return `${issue.message} at "${joinPath(issue.path)}"`;
7091
+ }
7092
+ return issue.message;
7093
+ }
7094
+ function fromZodError(zodError, options = {}) {
7095
+ if (!(zodError instanceof ZodError)) {
7096
+ throw new TypeError(
7097
+ `Invalid zodError param; expected instance of ZodError. Did you mean to use the "${fromError.name}" method instead?`
7098
+ );
7099
+ }
7100
+ const {
7101
+ maxIssuesInMessage = MAX_ISSUES_IN_MESSAGE,
7102
+ issueSeparator = ISSUE_SEPARATOR,
7103
+ unionSeparator = UNION_SEPARATOR,
7104
+ prefixSeparator = PREFIX_SEPARATOR,
7105
+ prefix = PREFIX,
7106
+ includePath = true
7107
+ } = options;
7108
+ const zodIssues = zodError.errors;
7109
+ const reason = zodIssues.length === 0 ? zodError.message : zodIssues.slice(0, maxIssuesInMessage).map(
7110
+ (issue) => getMessageFromZodIssue({
7111
+ issue,
7112
+ issueSeparator,
7113
+ unionSeparator,
7114
+ includePath
7115
+ })
7116
+ ).join(issueSeparator);
7117
+ const message = prefixMessage(reason, prefix, prefixSeparator);
7118
+ return new ValidationError(message, { cause: zodError });
7119
+ }
7120
+ var toValidationError = (options = {}) => (err) => {
7121
+ if (err instanceof ZodError) {
7122
+ return fromZodError(err, options);
7123
+ }
7124
+ if (err instanceof Error) {
7125
+ return new ValidationError(err.message, { cause: err });
7126
+ }
7127
+ return new ValidationError("Unknown error");
7128
+ };
7129
+ function fromError(err, options = {}) {
7130
+ return toValidationError(options)(err);
7131
+ }
7132
+
7133
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
7134
+ var LuzmoBaseVizItem = class extends s3 {
7135
+ constructor() {
7136
+ super();
7137
+ this.appServer = "https://app.luzmo.com";
7138
+ this.apiHost = "https://api.luzmo.com";
7139
+ this.slots = [];
7140
+ this.options = {
7141
+ title: {
7142
+ en: ""
7143
+ },
7144
+ theme: "default"
7145
+ };
7146
+ this.version = version + "-wc-luzmo";
7147
+ }
7148
+ static {
7149
+ // Static styles to set host display to block, else it is not shown at all for some reason.
7150
+ this.styles = i`
7151
+ :host {
7152
+ display: block;
7153
+ width: 100%;
7154
+ height: 100%;
7155
+ }
7156
+ `;
7157
+ }
7158
+ async firstUpdated(_changedProperties) {
7159
+ super.firstUpdated(_changedProperties);
7160
+ if (this.type) {
7161
+ await loadLibrary(this.appServer, "DashboardApp");
7162
+ this.createAndAppendElement();
7163
+ }
7164
+ }
7165
+ createAndAppendElement() {
7166
+ if (!this.chartElement) {
7167
+ this.chartElement = document.createElement("chart-component");
7168
+ this.chartElement.setAttribute("embedding-mode", "chart");
7169
+ this.updateVizItemProperties();
7170
+ this.renderRoot.append(this.chartElement);
7171
+ }
7172
+ }
7173
+ updateVizItemProperties() {
7174
+ if (this.chartElement) {
7175
+ for (const key in libraryTypeToWebComponentTypeMapping) {
7176
+ const value = this[key];
7177
+ if (value) {
7178
+ this.parseAndValidate(key);
7179
+ const attributeValue = ["appServer", "apiHost"].includes(key) ? removeTrailingSlash(value) : value;
7180
+ this.chartElement.setAttribute(
7181
+ libraryTypeToWebComponentTypeMapping[key],
7182
+ typeof attributeValue === "object" ? JSON.stringify(attributeValue) : attributeValue
7183
+ );
7184
+ }
7185
+ }
7186
+ }
7187
+ }
7188
+ async updated(changedProperties) {
7189
+ if (this.chartElement) {
7190
+ for (const [propertyName] of changedProperties.entries()) {
7191
+ const mappedAttributeName = libraryTypeToWebComponentTypeMapping[propertyName] ?? propertyName;
7192
+ this.parseAndValidate(propertyName);
7193
+ const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
7194
+ this.chartElement.setAttribute(mappedAttributeName, attributeValue);
7195
+ }
7196
+ } else {
7197
+ if (this.type) {
7198
+ itemTypeParser.parse(this.type);
7199
+ await loadLibrary(this.appServer, "DashboardApp");
7200
+ this.createAndAppendElement();
7201
+ }
7202
+ }
7203
+ }
7204
+ parseAndValidate(key) {
7205
+ try {
7206
+ if (key === "slots") {
7207
+ slotsParser.parse(this.slots);
7208
+ } else if (key === "options") {
7209
+ vizItemOptionsParser.parse(this.options);
7210
+ } else if (key === "canFilter") {
7211
+ canFilterParser.parse(this.canFilter);
7212
+ }
7213
+ } catch (err) {
7214
+ const validationError = fromError(err);
7215
+ console.error(err);
7216
+ console.error(validationError.toString());
7217
+ }
7218
+ }
7219
+ render() {
7220
+ return x` `;
7221
+ }
7222
+ };
7223
+ __decorateClass([
7224
+ n3()
7225
+ ], LuzmoBaseVizItem.prototype, "appServer", 2);
7226
+ __decorateClass([
7227
+ n3()
7228
+ ], LuzmoBaseVizItem.prototype, "apiHost", 2);
7229
+ __decorateClass([
7230
+ n3({ type: Array })
7231
+ ], LuzmoBaseVizItem.prototype, "slots", 2);
7232
+ __decorateClass([
7233
+ n3({ type: Object })
7234
+ ], LuzmoBaseVizItem.prototype, "options", 2);
7235
+ __decorateClass([
7236
+ n3()
7237
+ ], LuzmoBaseVizItem.prototype, "type", 2);
7238
+ __decorateClass([
7239
+ n3()
7240
+ ], LuzmoBaseVizItem.prototype, "authKey", 2);
7241
+ __decorateClass([
7242
+ n3()
7243
+ ], LuzmoBaseVizItem.prototype, "authToken", 2);
7244
+ __decorateClass([
7245
+ n3()
7246
+ ], LuzmoBaseVizItem.prototype, "version", 2);
7247
+ __decorateClass([
7248
+ n3()
7249
+ ], LuzmoBaseVizItem.prototype, "contextId", 2);
7250
+ __decorateClass([
7251
+ n3({
7252
+ converter: (value) => {
7253
+ try {
7254
+ return JSON.parse(value);
7255
+ } catch (exc) {
7256
+ return value;
7257
+ }
7258
+ }
7259
+ })
7260
+ ], LuzmoBaseVizItem.prototype, "canFilter", 2);
7261
+ __decorateClass([
7262
+ n3({ type: Array })
7263
+ ], LuzmoBaseVizItem.prototype, "filters", 2);
7264
+
7265
+ // libs/embed-libs/embed/src/lib/viz-item/viz-item-component.ts
7266
+ var LuzmoVizItem = class extends LuzmoBaseVizItem {
7267
+ };
7268
+ LuzmoVizItem = __decorateClass([
7269
+ t("luzmo-viz-item")
7270
+ ], LuzmoVizItem);
2957
7271
  /*! Bundled license information:
2958
7272
 
2959
7273
  @lit/reactive-element/decorators/custom-element.js: