@jsdev_ninja/core 0.14.0 → 0.14.2

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.
package/dist/core.es.js CHANGED
@@ -45,7 +45,7 @@ var je;
45
45
  // second overwrites first
46
46
  });
47
47
  })(je || (je = {}));
48
- const f = x.arrayToEnum([
48
+ const p = x.arrayToEnum([
49
49
  "string",
50
50
  "nan",
51
51
  "number",
@@ -69,23 +69,23 @@ const f = x.arrayToEnum([
69
69
  ]), R = (n) => {
70
70
  switch (typeof n) {
71
71
  case "undefined":
72
- return f.undefined;
72
+ return p.undefined;
73
73
  case "string":
74
- return f.string;
74
+ return p.string;
75
75
  case "number":
76
- return isNaN(n) ? f.nan : f.number;
76
+ return isNaN(n) ? p.nan : p.number;
77
77
  case "boolean":
78
- return f.boolean;
78
+ return p.boolean;
79
79
  case "function":
80
- return f.function;
80
+ return p.function;
81
81
  case "bigint":
82
- return f.bigint;
82
+ return p.bigint;
83
83
  case "symbol":
84
- return f.symbol;
84
+ return p.symbol;
85
85
  case "object":
86
- return Array.isArray(n) ? f.array : n === null ? f.null : n.then && typeof n.then == "function" && n.catch && typeof n.catch == "function" ? f.promise : typeof Map < "u" && n instanceof Map ? f.map : typeof Set < "u" && n instanceof Set ? f.set : typeof Date < "u" && n instanceof Date ? f.date : f.object;
86
+ return Array.isArray(n) ? p.array : n === null ? p.null : n.then && typeof n.then == "function" && n.catch && typeof n.catch == "function" ? p.promise : typeof Map < "u" && n instanceof Map ? p.map : typeof Set < "u" && n instanceof Set ? p.set : typeof Date < "u" && n instanceof Date ? p.date : p.object;
87
87
  default:
88
- return f.unknown;
88
+ return p.unknown;
89
89
  }
90
90
  }, d = x.arrayToEnum([
91
91
  "invalid_type",
@@ -169,7 +169,7 @@ const G = (n, e) => {
169
169
  let t;
170
170
  switch (n.code) {
171
171
  case d.invalid_type:
172
- n.received === f.undefined ? t = "Required" : t = `Expected ${n.expected}, received ${n.received}`;
172
+ n.received === p.undefined ? t = "Required" : t = `Expected ${n.expected}, received ${n.received}`;
173
173
  break;
174
174
  case d.invalid_literal:
175
175
  t = `Invalid literal value, expected ${JSON.stringify(n.expected, x.jsonStringifyReplacer)}`;
@@ -248,7 +248,7 @@ const _e = (n) => {
248
248
  path: i,
249
249
  message: c
250
250
  };
251
- }, ft = [];
251
+ }, pt = [];
252
252
  function m(n, e) {
253
253
  const t = ve(), r = _e({
254
254
  issueData: e,
@@ -355,8 +355,8 @@ function v(n) {
355
355
  throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
356
356
  return e ? { errorMap: e, description: s } : { errorMap: (o, c) => {
357
357
  var l, u;
358
- const { message: p } = n;
359
- return o.code === "invalid_enum_value" ? { message: p ?? c.defaultError } : typeof c.data > "u" ? { message: (l = p ?? r) !== null && l !== void 0 ? l : c.defaultError } : o.code !== "invalid_type" ? { message: c.defaultError } : { message: (u = p ?? t) !== null && u !== void 0 ? u : c.defaultError };
358
+ const { message: f } = n;
359
+ return o.code === "invalid_enum_value" ? { message: f ?? c.defaultError } : typeof c.data > "u" ? { message: (l = f ?? r) !== null && l !== void 0 ? l : c.defaultError } : o.code !== "invalid_type" ? { message: c.defaultError } : { message: (u = f ?? t) !== null && u !== void 0 ? u : c.defaultError };
360
360
  }, description: s };
361
361
  }
362
362
  class _ {
@@ -536,7 +536,7 @@ class _ {
536
536
  }
537
537
  default(e) {
538
538
  const t = typeof e == "function" ? e : () => e;
539
- return new pe({
539
+ return new fe({
540
540
  ...v(this._def),
541
541
  innerType: this,
542
542
  defaultValue: t,
@@ -579,7 +579,7 @@ class _ {
579
579
  return this.safeParse(null).success;
580
580
  }
581
581
  }
582
- const pt = /^c[^\s-]{8,}$/i, ht = /^[0-9a-z]+$/, gt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, yt = /^[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, vt = /^[a-z0-9_-]{21}$/i, _t = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, bt = /^[-+]?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)?)??$/, xt = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, kt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
582
+ const ft = /^c[^\s-]{8,}$/i, ht = /^[0-9a-z]+$/, gt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, yt = /^[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, vt = /^[a-z0-9_-]{21}$/i, _t = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, bt = /^[-+]?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)?)??$/, xt = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, kt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
583
583
  let Ze;
584
584
  const wt = /^(?:(?: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])$/, Tt = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, St = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, It = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Nt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, At = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Be = "((\\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])))", Ct = new RegExp(`^${Be}$`);
585
585
  function We(n) {
@@ -612,11 +612,11 @@ function Dt(n, e) {
612
612
  }
613
613
  class A extends _ {
614
614
  _parse(e) {
615
- if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== f.string) {
615
+ if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== p.string) {
616
616
  const i = this._getOrReturnCtx(e);
617
617
  return m(i, {
618
618
  code: d.invalid_type,
619
- expected: f.string,
619
+ expected: p.string,
620
620
  received: i.parsedType
621
621
  }), y;
622
622
  }
@@ -683,7 +683,7 @@ class A extends _ {
683
683
  message: i.message
684
684
  }), r.dirty());
685
685
  else if (i.kind === "cuid")
686
- pt.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
686
+ ft.test(e.data) || (s = this._getOrReturnCtx(e, s), m(s, {
687
687
  validation: "cuid",
688
688
  code: d.invalid_string,
689
689
  message: i.message
@@ -1006,11 +1006,11 @@ class V extends _ {
1006
1006
  super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
1007
1007
  }
1008
1008
  _parse(e) {
1009
- if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== f.number) {
1009
+ if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== p.number) {
1010
1010
  const i = this._getOrReturnCtx(e);
1011
1011
  return m(i, {
1012
1012
  code: d.invalid_type,
1013
- expected: f.number,
1013
+ expected: p.number,
1014
1014
  received: i.parsedType
1015
1015
  }), y;
1016
1016
  }
@@ -1184,7 +1184,7 @@ class z extends _ {
1184
1184
  } catch {
1185
1185
  return this._getInvalidInput(e);
1186
1186
  }
1187
- if (this._getType(e) !== f.bigint)
1187
+ if (this._getType(e) !== p.bigint)
1188
1188
  return this._getInvalidInput(e);
1189
1189
  let r;
1190
1190
  const s = new T();
@@ -1212,7 +1212,7 @@ class z extends _ {
1212
1212
  const t = this._getOrReturnCtx(e);
1213
1213
  return m(t, {
1214
1214
  code: d.invalid_type,
1215
- expected: f.bigint,
1215
+ expected: p.bigint,
1216
1216
  received: t.parsedType
1217
1217
  }), y;
1218
1218
  }
@@ -1311,11 +1311,11 @@ z.create = (n) => {
1311
1311
  };
1312
1312
  class ae extends _ {
1313
1313
  _parse(e) {
1314
- if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== f.boolean) {
1314
+ if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== p.boolean) {
1315
1315
  const r = this._getOrReturnCtx(e);
1316
1316
  return m(r, {
1317
1317
  code: d.invalid_type,
1318
- expected: f.boolean,
1318
+ expected: p.boolean,
1319
1319
  received: r.parsedType
1320
1320
  }), y;
1321
1321
  }
@@ -1329,11 +1329,11 @@ ae.create = (n) => new ae({
1329
1329
  });
1330
1330
  class B extends _ {
1331
1331
  _parse(e) {
1332
- if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== f.date) {
1332
+ if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== p.date) {
1333
1333
  const i = this._getOrReturnCtx(e);
1334
1334
  return m(i, {
1335
1335
  code: d.invalid_type,
1336
- expected: f.date,
1336
+ expected: p.date,
1337
1337
  received: i.parsedType
1338
1338
  }), y;
1339
1339
  }
@@ -1407,11 +1407,11 @@ B.create = (n) => new B({
1407
1407
  });
1408
1408
  class xe extends _ {
1409
1409
  _parse(e) {
1410
- if (this._getType(e) !== f.symbol) {
1410
+ if (this._getType(e) !== p.symbol) {
1411
1411
  const r = this._getOrReturnCtx(e);
1412
1412
  return m(r, {
1413
1413
  code: d.invalid_type,
1414
- expected: f.symbol,
1414
+ expected: p.symbol,
1415
1415
  received: r.parsedType
1416
1416
  }), y;
1417
1417
  }
@@ -1424,11 +1424,11 @@ xe.create = (n) => new xe({
1424
1424
  });
1425
1425
  class ie extends _ {
1426
1426
  _parse(e) {
1427
- if (this._getType(e) !== f.undefined) {
1427
+ if (this._getType(e) !== p.undefined) {
1428
1428
  const r = this._getOrReturnCtx(e);
1429
1429
  return m(r, {
1430
1430
  code: d.invalid_type,
1431
- expected: f.undefined,
1431
+ expected: p.undefined,
1432
1432
  received: r.parsedType
1433
1433
  }), y;
1434
1434
  }
@@ -1441,11 +1441,11 @@ ie.create = (n) => new ie({
1441
1441
  });
1442
1442
  class oe extends _ {
1443
1443
  _parse(e) {
1444
- if (this._getType(e) !== f.null) {
1444
+ if (this._getType(e) !== p.null) {
1445
1445
  const r = this._getOrReturnCtx(e);
1446
1446
  return m(r, {
1447
1447
  code: d.invalid_type,
1448
- expected: f.null,
1448
+ expected: p.null,
1449
1449
  received: r.parsedType
1450
1450
  }), y;
1451
1451
  }
@@ -1485,7 +1485,7 @@ class $ extends _ {
1485
1485
  const t = this._getOrReturnCtx(e);
1486
1486
  return m(t, {
1487
1487
  code: d.invalid_type,
1488
- expected: f.never,
1488
+ expected: p.never,
1489
1489
  received: t.parsedType
1490
1490
  }), y;
1491
1491
  }
@@ -1496,11 +1496,11 @@ $.create = (n) => new $({
1496
1496
  });
1497
1497
  class ke extends _ {
1498
1498
  _parse(e) {
1499
- if (this._getType(e) !== f.undefined) {
1499
+ if (this._getType(e) !== p.undefined) {
1500
1500
  const r = this._getOrReturnCtx(e);
1501
1501
  return m(r, {
1502
1502
  code: d.invalid_type,
1503
- expected: f.void,
1503
+ expected: p.void,
1504
1504
  received: r.parsedType
1505
1505
  }), y;
1506
1506
  }
@@ -1514,10 +1514,10 @@ ke.create = (n) => new ke({
1514
1514
  class C extends _ {
1515
1515
  _parse(e) {
1516
1516
  const { ctx: t, status: r } = this._processInputParams(e), s = this._def;
1517
- if (t.parsedType !== f.array)
1517
+ if (t.parsedType !== p.array)
1518
1518
  return m(t, {
1519
1519
  code: d.invalid_type,
1520
- expected: f.array,
1520
+ expected: p.array,
1521
1521
  received: t.parsedType
1522
1522
  }), y;
1523
1523
  if (s.exactLength !== null) {
@@ -1611,11 +1611,11 @@ class k extends _ {
1611
1611
  return this._cached = { shape: e, keys: t };
1612
1612
  }
1613
1613
  _parse(e) {
1614
- if (this._getType(e) !== f.object) {
1614
+ if (this._getType(e) !== p.object) {
1615
1615
  const u = this._getOrReturnCtx(e);
1616
1616
  return m(u, {
1617
1617
  code: d.invalid_type,
1618
- expected: f.object,
1618
+ expected: p.object,
1619
1619
  received: u.parsedType
1620
1620
  }), y;
1621
1621
  }
@@ -1625,20 +1625,20 @@ class k extends _ {
1625
1625
  o.includes(u) || c.push(u);
1626
1626
  const l = [];
1627
1627
  for (const u of o) {
1628
- const p = i[u], b = s.data[u];
1628
+ const f = i[u], b = s.data[u];
1629
1629
  l.push({
1630
1630
  key: { status: "valid", value: u },
1631
- value: p._parse(new D(s, b, s.path, u)),
1631
+ value: f._parse(new D(s, b, s.path, u)),
1632
1632
  alwaysSet: u in s.data
1633
1633
  });
1634
1634
  }
1635
1635
  if (this._def.catchall instanceof $) {
1636
1636
  const u = this._def.unknownKeys;
1637
1637
  if (u === "passthrough")
1638
- for (const p of c)
1638
+ for (const f of c)
1639
1639
  l.push({
1640
- key: { status: "valid", value: p },
1641
- value: { status: "valid", value: s.data[p] }
1640
+ key: { status: "valid", value: f },
1641
+ value: { status: "valid", value: s.data[f] }
1642
1642
  });
1643
1643
  else if (u === "strict")
1644
1644
  c.length > 0 && (m(s, {
@@ -1648,26 +1648,26 @@ class k extends _ {
1648
1648
  else if (u !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
1649
1649
  } else {
1650
1650
  const u = this._def.catchall;
1651
- for (const p of c) {
1652
- const b = s.data[p];
1651
+ for (const f of c) {
1652
+ const b = s.data[f];
1653
1653
  l.push({
1654
- key: { status: "valid", value: p },
1654
+ key: { status: "valid", value: f },
1655
1655
  value: u._parse(
1656
- new D(s, b, s.path, p)
1656
+ new D(s, b, s.path, f)
1657
1657
  //, ctx.child(key), value, getParsedType(value)
1658
1658
  ),
1659
- alwaysSet: p in s.data
1659
+ alwaysSet: f in s.data
1660
1660
  });
1661
1661
  }
1662
1662
  }
1663
1663
  return s.common.async ? Promise.resolve().then(async () => {
1664
1664
  const u = [];
1665
- for (const p of l) {
1666
- const b = await p.key, w = await p.value;
1665
+ for (const f of l) {
1666
+ const b = await f.key, w = await f.value;
1667
1667
  u.push({
1668
1668
  key: b,
1669
1669
  value: w,
1670
- alwaysSet: p.alwaysSet
1670
+ alwaysSet: f.alwaysSet
1671
1671
  });
1672
1672
  }
1673
1673
  return u;
@@ -1933,14 +1933,14 @@ class ce extends _ {
1933
1933
  issues: []
1934
1934
  },
1935
1935
  parent: null
1936
- }, p = l._parseSync({
1936
+ }, f = l._parseSync({
1937
1937
  data: t.data,
1938
1938
  path: t.path,
1939
1939
  parent: u
1940
1940
  });
1941
- if (p.status === "valid")
1942
- return p;
1943
- p.status === "dirty" && !i && (i = { result: p, ctx: u }), u.common.issues.length && o.push(u.common.issues);
1941
+ if (f.status === "valid")
1942
+ return f;
1943
+ f.status === "dirty" && !i && (i = { result: f, ctx: u }), u.common.issues.length && o.push(u.common.issues);
1944
1944
  }
1945
1945
  if (i)
1946
1946
  return t.common.issues.push(...i.ctx.common.issues), i.result;
@@ -1960,14 +1960,14 @@ ce.create = (n, e) => new ce({
1960
1960
  typeName: g.ZodUnion,
1961
1961
  ...v(e)
1962
1962
  });
1963
- const E = (n) => n instanceof le ? E(n.schema) : n instanceof Z ? E(n.innerType()) : n instanceof me ? [n.value] : n instanceof F ? n.options : n instanceof fe ? x.objectValues(n.enum) : n instanceof pe ? E(n._def.innerType) : n instanceof ie ? [void 0] : n instanceof oe ? [null] : n instanceof O ? [void 0, ...E(n.unwrap())] : n instanceof U ? [null, ...E(n.unwrap())] : n instanceof Ee || n instanceof ge ? E(n.unwrap()) : n instanceof he ? E(n._def.innerType) : [];
1963
+ const E = (n) => n instanceof le ? E(n.schema) : n instanceof Z ? E(n.innerType()) : n instanceof me ? [n.value] : n instanceof F ? n.options : n instanceof pe ? x.objectValues(n.enum) : n instanceof fe ? E(n._def.innerType) : n instanceof ie ? [void 0] : n instanceof oe ? [null] : n instanceof O ? [void 0, ...E(n.unwrap())] : n instanceof U ? [null, ...E(n.unwrap())] : n instanceof Ee || n instanceof ge ? E(n.unwrap()) : n instanceof he ? E(n._def.innerType) : [];
1964
1964
  class Se extends _ {
1965
1965
  _parse(e) {
1966
1966
  const { ctx: t } = this._processInputParams(e);
1967
- if (t.parsedType !== f.object)
1967
+ if (t.parsedType !== p.object)
1968
1968
  return m(t, {
1969
1969
  code: d.invalid_type,
1970
- expected: f.object,
1970
+ expected: p.object,
1971
1971
  received: t.parsedType
1972
1972
  }), y;
1973
1973
  const r = this.discriminator, s = t.data[r], i = this.optionsMap.get(s);
@@ -2027,7 +2027,7 @@ function Pe(n, e) {
2027
2027
  const t = R(n), r = R(e);
2028
2028
  if (n === e)
2029
2029
  return { valid: !0, data: n };
2030
- if (t === f.object && r === f.object) {
2030
+ if (t === p.object && r === p.object) {
2031
2031
  const s = x.objectKeys(e), i = x.objectKeys(n).filter((c) => s.indexOf(c) !== -1), o = { ...n, ...e };
2032
2032
  for (const c of i) {
2033
2033
  const l = Pe(n[c], e[c]);
@@ -2036,7 +2036,7 @@ function Pe(n, e) {
2036
2036
  o[c] = l.data;
2037
2037
  }
2038
2038
  return { valid: !0, data: o };
2039
- } else if (t === f.array && r === f.array) {
2039
+ } else if (t === p.array && r === p.array) {
2040
2040
  if (n.length !== e.length)
2041
2041
  return { valid: !1 };
2042
2042
  const s = [];
@@ -2047,7 +2047,7 @@ function Pe(n, e) {
2047
2047
  s.push(l.data);
2048
2048
  }
2049
2049
  return { valid: !0, data: s };
2050
- } else return t === f.date && r === f.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
2050
+ } else return t === p.date && r === p.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
2051
2051
  }
2052
2052
  class ue extends _ {
2053
2053
  _parse(e) {
@@ -2090,10 +2090,10 @@ ue.create = (n, e, t) => new ue({
2090
2090
  class P extends _ {
2091
2091
  _parse(e) {
2092
2092
  const { status: t, ctx: r } = this._processInputParams(e);
2093
- if (r.parsedType !== f.array)
2093
+ if (r.parsedType !== p.array)
2094
2094
  return m(r, {
2095
2095
  code: d.invalid_type,
2096
- expected: f.array,
2096
+ expected: p.array,
2097
2097
  received: r.parsedType
2098
2098
  }), y;
2099
2099
  if (r.data.length < this._def.items.length)
@@ -2146,10 +2146,10 @@ class de extends _ {
2146
2146
  }
2147
2147
  _parse(e) {
2148
2148
  const { status: t, ctx: r } = this._processInputParams(e);
2149
- if (r.parsedType !== f.object)
2149
+ if (r.parsedType !== p.object)
2150
2150
  return m(r, {
2151
2151
  code: d.invalid_type,
2152
- expected: f.object,
2152
+ expected: p.object,
2153
2153
  received: r.parsedType
2154
2154
  }), y;
2155
2155
  const s = [], i = this._def.keyType, o = this._def.valueType;
@@ -2187,10 +2187,10 @@ class we extends _ {
2187
2187
  }
2188
2188
  _parse(e) {
2189
2189
  const { status: t, ctx: r } = this._processInputParams(e);
2190
- if (r.parsedType !== f.map)
2190
+ if (r.parsedType !== p.map)
2191
2191
  return m(r, {
2192
2192
  code: d.invalid_type,
2193
- expected: f.map,
2193
+ expected: p.map,
2194
2194
  received: r.parsedType
2195
2195
  }), y;
2196
2196
  const s = this._def.keyType, i = this._def.valueType, o = [...r.data.entries()].map(([c, l], u) => ({
@@ -2201,20 +2201,20 @@ class we extends _ {
2201
2201
  const c = /* @__PURE__ */ new Map();
2202
2202
  return Promise.resolve().then(async () => {
2203
2203
  for (const l of o) {
2204
- const u = await l.key, p = await l.value;
2205
- if (u.status === "aborted" || p.status === "aborted")
2204
+ const u = await l.key, f = await l.value;
2205
+ if (u.status === "aborted" || f.status === "aborted")
2206
2206
  return y;
2207
- (u.status === "dirty" || p.status === "dirty") && t.dirty(), c.set(u.value, p.value);
2207
+ (u.status === "dirty" || f.status === "dirty") && t.dirty(), c.set(u.value, f.value);
2208
2208
  }
2209
2209
  return { status: t.value, value: c };
2210
2210
  });
2211
2211
  } else {
2212
2212
  const c = /* @__PURE__ */ new Map();
2213
2213
  for (const l of o) {
2214
- const u = l.key, p = l.value;
2215
- if (u.status === "aborted" || p.status === "aborted")
2214
+ const u = l.key, f = l.value;
2215
+ if (u.status === "aborted" || f.status === "aborted")
2216
2216
  return y;
2217
- (u.status === "dirty" || p.status === "dirty") && t.dirty(), c.set(u.value, p.value);
2217
+ (u.status === "dirty" || f.status === "dirty") && t.dirty(), c.set(u.value, f.value);
2218
2218
  }
2219
2219
  return { status: t.value, value: c };
2220
2220
  }
@@ -2229,10 +2229,10 @@ we.create = (n, e, t) => new we({
2229
2229
  class W extends _ {
2230
2230
  _parse(e) {
2231
2231
  const { status: t, ctx: r } = this._processInputParams(e);
2232
- if (r.parsedType !== f.set)
2232
+ if (r.parsedType !== p.set)
2233
2233
  return m(r, {
2234
2234
  code: d.invalid_type,
2235
- expected: f.set,
2235
+ expected: p.set,
2236
2236
  received: r.parsedType
2237
2237
  }), y;
2238
2238
  const s = this._def;
@@ -2254,10 +2254,10 @@ class W extends _ {
2254
2254
  const i = this._def.valueType;
2255
2255
  function o(l) {
2256
2256
  const u = /* @__PURE__ */ new Set();
2257
- for (const p of l) {
2258
- if (p.status === "aborted")
2257
+ for (const f of l) {
2258
+ if (f.status === "aborted")
2259
2259
  return y;
2260
- p.status === "dirty" && t.dirty(), u.add(p.value);
2260
+ f.status === "dirty" && t.dirty(), u.add(f.value);
2261
2261
  }
2262
2262
  return { status: t.value, value: u };
2263
2263
  }
@@ -2296,10 +2296,10 @@ class X extends _ {
2296
2296
  }
2297
2297
  _parse(e) {
2298
2298
  const { ctx: t } = this._processInputParams(e);
2299
- if (t.parsedType !== f.function)
2299
+ if (t.parsedType !== p.function)
2300
2300
  return m(t, {
2301
2301
  code: d.invalid_type,
2302
- expected: f.function,
2302
+ expected: p.function,
2303
2303
  received: t.parsedType
2304
2304
  }), y;
2305
2305
  function r(c, l) {
@@ -2338,9 +2338,9 @@ class X extends _ {
2338
2338
  if (this._def.returns instanceof H) {
2339
2339
  const c = this;
2340
2340
  return S(async function(...l) {
2341
- const u = new N([]), p = await c._def.args.parseAsync(l, i).catch((I) => {
2341
+ const u = new N([]), f = await c._def.args.parseAsync(l, i).catch((I) => {
2342
2342
  throw u.addIssue(r(l, I)), u;
2343
- }), b = await Reflect.apply(o, this, p);
2343
+ }), b = await Reflect.apply(o, this, f);
2344
2344
  return await c._def.returns._def.type.parseAsync(b, i).catch((I) => {
2345
2345
  throw u.addIssue(s(b, I)), u;
2346
2346
  });
@@ -2351,9 +2351,9 @@ class X extends _ {
2351
2351
  const u = c._def.args.safeParse(l, i);
2352
2352
  if (!u.success)
2353
2353
  throw new N([r(l, u.error)]);
2354
- const p = Reflect.apply(o, this, u.data), b = c._def.returns.safeParse(p, i);
2354
+ const f = Reflect.apply(o, this, u.data), b = c._def.returns.safeParse(f, i);
2355
2355
  if (!b.success)
2356
- throw new N([s(p, b.error)]);
2356
+ throw new N([s(f, b.error)]);
2357
2357
  return b.data;
2358
2358
  });
2359
2359
  }
@@ -2492,13 +2492,13 @@ class F extends _ {
2492
2492
  }
2493
2493
  te = /* @__PURE__ */ new WeakMap();
2494
2494
  F.create = Ye;
2495
- class fe extends _ {
2495
+ class pe extends _ {
2496
2496
  constructor() {
2497
2497
  super(...arguments), ne.set(this, void 0);
2498
2498
  }
2499
2499
  _parse(e) {
2500
2500
  const t = x.getValidEnumValues(this._def.values), r = this._getOrReturnCtx(e);
2501
- if (r.parsedType !== f.string && r.parsedType !== f.number) {
2501
+ if (r.parsedType !== p.string && r.parsedType !== p.number) {
2502
2502
  const s = x.objectValues(t);
2503
2503
  return m(r, {
2504
2504
  expected: x.joinValues(s),
@@ -2521,7 +2521,7 @@ class fe extends _ {
2521
2521
  }
2522
2522
  }
2523
2523
  ne = /* @__PURE__ */ new WeakMap();
2524
- fe.create = (n, e) => new fe({
2524
+ pe.create = (n, e) => new pe({
2525
2525
  values: n,
2526
2526
  typeName: g.ZodNativeEnum,
2527
2527
  ...v(e)
@@ -2532,13 +2532,13 @@ class H extends _ {
2532
2532
  }
2533
2533
  _parse(e) {
2534
2534
  const { ctx: t } = this._processInputParams(e);
2535
- if (t.parsedType !== f.promise && t.common.async === !1)
2535
+ if (t.parsedType !== p.promise && t.common.async === !1)
2536
2536
  return m(t, {
2537
2537
  code: d.invalid_type,
2538
- expected: f.promise,
2538
+ expected: p.promise,
2539
2539
  received: t.parsedType
2540
2540
  }), y;
2541
- const r = t.parsedType === f.promise ? t.data : Promise.resolve(t.data);
2541
+ const r = t.parsedType === p.promise ? t.data : Promise.resolve(t.data);
2542
2542
  return S(r.then((s) => this._def.type.parseAsync(s, {
2543
2543
  path: t.path,
2544
2544
  errorMap: t.common.contextualErrorMap
@@ -2641,7 +2641,7 @@ Z.createWithPreprocess = (n, e, t) => new Z({
2641
2641
  });
2642
2642
  class O extends _ {
2643
2643
  _parse(e) {
2644
- return this._getType(e) === f.undefined ? S(void 0) : this._def.innerType._parse(e);
2644
+ return this._getType(e) === p.undefined ? S(void 0) : this._def.innerType._parse(e);
2645
2645
  }
2646
2646
  unwrap() {
2647
2647
  return this._def.innerType;
@@ -2654,7 +2654,7 @@ O.create = (n, e) => new O({
2654
2654
  });
2655
2655
  class U extends _ {
2656
2656
  _parse(e) {
2657
- return this._getType(e) === f.null ? S(null) : this._def.innerType._parse(e);
2657
+ return this._getType(e) === p.null ? S(null) : this._def.innerType._parse(e);
2658
2658
  }
2659
2659
  unwrap() {
2660
2660
  return this._def.innerType;
@@ -2665,11 +2665,11 @@ U.create = (n, e) => new U({
2665
2665
  typeName: g.ZodNullable,
2666
2666
  ...v(e)
2667
2667
  });
2668
- class pe extends _ {
2668
+ class fe extends _ {
2669
2669
  _parse(e) {
2670
2670
  const { ctx: t } = this._processInputParams(e);
2671
2671
  let r = t.data;
2672
- return t.parsedType === f.undefined && (r = this._def.defaultValue()), this._def.innerType._parse({
2672
+ return t.parsedType === p.undefined && (r = this._def.defaultValue()), this._def.innerType._parse({
2673
2673
  data: r,
2674
2674
  path: t.path,
2675
2675
  parent: t
@@ -2679,7 +2679,7 @@ class pe extends _ {
2679
2679
  return this._def.innerType;
2680
2680
  }
2681
2681
  }
2682
- pe.create = (n, e) => new pe({
2682
+ fe.create = (n, e) => new fe({
2683
2683
  innerType: n,
2684
2684
  typeName: g.ZodDefault,
2685
2685
  defaultValue: typeof e.default == "function" ? e.default : () => e.default,
@@ -2730,11 +2730,11 @@ he.create = (n, e) => new he({
2730
2730
  });
2731
2731
  class Te extends _ {
2732
2732
  _parse(e) {
2733
- if (this._getType(e) !== f.nan) {
2733
+ if (this._getType(e) !== p.nan) {
2734
2734
  const r = this._getOrReturnCtx(e);
2735
2735
  return m(r, {
2736
2736
  code: d.invalid_type,
2737
- expected: f.nan,
2737
+ expected: p.nan,
2738
2738
  received: r.parsedType
2739
2739
  }), y;
2740
2740
  }
@@ -2823,9 +2823,9 @@ function Xe(n, e = {}, t) {
2823
2823
  const c = n(r);
2824
2824
  if (c instanceof Promise)
2825
2825
  return c.then((l) => {
2826
- var u, p;
2826
+ var u, f;
2827
2827
  if (!l) {
2828
- const b = Ve(e, r), w = (p = (u = b.fatal) !== null && u !== void 0 ? u : t) !== null && p !== void 0 ? p : !0;
2828
+ const b = Ve(e, r), w = (f = (u = b.fatal) !== null && u !== void 0 ? u : t) !== null && f !== void 0 ? f : !0;
2829
2829
  s.addIssue({ code: "custom", ...b, fatal: w });
2830
2830
  }
2831
2831
  });
@@ -2844,7 +2844,7 @@ var g;
2844
2844
  })(g || (g = {}));
2845
2845
  const Mt = (n, e = {
2846
2846
  message: `Input not instance of ${n.name}`
2847
- }) => Xe((t) => t instanceof n, e), Ge = A.create, Je = V.create, $t = Te.create, Vt = z.create, He = ae.create, zt = B.create, Ft = xe.create, Ut = ie.create, Lt = oe.create, qt = J.create, Bt = L.create, Wt = $.create, Qt = ke.create, Yt = C.create, Xt = k.create, Gt = k.strictCreate, Jt = ce.create, Ht = Se.create, Kt = ue.create, en = P.create, tn = de.create, nn = we.create, rn = W.create, sn = X.create, an = le.create, on = me.create, cn = F.create, un = fe.create, dn = H.create, ze = Z.create, ln = O.create, mn = U.create, fn = Z.createWithPreprocess, pn = ye.create, hn = () => Ge().optional(), gn = () => Je().optional(), yn = () => He().optional(), vn = {
2847
+ }) => Xe((t) => t instanceof n, e), Ge = A.create, Je = V.create, $t = Te.create, Vt = z.create, He = ae.create, zt = B.create, Ft = xe.create, Ut = ie.create, Lt = oe.create, qt = J.create, Bt = L.create, Wt = $.create, Qt = ke.create, Yt = C.create, Xt = k.create, Gt = k.strictCreate, Jt = ce.create, Ht = Se.create, Kt = ue.create, en = P.create, tn = de.create, nn = we.create, rn = W.create, sn = X.create, an = le.create, on = me.create, cn = F.create, un = pe.create, dn = H.create, ze = Z.create, ln = O.create, mn = U.create, pn = Z.createWithPreprocess, fn = ye.create, hn = () => Ge().optional(), gn = () => Je().optional(), yn = () => He().optional(), vn = {
2848
2848
  string: (n) => A.create({ ...n, coerce: !0 }),
2849
2849
  number: (n) => V.create({ ...n, coerce: !0 }),
2850
2850
  boolean: (n) => ae.create({
@@ -2860,7 +2860,7 @@ var a = /* @__PURE__ */ Object.freeze({
2860
2860
  setErrorMap: mt,
2861
2861
  getErrorMap: ve,
2862
2862
  makeIssue: _e,
2863
- EMPTY_PATH: ft,
2863
+ EMPTY_PATH: pt,
2864
2864
  addIssueToContext: m,
2865
2865
  ParseStatus: T,
2866
2866
  INVALID: y,
@@ -2876,7 +2876,7 @@ var a = /* @__PURE__ */ Object.freeze({
2876
2876
  get objectUtil() {
2877
2877
  return je;
2878
2878
  },
2879
- ZodParsedType: f,
2879
+ ZodParsedType: p,
2880
2880
  getParsedType: R,
2881
2881
  ZodType: _,
2882
2882
  datetimeRegex: Qe,
@@ -2905,13 +2905,13 @@ var a = /* @__PURE__ */ Object.freeze({
2905
2905
  ZodLazy: le,
2906
2906
  ZodLiteral: me,
2907
2907
  ZodEnum: F,
2908
- ZodNativeEnum: fe,
2908
+ ZodNativeEnum: pe,
2909
2909
  ZodPromise: H,
2910
2910
  ZodEffects: Z,
2911
2911
  ZodTransformer: Z,
2912
2912
  ZodOptional: O,
2913
2913
  ZodNullable: U,
2914
- ZodDefault: pe,
2914
+ ZodDefault: fe,
2915
2915
  ZodCatch: he,
2916
2916
  ZodNaN: Te,
2917
2917
  BRAND: Et,
@@ -2951,8 +2951,8 @@ var a = /* @__PURE__ */ Object.freeze({
2951
2951
  onumber: gn,
2952
2952
  optional: ln,
2953
2953
  ostring: hn,
2954
- pipeline: pn,
2955
- preprocess: fn,
2954
+ pipeline: fn,
2955
+ preprocess: pn,
2956
2956
  promise: dn,
2957
2957
  record: tn,
2958
2958
  set: rn,
@@ -3041,6 +3041,10 @@ const re = a.object({
3041
3041
  created_at: a.number(),
3042
3042
  updated_at: a.number(),
3043
3043
  categoryIds: a.array(a.string().nonempty()),
3044
+ stock: a.object({
3045
+ quantity: a.number().min(0),
3046
+ unit: a.enum(["piece", "kg", "gram", "liter", "ml"])
3047
+ }).optional(),
3044
3048
  // @deprecated
3045
3049
  categoryList: a.array(Re).optional(),
3046
3050
  // @deprecated
@@ -3316,12 +3320,12 @@ class Cn {
3316
3320
  const { productsId: r, requiredQuantity: s, bundlePrice: i } = e.variant, o = t.cart.filter((K) => r.includes(K.product.id)), c = this.getTotalQuantity(t.cart, r), l = Math.floor(c / s);
3317
3321
  if (l === 0)
3318
3322
  return { applicable: !1, discountAmount: 0, affectedItems: [] };
3319
- const u = this.calculateOriginalPrice(o), p = this.getTotalQuantity(t.cart, r), b = this.calculateDiscountedPrice(
3323
+ const u = this.calculateOriginalPrice(o), f = this.getTotalQuantity(t.cart, r), b = this.calculateDiscountedPrice(
3320
3324
  u,
3321
3325
  i,
3322
3326
  l,
3323
3327
  s,
3324
- p
3328
+ f
3325
3329
  ), w = u - b, I = this.distributeDiscount(o, w, u);
3326
3330
  return {
3327
3331
  applicable: !0,
@@ -3376,7 +3380,7 @@ Me(st, "strategies", /* @__PURE__ */ new Map([
3376
3380
  ]));
3377
3381
  class Zn {
3378
3382
  static calculateDiscounts(e, t, r) {
3379
- var u, p;
3383
+ var u, f;
3380
3384
  const s = {
3381
3385
  cart: e,
3382
3386
  user: r,
@@ -3388,7 +3392,7 @@ class Zn {
3388
3392
  const I = w.calculate(b, s);
3389
3393
  I.applicable && (o.push({
3390
3394
  discountId: b.id,
3391
- discountName: ((p = b.name[0]) == null ? void 0 : p.value) || "Discount",
3395
+ discountName: ((f = b.name[0]) == null ? void 0 : f.value) || "Discount",
3392
3396
  discountAmount: Number(I.discountAmount.toFixed(2)),
3393
3397
  affectedItems: I.affectedItems
3394
3398
  }), s.appliedDiscounts = o);
@@ -3414,10 +3418,10 @@ class Zn {
3414
3418
  const s = t.filter(
3415
3419
  (l) => l.affectedItems.some((u) => u.productId === r.product.id)
3416
3420
  ), i = s.reduce((l, u) => {
3417
- const p = u.affectedItems.find(
3421
+ const f = u.affectedItems.find(
3418
3422
  (b) => b.productId === r.product.id
3419
3423
  );
3420
- return l + ((p == null ? void 0 : p.discountAmount) || 0);
3424
+ return l + ((f == null ? void 0 : f.discountAmount) || 0);
3421
3425
  }, 0), o = i / r.amount, c = r.product.price - o;
3422
3426
  return {
3423
3427
  amount: r.amount,
@@ -3529,8 +3533,8 @@ function sr({
3529
3533
  id: u.product.id,
3530
3534
  price: u.product.price
3531
3535
  }
3532
- })), o = Zn.calculateDiscounts(i, e), c = n.map((u, p) => {
3533
- const b = o.items[p];
3536
+ })), o = Zn.calculateDiscounts(i, e), c = n.map((u, f) => {
3537
+ const b = o.items[f];
3534
3538
  return {
3535
3539
  amount: u.amount,
3536
3540
  product: { ...u.product },
@@ -3539,8 +3543,8 @@ function sr({
3539
3543
  finalDiscount: b ? b.finalDiscount : Dn(u.product)
3540
3544
  };
3541
3545
  }), l = c.reduce(
3542
- (u, p) => {
3543
- const { product: b, amount: w, finalPrice: I, finalDiscount: K } = p;
3546
+ (u, f) => {
3547
+ const { product: b, amount: w, finalPrice: I, finalDiscount: K } = f;
3544
3548
  let j = 0;
3545
3549
  if (b.vat) {
3546
3550
  let Ce = 0;