import { $constructor as c } from "./core.js";
import { lowercase as p, uppercase as _, integer as b } from "./regexes.js";
import { floatSafeRemainder as k, nullish as m, getLengthableOrigin as h, escapeRegex as l, NUMBER_FORMAT_RANGES as x } from "./util.js";
const s = /* @__PURE__ */ c("$ZodCheck", (e, t) => {
  var o;
  e._zod ?? (e._zod = {}), e._zod.def = t, (o = e._zod).onattach ?? (o.onattach = []);
}), v = {
  number: "number",
  bigint: "bigint",
  object: "date"
}, Z = /* @__PURE__ */ c("$ZodCheckLessThan", (e, t) => {
  s.init(e, t);
  const o = v[typeof t.value];
  e._zod.onattach.push((n) => {
    const i = n._zod.bag, u = (t.inclusive ? i.maximum : i.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
    t.value < u && (t.inclusive ? i.maximum = t.value : i.exclusiveMaximum = t.value);
  }), e._zod.check = (n) => {
    (t.inclusive ? n.value <= t.value : n.value < t.value) || n.issues.push({
      origin: o,
      code: "too_big",
      maximum: t.value,
      input: n.value,
      inclusive: t.inclusive,
      inst: e,
      continue: !t.abort
    });
  };
}), I = /* @__PURE__ */ c("$ZodCheckGreaterThan", (e, t) => {
  s.init(e, t);
  const o = v[typeof t.value];
  e._zod.onattach.push((n) => {
    const i = n._zod.bag, u = (t.inclusive ? i.minimum : i.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
    t.value > u && (t.inclusive ? i.minimum = t.value : i.exclusiveMinimum = t.value);
  }), e._zod.check = (n) => {
    (t.inclusive ? n.value >= t.value : n.value > t.value) || n.issues.push({
      origin: o,
      code: "too_small",
      minimum: t.value,
      input: n.value,
      inclusive: t.inclusive,
      inst: e,
      continue: !t.abort
    });
  };
}), N = /* @__PURE__ */ c("$ZodCheckMultipleOf", (e, t) => {
  s.init(e, t), e._zod.onattach.push((o) => {
    var n;
    (n = o._zod.bag).multipleOf ?? (n.multipleOf = t.value);
  }), e._zod.check = (o) => {
    if (typeof o.value != typeof t.value)
      throw new Error("Cannot mix number and bigint in multiple_of check.");
    (typeof o.value == "bigint" ? o.value % t.value === BigInt(0) : k(o.value, t.value) === 0) || o.issues.push({
      origin: typeof o.value,
      code: "not_multiple_of",
      divisor: t.value,
      input: o.value,
      inst: e,
      continue: !t.abort
    });
  };
}), w = /* @__PURE__ */ c("$ZodCheckNumberFormat", (e, t) => {
  s.init(e, t), t.format = t.format || "float64";
  const o = t.format?.includes("int"), n = o ? "int" : "number", [i, u] = x[t.format];
  e._zod.onattach.push((a) => {
    const r = a._zod.bag;
    r.format = t.format, r.minimum = i, r.maximum = u, o && (r.pattern = b);
  }), e._zod.check = (a) => {
    const r = a.value;
    if (o) {
      if (!Number.isInteger(r)) {
        a.issues.push({
          expected: n,
          format: t.format,
          code: "invalid_type",
          continue: !1,
          input: r,
          inst: e
        });
        return;
      }
      if (!Number.isSafeInteger(r)) {
        r > 0 ? a.issues.push({
          input: r,
          code: "too_big",
          maximum: Number.MAX_SAFE_INTEGER,
          note: "Integers must be within the safe integer range.",
          inst: e,
          origin: n,
          continue: !t.abort
        }) : a.issues.push({
          input: r,
          code: "too_small",
          minimum: Number.MIN_SAFE_INTEGER,
          note: "Integers must be within the safe integer range.",
          inst: e,
          origin: n,
          continue: !t.abort
        });
        return;
      }
    }
    r < i && a.issues.push({
      origin: "number",
      input: r,
      code: "too_small",
      minimum: i,
      inclusive: !0,
      inst: e,
      continue: !t.abort
    }), r > u && a.issues.push({
      origin: "number",
      input: r,
      code: "too_big",
      maximum: u,
      inst: e
    });
  };
}), E = /* @__PURE__ */ c("$ZodCheckMaxLength", (e, t) => {
  var o;
  s.init(e, t), (o = e._zod.def).when ?? (o.when = (n) => {
    const i = n.value;
    return !m(i) && i.length !== void 0;
  }), e._zod.onattach.push((n) => {
    const i = n._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
    t.maximum < i && (n._zod.bag.maximum = t.maximum);
  }), e._zod.check = (n) => {
    const i = n.value;
    if (i.length <= t.maximum)
      return;
    const a = h(i);
    n.issues.push({
      origin: a,
      code: "too_big",
      maximum: t.maximum,
      inclusive: !0,
      input: i,
      inst: e,
      continue: !t.abort
    });
  };
}), M = /* @__PURE__ */ c("$ZodCheckMinLength", (e, t) => {
  var o;
  s.init(e, t), (o = e._zod.def).when ?? (o.when = (n) => {
    const i = n.value;
    return !m(i) && i.length !== void 0;
  }), e._zod.onattach.push((n) => {
    const i = n._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
    t.minimum > i && (n._zod.bag.minimum = t.minimum);
  }), e._zod.check = (n) => {
    const i = n.value;
    if (i.length >= t.minimum)
      return;
    const a = h(i);
    n.issues.push({
      origin: a,
      code: "too_small",
      minimum: t.minimum,
      inclusive: !0,
      input: i,
      inst: e,
      continue: !t.abort
    });
  };
}), S = /* @__PURE__ */ c("$ZodCheckLengthEquals", (e, t) => {
  var o;
  s.init(e, t), (o = e._zod.def).when ?? (o.when = (n) => {
    const i = n.value;
    return !m(i) && i.length !== void 0;
  }), e._zod.onattach.push((n) => {
    const i = n._zod.bag;
    i.minimum = t.length, i.maximum = t.length, i.length = t.length;
  }), e._zod.check = (n) => {
    const i = n.value, u = i.length;
    if (u === t.length)
      return;
    const a = h(i), r = u > t.length;
    n.issues.push({
      origin: a,
      ...r ? { code: "too_big", maximum: t.length } : { code: "too_small", minimum: t.length },
      inclusive: !0,
      exact: !0,
      input: n.value,
      inst: e,
      continue: !t.abort
    });
  };
}), g = /* @__PURE__ */ c("$ZodCheckStringFormat", (e, t) => {
  var o, n;
  s.init(e, t), e._zod.onattach.push((i) => {
    const u = i._zod.bag;
    u.format = t.format, t.pattern && (u.patterns ?? (u.patterns = /* @__PURE__ */ new Set()), u.patterns.add(t.pattern));
  }), t.pattern ? (o = e._zod).check ?? (o.check = (i) => {
    t.pattern.lastIndex = 0, !t.pattern.test(i.value) && i.issues.push({
      origin: "string",
      code: "invalid_format",
      format: t.format,
      input: i.value,
      ...t.pattern ? { pattern: t.pattern.toString() } : {},
      inst: e,
      continue: !t.abort
    });
  }) : (n = e._zod).check ?? (n.check = () => {
  });
}), T = /* @__PURE__ */ c("$ZodCheckRegex", (e, t) => {
  g.init(e, t), e._zod.check = (o) => {
    t.pattern.lastIndex = 0, !t.pattern.test(o.value) && o.issues.push({
      origin: "string",
      code: "invalid_format",
      format: "regex",
      input: o.value,
      pattern: t.pattern.toString(),
      inst: e,
      continue: !t.abort
    });
  };
}), R = /* @__PURE__ */ c("$ZodCheckLowerCase", (e, t) => {
  t.pattern ?? (t.pattern = p), g.init(e, t);
}), d = /* @__PURE__ */ c("$ZodCheckUpperCase", (e, t) => {
  t.pattern ?? (t.pattern = _), g.init(e, t);
}), F = /* @__PURE__ */ c("$ZodCheckIncludes", (e, t) => {
  s.init(e, t);
  const o = l(t.includes), n = new RegExp(typeof t.position == "number" ? `^.{${t.position}}${o}` : o);
  t.pattern = n, e._zod.onattach.push((i) => {
    const u = i._zod.bag;
    u.patterns ?? (u.patterns = /* @__PURE__ */ new Set()), u.patterns.add(n);
  }), e._zod.check = (i) => {
    i.value.includes(t.includes, t.position) || i.issues.push({
      origin: "string",
      code: "invalid_format",
      format: "includes",
      includes: t.includes,
      input: i.value,
      inst: e,
      continue: !t.abort
    });
  };
}), L = /* @__PURE__ */ c("$ZodCheckStartsWith", (e, t) => {
  s.init(e, t);
  const o = new RegExp(`^${l(t.prefix)}.*`);
  t.pattern ?? (t.pattern = o), e._zod.onattach.push((n) => {
    const i = n._zod.bag;
    i.patterns ?? (i.patterns = /* @__PURE__ */ new Set()), i.patterns.add(o);
  }), e._zod.check = (n) => {
    n.value.startsWith(t.prefix) || n.issues.push({
      origin: "string",
      code: "invalid_format",
      format: "starts_with",
      prefix: t.prefix,
      input: n.value,
      inst: e,
      continue: !t.abort
    });
  };
}), O = /* @__PURE__ */ c("$ZodCheckEndsWith", (e, t) => {
  s.init(e, t);
  const o = new RegExp(`.*${l(t.suffix)}$`);
  t.pattern ?? (t.pattern = o), e._zod.onattach.push((n) => {
    const i = n._zod.bag;
    i.patterns ?? (i.patterns = /* @__PURE__ */ new Set()), i.patterns.add(o);
  }), e._zod.check = (n) => {
    n.value.endsWith(t.suffix) || n.issues.push({
      origin: "string",
      code: "invalid_format",
      format: "ends_with",
      suffix: t.suffix,
      input: n.value,
      inst: e,
      continue: !t.abort
    });
  };
}), A = /* @__PURE__ */ c("$ZodCheckOverwrite", (e, t) => {
  s.init(e, t), e._zod.check = (o) => {
    o.value = t.tx(o.value);
  };
});
export {
  s as $ZodCheck,
  O as $ZodCheckEndsWith,
  I as $ZodCheckGreaterThan,
  F as $ZodCheckIncludes,
  S as $ZodCheckLengthEquals,
  Z as $ZodCheckLessThan,
  R as $ZodCheckLowerCase,
  E as $ZodCheckMaxLength,
  M as $ZodCheckMinLength,
  N as $ZodCheckMultipleOf,
  w as $ZodCheckNumberFormat,
  A as $ZodCheckOverwrite,
  T as $ZodCheckRegex,
  L as $ZodCheckStartsWith,
  g as $ZodCheckStringFormat,
  d as $ZodCheckUpperCase
};
//# sourceMappingURL=checks.js.map
