openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
5,319 lines • 164 kB
JavaScript
import { r as __exportAll } from "./rolldown-runtime-C_OpTf0N.mjs";
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/util.js
var util_exports = /* @__PURE__ */ __exportAll({
BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
CONSTANT_CATCH: () => CONSTANT_CATCH,
Class: () => Class,
NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
aborted: () => aborted,
allowsEval: () => allowsEval,
assert: () => assert,
assertEqual: () => assertEqual,
assertIs: () => assertIs,
assertNever: () => assertNever,
assertNotEqual: () => assertNotEqual,
assignProp: () => assignProp,
attachSchema: () => attachSchema,
base64ToUint8Array: () => base64ToUint8Array,
base64urlToUint8Array: () => base64urlToUint8Array,
cached: () => cached,
captureStackTrace: () => captureStackTrace,
cleanEnum: () => cleanEnum,
cleanRegex: () => cleanRegex,
clone: () => clone,
cloneDef: () => cloneDef,
codePointLength: () => codePointLength,
constantCatch: () => constantCatch,
createTransparentProxy: () => createTransparentProxy,
defineLazy: () => defineLazy,
defineLazyInternal: () => defineLazyInternal,
derived: () => derived,
esc: () => esc,
escapeRegex: () => escapeRegex,
explicitlyAborted: () => explicitlyAborted,
extend: () => extend,
finalizeIssue: () => finalizeIssue,
floatSafeRemainder: () => floatSafeRemainder,
getElementAtPath: () => getElementAtPath,
getEnumValues: () => getEnumValues,
getLengthableOrigin: () => getLengthableOrigin,
getParsedType: () => getParsedType,
getSizableOrigin: () => getSizableOrigin,
hexToUint8Array: () => hexToUint8Array,
hide: () => hide,
installLazyProp: () => installLazyProp,
isObject: () => isObject,
isPlainObject: () => isPlainObject,
issue: () => issue,
joinValues: () => joinValues,
jsonStringifyReplacer: () => jsonStringifyReplacer,
members: () => members,
merge: () => merge,
mergeDefs: () => mergeDefs,
normalizeParams: () => normalizeParams,
nullish: () => nullish,
numKeys: () => numKeys,
objectClone: () => objectClone,
omit: () => omit,
optionalKeys: () => optionalKeys,
own: () => own,
parsedType: () => parsedType,
partial: () => partial,
pick: () => pick,
prefixIssues: () => prefixIssues,
primitiveTypes: () => primitiveTypes,
promiseAllObject: () => promiseAllObject,
propertyKeyTypes: () => propertyKeyTypes,
randomString: () => randomString,
rawShape: () => rawShape,
required: () => required,
safeExtend: () => safeExtend,
shallowClone: () => shallowClone,
sizeCaps: () => sizeCaps,
slugify: () => slugify,
stringifyPrimitive: () => stringifyPrimitive,
toZod: () => toZod,
uint8ArrayToBase64: () => uint8ArrayToBase64,
uint8ArrayToBase64url: () => uint8ArrayToBase64url,
uint8ArrayToHex: () => uint8ArrayToHex,
unwrapMessage: () => unwrapMessage
});
function assertEqual(e) {
return e;
}
function assertNotEqual(e) {
return e;
}
function toZod() {
return (e) => e;
}
function assertIs(e) {}
function assertNever(e) {
throw new Error("Unexpected value in exhaustive check");
}
function assert(e) {}
function getEnumValues(e) {
const t = Object.values(e).filter((e) => typeof e === "number");
return Object.entries(e).filter(([e, n]) => t.indexOf(+e) === -1).map(([e, t]) => t);
}
function joinValues(e, t = "|") {
return e.map((e) => stringifyPrimitive(e)).join(t);
}
function jsonStringifyReplacer(e, t) {
if (typeof t === "bigint") return t.toString();
return t;
}
var Cached = class {
constructor(e) {
this._getter = e;
this._value = void 0;
}
get value() {
const e = this._getter;
if (e !== void 0) {
this._value = e();
this._getter = void 0;
}
return this._value;
}
};
function cached(e) {
return new Cached(e);
}
function nullish(e) {
return e === null || e === void 0;
}
function cleanRegex(e) {
const t = e.startsWith("^") ? 1 : 0;
const n = e.endsWith("$") ? e.length - 1 : e.length;
return e.slice(t, n);
}
function floatSafeRemainder(e, t) {
const n = e / t;
const r = Math.round(n);
const i = 4 * Number.EPSILON * Math.max(Math.abs(n), 1);
if (Math.abs(n - r) < i) return 0;
return n - r;
}
const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
function defineLazy(e, t, n) {
let r = void 0;
Object.defineProperty(e, t, {
get() {
if (r === EVALUATING) return;
if (r === void 0) {
r = EVALUATING;
r = n();
}
return r;
},
set(n) {
Object.defineProperty(e, t, { value: n });
},
configurable: true
});
}
function objectClone(e) {
return Object.create(Object.getPrototypeOf(e), Object.getOwnPropertyDescriptors(e));
}
function assignProp(e, t, n) {
Object.defineProperty(e, t, {
value: n,
writable: true,
enumerable: true,
configurable: true
});
}
/**
* Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it.
*
* Its keys and descriptors read without invoking anything, which is what lets a discriminated union check its discriminator, and the cycle walk read a shape, without resolving a getter that references the schema being constructed. A def that answers `shape` from an accessor of its own has none.
*/
function rawShape(e) {
const t = Object.getOwnPropertyDescriptor(e, "shape");
return t?.get ? t.get.raw : t?.value;
}
function sourceShape(e) {
return rawShape(e._zod.def) ?? e._zod.def.shape;
}
function deferProp(e, t, n) {
Object.defineProperty(e, t, {
get() {
const e = n();
assignProp(this, t, e);
return e;
},
enumerable: true,
configurable: true
});
}
function putProp(e, t, n) {
if (t in e) assignProp(e, t, n);
else e[t] = n;
}
/**
* Copies `keys` of `source`'s shape onto `target`, each value passed through `wrap`.
*
* A key the source has resolved is copied through now, so the derived shape states it outright and nothing has to resolve it to learn what it holds. A key the source still defers stays deferred, and reads back through the source's own `shape`, so it resolves once and both shapes get that one schema.
*/
function mirrorShape(e, t, n, r) {
const i = sourceShape(t);
for (const a of n) {
const n = Object.getOwnPropertyDescriptor(i, a);
if (!n.enumerable) continue;
if (n.get) deferProp(e, a, () => {
const e = t._zod.def.shape[a];
return r ? r(e, a) : e;
});
else putProp(e, a, r ? r(n.value, a) : n.value);
}
}
function mirrorProps(e, t) {
for (const n of Reflect.ownKeys(t)) {
const r = Object.getOwnPropertyDescriptor(t, n);
if (!r.enumerable) continue;
if (r.get) deferProp(e, n, () => t[n]);
else putProp(e, n, r.value);
}
}
function mergeDefs(...e) {
const t = {};
for (const n of e) {
const e = Object.getOwnPropertyDescriptors(n);
Object.assign(t, e);
}
return Object.defineProperties({}, t);
}
function cloneDef(e) {
return mergeDefs(e._zod.def);
}
function getElementAtPath(e, t) {
if (!t) return e;
return t.reduce((e, t) => e?.[t], e);
}
function promiseAllObject(e) {
const t = Object.keys(e);
const n = t.map((t) => e[t]);
return Promise.all(n).then((e) => {
const n = {};
for (let r = 0; r < t.length; r++) n[t[r]] = e[r];
return n;
});
}
function randomString(e = 10) {
const t = "abcdefghijklmnopqrstuvwxyz";
let n = "";
for (let r = 0; r < e; r++) n += t[Math.floor(Math.random() * 26)];
return n;
}
function esc(e) {
return JSON.stringify(e);
}
function slugify(e) {
return e.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
}
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (...e) => {};
function isObject(e) {
return typeof e === "object" && e !== null && !Array.isArray(e);
}
const allowsEval = /* @__PURE__*/ cached(() => {
if (globalConfig.jitless) return false;
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
try {
new Function("");
return true;
} catch (e) {
return false;
}
});
function isPlainObject(e) {
if (isObject(e) === false) return false;
const t = e.constructor;
if (t === void 0) return true;
if (typeof t !== "function") return true;
const n = t.prototype;
if (isObject(n) === false) return false;
if (Object.prototype.hasOwnProperty.call(n, "isPrototypeOf") === false) return false;
return true;
}
function shallowClone(e) {
if (isPlainObject(e)) return { ...e };
if (Array.isArray(e)) return [...e];
if (e instanceof Map) return new Map(e);
if (e instanceof Set) return new Set(e);
return e;
}
function numKeys(e) {
let t = 0;
for (const n in e) if (Object.prototype.hasOwnProperty.call(e, n)) t++;
return t;
}
const getParsedType = (e) => {
const t = typeof e;
switch (t) {
case "undefined": return "undefined";
case "string": return "string";
case "number": return Number.isNaN(e) ? "nan" : "number";
case "boolean": return "boolean";
case "function": return "function";
case "bigint": return "bigint";
case "symbol": return "symbol";
case "object":
if (Array.isArray(e)) return "array";
if (e === null) return "null";
if (e.then && typeof e.then === "function" && e.catch && typeof e.catch === "function") return "promise";
if (typeof Map !== "undefined" && e instanceof Map) return "map";
if (typeof Set !== "undefined" && e instanceof Set) return "set";
if (typeof Date !== "undefined" && e instanceof Date) return "date";
if (typeof File !== "undefined" && e instanceof File) return "file";
return "object";
default: throw new Error(`Unknown data type: ${t}`);
}
};
const propertyKeyTypes = /* @__PURE__*/ new Set([
"string",
"number",
"symbol"
]);
const primitiveTypes = /* @__PURE__*/ new Set([
"string",
"number",
"bigint",
"boolean",
"symbol",
"undefined"
]);
function escapeRegex(e) {
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function clone(e, t, n) {
const r = new e._zod.constr(t ?? e._zod.def);
if (!t || n?.parent) r._zod.parent = e;
return r;
}
function normalizeParams(e) {
const t = e;
if (!t) return {};
if (typeof t === "string") return { error: () => t };
if (t?.message !== void 0) {
if (t?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
t.error = t.message;
}
delete t.message;
if (typeof t.error === "string") return {
...t,
error: () => t.error
};
return t;
}
function createTransparentProxy(e) {
let t;
return new Proxy({}, {
get(n, r, i) {
t ?? (t = e());
return Reflect.get(t, r, i);
},
set(n, r, i, a) {
t ?? (t = e());
return Reflect.set(t, r, i, a);
},
has(n, r) {
t ?? (t = e());
return Reflect.has(t, r);
},
deleteProperty(n, r) {
t ?? (t = e());
return Reflect.deleteProperty(t, r);
},
ownKeys(n) {
t ?? (t = e());
return Reflect.ownKeys(t);
},
getOwnPropertyDescriptor(n, r) {
t ?? (t = e());
return Reflect.getOwnPropertyDescriptor(t, r);
},
defineProperty(n, r, i) {
t ?? (t = e());
return Reflect.defineProperty(t, r, i);
}
});
}
function stringifyPrimitive(e) {
if (typeof e === "bigint") return e.toString() + "n";
if (typeof e === "string") return `"${e}"`;
return `${e}`;
}
function optionalKeys(e) {
return Object.keys(e).filter((t) => {
return e[t]._zod.optin !== void 0 && e[t]._zod.optout === "optional";
});
}
const NUMBER_FORMAT_RANGES = /*@__PURE__*/ (() => ({
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
int32: [-2147483648, 2147483647],
uint32: [0, 4294967295],
float32: [-34028234663852886e22, 34028234663852886e22],
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
}))();
const BIGINT_FORMAT_RANGES = {
int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")]
};
function pick(e, t) {
const n = e._zod.def;
const r = n.checks;
if (r && r.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
const i = {};
mirrorShape(i, e, maskedKeys(e, t));
return clone(e, mergeDefs(n, {
shape: i,
checks: []
}));
}
function maskedKeys(e, t) {
const n = sourceShape(e);
const r = [];
for (const e of Reflect.ownKeys(t)) {
if (!Object.getOwnPropertyDescriptor(n, e)?.enumerable) throw new Error(`Unrecognized key: "${String(e)}"`);
if (t[e]) r.push(e);
}
return r;
}
function omit(e, t) {
const n = e._zod.def;
const r = n.checks;
if (r && r.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
const i = new Set(maskedKeys(e, t));
const a = {};
mirrorShape(a, e, Reflect.ownKeys(sourceShape(e)).filter((e) => !i.has(e)));
return clone(e, mergeDefs(n, {
shape: a,
checks: []
}));
}
function extend(e, t) {
if (!isPlainObject(t)) throw new Error("Invalid input to extend: expected a plain object");
const n = e._zod.def.checks;
if (n && n.length > 0) {
const n = sourceShape(e);
for (const e of Reflect.ownKeys(t)) if (Object.getOwnPropertyDescriptor(n, e) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
}
return clone(e, mergeDefs(e._zod.def, { shape: extended(e, t) }));
}
function extended(e, t) {
const n = {};
mirrorShape(n, e, Reflect.ownKeys(sourceShape(e)));
mirrorProps(n, t);
return n;
}
function safeExtend(e, t) {
if (!isPlainObject(t)) throw new Error("Invalid input to safeExtend: expected a plain object");
return clone(e, mergeDefs(e._zod.def, { shape: extended(e, t) }));
}
function merge(e, t) {
if (!t?._zod?.def) throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
if (e._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
const n = {};
mirrorShape(n, e, Reflect.ownKeys(sourceShape(e)));
mirrorShape(n, t, Reflect.ownKeys(sourceShape(t)));
return clone(e, mergeDefs(e._zod.def, {
shape: n,
get catchall() {
return t._zod.def.catchall;
},
checks: t._zod.def.checks ?? []
}));
}
function partial(e, t, n, r = "partial") {
const i = t._zod.def.checks;
if (i && i.length > 0) throw new Error(`.${r}() cannot be used on object schemas containing refinements`);
const a = n ? new Set(maskedKeys(t, n)) : void 0;
const o = {};
mirrorShape(o, t, Reflect.ownKeys(sourceShape(t)), e && ((t, n) => a && !a.has(n) ? t : new e({
type: "optional",
innerType: t
})));
return clone(t, mergeDefs(t._zod.def, {
shape: o,
checks: []
}));
}
function required(e, t, n) {
const r = n ? new Set(maskedKeys(t, n)) : void 0;
const i = {};
mirrorShape(i, t, Reflect.ownKeys(sourceShape(t)), (t, n) => r && !r.has(n) ? t : new e({
type: "nonoptional",
innerType: t
}));
return clone(t, mergeDefs(t._zod.def, { shape: i }));
}
function aborted(e, t = 0) {
if (e.aborted === true) return true;
for (let n = t; n < e.issues.length; n++) if (e.issues[n]?.continue !== true) return true;
return false;
}
function explicitlyAborted(e, t = 0) {
if (e.aborted === true) return true;
for (let n = t; n < e.issues.length; n++) if (e.issues[n]?.continue === false) return true;
return false;
}
function prefixIssues(e, t) {
return t.map((t) => {
var n;
(n = t).path ?? (n.path = []);
t.path.unshift(e);
return t;
});
}
function unwrapMessage(e) {
return typeof e === "string" ? e : e?.message;
}
/** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
function sizeCaps(e) {
const t = [];
for (const n of e ?? []) {
const e = n._zod.def;
if (!/_(length|size)$|_equals$/.test(e.check)) break;
const r = e.maximum ?? e.length ?? e.size;
if (r >= 0) t.push([r, n]);
}
return t;
}
function attachSchema(e, t, n) {
var r;
for (let i = t; i < e.length; i++) (r = e[i]).schema ?? (r.schema = n);
}
function finalizeIssue(e, t, n) {
var r;
const i = e.inst?._zod?.traits;
if (i?.has("$ZodType")) {
if (i.has("$ZodCheck")) (r = e).schema ?? (r.schema = e.inst);
else e.schema = e.inst;
}
const a = e.schema !== e.inst ? e.schema?._zod.def?.error : void 0;
const o = e.message ? e.message : unwrapMessage(e.inst?._zod.def?.error?.(e)) ?? unwrapMessage(a?.(e)) ?? unwrapMessage(t?.error?.(e)) ?? unwrapMessage(n.customError?.(e)) ?? unwrapMessage(n.localeError?.(e)) ?? "Invalid input";
const s = {};
for (const t of Object.keys(e)) {
if (t === "inst" || t === "schema" || t === "continue" || t === "input" || t === "__proto__") continue;
s[t] = e[t];
}
s.path ?? (s.path = []);
s.message = o;
if (t?.reportInput) s.input = e.input;
return s;
}
function getSizableOrigin(e) {
if (e instanceof Set) return "set";
if (e instanceof Map) return "map";
if (e instanceof File) return "file";
return "unknown";
}
const highSurrogate = /[\uD800-\uDBFF]/;
function codePointLength(e) {
const t = e.length;
if (!highSurrogate.test(e)) return t;
let n = t;
for (let r = 0; r < t - 1; r++) if ((e.charCodeAt(r) & 64512) === 55296 && (e.charCodeAt(r + 1) & 64512) === 56320) {
n--;
r++;
}
return n;
}
function getLengthableOrigin(e) {
if (Array.isArray(e)) return "array";
if (typeof e === "string") return "string";
return "unknown";
}
function parsedType(e) {
const t = typeof e;
switch (t) {
case "number": return Number.isNaN(e) ? "nan" : "number";
case "object": {
if (e === null) return "null";
if (Array.isArray(e)) return "array";
const t = e;
if (t && Object.getPrototypeOf(t) !== Object.prototype && "constructor" in t && t.constructor) return t.constructor.name;
}
}
return t;
}
function issue(...e) {
const [t, n, r] = e;
if (typeof t === "string") return {
message: t,
code: "custom",
input: n,
inst: r
};
return { ...t };
}
function cleanEnum(e) {
return Object.entries(e).filter(([e, t]) => {
return Number.isNaN(Number.parseInt(e, 10));
}).map((e) => e[1]);
}
function base64ToUint8Array(e) {
const t = atob(e);
const n = new Uint8Array(t.length);
for (let e = 0; e < t.length; e++) n[e] = t.charCodeAt(e);
return n;
}
function uint8ArrayToBase64(e) {
let t = "";
for (let n = 0; n < e.length; n++) t += String.fromCharCode(e[n]);
return btoa(t);
}
function base64urlToUint8Array(e) {
const t = e.replace(/-/g, "+").replace(/_/g, "/");
return base64ToUint8Array(t + "=".repeat((4 - t.length % 4) % 4));
}
function uint8ArrayToBase64url(e) {
return uint8ArrayToBase64(e).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
}
function hexToUint8Array(e) {
const t = e.replace(/^0x/, "");
if (t.length % 2 !== 0) throw new Error("Invalid hex string length");
const n = new Uint8Array(t.length / 2);
for (let e = 0; e < t.length; e += 2) n[e / 2] = Number.parseInt(t.slice(e, e + 2), 16);
return n;
}
function uint8ArrayToHex(e) {
return Array.from(e).map((e) => e.toString(16).padStart(2, "0")).join("");
}
var Class = class {
constructor(...e) {}
};
/**
* Installs a trait's members on its prototype. Each value builds that member for the instance on first read; the built value shadows the accessor as an own property, so a detached `const { parse } = schema` keeps working.
*
* Call this from a `proto` initializer, which runs once per prototype — never per instance.
*/
function members(e, t) {
for (const n in t) {
const r = Object.getOwnPropertyDescriptor(t, n);
if (r.get) Object.defineProperty(e, n, {
...r,
enumerable: false
});
else defineBound(e, n, r.value);
}
}
/** Shadows a prototype member with an own value, so a getter that builds from the instance runs once. */
function own(e, t, n, r = true) {
Object.defineProperty(e, t, {
configurable: true,
writable: true,
enumerable: r,
value: n
});
return n;
}
/** Like {@link own}, for a member that was never an own data property and has to stay out of `Object.keys`. */
function hide(e, t, n) {
return own(e, t, n, false);
}
/** Adds members a table derives from the instance: each builds on first read and shadows as own data, and assignment shadows the same way, as when these were own properties. */
/* @__NO_SIDE_EFFECTS__ */
function derived(e, t) {
for (const n in e) {
const r = e[n];
Object.defineProperty(t, n, {
configurable: true,
enumerable: true,
get() {
return own(this, n, r(this));
},
set(e) {
own(this, n, e);
}
});
}
return t;
}
function defineBound(e, t, n) {
Object.defineProperty(e, t, {
configurable: true,
get() {
return this == null ? n : own(this, t, n.bind(this));
},
set(e) {
own(this, t, e);
}
});
}
/** Returns the prototype to install on, or `undefined` if this group is already installed on it. */
function claim(e, t) {
const n = Object.getPrototypeOf(e);
return t in n ? void 0 : n;
}
let installing;
let broke = false;
const breaker = {
configurable: true,
get() {
broke = true;
}
};
/**
* Installs a lazily-derived internal on the `_zod` prototype of `inst`'s
* constructor, computed from the internals object itself and cached there on
* first read. One accessor per constructor rather than one per instance.
*/
function defineLazyInternal(e, t, n) {
const r = Object.getPrototypeOf(e._zod);
if (t in r && installing !== e._zod) {
installing = void 0;
return;
}
installing = e._zod;
Object.defineProperty(r, t, {
configurable: true,
get() {
Object.defineProperty(this, t, breaker);
const e = broke;
broke = false;
try {
const r = n(this);
if (broke) delete this[t];
else Object.defineProperty(this, t, {
configurable: true,
writable: true,
value: r
});
broke = broke || e;
return r;
} catch (n) {
delete this[t];
broke = broke || e;
throw n;
}
},
set(e) {
Object.defineProperty(this, t, {
configurable: true,
writable: true,
value: e
});
}
});
}
/**
* Installs `key` on `inst`'s prototype, computed by `make` on first read and cached there as an own
* data property. One accessor per constructor rather than one per instance, because an own accessor
* puts every instance after the first into v8 dictionary mode. The key doubles as the sentinel.
*/
function installLazyProp(e, t, n, r) {
const i = claim(e, t);
if (!i) return;
Object.defineProperty(i, t, {
configurable: true,
get() {
const e = {
configurable: true,
writable: true,
enumerable: r,
value: void 0
};
Object.defineProperty(this, t, e);
e.value = n(this);
Object.defineProperty(this, t, e);
return e.value;
},
set(e) {
Object.defineProperty(this, t, {
configurable: true,
writable: true,
enumerable: r,
value: e
});
}
});
}
/** Marks the thunk `_catch` synthesises for a constant catch value. `Function.length` cannot tell that thunk from a user callback — rest and defaulted parameters both report arity 0 — and a user callback reads `ctx.error`, whose issues only finalize correctly against the caller's per-parse error map. Provenance can say what arity cannot. A plain string key rather than `Symbol.for`, whose call at module scope no bundler can prove pure — the same shape that anchored `urlCanParse` into every build. */
const CONSTANT_CATCH = "~constantCatch";
/** Wraps a constant catch value in a thunk tagged with {@link CONSTANT_CATCH}. */
function constantCatch(e) {
const fn = () => e;
fn[CONSTANT_CATCH] = true;
return fn;
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/core.js
var _a$1;
/** A special constant with type `never` */
const NEVER = /*@__PURE__*/ Object.freeze({ status: "aborted" });
const _zodDesc = {
value: void 0,
enumerable: false
};
let _E = "captureStackTrace" in Error ? Error : null;
function newError(e) {
const t = _E;
if (t) {
const n = t.stackTraceLimit;
if (typeof n === "number") {
try {
t.stackTraceLimit = 0;
} catch {
_E = null;
return new e();
}
try {
return new e();
} finally {
t.stackTraceLimit = n;
}
}
}
return new e();
}
/* @__NO_SIDE_EFFECTS__ */
function $constructor(e, t, n, r) {
const i = {};
function Internals(e) {
this.def = e;
this.constr = _;
this.traits = /* @__PURE__ */ new Set();
}
Internals.prototype = i;
const a = n;
const o = a && /* @__PURE__ */ new WeakSet();
function init(n, r) {
if (!n._zod) {
_zodDesc.value = new Internals(r);
try {
Object.defineProperty(n, "_zod", _zodDesc);
} finally {
_zodDesc.value = void 0;
}
} else if (n._zod.traits.has(e)) return;
n._zod.traits.add(e);
t(n, r);
if (o) {
const e = Object.getPrototypeOf(n);
const t = n._zod.constr.prototype;
let r = e;
while (r && r !== t) r = Object.getPrototypeOf(r);
const i = r ?? e;
if (!o.has(i)) {
o.add(i);
members(i, a);
}
}
const i = _.prototype;
for (const e in i) {
if (!Object.prototype.hasOwnProperty.call(i, e)) continue;
if (!(e in n)) n[e] = i[e].bind(n);
}
}
const s = r?.Parent ?? Object;
class Definition extends s {}
Object.defineProperty(Definition, "name", { value: e });
function _(e) {
const t = r?.Parent ? newError(Definition) : this;
init(t, e);
const n = t._zod.deferred;
if (n) {
for (const e of n) e();
t._zod.deferred = void 0;
}
const i = globalThis.__zod_globalConfig?.postProcessor;
if (i) i(t);
return t;
}
Object.defineProperty(_, "init", { value: init });
Object.defineProperty(_, Symbol.hasInstance, { value: (t) => {
if (r?.Parent && t instanceof r.Parent) return true;
return t?._zod?.traits?.has(e);
} });
Object.defineProperty(_, "name", { value: e });
return _;
}
const $brand = /*@__PURE__*/ Symbol("zod_brand");
var $ZodAsyncError = class extends Error {
constructor() {
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
}
};
var $ZodEncodeError = class extends Error {
constructor(e) {
super(`Encountered unidirectional transform during encode: ${e}`);
this.name = "ZodEncodeError";
}
};
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
const globalConfig = globalThis.__zod_globalConfig;
function config(e) {
if (e) Object.assign(globalConfig, e);
return globalConfig;
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/errors.js
function _getMessage() {
const e = this._zod;
e.message ?? (e.message = JSON.stringify(e.def, jsonStringifyReplacer, 2));
return e.message;
}
function _setMessage(e) {
this._zod.message = e;
}
const _messageDesc = {
get: _getMessage,
set: _setMessage,
enumerable: true,
configurable: true
};
const _issuesDesc = {
value: void 0,
enumerable: false
};
const _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
const initializer = (e, t) => {
e.name = "$ZodError";
_issuesDesc.value = t;
Object.defineProperty(e, "issues", _issuesDesc);
_issuesDesc.value = void 0;
Object.defineProperty(e, "message", _messageDesc);
const n = Object.getPrototypeOf(e);
if (!_installedToString.has(n)) {
_installedToString.add(n);
Object.defineProperty(n, "toString", {
configurable: true,
enumerable: false,
get() {
const value = () => this.message;
Object.defineProperty(this, "toString", {
value,
configurable: true,
writable: true
});
return value;
},
set(e) {
Object.defineProperty(this, "toString", {
value: e,
configurable: true,
writable: true
});
}
});
}
};
const $ZodError = /* @__PURE__ */ $constructor("$ZodError", initializer);
const $ZodRealError = /* @__PURE__ */ $constructor("$ZodError", initializer, void 0, { Parent: Error });
/** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member
* ("toString", "constructor") would otherwise read through to the prototype, and assigning
* "__proto__" would hit the setter instead of creating a key. */
function node(e, t, n) {
if (!Object.prototype.hasOwnProperty.call(e, t)) {
if (t === "__proto__") Object.defineProperty(e, t, {
value: n(),
writable: true,
enumerable: true,
configurable: true
});
else e[t] = n();
}
return e[t];
}
function flattenError(e, t = (e) => e.message) {
const n = {};
const r = [];
for (const i of e.issues) if (i.path.length > 0) node(n, i.path[0], () => []).push(t(i));
else r.push(t(i));
return {
formErrors: r,
fieldErrors: n
};
}
function formatError(e, t = (e) => e.message) {
const n = { _errors: [] };
const processError = (e, r = []) => {
for (const i of e.issues) if (i.code === "invalid_union" && i.errors.length) i.errors.map((e) => processError({ issues: e }, [...r, ...i.path]));
else if (i.code === "invalid_key") processError({ issues: i.issues }, [...r, ...i.path]);
else if (i.code === "invalid_element") processError({ issues: i.issues }, [...r, ...i.path]);
else {
const e = [...r, ...i.path];
if (e.length === 0) n._errors.push(t(i));
else {
let r = n;
let a = 0;
while (a < e.length) {
const n = e[a];
const o = a === e.length - 1;
if (n === "_errors") {
if (o) r._errors.push(t(i));
a++;
continue;
}
if (!Object.prototype.hasOwnProperty.call(r, n)) Object.defineProperty(r, n, {
value: { _errors: [] },
enumerable: true,
writable: true,
configurable: true
});
const s = r[n];
if (o) s._errors.push(t(i));
r = s;
a++;
}
}
}
};
processError(e);
return n;
}
function treeifyError(e, t = (e) => e.message) {
const n = { errors: [] };
const processError = (e, r = []) => {
var i;
for (const a of e.issues) if (a.code === "invalid_union" && a.errors.length) a.errors.map((e) => processError({ issues: e }, [...r, ...a.path]));
else if (a.code === "invalid_key") processError({ issues: a.issues }, [...r, ...a.path]);
else if (a.code === "invalid_element") processError({ issues: a.issues }, [...r, ...a.path]);
else {
const e = [...r, ...a.path];
if (e.length === 0) {
n.errors.push(t(a));
continue;
}
let o = n;
let s = 0;
while (s < e.length) {
const n = e[s];
const r = s === e.length - 1;
if (typeof n === "string") {
o.properties ?? (o.properties = {});
if (!Object.prototype.hasOwnProperty.call(o.properties, n)) Object.defineProperty(o.properties, n, {
value: { errors: [] },
enumerable: true,
writable: true,
configurable: true
});
o = o.properties[n];
} else {
o.items ?? (o.items = []);
(i = o.items)[n] ?? (i[n] = { errors: [] });
o = o.items[n];
}
if (r) o.errors.push(t(a));
s++;
}
}
};
processError(e);
return n;
}
/** Format a ZodError as a human-readable string in the following form.
*
* From
*
* ```ts
* ZodError {
* issues: [
* {
* expected: 'string',
* code: 'invalid_type',
* path: [ 'username' ],
* message: 'Invalid input: expected string'
* },
* {
* expected: 'number',
* code: 'invalid_type',
* path: [ 'favoriteNumbers', 1 ],
* message: 'Invalid input: expected number'
* }
* ];
* }
* ```
*
* to
*
* ```
* username
* ✖ Expected number, received string at "username
* favoriteNumbers[0]
* ✖ Invalid input: expected number
* ```
*/
function toDotPath(e) {
const t = [];
const n = e.map((e) => typeof e === "object" ? e.key : e);
for (const e of n) if (typeof e === "number") t.push(`[${e}]`);
else if (typeof e === "symbol") t.push(`[${JSON.stringify(String(e))}]`);
else if (/[^\w$]/.test(e)) t.push(`[${JSON.stringify(e)}]`);
else {
if (t.length) t.push(".");
t.push(e);
}
return t.join("");
}
function prettifyError(e) {
const t = [];
const n = [...e.issues].sort((e, t) => (e.path ?? []).length - (t.path ?? []).length);
for (const e of n) {
t.push(`✖ ${e.message}`);
if (e.path?.length) t.push(` → at ${toDotPath(e.path)}`);
}
return t.join("\n");
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/parse.js
function finalizeParams(e, t) {
return {
callee: t?.callee ?? e,
Err: t?.Err
};
}
const _parse = (e) => {
const fn = (t, n, r, i) => {
const a = r ? {
...r,
async: false
} : { async: false };
const o = t._zod.run({
value: n,
issues: []
}, a);
if (o instanceof Promise) throw new $ZodAsyncError();
if (o.issues.length) {
const t = new ((i?.Err) ?? e)(o.issues.map((e) => finalizeIssue(e, a, config())));
captureStackTrace(t, i?.callee ?? fn);
throw t;
}
return o.value;
};
return fn;
};
const parse = /* @__PURE__*/ _parse($ZodRealError);
const _parseAsync = (e) => {
const fn = async (t, n, r, i) => {
const a = r ? {
...r,
async: true
} : { async: true };
let o = t._zod.run({
value: n,
issues: []
}, a);
if (o instanceof Promise) o = await o;
if (o.issues.length) {
const t = new ((i?.Err) ?? e)(o.issues.map((e) => finalizeIssue(e, a, config())));
captureStackTrace(t, i?.callee ?? fn);
throw t;
}
return o.value;
};
return fn;
};
const parseAsync = /* @__PURE__*/ _parseAsync($ZodRealError);
const _safeParse = (e) => (t, n, r) => {
const i = r ? {
...r,
async: false
} : { async: false };
const a = t._zod.run({
value: n,
issues: []
}, i);
if (a instanceof Promise) throw new $ZodAsyncError();
return a.issues.length ? failure(e, a.issues, i) : {
success: true,
data: a.value
};
};
const safeParse = /* @__PURE__*/ _safeParse($ZodRealError);
function failure(e, t, n) {
let r;
return {
success: false,
get error() {
if (!r) {
r = new e(t.map((e) => finalizeIssue(e, n, config())));
t = void 0;
n = void 0;
}
return r;
},
set error(e) {
r = e;
t = void 0;
n = void 0;
}
};
}
const _safeParseAsync = (e) => async (t, n, r) => {
const i = r ? {
...r,
async: true
} : { async: true };
let a = t._zod.run({
value: n,
issues: []
}, i);
if (a instanceof Promise) a = await a;
return a.issues.length ? failure(e, a.issues, i) : {
success: true,
data: a.value
};
};
const safeParseAsync = /* @__PURE__*/ _safeParseAsync($ZodRealError);
const COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
const COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
const validate = ((e, t, n) => {
const r = e._zod.bag.validator;
if (r !== void 0) {
if (r(t) !== COMPILE_INVALID) return true;
if (r.definite === true && n === void 0) return false;
}
return validateFallback(e, t, n);
});
function validateFallback(e, t, n) {
const r = n ? {
...n,
async: false,
abortEarly: true
} : {
async: false,
abortEarly: true
};
const i = e._zod.bag.fallbackRun;
let a;
if (i) {
r[COMPILE_FALLBACK] = true;
a = i({
value: t,
issues: []
}, r);
} else a = e._zod.run({
value: t,
issues: []
}, r);
if (a instanceof Promise) throw new $ZodAsyncError();
return a.issues.length === 0;
}
const validateAsync$1 = async (e, t, n) => {
const r = n ? {
...n,
async: true,
abortEarly: true
} : {
async: true,
abortEarly: true
};
let i = e._zod.run({
value: t,
issues: []
}, r);
if (i instanceof Promise) i = await i;
return i.issues.length === 0;
};
const _encode = (e) => {
const t = _parse(e);
const fn = (e, n, r, i) => {
const a = r ? {
...r,
direction: "backward"
} : { direction: "backward" };
return t(e, n, a, finalizeParams(fn, i));
};
return fn;
};
const encode = /* @__PURE__*/ _encode($ZodRealError);
const _decode = (e) => {
const t = _parse(e);
const fn = (e, n, r, i) => {
return t(e, n, r, finalizeParams(fn, i));
};
return fn;
};
const decode = /* @__PURE__*/ _decode($ZodRealError);
const _encodeAsync = (e) => {
const t = _parseAsync(e);
const fn = async (e, n, r, i) => {
const a = r ? {
...r,
direction: "backward"
} : { direction: "backward" };
return await t(e, n, a, finalizeParams(fn, i));
};
return fn;
};
const encodeAsync = /* @__PURE__*/ _encodeAsync($ZodRealError);
const _decodeAsync = (e) => {
const t = _parseAsync(e);
const fn = async (e, n, r, i) => {
return await t(e, n, r, finalizeParams(fn, i));
};
return fn;
};
const decodeAsync = /* @__PURE__*/ _decodeAsync($ZodRealError);
const _safeEncode = (e) => (t, n, r) => {
const i = r ? {
...r,
direction: "backward"
} : { direction: "backward" };
return _safeParse(e)(t, n, i);
};
const safeEncode = /* @__PURE__*/ _safeEncode($ZodRealError);
const _safeDecode = (e) => (t, n, r) => {
return _safeParse(e)(t, n, r);
};
const safeDecode = /* @__PURE__*/ _safeDecode($ZodRealError);
const _safeEncodeAsync = (e) => async (t, n, r) => {
const i = r ? {
...r,
direction: "backward"
} : { direction: "backward" };
return _safeParseAsync(e)(t, n, i);
};
const safeEncodeAsync = /* @__PURE__*/ _safeEncodeAsync($ZodRealError);
const _safeDecodeAsync = (e) => async (t, n, r) => {
return _safeParseAsync(e)(t, n, r);
};
const safeDecodeAsync = /* @__PURE__*/ _safeDecodeAsync($ZodRealError);
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/regexes.js
var regexes_exports = /* @__PURE__ */ __exportAll({
anyString: () => anyString,
base64: () => base64,
base64url: () => base64url,
bigint: () => bigint,
boolean: () => boolean,
browserEmail: () => browserEmail,
cidrv4: () => cidrv4,
cidrv6: () => cidrv6,
creditCard: () => creditCard,
cuid: () => cuid,
cuid2: () => cuid2,
currencyCode: () => currencyCode,
date: () => date,
datetime: () => datetime,
domain: () => domain,
duration: () => duration,
e164: () => e164,
email: () => email,
emoji: () => emoji,
extendedDuration: () => extendedDuration,
guid: () => guid,
hex: () => hex,
hostname: () => hostname,
html5Email: () => html5Email,
httpProtocol: () => httpProtocol,
iban: () => iban,
idnEmail: () => idnEmail,
integer: () => integer,
ipv4: () => ipv4,
ipv6: () => ipv6,
ksuid: () => ksuid,
lowercase: () => lowercase,
mac: () => mac,
md5_base64: () => md5_base64,
md5_base64url: () => md5_base64url,
md5_hex: () => md5_hex,
nanoid: () => nanoid,
nanoidOfLength: () => nanoidOfLength,
null: () => _null,
number: () => number,
rfc5322Email: () => rfc5322Email,
sha1_base64: () => sha1_base64,
sha1_base64url: () => sha1_base64url,
sha1_hex: () => sha1_hex,
sha256_base64: () => sha256_base64,
sha256_base64url: () => sha256_base64url,
sha256_hex: () => sha256_hex,
sha384_base64: () => sha384_base64,
sha384_base64url: () => sha384_base64url,
sha384_hex: () => sha384_hex,
sha512_base64: () => sha512_base64,
sha512_base64url: () => sha512_base64url,
sha512_hex: () => sha512_hex,
string: () => string,
time: () => time,
ulid: () => ulid,
undefined: () => _undefined,
unicodeEmail: () => unicodeEmail,
uppercase: () => uppercase,
uuid: () => uuid,
uuid4: () => uuid4,
uuid6: () => uuid6,
uuid7: () => uuid7,
xid: () => xid
});
/**
* @deprecated CUID v1 is deprecated by its authors due to information leakage
* (timestamps embedded in the id). Use {@link cuid2} instead.
* See https://github.com/paralleldrive/cuid.
*/
const cuid = /^[cC][0-9a-z]{6,}$/;
const cuid2 = /^[0-9a-z]+$/;
const ulid = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;
const xid = /^[0-9a-vA-V]{20}$/;
const ksuid = /^[A-Za-z0-9]{27}$/;
const nanoid = /^[a-zA-Z0-9_-]{21}$/;
function nanoidOfLength(e) {
return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`);
}
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
/** Implements ISO 8601-2 extensions like explicit +- prefixes, mixing weeks with other units, and fractional/negative components. */
const extendedDuration = /^[-+]?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)?)??$/;
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
/** Returns a regex for validating an RFC 9562/4122 UUID.
*
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
const uuid = (e) => {
if (!e) return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
};
const uuid4 = /*@__PURE__*/ uuid(4);
const uuid6 = /*@__PURE__*/ uuid(6);
const uuid7 = /*@__PURE__*/ uuid(7);
/** Practical email validation */
const email = /^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
/** Equivalent to the HTML5 input[type=email] validation implemented by browsers. Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email */
const html5Email = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
/** The classic emailregex.com regex for RFC 5322-compliant emails */
const rfc5322Email = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
/** A loose regex that allows Unicode characters, enforces length limits, and that's about it. */
const unicodeEmail = /^[^\s@"]{1,64}@[^\s@]{1,255}$/u;
const idnEmail = unicodeEmail;
const browserEmail = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
const _emoji = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
function emoji() {
return new RegExp(_emoji, "u");
}
const ipv4 = /^(?:(?: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])$/;
const ipv6 = /^(([0-9a-fA-F]{1,4}:){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}|:))$/;
const mac = (e) => {
const t = escapeRegex(e ?? ":");
return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`);
};
const cidrv4 = /^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/;
const cidrv6 = /^(([0-9a-fA-F]{1,4}:){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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
const base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
const hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
const domain = /^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/;
const httpProtocol = /^https?$/;
const e164 = /^\+[1-9]\d{6,14}$/;
const creditCard = /^\d(?:[ -]?\d){11,18}$/;
const currencyCode = /^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/;
const iban = /^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/;
const dateSource = `(?:(?:\\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])))`;
/** Anchors a pattern source. The interpolation lives here rather than at the call site because
* esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it
* will drop `anchor(dateSource)`. Keeping it inline pinned `date` into every bundle. */
function anchor(e) {
return new RegExp(`^${e}$`);
}
const date = /*@__PURE__*/ anchor(dateSource);
function timeSource(e) {
const t = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
return typeof e.precision === "number" ? e.precision === -1 ? `${t}` : e.precision === 0 ? `${t}:[0-5]\\d` : `${t}:[0-5]\\d\\.\\d{${e.precision}}` : e.seconds ? `${t}:[0-5]\\d(?:\\.\\d+)?` : `${t}(?::[0-5]\\d(?:\\.\\d+)?)?`;
}
function time(e) {
return new RegExp(`^${timeSource(e)}$`);
}
function datetime(e) {
const t = ["Z"];
if (e.offset) t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
const n = `${timeSource({
precision: e.precision,
seconds: true
})}(?:${t.join("|")})`;
const r = e.local ? `${n}|${timeSource({ precision: e.precision })}` : n;
return new RegExp(`^${dateSource}T(?:${r})$`);
}
const anyString = /^[\s\S]{0,}$/;
const string = (e) => {
const t = e ? `[\\s\\S]{${e?.minimum ?? 0},${e?.maximum ?? ""}}` : `[\\s\\S]*`;
return new RegExp(`^${t}$`);
};
const bigint = /^-?\d+n?$/;
const integer = /^-?\d+$/;
const number = /^-?\d+(?:\.\d+)?$/;
const boolean = /^(?:true|false)$/i;
const _null = /^null$/i;
const _undefined = /^undefined$/i;
const lowercase = /^[^A-Z]*$/;
const uppercase = /^[^a-z]*$/;
const hex = /^[0-9a-fA-F]*$/;
function fixedBase64(e, t) {
return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`);
}
function fixedBase64url(e) {
return new RegExp(`^[A-Za-z0-9_-]{${e}}$`);
}
const md5_hex = /^[0-9a-fA-F]{32}$/;
const md5_base64 = /*@__PURE__*/ fixedBase64(22, "==");
const md5_base64url = /*@__PURE__*/ fixedBase64url(22);
const sha1_hex = /^[0-9a-fA-F]{40}$/;
const sha1_base64 = /*@__PURE__*/ fixedBase64(27, "=");
const sha1_base64url = /*@__PURE__*/ fixedBase64url(27);
const sha256_hex = /^[0-9a-fA-F]{64}$/;
const sha256_base64 = /*@__PURE__*/ fixedBase64(43, "=");
const sha256_base64url = /*@__PURE__*/ fixedBase64url(43);
const sha384_hex = /^[0-9a-fA-F]{96}$/;
const sha384_base64 = /*@__PURE__*/ fixedBase64(64, "");
const sha384_base64url = /*@__PURE__*/ fixedBase64url(64);
const sha512_hex = /^[0-9a-fA-F]{128}$/;
const sha512_base64 = /*@__PURE__*/ fixedBase64(86, "==");
const sha512_base64url = /*@__PURE__*/ fixedBase64url(86);
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/checks.js
const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (e, t) => {
var n;
e._zod ?? (e._zod = {});
e._zod.def = t;
(n = e._zod).onattach ?? (n.onattach = []);
});
/** Default `when` for size-based checks: run only on non-nullish values with a `size`. */
const _whenHasSize = (e) => {
const t = e.value;
return !nullish(t) && t.size !== void 0;
};
/** Default `when` for length-based checks: run only on non-nullish values with a `length`. */
const _whenHasLength = (e) => {
const t = e.value;
return !nullish(t) && t.length !== void 0;
};
const numericOriginMap = {
number: "number",
bigint: "bigint",
object: "date"
};
const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (e, t) => {
$ZodCheck.init(e, t);
const n = numericOriginMap[typeof t.value];
e._zod.check = (r) => {
if (t.inclusive ? r.value <= t.value : r.value < t.value) return;
r.issues.push({
origin: numericOriginMap[typeof r.value] ?? n,
code: "too_big",
maximum: typeof t.value === "object" ? t.value.getTime() : t.value,
input: r.value,
inclusive: t.inclusive,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (e, t) => {
$ZodCheck.init(e, t);
const n = numericOriginMap[typeof t.value];
e._zod.check = (r) => {
if (t.inclusive ? r.value >= t.value : r.value > t.value) return;
r.issues.push({
origin: numericOriginMap[typeof r.value] ?? n,
code: "too_small",
minimum: typeof t.value === "object" ? t.value.getTime() : t.value,
input: r.value,
inclusive: t.inclusive,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (e, t) => {
$ZodCheck.init(e, t);
e._zod.check = (n) => {
if (typeof n.value !== typeof t.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
if (typeof n.value === "bigint" ? t.value !== BigInt(0) && n.value % t.value === BigInt(0) : floatSafeRemainder(n.value, t.value) === 0) return;
n.issues.push({
origin: typeof n.value,
code: "not_multiple_of",
divisor: t.value,
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat", (e, t) => {
$ZodCheck.init(e, t);
t.format = t.format || "float64";
const n = t.format?.includes("int");
const r = n ? "int" : "number";
const [i, a] = NUMBER_FORMAT_RANGES[t.format];
e._zod.check = (o) => {
const s = o.value;
if (n) {
if (!Number.isInteger(s)) {
o.issues.push({
expected: r,
format: t.format,
code: "invalid_type",
continue: false,
input: s,
inst: e
});
return;
}
if (!Number.isSafeInteger(s)) {
if (s > 0) o.issues.push({
input: s,
code: "too_big",
maximum: Number.MAX_SAFE_INTEGER,
note: "Integers must be within the safe integer range.",
inst: e,
origin: r,
inclusive: true,
continue: !t.abort
});
else o.issues.push({
input: s,
code: "too_small",
minimum: Number.MIN_SAFE_INTEGER,
note: "Integers must be within the safe integer range.",
inst: e,
origin: r,
inclusive: true,
continue: !t.abort
});
return;
}
}
if (s < i) o.issues.push({
origin: "number",
input: s,
code: "too_small",
minimum: i,
inclusive: true,
inst: e,
continue: !t.abort
});
if (s > a) o.issues.push({
origin: "number",
input: s,
code: "too_big",
maximum: a,
inclusive: true,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckBigIntFormat = /*@__PURE__*/ $constructor("$ZodCheckBigIntFormat", (e, t) => {
$ZodCheck.init(e, t);
const [n, r] = BIGINT_FORMAT_RANGES[t.format];
e._zod.check = (i) => {
const a = i.value;
if (a < n) i.issues.push({
origin: "bigint",
input: a,
code: "too_small",
minimum: n,
inclusive: true,
inst: e,
continue: !t.abort
});
if (a > r) i.issues.push({
origin: "bigint",
input: a,
code: "too_big",
maximum: r,
inclusive: true,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckMaxSize = /*@__PURE__*/ $constructor("$ZodCheckMaxSize", (e, t) => {
var n;
$ZodCheck.init(e, t);
(n = e._zod.def).when ?? (n.when = _whenHasSize);
e._zod.check = (n) => {
const r = n.value;
if (r.size <= t.maximum) return;
n.issues.push({
origin: getSizableOrigin(r),
code: "too_big",
maximum: t.maximum,
inclusive: true,
input: r,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckMinSize = /*@__PURE__*/ $constructor("$ZodCheckMinSize", (e, t) => {
var n;
$ZodCheck.init(e, t);
(n = e._zod.def).when ?? (n.when = _whenHasSize);
e._zod.check = (n) => {
const r = n.value;
if (r.size >= t.minimum) return;
n.issues.push({
origin: getSizableOrigin(r),
code: "too_small",
minimum: t.minimum,
inclusive: true,
input: r,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckSizeEquals = /*@__PURE__*/ $constructor("$ZodCheckSizeEquals", (e, t) => {
var n;
$ZodCheck.init(e, t);
(n = e._zod.def).when ?? (n.when = _whenHasSize);
e._zod.check = (n) => {
const r = n.value;
const i = r.size;
if (i === t.size) return;
const a = i > t.size;
n.issues.push({
origin: getSizableOrigin(r),
...a ? {
code: "too_big",
maximum: t.size
} : {
code: "too_small",
minimum: t.size
},
inclusive: true,
exact: true,
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (e, t) => {
var n;
$ZodCheck.init(e, t);
(n = e._zod.def).when ?? (n.when = _whenHasLength);
e._zod.check = (n) => {
const r = n.value;
const i = r.length;
if ((typeof r === "string" && i > t.maximum ? codePointLength(r) : i) <= t.maximum) return;
const a = getLengthableOrigin(r);
n.issues.push({
origin: a,
code: "too_big",
maximum: t.maximum,
inclusive: true,
input: r,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (e, t) => {
var n;
$ZodCheck.init(e, t);
(n = e._zod.def).when ?? (n.when = _whenHasLength);
e._zod.check = (n) => {
const r = n.value;
const i = r.length;
if ((typeof r === "string" && i >= t.minimum && i < t.minimum * 2 ? codePointLength(r) : i) >= t.minimum) return;
const a = getLengthableOrigin(r);
n.issues.push({
origin: a,
code: "too_small",
minimum: t.minimum,
inclusive: true,
input: r,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (e, t) => {
var n;
$ZodCheck.init(e, t);
(n = e._zod.def).when ?? (n.when = _whenHasLength);
e._zod.check = (n) => {
const r = n.value;
const i = r.length;
const a = typeof r === "string" && i >= t.length && i <= t.length * 2 ? codePointLength(r) : i;
if (a === t.length) return;
const o = getLengthableOrigin(r);
const s = a > t.length;
n.issues.push({
origin: o,
...s ? {
code: "too_big",
maximum: t.length
} : {
code: "too_small",
minimum: t.length
},
inclusive: true,
exact: true,
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (e, t) => {
var n, r;
$ZodCheck.init(e, t);
if (t.pattern) (n = e._zod).check ?? (n.check = (n) => {
t.pattern.lastIndex = 0;
if (t.pattern.test(n.value)) return;
n.issues.push({
origin: "string",
code: "invalid_format",
format: t.format,
input: n.value,
...t.pattern ? { pattern: t.pattern.toString() } : {},
inst: e,
continue: !t.abort
});
});
else (r = e._zod).check ?? (r.check = () => {});
});
const $ZodCheckRegex = /*@__PURE__*/ $constructor("$ZodCheckRegex", (e, t) => {
$ZodCheckStringFormat.init(e, t);
e._zod.check = (n) => {
t.pattern.lastIndex = 0;
if (t.pattern.test(n.value)) return;
n.issues.push({
origin: "string",
code: "invalid_format",
format: "regex",
input: n.value,
pattern: t.pattern.toString(),
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckLowerCase = /*@__PURE__*/ $constructor("$ZodCheckLowerCase", (e, t) => {
t.pattern ?? (t.pattern = lowercase);
$ZodCheckStringFormat.init(e, t);
});
const $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (e, t) => {
t.pattern ?? (t.pattern = uppercase);
$ZodCheckStringFormat.init(e, t);
});
const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (e, t) => {
$ZodCheck.init(e, t);
const n = escapeRegex(t.includes);
t.pattern = new RegExp(typeof t.position === "number" ? `^.{${t.position},}${n}` : n);
e._zod.check = (n) => {
if (n.value.includes(t.includes, t.position)) return;
n.issues.push({
origin: "string",
code: "invalid_format",
format: "includes",
includes: t.includes,
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (e, t) => {
$ZodCheck.init(e, t);
const n = new RegExp(`^${escapeRegex(t.prefix)}.*`);
t.pattern ?? (t.pattern = n);
e._zod.check = (n) => {
if (n.value.startsWith(t.prefix)) return;
n.issues.push({
origin: "string",
code: "invalid_format",
format: "starts_with",
prefix: t.prefix,
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (e, t) => {
$ZodCheck.init(e, t);
const n = new RegExp(`.*${escapeRegex(t.suffix)}$`);
t.pattern ?? (t.pattern = n);
e._zod.check = (n) => {
if (n.value.endsWith(t.suffix)) return;
n.issues.push({
origin: "string",
code: "invalid_format",
format: "ends_with",
suffix: t.suffix,
input: n.value,
inst: e,
continue: !t.abort
});
};
});
function handleCheckPropertyResult(e, t, n) {
if (e.issues.length) t.issues.push(...prefixIssues(n, e.issues));
}
const $ZodCheckProperty = /*@__PURE__*/ $constructor("$ZodCheckProperty", (e, t) => {
$ZodCheck.init(e, t);
e._zod.check = (e) => {
const n = t.schema._zod.run({
value: e.value[t.property],
issues: []
}, {});
if (n instanceof Promise) return n.then((n) => handleCheckPropertyResult(n, e, t.property));
handleCheckPropertyResult(n, e, t.property);
};
});
const $ZodCheckProperties = /*@__PURE__*/ $constructor("$ZodCheckProperties", (e, t) => {
$ZodCheck.init(e, t);
hide(e, Symbol.iterator, function* () {
yield e;
});
let n;
e._zod.check = (r) => {
if (r.value == null) {
r.issues.push({
expected: "object",
code: "invalid_type",
input: r.value,
inst: e
});
return;
}
n ?? (n = Reflect.ownKeys(t.shape).map((e) => [e, t.shape[e]]));
const i = r.value;
let a;
for (const [e, t] of n) {
const n = t._zod.run({
value: i[e],
issues: []
}, {});
if (n instanceof Promise) {
a ?? (a = []);
a.push(n.then((t) => handleCheckPropertyResult(t, r, e)));
} else handleCheckPropertyResult(n, r, e);
}
if (a) return Promise.all(a).then(() => void 0);
};
});
const $ZodCheckMimeType = /*@__PURE__*/ $constructor("$ZodCheckMimeType", (e, t) => {
$ZodCheck.init(e, t);
const n = new Set(t.mime);
e._zod.check = (r) => {
if (n.has(r.value.type)) return;
r.issues.push({
code: "invalid_value",
values: t.mime,
input: r.value.type,
inst: e,
continue: !t.abort
});
};
});
const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (e, t) => {
$ZodCheck.init(e, t);
e._zod.check = (e) => {
e.value = t.tx(e.value);
};
});
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/doc.js
var Doc = class {
constructor(e = [], t = {}) {
this.content = [];
this.indent = 0;
this.args = e;
this.closed = t;
}
indented(e) {
this.indent += 1;
try {
e(this);
} finally {
this.indent -= 1;
}
}
write(e) {
if (typeof e === "function") {
e(this, { execution: "sync" });
e(this, { execution: "async" });
return;
}
const t = e.split("\n").filter((e) => e);
const n = Math.min(...t.map((e) => e.length - e.trimStart().length));
const r = t.map((e) => e.slice(n)).map((e) => " ".repeat(this.indent * 2) + e);
for (const e of r) this.content.push(e);
}
compile() {
const e = Function;
const t = this?.content ?? [``];
return new e(...Object.keys(this.closed), `return function (${this.args.join(", ")}) {\n${t.join("\n")}\n};`)(...Object.values(this.closed));
}
};
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/versions.js
const version = {
major: 4,
minor: 6,
patch: 7
};
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/schemas.js
const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (e, t) => {
var n;
e ?? (e = {});
e._zod.def = t;
e._zod.bag = e._zod.bag || {};
e._zod.version = version;
const r = e._zod.def.checks;
const i = e._zod.traits.has("$ZodCheck") ? [e, ...r ?? []] : r?.length ? [...r] : [];
for (const t of i) for (const n of t._zod.onattach) n(e);
if (i.length === 0) {
(n = e._zod).deferred ?? (n.deferred = []);
e._zod.deferred?.push(() => {
e._zod.run = e._zod.parse;
});
} else {
const runChecks = (t, n, r) => {
if (t.memo) return t;
let i = aborted(t);
let a;
for (const o of n) {
if (o._zod.def.when) {
if (explicitlyAborted(t)) continue;
if (!o._zod.def.when(t)) continue;
} else if (i) continue;
const n = t.issues.length;
const s = o._zod.check(t);
if (s instanceof Promise && r?.async === false) throw new $ZodAsyncError();
if (a || s instanceof Promise) a = (a ?? Promise.resolve()).then(async () => {
await s;
if (t.issues.length === n) return;
attachSchema(t.issues, n, e);
if (!i) i = aborted(t, n);
});
else {
if (t.issues.length === n) continue;
attachSchema(t.issues, n, e);
if (!i) i = aborted(t, n);
}
}
if (a) return a.then(() => {
return t;
});
return t;
};
const handleCanaryResult = (t, n, r) => {
if (aborted(t)) {
t.aborted = true;
return t;
}
const a = runChecks(n, i, r);
if (a instanceof Promise) {
if (r.async === false) throw new $ZodAsyncError();
return a.then((t) => e._zod.parse(t, r));
}
return e._zod.parse(a, r);
};
e._zod.run = (t, n) => {
if (n.skipChecks) return e._zod.parse(t, n);
if (n.direction === "backward") {
const r = e._zod.parse({
value: t.value,
issues: []
}, {
...n,
skipChecks: true
});
if (r instanceof Promise) return r.then((e) => {
return handleCanaryResult(e, t, n);
});
return handleCanaryResult(r, t, n);
}
const r = e._zod.parse(t, n);
if (r instanceof Promise) {
if (n.async === false) throw new $ZodAsyncError();
return r.then((e) => runChecks(e, i, n));
}
return runChecks(r, i, n);
};
}
}, {
get "~standard"() {
return hide(this, "~standard", standardProps(this));
},
set "~standard"(e) {
own(this, "~standard", e);
}
});
/** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
const toStandardResult = (e, t) => e.issues.length ? { issues: e.issues.map((e) => finalizeIssue(e, t, config())) } : { value: e.value };
async function validateAsync(e, t) {
const n = { async: true };
return toStandardResult(await e._zod.run({
value: t,
issues: []
}, n), n);
}
function standardProps(e) {
return {
validate: (t) => {
const n = { async: false };
try {
const r = e._zod.run({
value: t,
issues: []
}, n);
if (!(r instanceof Promise)) return toStandardResult(r, n);
} catch (e) {}
return validateAsync(e, t);
},
vendor: "zod",
version: 1
};
}
const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (e, t) => {
$ZodType.init(e, t);
e._zod.pattern = t.pattern ?? anyString;
e._zod.parse = (n, r) => {
if (t.coerce) try {
n.value = String(n.value);
} catch (e) {}
if (typeof n.value === "string") return n;
n.issues.push({
expected: "string",
code: "invalid_type",
input: n.value,
inst: e
});
return n;
};
});
const $ZodStringFormat = /*@__PURE__*/ $constructor("$ZodStringFormat", (e, t) => {
$ZodCheckStringFormat.init(e, t);
$ZodString.init(e, t);
});
const $ZodGUID = /*@__PURE__*/ $constructor("$ZodGUID", (e, t) => {
t.pattern ?? (t.pattern = guid);
$ZodStringFormat.init(e, t);
});
const $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (e, t) => {
if (t.version) {
const e = {
v1: 1,
v2: 2,
v3: 3,
v4: 4,
v5: 5,
v6: 6,
v7: 7,
v8: 8
}[t.version];
if (e === void 0) throw new Error(`Invalid UUID version: "${t.version}"`);
t.pattern ?? (t.pattern = uuid(e));
} else t.pattern ?? (t.pattern = uuid());
$ZodStringFormat.init(e, t);
});
const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (e, t) => {
t.pattern ?? (t.pattern = email);
$ZodStringFormat.init(e, t);
});
/** The `://` guard rejected the input before the URL constructor saw it. */
const URL_BAD_FORMAT = 1;
/** The URL parser rejected the input. */
const URL_UNPARSEABLE = 2;
function canParseURL(e) {
try {
if (typeof URL !== "undefined" && typeof URL.canParse === "function") return URL.canParse(e);
new URL(e);
return true;
} catch {
return false;
}
}
function validateURL(e, t) {
if (!("normalize" in t) && !("hostname" in t) && !("protocol" in t)) return canParseURL(e) || 2;
return parseURLObject(e, t);
}
/** Parses a URL while preserving the non-normalizing HTTP guard. */
function parseURLObject(e, t) {
if (!t.normalize && t.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(e)) return 1;
try {
if (typeof URL !== "undefined") {
const t = URL;
if (typeof t.parse === "function") return t.parse(e) ?? 2;
}
return new URL(e);
} catch {
return 2;
}
}
const asciiTabOrNewline = /[\t\n\r]/g;
/** The URL parser deletes every ASCII tab, LF and CR from its input before it parses, so `new URL("https://exa\nmple.com")` reports on `example.com`. Applying the same deletion to the returned value closes the half of that divergence which can move the host; the parser's other rewrite, stripping C0 controls at the edges, cannot. */
function stripTabAndNewline(e) {
return e.replace(asciiTabOrNewline, "");
}
function urlHostnameOk(e, t) {
t.lastIndex = 0;
return t.test(e.hostname);
}
function urlProtocolOk(e, t) {
t.lastIndex = 0;
return t.test(e.protocol.endsWith(":") ? e.protocol.slice(0, -1) : e.protocol);
}
const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (e, t) => {
$ZodStringFormat.init(e, t);
e._zod.check = (n) => {
try {
const r = n.value.trim();
const i = validateURL(r, t);
if (i === 1) {
n.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid URL format",
input: n.value,
inst: e,
continue: !t.abort
});
return;
}
if (i === 2) {
n.issues.push({
code: "invalid_format",
format: "url",
input: n.value,
inst: e,
continue: !t.abort
});
return;
}
if (i === true) {
n.value = stripTabAndNewline(r);
return;
}
if (t.hostname && !urlHostnameOk(i, t.hostname)) n.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid hostname",
pattern: t.hostname.source,
input: n.value,
inst: e,
continue: !t.abort
});
if (t.protocol && !urlProtocolOk(i, t.protocol)) n.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid protocol",
pattern: t.protocol.source,
input: n.value,
inst: e,
continue: !t.abort
});
n.value = t.normalize ? i.href : stripTabAndNewline(r);
return;
} catch (r) {
n.issues.push({
code: "invalid_format",
format: "url",
input: n.value,
inst: e,
continue: !t.abort
});
}
};
});
const $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (e, t) => {
t.pattern ?? (t.pattern = emoji());
$ZodStringFormat.init(e, t);
});
const $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (e, t) => {
if (t.length !== void 0 && (!Number.isInteger(t.length) || t.length < 1)) throw new Error(`Invalid nanoid length: ${t.length}`);
t.pattern ?? (t.pattern = t.length === void 0 ? nanoid : nanoidOfLength(t.length));
$ZodStringFormat.init(e, t);
});
/**
* @deprecated CUID v1 is deprecated by its authors due to information leakage
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
* See https://github.com/paralleldrive/cuid.
*/
const $ZodCUID = /*@__PURE__*/ $constructor("$ZodCUID", (e, t) => {
t.pattern ?? (t.pattern = cuid);
$ZodStringFormat.init(e, t);
});
const $ZodCUID2 = /*@__PURE__*/ $constructor("$ZodCUID2", (e, t) => {
t.pattern ?? (t.pattern = cuid2);
$ZodStringFormat.init(e, t);
});
const $ZodULID = /*@__PURE__*/ $constructor("$ZodULID", (e, t) => {
t.pattern ?? (t.pattern = ulid);
$ZodStringFormat.init(e, t);
});
const $ZodXID = /*@__PURE__*/ $constructor("$ZodXID", (e, t) => {
t.pattern ?? (t.pattern = xid);
$ZodStringFormat.init(e, t);
});
const $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (e, t) => {
t.pattern ?? (t.pattern = ksuid);
$ZodStringFormat.init(e, t);
});
const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (e, t) => {
t.pattern ?? (t.pattern = datetime(t));
$ZodStringFormat.init(e, t);
});
const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (e, t) => {
t.pattern ?? (t.pattern = date);
$ZodStringFormat.init(e, t);
});
const $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (e, t) => {
t.pattern ?? (t.pattern = time(t));
$ZodStringFormat.init(e, t);
});
const $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (e, t) => {
t.pattern ?? (t.pattern = duration);
$ZodStringFormat.init(e, t);
});
const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (e, t) => {
t.pattern ?? (t.pattern = ipv4);
$ZodStringFormat.init(e, t);
});
/** An IPv6 address is written with hex digits, colons and dots, and nothing else. The guard is what makes the check below an IPv6 check: `new URL("http://[...]")` parses an authority, not an address, so `@` and `\` re-delimit it and `"::@1\\"` validates against the host `0.0.0.1`. The URL parser also deletes ASCII tab, LF and CR rather than failing, which is how `"::1\n"` validated as `::1`. */
const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
function isValidIPv6(e) {
if (!ipv6Alphabet.test(e)) return false;
return canParseURL(`http://[${e}]`);
}
const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (e, t) => {
t.pattern ?? (t.pattern = ipv6);
$ZodStringFormat.init(e, t);
e._zod.check = (n) => {
if (!isValidIPv6(n.value)) n.issues.push({
code: "invalid_format",
format: "ipv6",
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const $ZodMAC = /*@__PURE__*/ $constructor("$ZodMAC", (e, t) => {
t.pattern ?? (t.pattern = mac(t.delimiter));
$ZodStringFormat.init(e, t);
});
const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (e, t) => {
t.pattern ?? (t.pattern = cidrv4);
$ZodStringFormat.init(e, t);
});
function isValidCIDRv6(e) {
const t = e.split("/");
if (t.length !== 2) return false;
const [n, r] = t;
if (!r) return false;
const i = Number(r);
if (`${i}` !== r) return false;
if (i < 0 || i > 128) return false;
return isValidIPv6(n);
}
const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (e, t) => {
t.pattern ?? (t.pattern = cidrv6);
$ZodStringFormat.init(e, t);
e._zod.check = (n) => {
if (!isValidCIDRv6(n.value)) n.issues.push({
code: "invalid_format",
format: "cidrv6",
input: n.value,
inst: e,
continue: !t.abort
});
};
});
function isValidBase64(e) {
if (e === "") return true;
if (/\s/.test(e)) return false;
if (e.length % 4 !== 0) return false;
try {
atob(e);
return true;
} catch {
return false;
}
}
const base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (e, t) => {
t.pattern ?? (t.pattern = base64Charset);
$ZodStringFormat.init(e, t);
e._zod.check = (n) => {
if (isValidBase64(n.value)) return;
n.issues.push({
code: "invalid_format",
format: "base64",
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const base64urlCharset = /^[A-Za-z0-9_-]*$/;
function isValidBase64URL(e) {
if (!base64urlCharset.test(e)) return false;
const t = e.replace(/[-_]/g, (e) => e === "-" ? "+" : "/");
return isValidBase64(t.padEnd(Math.ceil(t.length / 4) * 4, "="));
}
const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (e, t) => {
t.pattern ?? (t.pattern = base64urlCharset);
$ZodStringFormat.init(e, t);
e._zod.check = (n) => {
if (isValidBase64URL(n.value)) return;
n.issues.push({
code: "invalid_format",
format: "base64url",
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const $ZodE164 = /*@__PURE__*/ $constructor("$ZodE164", (e, t) => {
t.pattern ?? (t.pattern = e164);
$ZodStringFormat.init(e, t);
});
const CC_SANITIZE = /[- ]/g;
/** Luhn checksum on a digit-only string. Adapted from valibot (MIT). */
function isLuhnAlgo(e) {
let t = e.length;
let n = 1;
let r = 0;
while (t) {
const i = e.charCodeAt(--t) - 48;
n ^= 1;
r += n ? [
0,
2,
4,
6,
8,
1,
3,
5,
7,
9
][i] : i;
}
return r % 10 === 0;
}
function isValidCreditCard(e) {
if (!creditCard.test(e)) return false;
return isLuhnAlgo(e.replace(CC_SANITIZE, ""));
}
const $ZodCreditCard = /*@__PURE__*/ $constructor("$ZodCreditCard", (e, t) => {
t.pattern ?? (t.pattern = creditCard);
$ZodStringFormat.init(e, t);
e._zod.check = (n) => {
if (isValidCreditCard(n.value)) return;
n.issues.push({
code: "invalid_format",
format: "credit_card",
input: n.value,
inst: e,
continue: !t.abort
});
};
});
function isIso7064Mod97(e) {
let t = 0;
const n = e.length;
for (let r = 4; r < n; r++) {
const n = e.charCodeAt(r);
t = (n >= 65 ? t * 100 + (n - 55) : t * 10 + (n - 48)) % 97;
}
for (let n = 0; n < 4; n++) {
const r = e.charCodeAt(n);
t = (r >= 65 ? t * 100 + (r - 55) : t * 10 + (r - 48)) % 97;
}
return t === 1;
}
function isValidIBAN(e) {
if (!iban.test(e)) return false;
return isIso7064Mod97(e);
}
const $ZodIBAN = /*@__PURE__*/ $constructor("$ZodIBAN", (e, t) => {
t.pattern ?? (t.pattern = iban);
$ZodStringFormat.init(e, t);
e._zod.check = (n) => {
if (isValidIBAN(n.value)) return;
n.issues.push({
code: "invalid_format",
format: "iban",
input: n.value,
inst: e,
continue: !t.abort
});
};
});
function isValidJWT(e, t = null) {
try {
const n = e.split(".");
if (n.length !== 3) return false;
const [r] = n;
if (!r) return false;
const i = JSON.parse(atob(r));
if ("typ" in i && i?.typ !== "JWT") return false;
if (!i.alg) return false;
if (t && (!("alg" in i) || i.alg !== t)) return false;
return true;
} catch {
return false;
}
}
const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (e, t) => {
$ZodStringFormat.init(e, t);
e._zod.check = (n) => {
if (isValidJWT(n.value, t.alg)) return;
n.issues.push({
code: "invalid_format",
format: "jwt",
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const $ZodCustomStringFormat = /*@__PURE__*/ $constructor("$ZodCustomStringFormat", (e, t) => {
$ZodStringFormat.init(e, t);
e._zod.check = (n) => {
if (t.fn(n.value)) return;
n.issues.push({
code: "invalid_format",
format: t.format,
input: n.value,
inst: e,
continue: !t.abort
});
};
});
const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (e, t) => {
$ZodType.init(e, t);
e._zod.pattern = number;
e._zod.parse = (n, r) => {
if (t.coerce) try {
n.value = Number(n.value);
} catch (e) {}
const i = n.value;
if (typeof i === "number" && !Number.isNaN(i) && Number.isFinite(i)) return n;
const a = typeof i === "number" ? Number.isNaN(i) ? "NaN" : !Number.isFinite(i) ? String(i) : void 0 : void 0;
n.issues.push({
expected: "number",
code: "invalid_type",
input: i,
inst: e,
...a ? { received: a } : {}
});
return n;
};
});
const $ZodNumberFormat = /*@__PURE__*/ $constructor("$ZodNumberFormat", (e, t) => {
$ZodCheckNumberFormat.init(e, t);
$ZodNumber.init(e, t);
});
const $ZodBoolean = /*@__PURE__*/ $constructor("$ZodBoolean", (e, t) => {
$ZodType.init(e, t);
e._zod.pattern = boolean;
e._zod.parse = (n, r) => {
if (t.coerce) try {
n.value = Boolean(n.value);
} catch (e) {}
const i = n.value;
if (typeof i === "boolean") return n;
n.issues.push({
expected: "boolean",
code: "invalid_type",
input: i,
inst: e
});
return n;
};
});
const $ZodBigInt = /*@__PURE__*/ $constructor("$ZodBigInt", (e, t) => {
$ZodType.init(e, t);
e._zod.pattern = bigint;
e._zod.parse = (n, r) => {
if (t.coerce) try {
n.value = BigInt(n.value);
} catch (e) {}
if (typeof n.value === "bigint") return n;
n.issues.push({
expected: "bigint",
code: "invalid_type",
input: n.value,
inst: e
});
return n;
};
});
const $ZodBigIntFormat = /*@__PURE__*/ $constructor("$ZodBigIntFormat", (e, t) => {
$ZodCheckBigIntFormat.init(e, t);
$ZodBigInt.init(e, t);
});
const $ZodSymbol = /*@__PURE__*/ $constructor("$ZodSymbol", (e, t) => {
$ZodType.init(e, t);
e._zod.parse = (t, n) => {
const r = t.value;
if (typeof r === "symbol") return t;
t.issues.push({
expected: "symbol",
code: "invalid_type",
input: r,
inst: e
});
return t;
};
});
const $ZodUndefined = /*@__PURE__*/ $constructor("$ZodUndefined", (e, t) => {
$ZodType.init(e, t);
e._zod.pattern = _undefined;
e._zod.values = /* @__PURE__ */ new Set([void 0]);
e._zod.parse = (t, n) => {
const r = t.value;
if (typeof r === "undefined") return t;
t.issues.push({
expected: "undefined",
code: "invalid_type",
input: r,
inst: e
});
return t;
};
});
const $ZodNull = /*@__PURE__*/ $constructor("$ZodNull", (e, t) => {
$ZodType.init(e, t);
e._zod.pattern = _null;
e._zod.values = /* @__PURE__ */ new Set([null]);
e._zod.parse = (t, n) => {
const r = t.value;
if (r === null) return t;
t.issues.push({
expected: "null",
code: "invalid_type",
input: r,
inst: e
});
return t;
};
});
const $ZodAny = /*@__PURE__*/ $constructor("$ZodAny", (e, t) => {
$ZodType.init(e, t);
e._zod.parse = (e) => e;
});
const $ZodUnknown = /*@__PURE__*/ $constructor("$ZodUnknown", (e, t) => {
$ZodType.init(e, t);
e._zod.parse = (e) => e;
});
const $ZodNever = /*@__PURE__*/ $constructor("$ZodNever", (e, t) => {
$ZodType.init(e, t);
e._zod.parse = (t, n) => {
t.issues.push({
expected: "never",
code: "invalid_type",
input: t.value,
inst: e
});
return t;
};
});
const $ZodVoid = /*@__PURE__*/ $constructor("$ZodVoid", (e, t) => {
$ZodType.init(e, t);
e._zod.parse = (t, n) => {
const r = t.value;
if (typeof r === "undefined") return t;
t.issues.push({
expected: "void",
code: "invalid_type",
input: r,
inst: e
});
return t;
};
});
const $ZodDate = /*@__PURE__*/ $constructor("$ZodDate", (e, t) => {
$ZodType.init(e, t);
e._zod.parse = (n, r) => {
if (t.coerce) try {
n.value = new Date(n.value);
} catch (e) {}
const i = n.value;
const a = i instanceof Date;
if (a && !Number.isNaN(i.getTime())) return n;
n.issues.push({
expected: "date",
code: "invalid_type",
input: i,
...a ? { received: "Invalid Date" } : {},
inst: e
});
return n;
};
});
function capSize(e, t) {
const n = sizeCaps(e._zod.def.checks);
if (!n.length) return;
const r = Math.min(...n.map((e) => e[0]));
const i = e._zod.parse;
e._zod.parse = (n, a) => {
const o = t(n.value);
if (o > r && !a?.skipChecks && a?.direction !== "backward") {
for (const [t, r] of sizeCaps(e._zod.def.checks)) if (o > t && r._zod.def.when(n)) {
const t = n.issues.length;
r._zod.check(n);
n.issues[t].continue = false;
attachSchema(n.issues, t, e);
return n;
}
}
return i(n, a);
};
}
const arraySize = (e) => Array.isArray(e) ? e.length : -1;
const mapSize = (e) => e instanceof Map ? e.size : -1;
const setSize = (e) => e instanceof Set ? e.size : -1;
function handleArrayResult(e, t, n) {
if (e.issues.length) t.issues.push(...prefixIssues(n, e.issues));
t.value[n] = e.value;
}
const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (e, t) => {
$ZodType.init(e, t);
const n = globalConfig.memoizer;
n?.attach(e);
e._zod.parse = (r, i) => {
const a = r.value;
if (!Array.isArray(a)) {
r.issues.push({
expected: "array",
code: "invalid_type",
input: a,
inst: e
});
return r;
}
r.value = n ? n.alloc(e, r, Array(a.length), i) : Array(a.length);
const o = [];
const s = i?.abortEarly;
for (let e = 0; e < a.length; e++) {
const n = a[e];
const c = t.element._zod.run({
value: n,
issues: []
}, i);
if (c instanceof Promise) o.push(c.then((t) => handleArrayResult(t, r, e)));
else {
handleArrayResult(c, r, e);
if (s && c.issues.length !== 0 && aborted(c)) break;
}
}
if (o.length) return Promise.all(o).then(() => r);
return r;
};
capSize(e, arraySize);
});
function handlePropertyResult(e, t, n, r, i, a) {
const o = n in r;
const s = a === "optional";
if (!o && s && i === "optional") return;
if (e.issues.length) {
if (i !== void 0 && s && !o) return;
t.issues.push(...prefixIssues(n, e.issues));
}
if (!o && i === void 0) {
if (!e.issues.length) t.issues.push({
code: "invalid_type",
expected: "nonoptional",
input: void 0,
path: [n]
});
return;
}
if (e.value === void 0) {
if (o || i === "defaulted" && !s) t.value[n] = void 0;
} else t.value[n] = e.value;
}
const NO_SYMBOL_KEYS = [];
function normalizeDef(e) {
const t = Object.keys(e.shape);
const n = Object.getOwnPropertySymbols(e.shape);
const r = n.length ? n : NO_SYMBOL_KEYS;
const i = r.length ? [...t, ...r] : t;
for (const t of i) if (!e.shape?.[t]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${String(t)}": expected a Zod schema`);
const a = optionalKeys(e.shape);
return {
...e,
allKeys: i,
symbolKeys: r,
keySet: new Set(t),
numKeys: t.length,
optionalKeys: new Set(a)
};
}
function handleCatchall(e, t, n, r, i, a, o) {
const s = [];
const c = i.keySet;
const l = i.catchall._zod;
const u = l.def.type;
const d = l.optin;
const f = l.optout;
let p = 0;
for (const i in t) {
if (o && n.issues.length !== p) {
if (aborted(n, p)) break;
p = n.issues.length;
}
if (c.has(i)) continue;
if (i === "__proto__") {
if (u === "never") s.push(i);
continue;
}
if (u === "never") {
s.push(i);
continue;
}
const a = l.run({
value: t[i],
issues: []
}, r);
if (a instanceof Promise) e.push(a.then((e) => handlePropertyResult(e, n, i, t, d, f)));
else handlePropertyResult(a, n, i, t, d, f);
}
if (s.length) n.issues.push({
code: "unrecognized_keys",
keys: s,
input: t,
inst: a,
continue: true
});
if (!e.length) return n;
return Promise.all(e).then(() => {
return n;
});
}
const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (e, t) => {
$ZodType.init(e, t);
const n = Object.getOwnPropertyDescriptor(t, "shape");
const r = n?.get ? n.get.raw : t.shape ?? {};
if (r) {
const get = () => {
const e = { ...r };
Object.defineProperty(t, "shape", { value: e });
get.raw = e;
return e;
};
get.raw = r;
Object.defineProperty(t, "shape", { get });
}
const i = cached(() => normalizeDef(t));
defineLazyInternal(e, "propValues", (e) => {
const t = e.def.shape;
const n = {};
for (const e in t) {
const r = t[e]._zod;
if (r.values) {
if (!Object.prototype.hasOwnProperty.call(n, e)) assignProp(n, e, /* @__PURE__ */ new Set());
for (const t of r.values) n[e].add(t);
if (r.optin !== void 0) n[e].add(void 0);
}
}
return n;
});
const a = isObject;
const o = t.catchall;
let s;
const c = globalConfig.memoizer;
c?.attach(e);
e._zod.parse = (t, n) => {
s ?? (s = i.value);
const r = t.value;
if (!a(r)) {
t.issues.push({
expected: "object",
code: "invalid_type",
input: r,
inst: e
});
return t;
}
t.value = c ? c.alloc(e, t, {}, n) : {};
const l = [];
const u = s.shape;
const d = n?.abortEarly;
let f = t.issues.length;
for (const e of s.allKeys) {
if (d && t.issues.length !== f) {
if (aborted(t, f)) break;
f = t.issues.length;
}
if (e === "__proto__") continue;
const i = u[e];
const a = i._zod.optin;
const o = i._zod.optout;
const s = i._zod.run({
value: r[e],
issues: []
}, n);
if (s instanceof Promise) l.push(s.then((n) => handlePropertyResult(n, t, e, r, a, o)));
else handlePropertyResult(s, t, e, r, a, o);
}
if (!o) return l.length ? Promise.all(l).then(() => t) : t;
return handleCatchall(l, r, t, n, i.value, e, d === true);
};
});
const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (e, t) => {
$ZodObject.init(e, t);
const n = e._zod.parse;
const r = cached(() => normalizeDef(t));
const i = globalConfig.memoizer;
const generateFastpass = (t) => {
const n = r.value;
const a = n.symbolKeys;
const o = new Doc(["payload", "ctx"], {
shape: t,
inst: e,
memo: i,
syms: a
});
const parseStr = (e) => `shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`;
const prefixStr = (e, t) => `
let ${e}_ab = false;
for (let i = 0; i < ${e}.issues.length; i++) {
const iss = ${e}.issues[i];
iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
payload.issues.push(iss);
if (iss.continue !== true) ${e}_ab = true;
}
if (${e}_ab && ctx && ctx.abortEarly) {
payload.value = newResult;
return payload;
}`;
o.write(`const input = payload.value;`);
const s = Object.create(null);
let c = 0;
for (const e of n.allKeys) s[e] = `key_${c++}`;
o.write(i ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
for (const e of n.allKeys) {
if (e === "__proto__") continue;
const n = s[e];
const r = typeof e === "symbol" ? `syms[${a.indexOf(e)}]` : esc(e);
const i = `${r} in input`;
const c = t[e];
const l = c?._zod?.optin;
const u = l !== void 0;
const d = c?._zod?.optout === "optional";
o.write(`const ${n} = ${parseStr(r)};`);
if (u && d) {
const e = l === "optional" ? `${n}_present` : `${n}.value !== undefined || ${n}_present`;
o.write(`
const ${n}_present = ${i};
if (!${n}.issues.length || ${n}_present) {
if (${n}.issues.length) {${prefixStr(n, r)}
}
if (${e}) {
newResult[${r}] = ${n}.value;
}
}
`);
} else if (!u) o.write(`
const ${n}_present = ${i};
if (${n}.issues.length) {${prefixStr(n, r)}
}
if (!${n}_present && !${n}.issues.length) {
payload.issues.push({
code: "invalid_type",
expected: "nonoptional",
input: undefined,
path: [${r}]
});
if (ctx && ctx.abortEarly) {
payload.value = newResult;
return payload;
}
}
if (${n}_present) {
newResult[${r}] = ${n}.value;
}
`);
else {
o.write(`
if (${n}.issues.length) {${prefixStr(n, r)}
}
`);
if (l === "defaulted") o.write(`newResult[${r}] = ${n}.value;`);
else o.write(`
if (${n}.value !== undefined || ${i}) {
newResult[${r}] = ${n}.value;
}
`);
}
}
o.write(`payload.value = newResult;`);
o.write(`return payload;`);
return o.compile();
};
let a;
const o = isObject;
const s = !globalConfig.jitless;
const c = allowsEval;
const l = s && c.value;
const u = t.catchall;
let d;
e._zod.parse = (i, c) => {
d ?? (d = r.value);
const f = i.value;
if (!o(f)) {
i.issues.push({
expected: "object",
code: "invalid_type",
input: f,
inst: e
});
return i;
}
if (s && l && c?.async === false && c.jitless !== true) {
if (!a) a = generateFastpass(t.shape);
i = a(i, c);
if (!u) return i;
return handleCatchall([], f, i, c, d, e, c?.abortEarly === true);
}
return n(i, c);
};
});
function handleUnionResults(e, t, n, r) {
for (const n of e) if (n.issues.length === 0) {
t.value = n.value;
return t;
}
const i = e.filter((e) => !aborted(e));
if (i.length === 1) {
t.value = i[0].value;
return i[0];
}
t.issues.push({
code: "invalid_union",
input: t.value,
inst: n,
errors: e.map((e) => e.issues.map((e) => finalizeIssue(e, r, config())))
});
return t;
}
const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (e, t) => {
$ZodType.init(e, t);
defineLazyInternal(e, "optin", (e) => e.def.options.some((e) => e._zod.optin === "defaulted") ? "defaulted" : e.def.options.some((e) => e._zod.optin !== void 0) ? "optional" : void 0);
defineLazyInternal(e, "optout", (e) => e.def.options.some((e) => e._zod.optout === "optional") ? "optional" : void 0);
defineLazyInternal(e, "values", (e) => {
if (e.def.options.every((e) => e._zod.values)) return new Set(e.def.options.flatMap((e) => Array.from(e._zod.values)));
});
defineLazyInternal(e, "pattern", (e) => {
if (e.def.options.every((e) => e._zod.pattern)) {
const t = e.def.options.map((e) => e._zod.pattern);
return new RegExp(`^(${t.map((e) => cleanRegex(e.source)).join("|")})$`);
}
});
const n = t.options.length === 1 ? t.options[0]._zod.run : null;
e._zod.parse = (r, i) => {
if (n) return n(r, i);
let a = false;
const o = [];
for (const e of t.options) {
const t = e._zod.run({
value: r.value,
issues: []
}, i);
if (t instanceof Promise) {
o.push(t);
a = true;
} else {
if (t.issues.length === 0) return t;
o.push(t);
}
}
if (!a) return handleUnionResults(o, r, e, i);
return Promise.all(o).then((t) => {
return handleUnionResults(t, r, e, i);
});
};
});
function handleExclusiveUnionResults(e, t, n, r) {
const i = [];
for (let t = 0; t < e.length; t++) if (e[t].issues.length === 0) i.push(t);
if (i.length === 1) {
t.value = e[i[0]].value;
return t;
}
if (i.length === 0) t.issues.push({
code: "invalid_union",
input: t.value,
inst: n,
errors: e.map((e) => e.issues.map((e) => finalizeIssue(e, r, config())))
});
else t.issues.push({
code: "invalid_union",
input: t.value,
inst: n,
errors: [],
inclusive: false,
matches: i
});
return t;
}
const $ZodXor = /*@__PURE__*/ $constructor("$ZodXor", (e, t) => {
$ZodUnion.init(e, t);
t.inclusive = false;
const n = t.options.length === 1 ? t.options[0]._zod.run : null;
e._zod.parse = (r, i) => {
if (n) return n(r, i);
let a = false;
const o = [];
for (const e of t.options) {
const t = e._zod.run({
value: r.value,
issues: []
}, i);
if (t instanceof Promise) {
o.push(t);
a = true;
} else o.push(t);
}
if (!a) return handleExclusiveUnionResults(o, r, e, i);
return Promise.all(o).then((t) => {
return handleExclusiveUnionResults(t, r, e, i);
});
};
});
/** Returns the option whose discriminator claims `value`, or throws if ambiguous. */
function getDiscriminatedOption(e, t) {
const n = e._zod;
let r = n.bag.optionsMap;
if (!r) {
r = discriminatorMap(n.def);
n.bag.optionsMap = r;
}
const i = r.get(t);
if (i === null) throw new Error(`Ambiguous discriminator value "${String(t)}"`);
return i;
}
function discriminatorMap(e) {
const t = /* @__PURE__ */ new Map();
for (const n of e.options) {
const r = n._zod.propValues?.[e.discriminator];
if (!r || r.size === 0) throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);
for (const e of r) if (t.has(e)) {
if (e !== void 0) throw new Error(`Duplicate discriminator value "${String(e)}"`);
t.set(e, null);
} else t.set(e, n);
}
return t;
}
const $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion", (e, t) => {
t.inclusive = false;
$ZodUnion.init(e, t);
const n = e._zod.parse;
defineLazyInternal(e, "propValues", (e) => {
const t = {};
let n = 0;
for (const r of e.def.options) {
const i = r._zod.propValues;
if (!i || Object.keys(i).length === 0) throw new Error(`Invalid discriminated union option at index "${e.def.options.indexOf(r)}"`);
if (i[e.def.discriminator]?.has(void 0)) n++;
for (const [e, n] of Object.entries(i)) {
if (!Object.prototype.hasOwnProperty.call(t, e)) assignProp(t, e, /* @__PURE__ */ new Set());
for (const r of n) t[e].add(r);
}
}
if (!e.def.unionFallback && n > 1) t[e.def.discriminator]?.delete(void 0);
return t;
});
t.options.forEach((e, n) => {
const r = rawShape(e._zod.def);
if (r && !Object.prototype.hasOwnProperty.call(r, t.discriminator)) throw new Error(`Invalid discriminated union option at index "${n}"`);
});
const r = cached(() => discriminatorMap(t));
e._zod.parse = (i, a) => {
const o = i.value;
if (!isObject(o)) {
i.issues.push({
code: "invalid_type",
expected: "object",
input: o,
inst: e
});
return i;
}
const s = o?.[t.discriminator];
const c = r.value.get(s);
if (c && (s !== void 0 || a.direction !== "backward")) return c._zod.run(i, a);
if (t.unionFallback || a.direction === "backward") return n(i, a);
i.issues.push({
code: "invalid_union",
errors: [],
note: "No matching discriminator",
discriminator: t.discriminator,
options: Array.from(r.value.keys()).filter((e) => r.value.get(e) !== null),
input: o,
path: [t.discriminator],
inst: e
});
return i;
};
});
const $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (e, t) => {
$ZodType.init(e, t);
e._zod.parse = (e, n) => {
const r = e.value;
const i = t.left._zod.run({
value: r,
issues: []
}, n);
const a = t.right._zod.run({
value: r,
issues: []
}, n);
if (i instanceof Promise || a instanceof Promise) return Promise.all([i, a]).then(([t, n]) => {
return handleIntersectionResults(e, t, n);
});
return handleIntersectionResults(e, i, a);
};
});
function mergeValues(e, t) {
if (e === t) return {
valid: true,
data: e
};
if (e instanceof Date && t instanceof Date && +e === +t) return {
valid: true,
data: e
};
if (isPlainObject(e) && isPlainObject(t)) {
const n = Object.keys(t);
const r = Object.keys(e).filter((e) => n.indexOf(e) !== -1);
const i = {
...e,
...t
};
if (Object.prototype.hasOwnProperty.call(i, "__proto__")) delete i.__proto__;
for (const n of r) {
if (n === "__proto__") continue;
const r = mergeValues(e[n], t[n]);
if (!r.valid) return {
valid: false,
mergeErrorPath: [n, ...r.mergeErrorPath]
};
i[n] = r.data;
}
return {
valid: true,
data: i
};
}
if (Array.isArray(e) && Array.isArray(t)) {
if (e.length !== t.length) return {
valid: false,
mergeErrorPath: []
};
const n = [];
for (let r = 0; r < e.length; r++) {
const i = e[r];
const a = t[r];
const o = mergeValues(i, a);
if (!o.valid) return {
valid: false,
mergeErrorPath: [r, ...o.mergeErrorPath]
};
n.push(o.data);
}
return {
valid: true,
data: n
};
}
return {
valid: false,
mergeErrorPath: []
};
}
function handleIntersectionResults(e, t, n) {
const r = /* @__PURE__ */ new Map();
let i;
const a = /* @__PURE__ */ new Map();
const collect = (e, t) => {
let n;
if (e.code === "unrecognized_keys" && !e.path?.length) {
i ?? (i = e);
n = e.keys;
} else if (e.code === "invalid_key" && e.origin === "record" && e.path?.length === 1) {
const t = String(e.path[0]);
if (!a.has(t)) a.set(t, e);
n = [t];
} else return false;
for (const e of n) {
if (!r.has(e)) r.set(e, {});
r.get(e)[t] = true;
}
return true;
};
for (const n of t.issues) if (!collect(n, "l")) e.issues.push(n);
for (const t of n.issues) if (!collect(t, "r")) e.issues.push(t);
const o = [...r].filter(([, e]) => e.l && e.r).map(([e]) => e);
if (o.length) {
const t = i ? o.filter((e) => i.keys.includes(e)) : [];
if (t.length) e.issues.push({
...i,
keys: t
});
for (const n of o) if (!t.includes(n) && a.has(n)) e.issues.push(a.get(n));
}
const s = mergeValues(t.value, n.value);
if (!s.valid) {
if (aborted(e)) return e;
throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);
}
e.value = s.data;
return e;
}
const $ZodTuple = /*@__PURE__*/ $constructor("$ZodTuple", (e, t) => {
$ZodType.init(e, t);
const n = t.items;
const r = globalConfig.memoizer;
r?.attach(e);
e._zod.parse = (i, a) => {
const o = i.value;
if (!Array.isArray(o)) {
i.issues.push({
input: o,
inst: e,
expected: "tuple",
code: "invalid_type"
});
return i;
}
i.value = r ? r.alloc(e, i, [], a) : [];
const s = [];
const c = getTupleOptStart(n, "optin");
const l = getTupleOptStart(n, "optout");
if (!t.rest) {
if (o.length < c) {
i.issues.push({
code: "too_small",
minimum: c,
inclusive: true,
input: o,
inst: e,
origin: "array"
});
return i;
}
if (o.length > n.length) i.issues.push({
code: "too_big",
maximum: n.length,
inclusive: true,
input: o,
inst: e,
origin: "array"
});
}
const u = new Array(n.length);
const d = t.rest ? a?.abortEarly : void 0;
let f = false;
for (let e = 0; e < n.length; e++) {
const t = n[e]._zod.run({
value: o[e],
issues: []
}, a);
if (t instanceof Promise) s.push(t.then((t) => {
u[e] = t;
}));
else {
u[e] = t;
if (d && !f && t.issues.length) f = aborted(t);
}
}
if (t.rest && !f) {
let e = n.length - 1;
const r = o.slice(n.length);
let c = i.issues.length;
for (const n of r) {
if (d && i.issues.length !== c) {
if (aborted(i, c)) break;
c = i.issues.length;
}
e++;
const r = t.rest._zod.run({
value: n,
issues: []
}, a);
if (r instanceof Promise) s.push(r.then((t) => handleTupleResult(t, i, e)));
else handleTupleResult(r, i, e);
}
}
if (s.length) return Promise.all(s).then(() => handleTupleResults(u, i, n, o, l));
return handleTupleResults(u, i, n, o, l);
};
});
function getTupleOptStart(e, t) {
for (let n = e.length - 1; n >= 0; n--) if (!(t === "optin" ? e[n]._zod.optin !== void 0 : e[n]._zod.optout === "optional")) return n + 1;
return 0;
}
function handleTupleResult(e, t, n) {
if (e.issues.length) t.issues.push(...prefixIssues(n, e.issues));
t.value[n] = e.value;
}
function handleTupleResults(e, t, n, r, i) {
for (let a = 0; a < n.length; a++) {
const o = e[a];
const s = a < r.length;
if (!s && a >= i && n[a]._zod.optin === "optional") {
t.value.length = a;
break;
}
if (o.issues.length) {
if (!s && a >= i) {
t.value.length = a;
break;
}
t.issues.push(...prefixIssues(a, o.issues));
}
t.value[a] = o.value;
}
for (let e = t.value.length - 1; e >= r.length; e--) if (n[e]._zod.optout === "optional" && t.value[e] === void 0) t.value.length = e;
else break;
return t;
}
const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (e, t) => {
$ZodType.init(e, t);
const n = globalConfig.memoizer;
n?.attach(e);
e._zod.parse = (r, i) => {
const a = r.value;
if (!isPlainObject(a)) {
r.issues.push({
expected: "record",
code: "invalid_type",
input: a,
inst: e
});
return r;
}
const o = [];
const s = t.keyType._zod.values;
if (s && !t.partial) {
r.value = n ? n.alloc(e, r, {}, i) : {};
const c = /* @__PURE__ */ new Set();
for (const n of s) if (typeof n === "string" || typeof n === "number" || typeof n === "symbol") {
c.add(typeof n === "number" ? n.toString() : n);
if (n === "__proto__") continue;
const s = t.keyType._zod.run({
value: n,
issues: []
}, i);
if (s instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
if (s.issues.length) {
r.issues.push({
code: "invalid_key",
origin: "record",
issues: s.issues.map((e) => finalizeIssue(e, i, config())),
input: n,
path: [n],
inst: e
});
continue;
}
const l = s.value;
if (l === "__proto__") continue;
const u = t.valueType._zod.run({
value: a[n],
issues: []
}, i);
if (u instanceof Promise) o.push(u.then((e) => {
if (e.issues.length) r.issues.push(...prefixIssues(n, e.issues));
r.value[l] = e.value;
}));
else {
if (u.issues.length) r.issues.push(...prefixIssues(n, u.issues));
r.value[l] = u.value;
}
}
let l;
for (const e in a) if (!c.has(e)) {
if (t.mode === "loose") {
if (e === "__proto__") continue;
r.value[e] = a[e];
} else {
l = l ?? [];
l.push(e);
}
}
if (l && l.length > 0) r.issues.push({
code: "unrecognized_keys",
input: a,
inst: e,
keys: l,
continue: true
});
} else {
r.value = n ? n.alloc(e, r, {}, i) : {};
let c;
for (const n of Reflect.ownKeys(a)) {
if (n === "__proto__") continue;
if (!Object.prototype.propertyIsEnumerable.call(a, n)) continue;
let l = t.keyType._zod.run({
value: n,
issues: []
}, i);
if (l instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
if (typeof n === "string" && number.test(n) && l.issues.length) {
const e = t.keyType._zod.run({
value: Number(n),
issues: []
}, i);
if (e instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
if (e.issues.length === 0) l = e;
}
if (l.issues.length) {
if (t.mode === "loose") r.value[n] = a[n];
else if (s) {
c = c ?? [];
c.push(n);
} else r.issues.push({
code: "invalid_key",
origin: "record",
issues: l.issues.map((e) => finalizeIssue(e, i, config())),
input: n,
path: [n],
inst: e
});
continue;
}
const u = l.value;
if (u === "__proto__") continue;
const d = t.valueType._zod.run({
value: a[n],
issues: []
}, i);
if (d instanceof Promise) o.push(d.then((e) => {
if (e.issues.length) r.issues.push(...prefixIssues(n, e.issues));
r.value[u] = e.value;
}));
else {
if (d.issues.length) r.issues.push(...prefixIssues(n, d.issues));
r.value[u] = d.value;
}
}
if (c && c.length > 0) r.issues.push({
code: "unrecognized_keys",
input: a,
inst: e,
keys: c,
continue: true
});
}
if (o.length) return Promise.all(o).then(() => r);
return r;
};
});
const $ZodMap = /*@__PURE__*/ $constructor("$ZodMap", (e, t) => {
$ZodType.init(e, t);
const n = globalConfig.memoizer;
n?.attach(e);
e._zod.parse = (r, i) => {
const a = r.value;
if (!(a instanceof Map)) {
r.issues.push({
expected: "map",
code: "invalid_type",
input: a,
inst: e
});
return r;
}
const o = [];
r.value = n ? n.alloc(e, r, /* @__PURE__ */ new Map(), i) : /* @__PURE__ */ new Map();
const s = i?.abortEarly;
let c = r.issues.length;
for (const [n, l] of a) {
if (s && r.issues.length !== c) {
if (aborted(r, c)) break;
c = r.issues.length;
}
const u = t.keyType._zod.run({
value: n,
issues: []
}, i);
const d = t.valueType._zod.run({
value: l,
issues: []
}, i);
if (u instanceof Promise || d instanceof Promise) o.push(Promise.all([u, d]).then(([t, o]) => {
handleMapResult(t, o, r, n, a, e, i);
}));
else handleMapResult(u, d, r, n, a, e, i);
}
if (o.length) return Promise.all(o).then(() => r);
return r;
};
capSize(e, mapSize);
});
function handleMapResult(e, t, n, r, i, a, o) {
if (e.issues.length) {
if (propertyKeyTypes.has(typeof r)) n.issues.push(...prefixIssues(r, e.issues));
else n.issues.push({
code: "invalid_key",
origin: "map",
input: i,
inst: a,
issues: e.issues.map((e) => finalizeIssue(e, o, config()))
});
}
if (t.issues.length) {
if (propertyKeyTypes.has(typeof r)) n.issues.push(...prefixIssues(r, t.issues));
else n.issues.push({
origin: "map",
code: "invalid_element",
input: i,
inst: a,
key: r,
issues: t.issues.map((e) => finalizeIssue(e, o, config()))
});
}
n.value.set(e.value, t.value);
}
const $ZodSet = /*@__PURE__*/ $constructor("$ZodSet", (e, t) => {
$ZodType.init(e, t);
const n = globalConfig.memoizer;
n?.attach(e);
e._zod.parse = (r, i) => {
const a = r.value;
if (!(a instanceof Set)) {
r.issues.push({
input: a,
inst: e,
expected: "set",
code: "invalid_type"
});
return r;
}
const o = [];
r.value = n ? n.alloc(e, r, /* @__PURE__ */ new Set(), i) : /* @__PURE__ */ new Set();
const s = i?.abortEarly;
let c = r.issues.length;
for (const e of a) {
if (s && r.issues.length !== c) {
if (aborted(r, c)) break;
c = r.issues.length;
}
const n = t.valueType._zod.run({
value: e,
issues: []
}, i);
if (n instanceof Promise) o.push(n.then((e) => handleSetResult(e, r)));
else handleSetResult(n, r);
}
if (o.length) return Promise.all(o).then(() => r);
return r;
};
capSize(e, setSize);
});
function handleSetResult(e, t) {
if (e.issues.length) t.issues.push(...e.issues);
t.value.add(e.value);
}
const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (e, t) => {
$ZodType.init(e, t);
const n = getEnumValues(t.entries);
const r = new Set(n);
e._zod.values = r;
defineLazyInternal(e, "pattern", (e) => {
const t = getEnumValues(e.def.entries).filter((e) => propertyKeyTypes.has(typeof e));
return new RegExp(t.length ? `^(${t.map((e) => escapeRegex(e.toString())).join("|")})$` : "^[^\\s\\S]$");
});
e._zod.parse = (t, i) => {
const a = t.value;
if (r.has(a)) return t;
t.issues.push({
code: "invalid_value",
values: n,
input: a,
inst: e
});
return t;
};
});
const $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (e, t) => {
$ZodType.init(e, t);
const n = new Set(t.values);
e._zod.values = n;
defineLazyInternal(e, "pattern", (e) => {
const t = e.def.values;
return new RegExp(t.length ? `^(${t.map((e) => typeof e === "string" ? escapeRegex(e) : e ? escapeRegex(e.toString()) : String(e)).join("|")})$` : "^[^\\s\\S]$");
});
e._zod.parse = (r, i) => {
const a = r.value;
if (n.has(a)) return r;
r.issues.push({
code: "invalid_value",
values: t.values,
input: a,
inst: e
});
return r;
};
});
const $ZodFile = /*@__PURE__*/ $constructor("$ZodFile", (e, t) => {
$ZodType.init(e, t);
e._zod.parse = (t, n) => {
const r = t.value;
if (r instanceof File) return t;
t.issues.push({
expected: "file",
code: "invalid_type",
input: r,
inst: e
});
return t;
};
});
const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (e, t) => {
$ZodType.init(e, t);
e._zod.optin = "optional";
globalConfig.memoizer?.guard(e);
e._zod.parse = (n, r) => {
if (r.direction === "backward") throw new $ZodEncodeError(e.constructor.name);
const i = t.transform(n.value, n);
if (r.async) return (i instanceof Promise ? i : Promise.resolve(i)).then((e) => {
n.value = e;
return n;
});
if (i instanceof Promise) throw new $ZodAsyncError();
n.value = i;
return n;
};
});
function handleOptionalResult(e, t) {
e.value = t.issues.length ? void 0 : t.value;
return e;
}
const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (e, t) => {
$ZodType.init(e, t);
defineLazyInternal(e, "optin", (e) => e.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
e._zod.optout = "optional";
defineLazyInternal(e, "values", (e) => {
const t = e.def.innerType._zod.values;
return t ? /* @__PURE__ */ new Set([...t, void 0]) : void 0;
});
defineLazyInternal(e, "pattern", (e) => {
const t = e.def.innerType._zod.pattern;
return t ? new RegExp(`^(${cleanRegex(t.source)})?$`) : void 0;
});
e._zod.parse = (e, n) => {
if (e.value === void 0) {
if (t.innerType._zod.optin !== "defaulted") return e;
const r = t.innerType._zod.run({
value: e.value,
issues: []
}, n);
if (r instanceof Promise) return r.then((t) => handleOptionalResult(e, t));
return handleOptionalResult(e, r);
}
return t.innerType._zod.run(e, n);
};
});
const $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (e, t) => {
$ZodOptional.init(e, t);
defineLazyInternal(e, "values", (e) => e.def.innerType._zod.values);
defineLazyInternal(e, "pattern", (e) => e.def.innerType._zod.pattern);
e._zod.parse = (e, n) => {
return t.innerType._zod.run(e, n);
};
});
const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (e, t) => {
$ZodType.init(e, t);
defineLazyInternal(e, "optin", (e) => e.def.innerType._zod.optin);
defineLazyInternal(e, "optout", (e) => e.def.innerType._zod.optout);
defineLazyInternal(e, "pattern", (e) => {
const t = e.def.innerType._zod.pattern;
return t ? new RegExp(`^(${cleanRegex(t.source)}|null)$`) : void 0;
});
defineLazyInternal(e, "values", (e) => {
return e.def.innerType._zod.values ? /* @__PURE__ */ new Set([...e.def.innerType._zod.values, null]) : void 0;
});
e._zod.parse = (e, n) => {
if (e.value === null) return e;
return t.innerType._zod.run(e, n);
};
});
const $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (e, t) => {
$ZodType.init(e, t);
e._zod.optin = "defaulted";
defineLazyInternal(e, "values", (e) => e.def.innerType._zod.values);
e._zod.parse = (e, n) => {
if (n.direction === "backward") return t.innerType._zod.run(e, n);
if (e.value === void 0) {
e.value = t.defaultValue;
/**
* $ZodDefault returns the default value immediately in forward direction.
* It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
return e;
}
const r = t.innerType._zod.run(e, n);
if (r instanceof Promise) return r.then((e) => handleDefaultResult(e, t));
return handleDefaultResult(r, t);
};
});
function handleDefaultResult(e, t) {
if (e.value === void 0) e.value = t.defaultValue;
return e;
}
const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (e, t) => {
$ZodType.init(e, t);
e._zod.optin = "defaulted";
defineLazyInternal(e, "values", (e) => e.def.innerType._zod.values);
e._zod.parse = (e, n) => {
if (n.direction === "backward") return t.innerType._zod.run(e, n);
if (e.value === void 0) e.value = t.defaultValue;
return t.innerType._zod.run(e, n);
};
});
const $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (e, t) => {
$ZodType.init(e, t);
defineLazyInternal(e, "values", (e) => {
const t = e.def.innerType._zod.values;
return t ? new Set([...t].filter((e) => e !== void 0)) : void 0;
});
e._zod.parse = (n, r) => {
const i = t.innerType._zod.run(n, r);
if (i instanceof Promise) return i.then((t) => handleNonOptionalResult(t, e));
return handleNonOptionalResult(i, e);
};
});
function handleNonOptionalResult(e, t) {
if (!e.issues.length && e.value === void 0) e.issues.push({
code: "invalid_type",
expected: "nonoptional",
input: e.value,
inst: t
});
return e;
}
const $ZodSuccess = /*@__PURE__*/ $constructor("$ZodSuccess", (e, t) => {
$ZodType.init(e, t);
e._zod.parse = (e, n) => {
if (n.direction === "backward") throw new $ZodEncodeError("ZodSuccess");
const r = t.innerType._zod.run(e, n);
if (r instanceof Promise) return r.then((t) => {
e.value = t.issues.length === 0;
return e;
});
e.value = r.issues.length === 0;
return e;
};
});
function handleCatchResult(e, t, n, r) {
if (!t.issues.length) {
e.value = t.value;
if (t.memo) e.memo = true;
return e;
}
e.value = n.catchValue({
...t,
value: e.value,
error: { issues: t.issues.map((e) => finalizeIssue(e, r, config())) },
input: e.value
});
return e;
}
const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (e, t) => {
$ZodType.init(e, t);
defineLazyInternal(e, "optin", (e) => e.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
defineLazyInternal(e, "optout", (e) => e.def.innerType._zod.optout);
defineLazyInternal(e, "values", (e) => e.def.innerType._zod.values);
e._zod.parse = (e, n) => {
if (n.direction === "backward") return t.innerType._zod.run(e, n);
const r = t.innerType._zod.run({
value: e.value,
issues: []
}, n);
if (r instanceof Promise) return r.then((r) => handleCatchResult(e, r, t, n));
return handleCatchResult(e, r, t, n);
};
});
const $ZodNaN = /*@__PURE__*/ $constructor("$ZodNaN", (e, t) => {
$ZodType.init(e, t);
e._zod.parse = (t, n) => {
if (typeof t.value !== "number" || !Number.isNaN(t.value)) {
t.issues.push({
input: t.value,
inst: e,
expected: "nan",
code: "invalid_type"
});
return t;
}
return t;
};
});
const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (e, t) => {
$ZodType.init(e, t);
defineLazyInternal(e, "values", (e) => e.def.in._zod.values);
defineLazyInternal(e, "optin", (e) => e.def.in._zod.optin);
defineLazyInternal(e, "optout", (e) => e.def.out._zod.optout);
defineLazyInternal(e, "propValues", (e) => e.def.in._zod.propValues);
e._zod.parse = (e, n) => {
if (n.direction === "backward") {
const r = t.out._zod.run(e, n);
if (r instanceof Promise) return r.then((e) => handlePipeResult(e, t.in, n));
return handlePipeResult(r, t.in, n);
}
const r = t.in._zod.run(e, n);
if (r instanceof Promise) return r.then((e) => handlePipeResult(e, t.out, n));
return handlePipeResult(r, t.out, n);
};
});
function handlePipeResult(e, t, n) {
if (e.issues.some((e) => e.code !== "unrecognized_keys")) {
e.aborted = true;
return e;
}
return t._zod.run({
value: e.value,
issues: e.issues
}, n);
}
const $ZodCodec = /*@__PURE__*/ $constructor("$ZodCodec", (e, t) => {
$ZodType.init(e, t);
defineLazyInternal(e, "values", (e) => e.def.in._zod.values);
defineLazyInternal(e, "optin", (e) => e.def.in._zod.optin);
defineLazyInternal(e, "optout", (e) => e.def.out._zod.optout);
defineLazyInternal(e, "propValues", (e) => e.def.in._zod.propValues);
e._zod.parse = (e, n) => {
if ((n.direction || "forward") === "forward") {
const r = t.in._zod.run(e, n);
if (r instanceof Promise) return r.then((e) => handleCodecAResult(e, t, n));
return handleCodecAResult(r, t, n);
} else {
const r = t.out._zod.run(e, n);
if (r instanceof Promise) return r.then((e) => handleCodecAResult(e, t, n));
return handleCodecAResult(r, t, n);
}
};
});
function handleCodecAResult(e, t, n) {
if (e.issues.length) {
e.aborted = true;
return e;
}
if ((n.direction || "forward") === "forward") {
const r = t.transform(e.value, e);
if (r instanceof Promise) return r.then((r) => handleCodecTxResult(e, r, t.out, n));
return handleCodecTxResult(e, r, t.out, n);
} else {
const r = t.reverseTransform(e.value, e);
if (r instanceof Promise) return r.then((r) => handleCodecTxResult(e, r, t.in, n));
return handleCodecTxResult(e, r, t.in, n);
}
}
function handleCodecTxResult(e, t, n, r) {
if (e.issues.length) {
e.aborted = true;
return e;
}
return n._zod.run({
value: t,
issues: e.issues
}, r);
}
const $ZodPreprocess = /*@__PURE__*/ $constructor("$ZodPreprocess", (e, t) => {
$ZodPipe.init(e, t);
});
const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (e, t) => {
$ZodType.init(e, t);
defineLazyInternal(e, "propValues", (e) => e.def.innerType._zod.propValues);
defineLazyInternal(e, "values", (e) => e.def.innerType._zod.values);
defineLazyInternal(e, "optin", (e) => e.def.innerType?._zod?.optin);
defineLazyInternal(e, "optout", (e) => e.def.innerType?._zod?.optout);
e._zod.parse = (e, n) => {
if (n.direction === "backward") return t.innerType._zod.run(e, n);
const r = t.innerType._zod.run(e, n);
if (r instanceof Promise) return r.then(handleReadonlyResult);
return handleReadonlyResult(r);
};
});
function handleReadonlyResult(e) {
if (!e.memo) e.value = Object.freeze(e.value);
return e;
}
function leafPattern(e) {
const t = e._zod.def;
let n = t.pattern;
let r = !!t.format?.includes("int");
let i;
let a;
for (const e of t.checks ?? []) {
const t = e._zod.def;
if (t.pattern) n = t.pattern;
r || (r = !!t.format?.includes("int"));
const o = t.minimum ?? t.length;
const s = t.maximum ?? t.length;
if (o !== void 0 && (i === void 0 || o > i)) i = o;
if (s !== void 0 && (a === void 0 || s < a)) a = s;
}
if (n) return n.source;
if (i !== void 0 && a !== void 0 && i > a) return "(?!)";
if (i !== void 0 || a !== void 0) return string({
minimum: i,
maximum: a
}).source;
const o = e._zod.pattern;
return (r && o === number ? integer : o)?.source;
}
function partPattern(e) {
const t = e._zod.def;
const n = e._zod.pattern?.source;
const r = t.innerType ?? e._zod.innerType;
if (r) {
const e = r._zod.pattern?.source;
const t = partPattern(r);
if (n && e && t && t !== e) return n.replace(cleanRegex(e), () => cleanRegex(t));
return n;
}
if (t.options) {
const e = t.options.map(partPattern);
if (e.every(Boolean)) return `^(${e.map((e) => cleanRegex(e)).join("|")})$`;
}
return leafPattern(e);
}
const $ZodTemplateLiteral = /*@__PURE__*/ $constructor("$ZodTemplateLiteral", (e, t) => {
$ZodType.init(e, t);
const n = [];
for (const e of t.parts) if (typeof e === "object" && e !== null) {
const t = partPattern(e);
if (!t) throw new Error(`Invalid template literal part, no pattern found: ${[...e._zod.traits].shift()}`);
n.push(cleanRegex(t));
} else if (e === null || primitiveTypes.has(typeof e)) n.push(escapeRegex(`${e}`));
else throw new Error(`Invalid template literal part: ${e}`);
e._zod.pattern = new RegExp(`^${n.join("")}$`);
e._zod.parse = (n, r) => {
if (typeof n.value !== "string") {
n.issues.push({
input: n.value,
inst: e,
expected: "string",
code: "invalid_type"
});
return n;
}
e._zod.pattern.lastIndex = 0;
if (!e._zod.pattern.test(n.value)) {
n.issues.push({
input: n.value,
inst: e,
code: "invalid_format",
format: t.format ?? "template_literal",
pattern: e._zod.pattern.source
});
return n;
}
return n;
};
});
const $ZodFunction = /*@__PURE__*/ $constructor("$ZodFunction", (e, t) => {
$ZodType.init(e, t);
Object.defineProperty(e, "_def", { value: t });
e._zod.def = t;
e.implement = (t) => {
if (typeof t !== "function") throw new Error("implement() must be called with a function");
return Object.defineProperty(function(...n) {
const r = e._def.input ? parse(e._def.input, n) : n;
const i = Reflect.apply(t, this, r);
if (e._def.output) return parse(e._def.output, i);
return i;
}, "_zod", {
value: e._zod,
enumerable: false
});
};
e.implementAsync = (t) => {
if (typeof t !== "function") throw new Error("implementAsync() must be called with a function");
return Object.defineProperty(async function(...n) {
const r = e._def.input ? await parseAsync(e._def.input, n) : n;
const i = await Reflect.apply(t, this, r);
if (e._def.output) return await parseAsync(e._def.output, i);
return i;
}, "_zod", {
value: e._zod,
enumerable: false
});
};
e._zod.parse = (t, n) => {
if (typeof t.value !== "function") {
t.issues.push({
code: "invalid_type",
expected: "function",
input: t.value,
inst: e
});
return t;
}
if (e._def.output && e._def.output._zod.def.type === "promise") t.value = e.implementAsync(t.value);
else t.value = e.implement(t.value);
return t;
};
e.input = (...t) => {
const n = e.constructor;
if (Array.isArray(t[0])) return new n({
type: "function",
input: new $ZodTuple({
type: "tuple",
items: t[0],
rest: t[1]
}),
output: e._def.output
});
return new n({
type: "function",
input: t[0],
output: e._def.output
});
};
e.output = (t) => {
const n = e.constructor;
return new n({
type: "function",
input: e._def.input,
output: t
});
};
return e;
});
const $ZodPromise = /*@__PURE__*/ $constructor("$ZodPromise", (e, t) => {
$ZodType.init(e, t);
e._zod.parse = (e, n) => {
return Promise.resolve(e.value).then((e) => t.innerType._zod.run({
value: e,
issues: []
}, n));
};
});
const $ZodLazy = /*@__PURE__*/ $constructor("$ZodLazy", (e, t) => {
$ZodType.init(e, t);
defineLazy(e._zod, "innerType", () => {
const e = t;
if (!e._cachedInner) e._cachedInner = t.getter();
return e._cachedInner;
});
defineLazyInternal(e, "pattern", (e) => e.innerType?._zod?.pattern);
defineLazyInternal(e, "propValues", (e) => e.innerType?._zod?.propValues);
defineLazyInternal(e, "optin", (e) => e.innerType?._zod?.optin ?? void 0);
defineLazyInternal(e, "optout", (e) => e.innerType?._zod?.optout ?? void 0);
e._zod.parse = (t, n) => {
return e._zod.innerType._zod.run(t, n);
};
});
const $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (e, t) => {
$ZodCheck.init(e, t);
$ZodType.init(e, t);
e._zod.parse = (e, t) => {
return e;
};
e._zod.check = (n) => {
const r = n.value;
const i = t.fn(r);
if (i instanceof Promise) return i.then((t) => handleRefineResult(t, n, r, e));
handleRefineResult(i, n, r, e);
};
});
function handleRefineResult(e, t, n, r) {
if (!e) {
const e = {
code: "custom",
input: n,
inst: r,
path: [...r._zod.def.path ?? []],
continue: !r._zod.def.abort
};
if (r._zod.def.params) e.params = r._zod.def.params;
t.issues.push(issue(e));
}
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/registries.js
var _a;
const $output = /*@__PURE__*/ Symbol("ZodOutput");
const $input = /*@__PURE__*/ Symbol("ZodInput");
var $ZodRegistry = class {
constructor() {
this._map = /* @__PURE__ */ new WeakMap();
this._idmap = /* @__PURE__ */ new Map();
}
add(e, ...t) {
const n = t[0];
this._map.set(e, n);
if (n && typeof n === "object" && "id" in n) this._idmap.set(n.id, e);
return this;
}
clear() {
this._map = /* @__PURE__ */ new WeakMap();
this._idmap = /* @__PURE__ */ new Map();
return this;
}
remove(e) {
const t = this._map.get(e);
if (t && typeof t === "object" && "id" in t) this._idmap.delete(t.id);
this._map.delete(e);
return this;
}
get(e) {
const t = e._zod.parent;
if (t) {
const n = { ...this.get(t) ?? {} };
delete n.id;
const r = {
...n,
...this._map.get(e)
};
return Object.keys(r).length ? r : void 0;
}
return this._map.get(e);
}
has(e) {
return this._map.has(e);
}
};
function registry() {
return new $ZodRegistry();
}
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
const globalRegistry = globalThis.__zod_globalRegistry;
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/to-json-schema.js
function assignProps(e, ...t) {
for (const n of t) for (const t of Reflect.ownKeys(n)) if (Object.prototype.propertyIsEnumerable.call(n, t)) assignProp(e, t, n[t]);
return e;
}
function initializeContext(e) {
let t = e?.target ?? "draft-2020-12";
if (t === "draft-4") t = "draft-04";
if (t === "draft-7") t = "draft-07";
return {
processors: e.processors ?? {},
metadataRegistry: e?.metadata ?? globalRegistry,
target: t,
unrepresentable: e?.unrepresentable ?? "throw",
override: e?.override ?? (() => {}),
io: e?.io ?? "output",
counter: 0,
seen: /* @__PURE__ */ new Map(),
sharedDefsExtractedFor: void 0,
sharedEmitDoneFor: void 0,
cycles: e?.cycles ?? "ref",
reused: e?.reused ?? "inline",
intersections: [],
deferred: [],
external: e?.external ?? void 0
};
}
/**
* Applies the `unrepresentable` setting at a site that has no JSON Schema equivalent. Throws
* `message` unless the setting (or the handler's return value) says otherwise. Returns `true` if a
* custom JSON Schema was written into `json`, in which case the caller must not write its own.
*/
function handleUnrepresentable(e, t, n, r, i) {
const a = typeof t.unrepresentable === "function" ? t.unrepresentable({
zodSchema: e,
path: r.path,
message: i
}) : t.unrepresentable;
if (a === "any") return false;
if (a === void 0 || a === "throw") throw new Error(i);
Object.assign(n, a);
return true;
}
function processSchema(e, t, n = {
path: [],
schemaPath: []
}) {
var r;
const i = e._zod.def;
const a = t.seen.get(e);
if (a) {
a.count++;
if (n.schemaPath.includes(e)) a.cycle = n.path;
return a.schema;
}
const o = {
schema: {},
count: 1,
cycle: void 0,
path: n.path
};
t.seen.set(e, o);
t.sharedDefsExtractedFor = void 0;
t.sharedEmitDoneFor = void 0;
const s = e._zod.toJSONSchema?.();
if (s) o.schema = s;
else {
const r = {
...n,
schemaPath: [...n.schemaPath, e],
path: n.path
};
if (e._zod.processJSONSchema) e._zod.processJSONSchema(t, o.schema, r);
else {
const n = o.schema;
const a = t.processors[i.type];
if (!a) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);
a(e, t, n, r);
}
const a = e._zod.parent;
if (a) {
if (!o.ref) o.ref = a;
processSchema(a, t, r);
t.seen.get(a).isParent = true;
}
}
const c = t.metadataRegistry.get(e);
if (c) assignProps(o.schema, c);
if (t.io === "input" && isTransforming(e)) {
delete o.schema.examples;
delete o.schema.default;
}
if (t.io === "input" && "_prefault" in o.schema) (r = o.schema).default ?? (r.default = o.schema._prefault);
delete o.schema._prefault;
return t.seen.get(e).schema;
}
function encodeJSONPointerSegment(e) {
return e.replace(/~/g, "~0").replace(/\//g, "~1");
}
function extractDefs(e, t) {
const n = e.seen.get(t);
if (!n) throw new Error("Unprocessed schema. This is a bug in Zod.");
if (e.external && e.sharedDefsExtractedFor === e.external) return;
const r = /* @__PURE__ */ new Map();
for (const t of e.seen.entries()) {
const n = e.metadataRegistry.get(t[0])?.id;
if (n) {
const e = r.get(n);
if (e && e !== t[0]) throw new Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
r.set(n, t[0]);
}
}
const makeURI = (t) => {
const r = e.target === "draft-2020-12" ? "$defs" : "definitions";
if (e.external) {
const n = e.external.registry.get(t[0])?.id;
const i = e.external.uri ?? ((e) => e);
if (n) return { ref: i(n) };
const a = t[1].defId ?? t[1].schema.id ?? `schema${e.counter++}`;
t[1].defId = a;
return {
defId: a,
ref: `${i("__shared")}#/${r}/${encodeJSONPointerSegment(a)}`
};
}
const i = `#`;
const a = `${i}/${r}/`;
if (t[1] === n && !t[1].schema.id) return { ref: i };
const o = t[1].schema.id ?? `__schema${e.counter++}`;
return {
defId: o,
ref: a + encodeJSONPointerSegment(o)
};
};
const extractToDef = (e) => {
if (e[1].schema.$ref) return;
const t = e[1];
const { ref: n, defId: r } = makeURI(e);
t.def = { ...t.schema };
if (r) t.defId = r;
const i = t.schema;
for (const e in i) delete i[e];
i.$ref = n;
};
if (e.cycles === "throw") for (const t of e.seen.entries()) {
const e = t[1];
if (e.cycle) throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
}
for (const n of e.seen.entries()) {
const r = n[1];
if (t === n[0]) {
extractToDef(n);
continue;
}
if (e.external) {
const r = e.external.registry.get(n[0])?.id;
if (t !== n[0] && r) {
extractToDef(n);
continue;
}
}
if (e.metadataRegistry.get(n[0])?.id) {
extractToDef(n);
continue;
}
if (r.cycle) {
extractToDef(n);
continue;
}
if (r.count > 1) {
if (e.reused === "ref") extractToDef(n);
}
}
if (e.external) e.sharedDefsExtractedFor = e.external;
}
/** Rewrites `anyOf: [{type: "a"}, {type: "b"}]` to `type: ["a", "b"]`, which every JSON Schema draft treats as equivalent and most consumers render far better for the nullable case. Only branches that are a bare type assertion qualify — anything carrying a constraint, `$ref`, `const` or metadata is left alone. Runs after `flattenRef`, so a branch an override decorated or `$defs` extraction turned into a `$ref` is no longer bare and correctly stays in `anyOf`. `oneOf` is excluded: `integer` and `number` overlap, so "exactly one" and "at least one" are not the same there. OpenAPI 3.0 is excluded: its `type` must be a single string. */
function compactTypeUnion(e) {
const t = e.anyOf;
if (!Array.isArray(t) || t.length === 0 || e.type !== void 0) return;
const n = [];
for (const e of t) {
if (!e || typeof e !== "object") return;
compactTypeUnion(e);
const t = Object.keys(e);
if (t.length !== 1 || t[0] !== "type") return;
const r = e.type;
for (const e of Array.isArray(r) ? r : [r]) {
if (typeof e !== "string") return;
if (!n.includes(e)) n.push(e);
}
}
delete e.anyOf;
e.type = n.length === 1 ? n[0] : n;
}
/** Keywords `foldIntersection` knows how to combine. Anything else — `$ref`, `patternProperties`,
* an annotation like `description` — makes a member unfoldable, so a constraint this does not
* understand leaves the `allOf` alone instead of being silently dropped or misattributed. */
const FOLDABLE_KEYS = /* @__PURE__ */ new Set([
"type",
"properties",
"required",
"additionalProperties"
]);
const UNION_KEYS = ["oneOf", "anyOf"];
/** A member's constraint on a key it does not declare itself. A `catchall` states one; `false`, an absent `additionalProperties`, and the empty schema a loose object emits state nothing. */
function undeclaredConstraint(e) {
const t = e.additionalProperties;
if (t === void 0 || t === false || typeof t !== "object" || t === null) return null;
return Object.keys(t).length ? t : null;
}
/** Combines object members into the single object they describe together, or returns `null` if any of them carries a keyword outside {@link FOLDABLE_KEYS}. */
function foldObjects(e) {
const t = [];
for (const n of e) {
if (typeof n !== "object" || n.type !== "object") return null;
for (const e in n) if (!FOLDABLE_KEYS.has(e)) return null;
t.push(n);
}
const n = {};
const r = /* @__PURE__ */ new Set();
for (const e of t) {
for (const r in e.properties) {
if (Object.prototype.hasOwnProperty.call(n, r)) continue;
const e = [];
for (const n of t) {
const t = n.properties?.[r] ?? undeclaredConstraint(n);
if (t === null || t === void 0) continue;
if (!e.some((e) => JSON.stringify(e) === JSON.stringify(t))) e.push(t);
}
const i = e.length === 1 ? e[0] : foldObjects(e) ?? { allOf: e };
assignProp(n, r, i);
}
for (const t of e.required ?? []) r.add(t);
}
const i = {
type: "object",
properties: n
};
if (r.size) i.required = [...r];
if (t.every((e) => e.additionalProperties === false)) i.additionalProperties = false;
else {
const e = [];
for (const n of t) {
const t = undeclaredConstraint(n);
if (t && !e.some((e) => JSON.stringify(e) === JSON.stringify(t))) e.push(t);
}
if (e.length === 1) i.additionalProperties = e[0];
else if (e.length > 1) i.additionalProperties = { allOf: e };
}
return i;
}
/** `additionalProperties` in an `allOf` member sees only that member's own `properties`, so two
* closed object members reject each other's keys and the schema validates nothing. Zod's parser
* pools the key sets instead — `handleIntersectionResults` reports a key as unrecognized only when
* *every* side rejects it — so the emitted schema has to pool them too, and folding the members
* into one object is the encoding that says so on every target.
*
* This runs from `finalize`, after `extractDefs`, which is what keeps it clear of the `$ref`
* machinery: a member extracted into `$defs` is already a `$ref` by now and declines to fold, so it
* keeps its reference and its own closedness rather than being inlined as a stale copy. */
function foldIntersection(e) {
const t = e.allOf;
if (!Array.isArray(t) || t.length < 2) return;
for (const t of FOLDABLE_KEYS) if (t in e) return;
const n = t.filter((e) => UNION_KEYS.some((t) => Array.isArray(e[t])));
let r = null;
if (!n.length) r = foldObjects(t);
else {
const e = n[0];
const i = UNION_KEYS.find((t) => Array.isArray(e[t]));
if (Object.keys(e).length !== 1) return;
const a = t.filter((t) => t !== e);
const o = e[i].map((e) => foldObjects([...a, e]));
if (o.some((e) => !e)) return;
r = { [i]: o };
}
if (!r) return;
delete e.allOf;
assignProps(e, r);
}
function finalize(e, t) {
const n = e.seen.get(t);
if (!n) throw new Error("Unprocessed schema. This is a bug in Zod.");
const flattenRef = (t) => {
const n = e.seen.get(t);
if (n.ref === null) return;
const r = n.def ?? n.schema;
const i = { ...r };
const a = n.ref;
n.ref = null;
if (a) {
flattenRef(a);
const n = e.seen.get(a);
const o = n.schema;
if (o.$ref && (e.target === "draft-07" || e.target === "draft-04" || e.target === "openapi-3.0")) {
r.allOf = r.allOf ?? [];
r.allOf.push(o);
} else assignProps(r, o);
assignProps(r, i);
if (t._zod.parent === a) for (const e in r) {
if (e === "$ref" || e === "allOf") continue;
if (!(e in i)) delete r[e];
}
if (o.$ref && n.def) for (const e in r) {
if (e === "$ref" || e === "allOf") continue;
if (e in n.def && JSON.stringify(r[e]) === JSON.stringify(n.def[e])) delete r[e];
}
}
const o = t._zod.parent;
if (o && o !== a) {
flattenRef(o);
const t = e.seen.get(o);
if (t?.schema.$ref) {
r.$ref = t.schema.$ref;
if (t.def) for (const e in r) {
if (e === "$ref" || e === "allOf") continue;
if (e in t.def && JSON.stringify(r[e]) === JSON.stringify(t.def[e])) delete r[e];
}
}
}
e.override({
zodSchema: t,
jsonSchema: r,
path: n.path ?? []
});
};
if (!e.external || e.sharedEmitDoneFor !== e.external) {
for (const t of [...e.seen.entries()].reverse()) flattenRef(t[0]);
if (e.target !== "openapi-3.0") for (const t of e.seen.entries()) compactTypeUnion(t[1].def ?? t[1].schema);
for (const t of e.deferred) t();
if (e.intersections.length) {
const t = /* @__PURE__ */ new Map();
for (const n of e.seen.values()) for (const e of [n.schema, n.def]) {
const n = e?.allOf;
if (!Array.isArray(n)) continue;
const r = t.get(n);
if (r) r.push(e);
else t.set(n, [e]);
}
for (const n of e.intersections) for (const e of t.get(n) ?? []) foldIntersection(e);
}
}
const r = {};
if (e.target === "draft-2020-12") r.$schema = "https://json-schema.org/draft/2020-12/schema";
else if (e.target === "draft-07") r.$schema = "http://json-schema.org/draft-07/schema#";
else if (e.target === "draft-04") r.$schema = "http://json-schema.org/draft-04/schema#";
else if (e.target === "openapi-3.0") {}
if (e.external?.uri) {
const n = e.external.registry.get(t)?.id;
if (!n) throw new Error("Schema is missing an `id` property");
r.$id = e.external.uri(n);
}
assignProps(r, n.defId ? n.schema : n.def ?? n.schema);
const i = e.metadataRegistry.get(t)?.id;
if (i !== void 0 && r.id === i) delete r.id;
const a = e.external?.defs ?? {};
if (!e.external || e.sharedEmitDoneFor !== e.external) for (const t of e.seen.entries()) {
const e = t[1];
if (e.def && e.defId) {
if (e.def.id === e.defId) delete e.def.id;
assignProp(a, e.defId, e.def);
}
}
if (e.external) e.sharedEmitDoneFor = e.external;
if (e.external) {} else if (Object.keys(a).length > 0) {
if (e.target === "draft-2020-12") r.$defs = a;
else r.definitions = a;
}
try {
const n = JSON.parse(JSON.stringify(r));
Object.defineProperty(n, "~standard", {
value: {
...t["~standard"],
jsonSchema: {
input: createStandardJSONSchemaMethod(t, "input", e.processors),
output: createStandardJSONSchemaMethod(t, "output", e.processors)
}
},
enumerable: false,
writable: false
});
return n;
} catch (e) {
throw new Error("Error converting schema to JSON.");
}
}
function isTransforming(e, t) {
const n = t ?? { seen: /* @__PURE__ */ new Set() };
if (n.seen.has(e)) return false;
n.seen.add(e);
const r = e._zod.def;
if (r.type === "transform") return true;
if (r.type === "array") return isTransforming(r.element, n);
if (r.type === "set") return isTransforming(r.valueType, n);
if (r.type === "lazy") return isTransforming(r.getter(), n);
if (r.type === "promise" || r.type === "optional" || r.type === "nonoptional" || r.type === "nullable" || r.type === "readonly" || r.type === "default" || r.type === "prefault" || r.type === "catch") return isTransforming(r.innerType, n);
if (r.type === "intersection") return isTransforming(r.left, n) || isTransforming(r.right, n);
if (r.type === "record" || r.type === "map") return isTransforming(r.keyType, n) || isTransforming(r.valueType, n);
if (r.type === "pipe") {
if (e._zod.traits.has("$ZodCodec")) return true;
return isTransforming(r.in, n) || isTransforming(r.out, n);
}
if (r.type === "object") {
for (const e in r.shape) if (isTransforming(r.shape[e], n)) return true;
return false;
}
if (r.type === "union") {
for (const e of r.options) if (isTransforming(e, n)) return true;
return false;
}
if (r.type === "tuple") {
for (const e of r.items) if (isTransforming(e, n)) return true;
if (r.rest && isTransforming(r.rest, n)) return true;
return false;
}
return false;
}
/**
* Creates a toJSONSchema method for a schema instance.
* This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
*/
const createToJSONSchemaMethod = (e, t = {}) => (n) => {
const r = initializeContext({
...n,
processors: t
});
processSchema(e, r);
extractDefs(r, e);
return finalize(r, e);
};
const createStandardJSONSchemaMethod = (e, t, n = {}) => (r) => {
const { libraryOptions: i, target: a } = r ?? {};
const o = initializeContext({
...i ?? {},
target: a,
io: t,
processors: n
});
processSchema(e, o);
extractDefs(o, e);
return finalize(o, e);
};
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/json-schema-processors.js
const narrowMin = (e, t, n) => {
if (e[t] === void 0 || n > e[t]) e[t] = n;
};
const narrowMax = (e, t, n) => {
if (e[t] === void 0 || n < e[t]) e[t] = n;
};
const narrowBoth = (e, t) => {
narrowMin(e, "minimum", t);
narrowMax(e, "maximum", t);
};
const addDivisor = (e, t) => {
e.multipleOf ?? (e.multipleOf = []);
if (!e.multipleOf.includes(t)) e.multipleOf.push(t);
};
const addPattern = (e, t) => {
e.patterns ?? (e.patterns = /* @__PURE__ */ new Set());
e.patterns.add(t);
};
const intersectMime = (e, t) => {
e.mime = e.mime ? e.mime.filter((e) => t.includes(e)) : [...t];
};
const setFormat = (e, t) => {
e.format = t;
if (t.includes("int")) e.isInt = true;
};
const minContributor = (e, t) => narrowMin(e, "minimum", t.minimum);
const maxContributor = (e, t) => narrowMax(e, "maximum", t.maximum);
const formatContributor = (e) => (t, n) => {
setFormat(t, n.format);
const [r, i] = e[n.format];
narrowMin(t, "minimum", r);
narrowMax(t, "maximum", i);
};
const contributors = {
greater_than: (e, t) => narrowMin(e, t.inclusive ? "minimum" : "exclusiveMinimum", t.value),
less_than: (e, t) => narrowMax(e, t.inclusive ? "maximum" : "exclusiveMaximum", t.value),
multiple_of: (e, t) => addDivisor(e, t.value),
number_format: formatContributor(NUMBER_FORMAT_RANGES),
bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
min_length: minContributor,
max_length: maxContributor,
length_equals: (e, t) => narrowBoth(e, t.length),
min_size: minContributor,
max_size: maxContributor,
size_equals: (e, t) => narrowBoth(e, t.size),
string_format: (e, t) => {
setFormat(e, t.format);
if (t.pattern) addPattern(e, t.pattern);
if (t.format === "base64" || t.format === "base64url") e.contentEncoding = t.format;
if (t.local || t.precision === -1) e.laxFormat = true;
},
mime_type: (e, t) => intersectMime(e, t.mime)
};
function aggregateChecks(e) {
const t = {};
const n = e._zod.def;
const r = e._zod.traits.has("$ZodCheck") ? [e, ...n.checks ?? []] : n.checks ?? [];
for (const e of r) contributors[e._zod.def.check]?.(t, e._zod.def);
const i = e._zod.bag;
if (i.minimum !== void 0) narrowMin(t, "minimum", i.minimum);
if (i.exclusiveMinimum !== void 0) narrowMin(t, "exclusiveMinimum", i.exclusiveMinimum);
if (i.maximum !== void 0) narrowMax(t, "maximum", i.maximum);
if (i.exclusiveMaximum !== void 0) narrowMax(t, "exclusiveMaximum", i.exclusiveMaximum);
if (i.multipleOf !== void 0) addDivisor(t, i.multipleOf);
if (i.format !== void 0) {
t.format ?? (t.format = i.format);
if (i.format.includes("int")) t.isInt = true;
}
if (i.mime) intersectMime(t, i.mime);
for (const e of i.patterns ?? []) addPattern(t, e);
return t;
}
const formatMap = {
guid: "uuid",
url: "uri",
datetime: "date-time",
json_string: "json-string",
regex: ""
};
const exactPatterns = /* @__PURE__ */ new Map([[base64Charset, base64], [base64urlCharset, base64url]]);
const exactPattern = (e) => exactPatterns.get(e) ?? e;
const stringProcessor = (e, t, n, r) => {
const i = n;
i.type = "string";
const { minimum: a, maximum: o, format: s, patterns: c, contentEncoding: l, laxFormat: u } = aggregateChecks(e);
if (typeof a === "number") i.minLength = a;
if (typeof o === "number") i.maxLength = o;
if (s) {
i.format = formatMap[s] ?? s;
if (i.format === "") delete i.format;
if (s === "time" || u) delete i.format;
}
if (l) i.contentEncoding = l;
if (c && c.size > 0) {
const e = [...c].map(exactPattern);
if (e.length === 1) i.pattern = e[0].source;
else if (e.length > 1) i.allOf = [...e.map((e) => ({
...t.target === "draft-07" || t.target === "draft-04" || t.target === "openapi-3.0" ? { type: "string" } : {},
pattern: e.source
}))];
}
};
const numberProcessor = (e, t, n, r) => {
const i = n;
const { minimum: a, maximum: o, multipleOf: s, exclusiveMaximum: c, exclusiveMinimum: l, isInt: u } = aggregateChecks(e);
i.type = u ? "integer" : "number";
const d = typeof l === "number" && l >= (a ?? Number.NEGATIVE_INFINITY);
const f = typeof c === "number" && c <= (o ?? Number.POSITIVE_INFINITY);
const p = t.target === "draft-04" || t.target === "openapi-3.0";
if (d) {
if (p) {
i.minimum = l;
i.exclusiveMinimum = true;
} else i.exclusiveMinimum = l;
} else if (typeof a === "number") i.minimum = a;
if (f) {
if (p) {
i.maximum = c;
i.exclusiveMaximum = true;
} else i.exclusiveMaximum = c;
} else if (typeof o === "number") i.maximum = o;
if (s) {
const n = /* @__PURE__ */ new Set();
for (const a of s) if (Number.isFinite(a) && a !== 0) n.add(Math.abs(a));
else handleUnrepresentable(e, t, i, r, `A multipleOf divisor of ${a} cannot be represented in JSON Schema`);
const [a, ...o] = n;
if (a !== void 0) i.multipleOf = a;
if (o.length) i.allOf = [...i.allOf ?? [], ...o.map((e) => ({ multipleOf: e }))];
}
};
const booleanProcessor = (e, t, n, r) => {
n.type = "boolean";
};
const bigintProcessor = (e, t, n, r) => {
handleUnrepresentable(e, t, n, r, "BigInt cannot be represented in JSON Schema");
};
const symbolProcessor = (e, t, n, r) => {
handleUnrepresentable(e, t, n, r, "Symbols cannot be represented in JSON Schema");
};
const nullProcessor = (e, t, n, r) => {
if (t.target === "openapi-3.0") {
n.type = "string";
n.nullable = true;
n.enum = [null];
} else n.type = "null";
};
const undefinedProcessor = (e, t, n, r) => {
handleUnrepresentable(e, t, n, r, "Undefined cannot be represented in JSON Schema");
};
const voidProcessor = (e, t, n, r) => {
handleUnrepresentable(e, t, n, r, "Void cannot be represented in JSON Schema");
};
const neverProcessor = (e, t, n, r) => {
n.not = {};
};
const anyProcessor = (e, t, n, r) => {};
const unknownProcessor = (e, t, n, r) => {};
const dateProcessor = (e, t, n, r) => {
handleUnrepresentable(e, t, n, r, "Date cannot be represented in JSON Schema");
};
const enumProcessor = (e, t, n, r) => {
const i = e._zod.def;
const a = getEnumValues(i.entries);
if (a.length === 0) {
n.not = {};
return;
}
if (a.every((e) => typeof e === "number")) n.type = "number";
if (a.every((e) => typeof e === "string")) n.type = "string";
n.enum = a;
};
const literalProcessor = (e, t, n, r) => {
const i = e._zod.def;
if (i.values.length === 0) {
n.not = {};
return;
}
const a = [];
for (const o of i.values) if (o === void 0) {
if (handleUnrepresentable(e, t, n, r, "Literal `undefined` cannot be represented in JSON Schema")) return;
} else if (typeof o === "bigint") {
if (handleUnrepresentable(e, t, n, r, "BigInt literals cannot be represented in JSON Schema")) return;
a.push(Number(o));
} else a.push(o);
if (a.length === 0) {} else if (a.length === 1) {
const e = a[0];
n.type = e === null ? "null" : typeof e;
if (t.target === "draft-04" || t.target === "openapi-3.0") n.enum = [e];
else n.const = e;
} else {
if (a.every((e) => typeof e === "number")) n.type = "number";
if (a.every((e) => typeof e === "string")) n.type = "string";
if (a.every((e) => typeof e === "boolean")) n.type = "boolean";
if (a.every((e) => e === null)) n.type = "null";
n.enum = a;
}
};
const nanProcessor = (e, t, n, r) => {
handleUnrepresentable(e, t, n, r, "NaN cannot be represented in JSON Schema");
};
const templateLiteralProcessor = (e, t, n, r) => {
const i = n;
const a = e._zod.pattern;
if (!a) throw new Error("Pattern not found in template literal");
i.type = "string";
i.pattern = a.source;
};
const fileProcessor = (e, t, n, r) => {
const i = n;
i.type = "string";
i.format = "binary";
i.contentEncoding = "binary";
const { minimum: a, maximum: o, mime: s } = aggregateChecks(e);
if (a !== void 0) i.minLength = a;
if (o !== void 0) i.maxLength = o;
if (!s) return;
if (s.length === 0) i.not = {};
else if (s.length === 1) i.contentMediaType = s[0];
else i.anyOf = s.map((e) => ({ contentMediaType: e }));
};
const successProcessor = (e, t, n, r) => {
n.type = "boolean";
};
const customProcessor = (e, t, n, r) => {
handleUnrepresentable(e, t, n, r, "Custom types cannot be represented in JSON Schema");
};
const functionProcessor = (e, t, n, r) => {
handleUnrepresentable(e, t, n, r, "Function types cannot be represented in JSON Schema");
};
const transformProcessor = (e, t, n, r) => {
handleUnrepresentable(e, t, n, r, "Transforms cannot be represented in JSON Schema");
};
const mapProcessor = (e, t, n, r) => {
handleUnrepresentable(e, t, n, r, "Map cannot be represented in JSON Schema");
};
const setProcessor = (e, t, n, r) => {
handleUnrepresentable(e, t, n, r, "Set cannot be represented in JSON Schema");
};
const arrayProcessor = (e, t, n, r) => {
const i = n;
const a = e._zod.def;
const { minimum: o, maximum: s } = aggregateChecks(e);
if (typeof o === "number") i.minItems = o;
if (typeof s === "number") i.maxItems = s;
i.type = "array";
i.items = processSchema(a.element, t, {
...r,
path: [...r.path, "items"]
});
};
function inputOptin(e) {
const t = e._zod.def;
if (t.type === "pipe" && t.in._zod.traits.has("$ZodTransform")) return inputOptin(t.out);
if (t.type === "catch") return inputOptin(t.innerType);
return e._zod.optin;
}
const objectProcessor = (e, t, n, r) => {
const i = n;
const a = e._zod.def;
const o = a.shape;
if (Object.getOwnPropertySymbols(o).length && handleUnrepresentable(e, t, i, r, "Symbol keys cannot be represented in JSON Schema")) return;
i.type = "object";
i.properties = {};
for (const e in o) assignProp(i.properties, e, processSchema(o[e], t, {
...r,
path: [
...r.path,
"properties",
e
]
}));
const s = [];
for (const e of Object.keys(o)) {
const n = a.shape[e];
if (t.io === "input" ? inputOptin(n) === void 0 : n._zod.optout === void 0) s.push(e);
}
if (s.length > 0) i.required = s;
if (a.catchall?._zod.def.type === "never") i.additionalProperties = false;
else if (!a.catchall) {
if (t.io === "output") i.additionalProperties = false;
} else if (a.catchall) i.additionalProperties = processSchema(a.catchall, t, {
...r,
path: [...r.path, "additionalProperties"]
});
};
const unionProcessor = (e, t, n, r) => {
const i = e._zod.def;
const a = i.inclusive === false;
const o = i.options.map((e, n) => processSchema(e, t, {
...r,
path: [
...r.path,
a ? "oneOf" : "anyOf",
n
]
}));
if (a) n.oneOf = o;
else n.anyOf = o;
};
const intersectionProcessor = (e, t, n, r) => {
const i = e._zod.def;
const a = processSchema(i.left, t, {
...r,
path: [
...r.path,
"allOf",
0
]
});
const o = processSchema(i.right, t, {
...r,
path: [
...r.path,
"allOf",
1
]
});
const isSimpleIntersection = (e) => "allOf" in e && Object.keys(e).length === 1;
const s = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(o) ? o.allOf : [o]];
n.allOf = s;
t.intersections.push(s);
};
const tupleProcessor = (e, t, n, r) => {
const i = n;
const a = e._zod.def;
i.type = "array";
const o = t.target === "draft-2020-12" ? "prefixItems" : "items";
const s = t.target === "draft-2020-12" ? "items" : t.target === "openapi-3.0" ? "items" : "additionalItems";
const c = a.items.map((e, n) => processSchema(e, t, {
...r,
path: [
...r.path,
o,
n
]
}));
const l = a.rest ? processSchema(a.rest, t, {
...r,
path: [
...r.path,
s,
...t.target === "openapi-3.0" ? [a.items.length] : []
]
}) : null;
let u = a.items.length;
while (u > 0) {
const e = a.items[u - 1];
if (!(t.io === "input" ? inputOptin(e) !== void 0 : e._zod.optout === "optional")) break;
u--;
}
const d = a.items.length;
const f = !a.rest;
if (t.target === "draft-2020-12") {
i.prefixItems = c;
if (f) i.items = false;
else if (l) i.items = l;
if (u > 0) i.minItems = u;
if (f) i.maxItems = d;
} else if (t.target === "openapi-3.0") {
i.items = { anyOf: c };
if (l) i.items.anyOf.push(l);
if (u > 0) i.minItems = u;
if (f) i.maxItems = d;
} else {
i.items = c;
if (f) i.additionalItems = false;
else if (l) i.additionalItems = l;
if (u > 0) i.minItems = u;
if (f) i.maxItems = d;
}
const { minimum: p, maximum: m } = aggregateChecks(e);
if (typeof p === "number") i.minItems = p;
if (typeof m === "number") i.maxItems = m;
};
/** JSON object keys are always strings, so a numeric record key schema is re-expressed over the
* numeric-string form the record parser matches. Deferred to `finalize`, after the flatten: a key
* behind a wrapper only carries its own `type` before then, and a union key only has its branches.
*
* A numeric bound cannot apply to a property name, so `minimum` and its siblings are dropped rather
* than carried over: keeping them beside `type: "string"` reproduces the match-nothing schema this
* exists to fix. A key that carries one therefore emits wider than the record parses — `z.record(z.number().min(5), V)`
* accepts `"3"` — which is the deliberate trade, since throwing on it would reject an ordinary schema
* outright. */
function stringifyKeyNames(e, t, n) {
if (t.$ref) {
if (n.has(t)) return t;
n.add(t);
const r = e.get(t)?.def;
if (!r) return t;
const i = stringifyKeyNames(e, r, n);
return i === r ? t : i;
}
for (const r of ["anyOf", "oneOf"]) {
const i = t[r];
if (!Array.isArray(i)) continue;
const a = i.map((t) => stringifyKeyNames(e, t, n));
if (a.some((e, t) => e !== i[t])) t = {
...t,
[r]: a
};
}
const r = Array.isArray(t.type) ? t.type : [t.type];
const i = !r.includes("string") && r.some((e) => e === "number" || e === "integer");
const a = t.enum ?? (t.const !== void 0 ? [t.const] : void 0);
if (!i && !a?.some((e) => typeof e === "number")) return t;
const { minimum: o, maximum: s, exclusiveMinimum: c, exclusiveMaximum: l, multipleOf: u, format: d, id: f, ...p } = t;
if (p.enum) p.enum = p.enum.map((e) => typeof e === "number" ? String(e) : e);
else if (typeof p.const === "number") p.const = String(p.const);
if (!i) return p;
p.type = "string";
if (!a) p.pattern = (r.includes("number") ? number : integer).source;
return p;
}
/** Every record of one conversion, so the carriers are found in a single pass rather than once per record. */
const pendingRecords = /* @__PURE__ */ new WeakMap();
function rewriteKeyNames(e) {
const t = /* @__PURE__ */ new Map();
for (const n of e.seen.values()) if (n.def && !t.has(n.schema)) t.set(n.schema, n);
const n = /* @__PURE__ */ new Map();
for (const r of pendingRecords.get(e) ?? []) {
const i = e.seen.get(r);
const a = (i?.def ?? i?.schema)?.propertyNames;
if (!a || a === true || n.has(a)) continue;
const o = stringifyKeyNames(t, a, /* @__PURE__ */ new Set());
if (o !== a) n.set(a, o);
}
if (!n.size) return;
for (const t of e.seen.values()) for (const e of [t.schema, t.def]) {
const t = e && n.get(e.propertyNames);
if (t) e.propertyNames = t;
}
}
const recordProcessor = (e, t, n, r) => {
const i = n;
const a = e._zod.def;
i.type = "object";
const o = a.keyType;
const s = aggregateChecks(o).patterns;
if (a.mode === "loose" && s && s.size > 0) {
const e = processSchema(a.valueType, t, {
...r,
path: [
...r.path,
"patternProperties",
"*"
]
});
i.patternProperties = {};
for (const t of s) assignProp(i.patternProperties, exactPattern(t).source, e);
} else {
if (t.target === "draft-07" || t.target === "draft-2020-12") {
i.propertyNames = processSchema(a.keyType, t, {
...r,
path: [...r.path, "propertyNames"]
});
let n = pendingRecords.get(t);
if (!n) {
n = [];
pendingRecords.set(t, n);
t.deferred.push(() => rewriteKeyNames(t));
}
n.push(e);
}
i.additionalProperties = processSchema(a.valueType, t, {
...r,
path: [...r.path, "additionalProperties"]
});
}
const c = o._zod.values;
const l = t.io === "input" && inputOptin(a.valueType) !== void 0;
if (c && !a.partial && !l) {
const e = [...c].filter((e) => typeof e === "string" || typeof e === "number");
if (e.length > 0) i.required = e.map(String);
}
};
const nullableProcessor = (e, t, n, r) => {
const i = e._zod.def;
const a = processSchema(i.innerType, t, r);
const o = t.seen.get(e);
if (t.target === "openapi-3.0") {
o.ref = i.innerType;
n.nullable = true;
} else n.anyOf = [a, { type: "null" }];
};
const nonoptionalProcessor = (e, t, n, r) => {
const i = e._zod.def;
processSchema(i.innerType, t, r);
const a = t.seen.get(e);
a.ref = i.innerType;
};
/** Round-trips a default value through JSON so the emitted schema is guaranteed to be valid JSON.
* A BigInt has no reliable encoding, so it goes through `unrepresentable` like any other
* unrepresentable value. Returns a sentinel when the caller must not write a default of its own. */
const UNREPRESENTABLE_DEFAULT = Symbol();
function serializeDefaultValue(e, t, n, r, i) {
let a = false;
const o = JSON.stringify(e, (e, t) => {
if (typeof t !== "bigint") return t;
a = true;
return null;
});
if (!a) return JSON.parse(o);
handleUnrepresentable(t, n, r, i, "BigInt defaults cannot be represented in JSON Schema");
return UNREPRESENTABLE_DEFAULT;
}
const defaultProcessor = (e, t, n, r) => {
const i = e._zod.def;
processSchema(i.innerType, t, r);
const a = t.seen.get(e);
a.ref = i.innerType;
const o = serializeDefaultValue(i.defaultValue, e, t, n, r);
if (o !== UNREPRESENTABLE_DEFAULT) n.default = o;
};
const prefaultProcessor = (e, t, n, r) => {
const i = e._zod.def;
processSchema(i.innerType, t, r);
const a = t.seen.get(e);
a.ref = i.innerType;
if (t.io !== "input") return;
const o = serializeDefaultValue(i.defaultValue, e, t, n, r);
if (o !== UNREPRESENTABLE_DEFAULT) n._prefault = o;
};
const catchProcessor = (e, t, n, r) => {
const i = e._zod.def;
processSchema(i.innerType, t, r);
const a = t.seen.get(e);
a.ref = i.innerType;
let o;
try {
o = i.catchValue(void 0);
} catch {
handleUnrepresentable(e, t, n, r, "Dynamic catch values are not supported in JSON Schema");
return;
}
n.default = o;
};
const pipeProcessor = (e, t, n, r) => {
const i = e._zod.def;
const a = i.in._zod.traits.has("$ZodTransform");
const o = t.io === "input" ? a ? i.out : i.in : i.out;
processSchema(o, t, r);
const s = t.seen.get(e);
s.ref = o;
};
const readonlyProcessor = (e, t, n, r) => {
const i = e._zod.def;
processSchema(i.innerType, t, r);
const a = t.seen.get(e);
a.ref = i.innerType;
n.readOnly = true;
};
const promiseProcessor = (e, t, n, r) => {
const i = e._zod.def;
processSchema(i.innerType, t, r);
const a = t.seen.get(e);
a.ref = i.innerType;
};
const optionalProcessor = (e, t, n, r) => {
const i = e._zod.def;
processSchema(i.innerType, t, r);
const a = t.seen.get(e);
a.ref = i.innerType;
};
const lazyProcessor = (e, t, n, r) => {
const i = e._zod.innerType;
processSchema(i, t, r);
const a = t.seen.get(e);
a.ref = i;
};
const allProcessors = {
string: stringProcessor,
number: numberProcessor,
boolean: booleanProcessor,
bigint: bigintProcessor,
symbol: symbolProcessor,
null: nullProcessor,
undefined: undefinedProcessor,
void: voidProcessor,
never: neverProcessor,
any: anyProcessor,
unknown: unknownProcessor,
date: dateProcessor,
enum: enumProcessor,
literal: literalProcessor,
nan: nanProcessor,
template_literal: templateLiteralProcessor,
file: fileProcessor,
success: successProcessor,
custom: customProcessor,
function: functionProcessor,
transform: transformProcessor,
map: mapProcessor,
set: setProcessor,
array: arrayProcessor,
object: objectProcessor,
union: unionProcessor,
intersection: intersectionProcessor,
tuple: tupleProcessor,
record: recordProcessor,
nullable: nullableProcessor,
nonoptional: nonoptionalProcessor,
default: defaultProcessor,
prefault: prefaultProcessor,
catch: catchProcessor,
pipe: pipeProcessor,
readonly: readonlyProcessor,
promise: promiseProcessor,
optional: optionalProcessor,
lazy: lazyProcessor
};
function toJSONSchema(e, t) {
if ("_idmap" in e) {
const n = e;
const r = initializeContext({
...t,
processors: allProcessors
});
const i = {};
for (const e of n._idmap.entries()) {
const [t, n] = e;
processSchema(n, r);
}
const a = {};
r.external = {
registry: n,
uri: t?.uri,
defs: i
};
for (const e of n._idmap.entries()) {
const [t, n] = e;
extractDefs(r, n);
assignProp(a, t, finalize(r, n));
}
if (Object.keys(i).length > 0) a.__shared = { [r.target === "draft-2020-12" ? "$defs" : "definitions"]: i };
return { schemas: a };
}
const n = initializeContext({
...t,
processors: allProcessors
});
processSchema(e, n);
extractDefs(n, e);
return finalize(n, e);
}
//#endregion
export { globalRegistry as $, $ZodCheckMimeType as $n, $ZodEncodeError as $r, $ZodPipe as $t, recordProcessor as A, safeExtend as Ai, isValidCreditCard as An, _safeParseAsync as Ar, $ZodIPv6 as At, unionProcessor as B, validateURL as Bn, safeEncodeAsync as Br, $ZodMAC as Bt, numberProcessor as C, omit as Ci, base64Charset as Cn, _parse as Cr, $ZodEnum as Ct, prefaultProcessor as D, pick as Di, isValidBase64 as Dn, _safeEncode as Dr, $ZodGUID as Dt, pipeProcessor as E, partial as Ei, getDiscriminatedOption as En, _safeDecodeAsync as Er, $ZodFunction as Et, templateLiteralProcessor as F, toZod as Fi, parseURLObject as Fn, parse as Fr, $ZodIntersection as Ft, extractDefs as G, $ZodCheckEndsWith as Gn, $ZodError as Gr, $ZodNonOptional as Gt, voidProcessor as H, Doc as Hn, safeParseAsync as Hr, $ZodNaN as Ht, toJSONSchema as I, util_exports as Ii, standardProps as In, parseAsync as Ir, $ZodJWT as It, initializeContext as J, $ZodCheckLengthEquals as Jn, formatError as Jr, $ZodNumber as Jt, finalize as K, $ZodCheckGreaterThan as Kn, $ZodRealError as Kr, $ZodNull as Kt, transformProcessor as L, stripTabAndNewline as Ln, safeDecode as Lr, $ZodKSUID as Lt, stringProcessor as M, sizeCaps as Mi, isValidIPv6 as Mn, decodeAsync as Mr, $ZodISODateTime as Mt, successProcessor as N, slugify as Ni, isValidJWT as Nn, encode as Nr, $ZodISODuration as Nt, promiseProcessor as O, rawShape as Oi, isValidBase64URL as On, _safeEncodeAsync as Or, $ZodIBAN as Ot, symbolProcessor as P, stringifyPrimitive as Pi, mergeValues as Pn, encodeAsync as Pr, $ZodISOTime as Pt, $output as Q, $ZodCheckMaxSize as Qn, $ZodAsyncError as Qr, $ZodOptional as Qt, tupleProcessor as R, urlHostnameOk as Rn, safeDecodeAsync as Rr, $ZodLazy as Rt, nullableProcessor as S, normalizeParams as Si, $ZodXor as Sn, _encodeAsync as Sr, $ZodEmoji as St, optionalProcessor as T, parsedType as Ti, canParseURL as Tn, _safeDecode as Tr, $ZodFile as Tt, createStandardJSONSchemaMethod as U, $ZodCheck as Un, validate as Ur, $ZodNanoID as Ut, unknownProcessor as V, version as Vn, safeParse as Vr, $ZodMap as Vt, createToJSONSchemaMethod as W, $ZodCheckBigIntFormat as Wn, validateAsync$1 as Wr, $ZodNever as Wt, $ZodRegistry as X, $ZodCheckLowerCase as Xn, toDotPath as Xr, $ZodObject as Xt, processSchema as Y, $ZodCheckLessThan as Yn, prettifyError as Yr, $ZodNumberFormat as Yt, $input as Z, $ZodCheckMaxLength as Zn, treeifyError as Zr, $ZodObjectJIT as Zt, mapProcessor as _, issue as _i, $ZodUndefined as _n, number as _r, $ZodDate as _t, bigintProcessor as a, CONSTANT_CATCH as ai, $ZodSet as an, $ZodCheckProperties as ar, $ZodBigInt as at, nonoptionalProcessor as b, merge as bi, $ZodVoid as bn, _decodeAsync as br, $ZodE164 as bt, customProcessor as c, codePointLength as ci, $ZodSuccess as cn, $ZodCheckSizeEquals as cr, $ZodCIDRv4 as ct, enumProcessor as d, esc as di, $ZodTransform as dn, $ZodCheckUpperCase as dr, $ZodCUID2 as dt, $brand as ei, $ZodPrefault as en, $ZodCheckMinLength as er, registry as et, fileProcessor as f, extend as fi, $ZodTuple as fn, currencyCode as fr, $ZodCatch as ft, literalProcessor as g, isPlainObject as gi, $ZodUUID as gn, httpProtocol as gr, $ZodCustomStringFormat as gt, lazyProcessor as h, installLazyProp as hi, $ZodURL as hn, hostname as hr, $ZodCustom as ht, arrayProcessor as i, globalConfig as ii, $ZodRecord as in, $ZodCheckOverwrite as ir, $ZodBase64URL as it, setProcessor as j, shallowClone as ji, isValidIBAN as jn, decode as jr, $ZodISODate as jt, readonlyProcessor as k, required as ki, isValidCIDRv6 as kn, _safeParse as kr, $ZodIPv4 as kt, dateProcessor as l, constantCatch as li, $ZodSymbol as ln, $ZodCheckStartsWith as lr, $ZodCIDRv6 as lt, intersectionProcessor as m, hide as mi, $ZodULID as mn, hex as mr, $ZodCreditCard as mt, allProcessors as n, NEVER as ni, $ZodPromise as nn, $ZodCheckMultipleOf as nr, $ZodArray as nt, booleanProcessor as o, assignProp as oi, $ZodString as on, $ZodCheckProperty as or, $ZodBigIntFormat as ot, functionProcessor as p, floatSafeRemainder as pi, $ZodType as pn, domain as pr, $ZodCodec as pt, handleUnrepresentable as q, $ZodCheckIncludes as qn, flattenError as qr, $ZodNullable as qt, anyProcessor as r, config as ri, $ZodReadonly as rn, $ZodCheckNumberFormat as rr, $ZodBase64 as rt, catchProcessor as s, clone as si, $ZodStringFormat as sn, $ZodCheckRegex as sr, $ZodBoolean as st, aggregateChecks as t, $constructor as ti, $ZodPreprocess as tn, $ZodCheckMinSize as tr, $ZodAny as tt, defaultProcessor as u, derived as ui, $ZodTemplateLiteral as un, $ZodCheckStringFormat as ur, $ZodCUID as ut, nanProcessor as v, joinValues as vi, $ZodUnion as vn, regexes_exports as vr, $ZodDefault as vt, objectProcessor as w, own as wi, base64urlCharset as wn, _parseAsync as wr, $ZodExactOptional as wt, nullProcessor as x, mergeDefs as xi, $ZodXID as xn, _encode as xr, $ZodEmail as xt, neverProcessor as y, jsonStringifyReplacer as yi, $ZodUnknown as yn, _decode as yr, $ZodDiscriminatedUnion as yt, undefinedProcessor as z, urlProtocolOk as zn, safeEncode as zr, $ZodLiteral as zt };