blade
Version:
React at the edge.
1,534 lines (1,523 loc) • 651 kB
JavaScript
//#region ../../node_modules/zod/v4/core/core.js
/** A special constant with type `never` */
const NEVER$1 = Object.freeze({ status: "aborted" });
function $constructor$1(name, initializer$4, params) {
function init(inst, def) {
var _a;
Object.defineProperty(inst, "_zod", {
value: inst._zod ?? {},
enumerable: false
});
(_a = inst._zod).traits ?? (_a.traits = /* @__PURE__ */ new Set());
inst._zod.traits.add(name);
initializer$4(inst, def);
for (const k in _.prototype) if (!(k in inst)) Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
inst._zod.constr = _;
inst._zod.def = def;
}
const Parent = params?.Parent ?? Object;
class Definition extends Parent {}
Object.defineProperty(Definition, "name", { value: name });
function _(def) {
var _a;
const inst = params?.Parent ? new Definition() : this;
init(inst, def);
(_a = inst._zod).deferred ?? (_a.deferred = []);
for (const fn of inst._zod.deferred) fn();
return inst;
}
Object.defineProperty(_, "init", { value: init });
Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
if (params?.Parent && inst instanceof params.Parent) return true;
return inst?._zod?.traits?.has(name);
} });
Object.defineProperty(_, "name", { value: name });
return _;
}
const $brand$1 = Symbol("zod_brand");
var $ZodAsyncError$1 = class extends Error {
constructor() {
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
}
};
var $ZodEncodeError$1 = class extends Error {
constructor(name) {
super(`Encountered unidirectional transform during encode: ${name}`);
this.name = "ZodEncodeError";
}
};
const globalConfig$1 = {};
function config$1(newConfig) {
if (newConfig) Object.assign(globalConfig$1, newConfig);
return globalConfig$1;
}
//#endregion
//#region ../../node_modules/zod/v4/core/util.js
function getEnumValues$1(entries) {
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
}
function jsonStringifyReplacer$1(_, value) {
if (typeof value === "bigint") return value.toString();
return value;
}
function cached$1(getter) {
return { get value() {
{
const value = getter();
Object.defineProperty(this, "value", { value });
return value;
}
throw new Error("cached value already set");
} };
}
function nullish$2(input) {
return input === null || input === void 0;
}
function cleanRegex$1(source) {
const start = source.startsWith("^") ? 1 : 0;
const end = source.endsWith("$") ? source.length - 1 : source.length;
return source.slice(start, end);
}
const EVALUATING$1 = Symbol("evaluating");
function defineLazy$1(object$2, key, getter) {
let value = void 0;
Object.defineProperty(object$2, key, {
get() {
if (value === EVALUATING$1) return;
if (value === void 0) {
value = EVALUATING$1;
value = getter();
}
return value;
},
set(v) {
Object.defineProperty(object$2, key, { value: v });
},
configurable: true
});
}
function assignProp$1(target, prop, value) {
Object.defineProperty(target, prop, {
value,
writable: true,
enumerable: true,
configurable: true
});
}
function mergeDefs$1(...defs) {
const mergedDescriptors = {};
for (const def of defs) {
const descriptors = Object.getOwnPropertyDescriptors(def);
Object.assign(mergedDescriptors, descriptors);
}
return Object.defineProperties({}, mergedDescriptors);
}
function esc$1(str) {
return JSON.stringify(str);
}
const captureStackTrace$1 = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
function isObject$2(data) {
return typeof data === "object" && data !== null && !Array.isArray(data);
}
const allowsEval$1 = cached$1(() => {
if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
try {
new Function("");
return true;
} catch (_) {
return false;
}
});
function isPlainObject$1(o) {
if (isObject$2(o) === false) return false;
const ctor = o.constructor;
if (ctor === void 0) return true;
const prot = ctor.prototype;
if (isObject$2(prot) === false) return false;
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
return true;
}
function shallowClone$1(o) {
if (isPlainObject$1(o)) return { ...o };
if (Array.isArray(o)) return [...o];
return o;
}
const propertyKeyTypes$1 = new Set([
"string",
"number",
"symbol"
]);
function escapeRegex$1(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function clone$1(inst, def, params) {
const cl = new inst._zod.constr(def ?? inst._zod.def);
if (!def || params?.parent) cl._zod.parent = inst;
return cl;
}
function normalizeParams$1(_params) {
const params = _params;
if (!params) return {};
if (typeof params === "string") return { error: () => params };
if (params?.message !== void 0) {
if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
params.error = params.message;
}
delete params.message;
if (typeof params.error === "string") return {
...params,
error: () => params.error
};
return params;
}
function optionalKeys$1(shape) {
return Object.keys(shape).filter((k) => {
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
});
}
const NUMBER_FORMAT_RANGES$1 = {
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]
};
function pick$1(schema, mask) {
const currDef = schema._zod.def;
return clone$1(schema, mergeDefs$1(schema._zod.def, {
get shape() {
const newShape = {};
for (const key in mask) {
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
if (!mask[key]) continue;
newShape[key] = currDef.shape[key];
}
assignProp$1(this, "shape", newShape);
return newShape;
},
checks: []
}));
}
function omit$1(schema, mask) {
const currDef = schema._zod.def;
return clone$1(schema, mergeDefs$1(schema._zod.def, {
get shape() {
const newShape = { ...schema._zod.def.shape };
for (const key in mask) {
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
if (!mask[key]) continue;
delete newShape[key];
}
assignProp$1(this, "shape", newShape);
return newShape;
},
checks: []
}));
}
function extend$1(schema, shape) {
if (!isPlainObject$1(shape)) throw new Error("Invalid input to extend: expected a plain object");
const checks = schema._zod.def.checks;
if (checks && checks.length > 0) throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
return clone$1(schema, mergeDefs$1(schema._zod.def, {
get shape() {
const _shape = {
...schema._zod.def.shape,
...shape
};
assignProp$1(this, "shape", _shape);
return _shape;
},
checks: []
}));
}
function safeExtend$1(schema, shape) {
if (!isPlainObject$1(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
return clone$1(schema, {
...schema._zod.def,
get shape() {
const _shape = {
...schema._zod.def.shape,
...shape
};
assignProp$1(this, "shape", _shape);
return _shape;
},
checks: schema._zod.def.checks
});
}
function merge$1(a, b) {
return clone$1(a, mergeDefs$1(a._zod.def, {
get shape() {
const _shape = {
...a._zod.def.shape,
...b._zod.def.shape
};
assignProp$1(this, "shape", _shape);
return _shape;
},
get catchall() {
return b._zod.def.catchall;
},
checks: []
}));
}
function partial$1(Class$1, schema, mask) {
return clone$1(schema, mergeDefs$1(schema._zod.def, {
get shape() {
const oldShape = schema._zod.def.shape;
const shape = { ...oldShape };
if (mask) for (const key in mask) {
if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
if (!mask[key]) continue;
shape[key] = Class$1 ? new Class$1({
type: "optional",
innerType: oldShape[key]
}) : oldShape[key];
}
else for (const key in oldShape) shape[key] = Class$1 ? new Class$1({
type: "optional",
innerType: oldShape[key]
}) : oldShape[key];
assignProp$1(this, "shape", shape);
return shape;
},
checks: []
}));
}
function required$1(Class$1, schema, mask) {
return clone$1(schema, mergeDefs$1(schema._zod.def, {
get shape() {
const oldShape = schema._zod.def.shape;
const shape = { ...oldShape };
if (mask) for (const key in mask) {
if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
if (!mask[key]) continue;
shape[key] = new Class$1({
type: "nonoptional",
innerType: oldShape[key]
});
}
else for (const key in oldShape) shape[key] = new Class$1({
type: "nonoptional",
innerType: oldShape[key]
});
assignProp$1(this, "shape", shape);
return shape;
},
checks: []
}));
}
function aborted$1(x, startIndex = 0) {
if (x.aborted === true) return true;
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
return false;
}
function prefixIssues$1(path, issues) {
return issues.map((iss) => {
var _a;
(_a = iss).path ?? (_a.path = []);
iss.path.unshift(path);
return iss;
});
}
function unwrapMessage$1(message) {
return typeof message === "string" ? message : message?.message;
}
function finalizeIssue$1(iss, ctx, config$2) {
const full = {
...iss,
path: iss.path ?? []
};
if (!iss.message) full.message = unwrapMessage$1(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage$1(ctx?.error?.(iss)) ?? unwrapMessage$1(config$2.customError?.(iss)) ?? unwrapMessage$1(config$2.localeError?.(iss)) ?? "Invalid input";
delete full.inst;
delete full.continue;
if (!ctx?.reportInput) delete full.input;
return full;
}
function getLengthableOrigin$1(input) {
if (Array.isArray(input)) return "array";
if (typeof input === "string") return "string";
return "unknown";
}
function issue$1(...args) {
const [iss, input, inst] = args;
if (typeof iss === "string") return {
message: iss,
code: "custom",
input,
inst
};
return { ...iss };
}
//#endregion
//#region ../../node_modules/zod/v4/core/errors.js
const initializer$3 = (inst, def) => {
inst.name = "$ZodError";
Object.defineProperty(inst, "_zod", {
value: inst._zod,
enumerable: false
});
Object.defineProperty(inst, "issues", {
value: def,
enumerable: false
});
inst.message = JSON.stringify(def, jsonStringifyReplacer$1, 2);
Object.defineProperty(inst, "toString", {
value: () => inst.message,
enumerable: false
});
};
const $ZodError$1 = $constructor$1("$ZodError", initializer$3);
const $ZodRealError$1 = $constructor$1("$ZodError", initializer$3, { Parent: Error });
function flattenError$1(error$45, mapper = (issue$2) => issue$2.message) {
const fieldErrors = {};
const formErrors = [];
for (const sub of error$45.issues) if (sub.path.length > 0) {
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
fieldErrors[sub.path[0]].push(mapper(sub));
} else formErrors.push(mapper(sub));
return {
formErrors,
fieldErrors
};
}
function formatError$1(error$45, mapper = (issue$2) => issue$2.message) {
const fieldErrors = { _errors: [] };
const processError = (error$46) => {
for (const issue$2 of error$46.issues) if (issue$2.code === "invalid_union" && issue$2.errors.length) issue$2.errors.map((issues) => processError({ issues }));
else if (issue$2.code === "invalid_key") processError({ issues: issue$2.issues });
else if (issue$2.code === "invalid_element") processError({ issues: issue$2.issues });
else if (issue$2.path.length === 0) fieldErrors._errors.push(mapper(issue$2));
else {
let curr = fieldErrors;
let i = 0;
while (i < issue$2.path.length) {
const el = issue$2.path[i];
if (!(i === issue$2.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
else {
curr[el] = curr[el] || { _errors: [] };
curr[el]._errors.push(mapper(issue$2));
}
curr = curr[el];
i++;
}
}
};
processError(error$45);
return fieldErrors;
}
//#endregion
//#region ../../node_modules/zod/v4/core/parse.js
const _parse$1 = (_Err) => (schema, value, _ctx, _params) => {
const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
const result = schema._zod.run({
value,
issues: []
}, ctx);
if (result instanceof Promise) throw new $ZodAsyncError$1();
if (result.issues.length) {
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue$1(iss, ctx, config$1())));
captureStackTrace$1(e, _params?.callee);
throw e;
}
return result.value;
};
const parse$4 = /* @__PURE__ */ _parse$1($ZodRealError$1);
const _parseAsync$1 = (_Err) => async (schema, value, _ctx, params) => {
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
let result = schema._zod.run({
value,
issues: []
}, ctx);
if (result instanceof Promise) result = await result;
if (result.issues.length) {
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue$1(iss, ctx, config$1())));
captureStackTrace$1(e, params?.callee);
throw e;
}
return result.value;
};
const parseAsync$3 = /* @__PURE__ */ _parseAsync$1($ZodRealError$1);
const _safeParse$1 = (_Err) => (schema, value, _ctx) => {
const ctx = _ctx ? {
..._ctx,
async: false
} : { async: false };
const result = schema._zod.run({
value,
issues: []
}, ctx);
if (result instanceof Promise) throw new $ZodAsyncError$1();
return result.issues.length ? {
success: false,
error: new (_Err ?? $ZodError$1)(result.issues.map((iss) => finalizeIssue$1(iss, ctx, config$1())))
} : {
success: true,
data: result.value
};
};
const safeParse$3 = /* @__PURE__ */ _safeParse$1($ZodRealError$1);
const _safeParseAsync$1 = (_Err) => async (schema, value, _ctx) => {
const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
let result = schema._zod.run({
value,
issues: []
}, ctx);
if (result instanceof Promise) result = await result;
return result.issues.length ? {
success: false,
error: new _Err(result.issues.map((iss) => finalizeIssue$1(iss, ctx, config$1())))
} : {
success: true,
data: result.value
};
};
const safeParseAsync$3 = /* @__PURE__ */ _safeParseAsync$1($ZodRealError$1);
const _encode$1 = (_Err) => (schema, value, _ctx) => {
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
return _parse$1(_Err)(schema, value, ctx);
};
const encode$3 = /* @__PURE__ */ _encode$1($ZodRealError$1);
const _decode$1 = (_Err) => (schema, value, _ctx) => {
return _parse$1(_Err)(schema, value, _ctx);
};
const decode$3 = /* @__PURE__ */ _decode$1($ZodRealError$1);
const _encodeAsync$1 = (_Err) => async (schema, value, _ctx) => {
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
return _parseAsync$1(_Err)(schema, value, ctx);
};
const encodeAsync$3 = /* @__PURE__ */ _encodeAsync$1($ZodRealError$1);
const _decodeAsync$1 = (_Err) => async (schema, value, _ctx) => {
return _parseAsync$1(_Err)(schema, value, _ctx);
};
const decodeAsync$3 = /* @__PURE__ */ _decodeAsync$1($ZodRealError$1);
const _safeEncode$1 = (_Err) => (schema, value, _ctx) => {
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
return _safeParse$1(_Err)(schema, value, ctx);
};
const safeEncode$3 = /* @__PURE__ */ _safeEncode$1($ZodRealError$1);
const _safeDecode$1 = (_Err) => (schema, value, _ctx) => {
return _safeParse$1(_Err)(schema, value, _ctx);
};
const safeDecode$3 = /* @__PURE__ */ _safeDecode$1($ZodRealError$1);
const _safeEncodeAsync$1 = (_Err) => async (schema, value, _ctx) => {
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
return _safeParseAsync$1(_Err)(schema, value, ctx);
};
const safeEncodeAsync$3 = /* @__PURE__ */ _safeEncodeAsync$1($ZodRealError$1);
const _safeDecodeAsync$1 = (_Err) => async (schema, value, _ctx) => {
return _safeParseAsync$1(_Err)(schema, value, _ctx);
};
const safeDecodeAsync$3 = /* @__PURE__ */ _safeDecodeAsync$1($ZodRealError$1);
//#endregion
//#region ../../node_modules/zod/v4/core/regexes.js
const cuid$2 = /^[cC][^\s-]{8,}$/;
const cuid2$2 = /^[0-9a-z]+$/;
const ulid$2 = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
const xid$2 = /^[0-9a-vA-V]{20}$/;
const ksuid$2 = /^[A-Za-z0-9]{27}$/;
const nanoid$2 = /^[a-zA-Z0-9_-]{21}$/;
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
const duration$3 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
const guid$2 = /^([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$2 = (version$4) => {
if (!version$4) 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 /* @__PURE__ */ new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version$4}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
};
/** Practical email validation */
const email$2 = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
const _emoji$3 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
function emoji$2() {
return new RegExp(_emoji$3, "u");
}
const ipv4$2 = /^(?:(?: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$2 = /^(([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 cidrv4$2 = /^((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$2 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
const base64$2 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
const base64url$2 = /^[A-Za-z0-9_-]*$/;
const hostname$2 = /^(?=.{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 e164$2 = /^\+(?:[0-9]){6,14}[0-9]$/;
const dateSource$1 = `(?:(?:\\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])))`;
const date$5 = /* @__PURE__ */ new RegExp(`^${dateSource$1}$`);
function timeSource$1(args) {
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
}
function time$3(args) {
return /* @__PURE__ */ new RegExp(`^${timeSource$1(args)}$`);
}
function datetime$3(args) {
const time$4 = timeSource$1({ precision: args.precision });
const opts = ["Z"];
if (args.local) opts.push("");
if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
const timeRegex = `${time$4}(?:${opts.join("|")})`;
return /* @__PURE__ */ new RegExp(`^${dateSource$1}T(?:${timeRegex})$`);
}
const string$4 = (params) => {
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
return /* @__PURE__ */ new RegExp(`^${regex}$`);
};
const _null$5 = /^null$/i;
const lowercase$1 = /^[^A-Z]*$/;
const uppercase$1 = /^[^a-z]*$/;
//#endregion
//#region ../../node_modules/zod/v4/core/checks.js
const $ZodCheck$1 = /* @__PURE__ */ $constructor$1("$ZodCheck", (inst, def) => {
var _a;
inst._zod ?? (inst._zod = {});
inst._zod.def = def;
(_a = inst._zod).onattach ?? (_a.onattach = []);
});
const $ZodCheckMaxLength$1 = /* @__PURE__ */ $constructor$1("$ZodCheckMaxLength", (inst, def) => {
var _a;
$ZodCheck$1.init(inst, def);
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
const val = payload.value;
return !nullish$2(val) && val.length !== void 0;
});
inst._zod.onattach.push((inst$1) => {
const curr = inst$1._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
if (def.maximum < curr) inst$1._zod.bag.maximum = def.maximum;
});
inst._zod.check = (payload) => {
const input = payload.value;
if (input.length <= def.maximum) return;
const origin = getLengthableOrigin$1(input);
payload.issues.push({
origin,
code: "too_big",
maximum: def.maximum,
inclusive: true,
input,
inst,
continue: !def.abort
});
};
});
const $ZodCheckMinLength$1 = /* @__PURE__ */ $constructor$1("$ZodCheckMinLength", (inst, def) => {
var _a;
$ZodCheck$1.init(inst, def);
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
const val = payload.value;
return !nullish$2(val) && val.length !== void 0;
});
inst._zod.onattach.push((inst$1) => {
const curr = inst$1._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
if (def.minimum > curr) inst$1._zod.bag.minimum = def.minimum;
});
inst._zod.check = (payload) => {
const input = payload.value;
if (input.length >= def.minimum) return;
const origin = getLengthableOrigin$1(input);
payload.issues.push({
origin,
code: "too_small",
minimum: def.minimum,
inclusive: true,
input,
inst,
continue: !def.abort
});
};
});
const $ZodCheckLengthEquals$1 = /* @__PURE__ */ $constructor$1("$ZodCheckLengthEquals", (inst, def) => {
var _a;
$ZodCheck$1.init(inst, def);
(_a = inst._zod.def).when ?? (_a.when = (payload) => {
const val = payload.value;
return !nullish$2(val) && val.length !== void 0;
});
inst._zod.onattach.push((inst$1) => {
const bag = inst$1._zod.bag;
bag.minimum = def.length;
bag.maximum = def.length;
bag.length = def.length;
});
inst._zod.check = (payload) => {
const input = payload.value;
const length = input.length;
if (length === def.length) return;
const origin = getLengthableOrigin$1(input);
const tooBig = length > def.length;
payload.issues.push({
origin,
...tooBig ? {
code: "too_big",
maximum: def.length
} : {
code: "too_small",
minimum: def.length
},
inclusive: true,
exact: true,
input: payload.value,
inst,
continue: !def.abort
});
};
});
const $ZodCheckStringFormat$1 = /* @__PURE__ */ $constructor$1("$ZodCheckStringFormat", (inst, def) => {
var _a, _b;
$ZodCheck$1.init(inst, def);
inst._zod.onattach.push((inst$1) => {
const bag = inst$1._zod.bag;
bag.format = def.format;
if (def.pattern) {
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
bag.patterns.add(def.pattern);
}
});
if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
def.pattern.lastIndex = 0;
if (def.pattern.test(payload.value)) return;
payload.issues.push({
origin: "string",
code: "invalid_format",
format: def.format,
input: payload.value,
...def.pattern ? { pattern: def.pattern.toString() } : {},
inst,
continue: !def.abort
});
});
else (_b = inst._zod).check ?? (_b.check = () => {});
});
const $ZodCheckRegex$1 = /* @__PURE__ */ $constructor$1("$ZodCheckRegex", (inst, def) => {
$ZodCheckStringFormat$1.init(inst, def);
inst._zod.check = (payload) => {
def.pattern.lastIndex = 0;
if (def.pattern.test(payload.value)) return;
payload.issues.push({
origin: "string",
code: "invalid_format",
format: "regex",
input: payload.value,
pattern: def.pattern.toString(),
inst,
continue: !def.abort
});
};
});
const $ZodCheckLowerCase$1 = /* @__PURE__ */ $constructor$1("$ZodCheckLowerCase", (inst, def) => {
def.pattern ?? (def.pattern = lowercase$1);
$ZodCheckStringFormat$1.init(inst, def);
});
const $ZodCheckUpperCase$1 = /* @__PURE__ */ $constructor$1("$ZodCheckUpperCase", (inst, def) => {
def.pattern ?? (def.pattern = uppercase$1);
$ZodCheckStringFormat$1.init(inst, def);
});
const $ZodCheckIncludes$1 = /* @__PURE__ */ $constructor$1("$ZodCheckIncludes", (inst, def) => {
$ZodCheck$1.init(inst, def);
const escapedRegex = escapeRegex$1(def.includes);
const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
def.pattern = pattern;
inst._zod.onattach.push((inst$1) => {
const bag = inst$1._zod.bag;
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
bag.patterns.add(pattern);
});
inst._zod.check = (payload) => {
if (payload.value.includes(def.includes, def.position)) return;
payload.issues.push({
origin: "string",
code: "invalid_format",
format: "includes",
includes: def.includes,
input: payload.value,
inst,
continue: !def.abort
});
};
});
const $ZodCheckStartsWith$1 = /* @__PURE__ */ $constructor$1("$ZodCheckStartsWith", (inst, def) => {
$ZodCheck$1.init(inst, def);
const pattern = /* @__PURE__ */ new RegExp(`^${escapeRegex$1(def.prefix)}.*`);
def.pattern ?? (def.pattern = pattern);
inst._zod.onattach.push((inst$1) => {
const bag = inst$1._zod.bag;
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
bag.patterns.add(pattern);
});
inst._zod.check = (payload) => {
if (payload.value.startsWith(def.prefix)) return;
payload.issues.push({
origin: "string",
code: "invalid_format",
format: "starts_with",
prefix: def.prefix,
input: payload.value,
inst,
continue: !def.abort
});
};
});
const $ZodCheckEndsWith$1 = /* @__PURE__ */ $constructor$1("$ZodCheckEndsWith", (inst, def) => {
$ZodCheck$1.init(inst, def);
const pattern = /* @__PURE__ */ new RegExp(`.*${escapeRegex$1(def.suffix)}$`);
def.pattern ?? (def.pattern = pattern);
inst._zod.onattach.push((inst$1) => {
const bag = inst$1._zod.bag;
bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
bag.patterns.add(pattern);
});
inst._zod.check = (payload) => {
if (payload.value.endsWith(def.suffix)) return;
payload.issues.push({
origin: "string",
code: "invalid_format",
format: "ends_with",
suffix: def.suffix,
input: payload.value,
inst,
continue: !def.abort
});
};
});
const $ZodCheckOverwrite$1 = /* @__PURE__ */ $constructor$1("$ZodCheckOverwrite", (inst, def) => {
$ZodCheck$1.init(inst, def);
inst._zod.check = (payload) => {
payload.value = def.tx(payload.value);
};
});
//#endregion
//#region ../../node_modules/zod/v4/core/doc.js
var Doc$1 = class {
constructor(args = []) {
this.content = [];
this.indent = 0;
if (this) this.args = args;
}
indented(fn) {
this.indent += 1;
fn(this);
this.indent -= 1;
}
write(arg) {
if (typeof arg === "function") {
arg(this, { execution: "sync" });
arg(this, { execution: "async" });
return;
}
const lines = arg.split("\n").filter((x) => x);
const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
for (const line of dedented) this.content.push(line);
}
compile() {
const F = Function;
const args = this?.args;
const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
return new F(...args, lines.join("\n"));
}
};
//#endregion
//#region ../../node_modules/zod/v4/core/versions.js
const version$3 = {
major: 4,
minor: 1,
patch: 12
};
//#endregion
//#region ../../node_modules/zod/v4/core/schemas.js
const $ZodType$1 = /* @__PURE__ */ $constructor$1("$ZodType", (inst, def) => {
var _a;
inst ?? (inst = {});
inst._zod.def = def;
inst._zod.bag = inst._zod.bag || {};
inst._zod.version = version$3;
const checks = [...inst._zod.def.checks ?? []];
if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
if (checks.length === 0) {
(_a = inst._zod).deferred ?? (_a.deferred = []);
inst._zod.deferred?.push(() => {
inst._zod.run = inst._zod.parse;
});
} else {
const runChecks = (payload, checks$1, ctx) => {
let isAborted = aborted$1(payload);
let asyncResult;
for (const ch of checks$1) {
if (ch._zod.def.when) {
if (!ch._zod.def.when(payload)) continue;
} else if (isAborted) continue;
const currLen = payload.issues.length;
const _ = ch._zod.check(payload);
if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError$1();
if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
await _;
if (payload.issues.length === currLen) return;
if (!isAborted) isAborted = aborted$1(payload, currLen);
});
else {
if (payload.issues.length === currLen) continue;
if (!isAborted) isAborted = aborted$1(payload, currLen);
}
}
if (asyncResult) return asyncResult.then(() => {
return payload;
});
return payload;
};
const handleCanaryResult = (canary, payload, ctx) => {
if (aborted$1(canary)) {
canary.aborted = true;
return canary;
}
const checkResult = runChecks(payload, checks, ctx);
if (checkResult instanceof Promise) {
if (ctx.async === false) throw new $ZodAsyncError$1();
return checkResult.then((checkResult$1) => inst._zod.parse(checkResult$1, ctx));
}
return inst._zod.parse(checkResult, ctx);
};
inst._zod.run = (payload, ctx) => {
if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
if (ctx.direction === "backward") {
const canary = inst._zod.parse({
value: payload.value,
issues: []
}, {
...ctx,
skipChecks: true
});
if (canary instanceof Promise) return canary.then((canary$1) => {
return handleCanaryResult(canary$1, payload, ctx);
});
return handleCanaryResult(canary, payload, ctx);
}
const result = inst._zod.parse(payload, ctx);
if (result instanceof Promise) {
if (ctx.async === false) throw new $ZodAsyncError$1();
return result.then((result$1) => runChecks(result$1, checks, ctx));
}
return runChecks(result, checks, ctx);
};
}
inst["~standard"] = {
validate: (value) => {
try {
const r = safeParse$3(inst, value);
return r.success ? { value: r.data } : { issues: r.error?.issues };
} catch (_) {
return safeParseAsync$3(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
}
},
vendor: "zod",
version: 1
};
});
const $ZodString$1 = /* @__PURE__ */ $constructor$1("$ZodString", (inst, def) => {
$ZodType$1.init(inst, def);
inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$4(inst._zod.bag);
inst._zod.parse = (payload, _) => {
if (def.coerce) try {
payload.value = String(payload.value);
} catch (_$1) {}
if (typeof payload.value === "string") return payload;
payload.issues.push({
expected: "string",
code: "invalid_type",
input: payload.value,
inst
});
return payload;
};
});
const $ZodStringFormat$1 = /* @__PURE__ */ $constructor$1("$ZodStringFormat", (inst, def) => {
$ZodCheckStringFormat$1.init(inst, def);
$ZodString$1.init(inst, def);
});
const $ZodGUID$1 = /* @__PURE__ */ $constructor$1("$ZodGUID", (inst, def) => {
def.pattern ?? (def.pattern = guid$2);
$ZodStringFormat$1.init(inst, def);
});
const $ZodUUID$1 = /* @__PURE__ */ $constructor$1("$ZodUUID", (inst, def) => {
if (def.version) {
const v = {
v1: 1,
v2: 2,
v3: 3,
v4: 4,
v5: 5,
v6: 6,
v7: 7,
v8: 8
}[def.version];
if (v === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
def.pattern ?? (def.pattern = uuid$2(v));
} else def.pattern ?? (def.pattern = uuid$2());
$ZodStringFormat$1.init(inst, def);
});
const $ZodEmail$1 = /* @__PURE__ */ $constructor$1("$ZodEmail", (inst, def) => {
def.pattern ?? (def.pattern = email$2);
$ZodStringFormat$1.init(inst, def);
});
const $ZodURL$1 = /* @__PURE__ */ $constructor$1("$ZodURL", (inst, def) => {
$ZodStringFormat$1.init(inst, def);
inst._zod.check = (payload) => {
try {
const trimmed = payload.value.trim();
const url$1 = new URL(trimmed);
if (def.hostname) {
def.hostname.lastIndex = 0;
if (!def.hostname.test(url$1.hostname)) payload.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid hostname",
pattern: hostname$2.source,
input: payload.value,
inst,
continue: !def.abort
});
}
if (def.protocol) {
def.protocol.lastIndex = 0;
if (!def.protocol.test(url$1.protocol.endsWith(":") ? url$1.protocol.slice(0, -1) : url$1.protocol)) payload.issues.push({
code: "invalid_format",
format: "url",
note: "Invalid protocol",
pattern: def.protocol.source,
input: payload.value,
inst,
continue: !def.abort
});
}
if (def.normalize) payload.value = url$1.href;
else payload.value = trimmed;
return;
} catch (_) {
payload.issues.push({
code: "invalid_format",
format: "url",
input: payload.value,
inst,
continue: !def.abort
});
}
};
});
const $ZodEmoji$1 = /* @__PURE__ */ $constructor$1("$ZodEmoji", (inst, def) => {
def.pattern ?? (def.pattern = emoji$2());
$ZodStringFormat$1.init(inst, def);
});
const $ZodNanoID$1 = /* @__PURE__ */ $constructor$1("$ZodNanoID", (inst, def) => {
def.pattern ?? (def.pattern = nanoid$2);
$ZodStringFormat$1.init(inst, def);
});
const $ZodCUID$1 = /* @__PURE__ */ $constructor$1("$ZodCUID", (inst, def) => {
def.pattern ?? (def.pattern = cuid$2);
$ZodStringFormat$1.init(inst, def);
});
const $ZodCUID2$1 = /* @__PURE__ */ $constructor$1("$ZodCUID2", (inst, def) => {
def.pattern ?? (def.pattern = cuid2$2);
$ZodStringFormat$1.init(inst, def);
});
const $ZodULID$1 = /* @__PURE__ */ $constructor$1("$ZodULID", (inst, def) => {
def.pattern ?? (def.pattern = ulid$2);
$ZodStringFormat$1.init(inst, def);
});
const $ZodXID$1 = /* @__PURE__ */ $constructor$1("$ZodXID", (inst, def) => {
def.pattern ?? (def.pattern = xid$2);
$ZodStringFormat$1.init(inst, def);
});
const $ZodKSUID$1 = /* @__PURE__ */ $constructor$1("$ZodKSUID", (inst, def) => {
def.pattern ?? (def.pattern = ksuid$2);
$ZodStringFormat$1.init(inst, def);
});
const $ZodISODateTime$1 = /* @__PURE__ */ $constructor$1("$ZodISODateTime", (inst, def) => {
def.pattern ?? (def.pattern = datetime$3(def));
$ZodStringFormat$1.init(inst, def);
});
const $ZodISODate$1 = /* @__PURE__ */ $constructor$1("$ZodISODate", (inst, def) => {
def.pattern ?? (def.pattern = date$5);
$ZodStringFormat$1.init(inst, def);
});
const $ZodISOTime$1 = /* @__PURE__ */ $constructor$1("$ZodISOTime", (inst, def) => {
def.pattern ?? (def.pattern = time$3(def));
$ZodStringFormat$1.init(inst, def);
});
const $ZodISODuration$1 = /* @__PURE__ */ $constructor$1("$ZodISODuration", (inst, def) => {
def.pattern ?? (def.pattern = duration$3);
$ZodStringFormat$1.init(inst, def);
});
const $ZodIPv4$1 = /* @__PURE__ */ $constructor$1("$ZodIPv4", (inst, def) => {
def.pattern ?? (def.pattern = ipv4$2);
$ZodStringFormat$1.init(inst, def);
inst._zod.onattach.push((inst$1) => {
const bag = inst$1._zod.bag;
bag.format = `ipv4`;
});
});
const $ZodIPv6$1 = /* @__PURE__ */ $constructor$1("$ZodIPv6", (inst, def) => {
def.pattern ?? (def.pattern = ipv6$2);
$ZodStringFormat$1.init(inst, def);
inst._zod.onattach.push((inst$1) => {
const bag = inst$1._zod.bag;
bag.format = `ipv6`;
});
inst._zod.check = (payload) => {
try {
new URL(`http://[${payload.value}]`);
} catch {
payload.issues.push({
code: "invalid_format",
format: "ipv6",
input: payload.value,
inst,
continue: !def.abort
});
}
};
});
const $ZodCIDRv4$1 = /* @__PURE__ */ $constructor$1("$ZodCIDRv4", (inst, def) => {
def.pattern ?? (def.pattern = cidrv4$2);
$ZodStringFormat$1.init(inst, def);
});
const $ZodCIDRv6$1 = /* @__PURE__ */ $constructor$1("$ZodCIDRv6", (inst, def) => {
def.pattern ?? (def.pattern = cidrv6$2);
$ZodStringFormat$1.init(inst, def);
inst._zod.check = (payload) => {
const parts = payload.value.split("/");
try {
if (parts.length !== 2) throw new Error();
const [address, prefix] = parts;
if (!prefix) throw new Error();
const prefixNum = Number(prefix);
if (`${prefixNum}` !== prefix) throw new Error();
if (prefixNum < 0 || prefixNum > 128) throw new Error();
new URL(`http://[${address}]`);
} catch {
payload.issues.push({
code: "invalid_format",
format: "cidrv6",
input: payload.value,
inst,
continue: !def.abort
});
}
};
});
function isValidBase64$1(data) {
if (data === "") return true;
if (data.length % 4 !== 0) return false;
try {
atob(data);
return true;
} catch {
return false;
}
}
const $ZodBase64$1 = /* @__PURE__ */ $constructor$1("$ZodBase64", (inst, def) => {
def.pattern ?? (def.pattern = base64$2);
$ZodStringFormat$1.init(inst, def);
inst._zod.onattach.push((inst$1) => {
inst$1._zod.bag.contentEncoding = "base64";
});
inst._zod.check = (payload) => {
if (isValidBase64$1(payload.value)) return;
payload.issues.push({
code: "invalid_format",
format: "base64",
input: payload.value,
inst,
continue: !def.abort
});
};
});
function isValidBase64URL$1(data) {
if (!base64url$2.test(data)) return false;
const base64$3 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
return isValidBase64$1(base64$3.padEnd(Math.ceil(base64$3.length / 4) * 4, "="));
}
const $ZodBase64URL$1 = /* @__PURE__ */ $constructor$1("$ZodBase64URL", (inst, def) => {
def.pattern ?? (def.pattern = base64url$2);
$ZodStringFormat$1.init(inst, def);
inst._zod.onattach.push((inst$1) => {
inst$1._zod.bag.contentEncoding = "base64url";
});
inst._zod.check = (payload) => {
if (isValidBase64URL$1(payload.value)) return;
payload.issues.push({
code: "invalid_format",
format: "base64url",
input: payload.value,
inst,
continue: !def.abort
});
};
});
const $ZodE164$1 = /* @__PURE__ */ $constructor$1("$ZodE164", (inst, def) => {
def.pattern ?? (def.pattern = e164$2);
$ZodStringFormat$1.init(inst, def);
});
function isValidJWT$1(token$1, algorithm = null) {
try {
const tokensParts = token$1.split(".");
if (tokensParts.length !== 3) return false;
const [header] = tokensParts;
if (!header) return false;
const parsedHeader = JSON.parse(atob(header));
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
if (!parsedHeader.alg) return false;
if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
return true;
} catch {
return false;
}
}
const $ZodJWT$1 = /* @__PURE__ */ $constructor$1("$ZodJWT", (inst, def) => {
$ZodStringFormat$1.init(inst, def);
inst._zod.check = (payload) => {
if (isValidJWT$1(payload.value, def.alg)) return;
payload.issues.push({
code: "invalid_format",
format: "jwt",
input: payload.value,
inst,
continue: !def.abort
});
};
});
const $ZodNull$1 = /* @__PURE__ */ $constructor$1("$ZodNull", (inst, def) => {
$ZodType$1.init(inst, def);
inst._zod.pattern = _null$5;
inst._zod.values = new Set([null]);
inst._zod.parse = (payload, _ctx) => {
const input = payload.value;
if (input === null) return payload;
payload.issues.push({
expected: "null",
code: "invalid_type",
input,
inst
});
return payload;
};
});
const $ZodAny$1 = /* @__PURE__ */ $constructor$1("$ZodAny", (inst, def) => {
$ZodType$1.init(inst, def);
inst._zod.parse = (payload) => payload;
});
const $ZodUnknown$1 = /* @__PURE__ */ $constructor$1("$ZodUnknown", (inst, def) => {
$ZodType$1.init(inst, def);
inst._zod.parse = (payload) => payload;
});
const $ZodNever$1 = /* @__PURE__ */ $constructor$1("$ZodNever", (inst, def) => {
$ZodType$1.init(inst, def);
inst._zod.parse = (payload, _ctx) => {
payload.issues.push({
expected: "never",
code: "invalid_type",
input: payload.value,
inst
});
return payload;
};
});
function handleArrayResult$1(result, final, index) {
if (result.issues.length) final.issues.push(...prefixIssues$1(index, result.issues));
final.value[index] = result.value;
}
const $ZodArray$1 = /* @__PURE__ */ $constructor$1("$ZodArray", (inst, def) => {
$ZodType$1.init(inst, def);
inst._zod.parse = (payload, ctx) => {
const input = payload.value;
if (!Array.isArray(input)) {
payload.issues.push({
expected: "array",
code: "invalid_type",
input,
inst
});
return payload;
}
payload.value = Array(input.length);
const proms = [];
for (let i = 0; i < input.length; i++) {
const item = input[i];
const result = def.element._zod.run({
value: item,
issues: []
}, ctx);
if (result instanceof Promise) proms.push(result.then((result$1) => handleArrayResult$1(result$1, payload, i)));
else handleArrayResult$1(result, payload, i);
}
if (proms.length) return Promise.all(proms).then(() => payload);
return payload;
};
});
function handlePropertyResult$1(result, final, key, input) {
if (result.issues.length) final.issues.push(...prefixIssues$1(key, result.issues));
if (result.value === void 0) {
if (key in input) final.value[key] = void 0;
} else final.value[key] = result.value;
}
function normalizeDef$1(def) {
const keys = Object.keys(def.shape);
for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
const okeys = optionalKeys$1(def.shape);
return {
...def,
keys,
keySet: new Set(keys),
numKeys: keys.length,
optionalKeys: new Set(okeys)
};
}
function handleCatchall$1(proms, input, payload, ctx, def, inst) {
const unrecognized = [];
const keySet = def.keySet;
const _catchall = def.catchall._zod;
const t = _catchall.def.type;
for (const key of Object.keys(input)) {
if (keySet.has(key)) continue;
if (t === "never") {
unrecognized.push(key);
continue;
}
const r = _catchall.run({
value: input[key],
issues: []
}, ctx);
if (r instanceof Promise) proms.push(r.then((r$1) => handlePropertyResult$1(r$1, payload, key, input)));
else handlePropertyResult$1(r, payload, key, input);
}
if (unrecognized.length) payload.issues.push({
code: "unrecognized_keys",
keys: unrecognized,
input,
inst
});
if (!proms.length) return payload;
return Promise.all(proms).then(() => {
return payload;
});
}
const $ZodObject$1 = /* @__PURE__ */ $constructor$1("$ZodObject", (inst, def) => {
$ZodType$1.init(inst, def);
if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
const sh = def.shape;
Object.defineProperty(def, "shape", { get: () => {
const newSh = { ...sh };
Object.defineProperty(def, "shape", { value: newSh });
return newSh;
} });
}
const _normalized = cached$1(() => normalizeDef$1(def));
defineLazy$1(inst._zod, "propValues", () => {
const shape = def.shape;
const propValues = {};
for (const key in shape) {
const field = shape[key]._zod;
if (field.values) {
propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
for (const v of field.values) propValues[key].add(v);
}
}
return propValues;
});
const isObject$3 = isObject$2;
const catchall = def.catchall;
let value;
inst._zod.parse = (payload, ctx) => {
value ?? (value = _normalized.value);
const input = payload.value;
if (!isObject$3(input)) {
payload.issues.push({
expected: "object",
code: "invalid_type",
input,
inst
});
return payload;
}
payload.value = {};
const proms = [];
const shape = value.shape;
for (const key of value.keys) {
const r = shape[key]._zod.run({
value: input[key],
issues: []
}, ctx);
if (r instanceof Promise) proms.push(r.then((r$1) => handlePropertyResult$1(r$1, payload, key, input)));
else handlePropertyResult$1(r, payload, key, input);
}
if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
return handleCatchall$1(proms, input, payload, ctx, _normalized.value, inst);
};
});
const $ZodObjectJIT$1 = /* @__PURE__ */ $constructor$1("$ZodObjectJIT", (inst, def) => {
$ZodObject$1.init(inst, def);
const superParse = inst._zod.parse;
const _normalized = cached$1(() => normalizeDef$1(def));
const generateFastpass = (shape) => {
const doc = new Doc$1([
"shape",
"payload",
"ctx"
]);
const normalized = _normalized.value;
const parseStr = (key) => {
const k = esc$1(key);
return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
};
doc.write(`const input = payload.value;`);
const ids = Object.create(null);
let counter = 0;
for (const key of normalized.keys) ids[key] = `key_${counter++}`;
doc.write(`const newResult = {};`);
for (const key of normalized.keys) {
const id = ids[key];
const k = esc$1(key);
doc.write(`const ${id} = ${parseStr(key)};`);
doc.write(`
if (${id}.issues.length) {
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
...iss,
path: iss.path ? [${k}, ...iss.path] : [${k}]
})));
}
if (${id}.value === undefined) {
if (${k} in input) {
newResult[${k}] = undefined;
}
} else {
newResult[${k}] = ${id}.value;
}
`);
}
doc.write(`payload.value = newResult;`);
doc.write(`return payload;`);
const fn = doc.compile();
return (payload, ctx) => fn(shape, payload, ctx);
};
let fastpass;
const isObject$3 = isObject$2;
const jit = !globalConfig$1.jitless;
const allowsEval$2 = allowsEval$1;
const fastEnabled = jit && allowsEval$2.value;
const catchall = def.catchall;
let value;
inst._zod.parse = (payload, ctx) => {
value ?? (value = _normalized.value);
const input = payload.value;
if (!isObject$3(input)) {
payload.issues.push({
expected: "object",
code: "invalid_type",
input,
inst
});
return payload;
}
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
if (!fastpass) fastpass = generateFastpass(def.shape);
payload = fastpass(payload, ctx);
if (!catchall) return payload;
return handleCatchall$1([], input, payload, ctx, value, inst);
}
return superParse(payload, ctx);
};
});
function handleUnionResults$1(results, final, inst, ctx) {
for (const result of results) if (result.issues.length === 0) {
final.value = result.value;
return final;
}
const nonaborted = results.filter((r) => !aborted$1(r));
if (nonaborted.length === 1) {
final.value = nonaborted[0].value;
return nonaborted[0];
}
final.issues.push({
code: "invalid_union",
input: final.value,
inst,
errors: results.map((result) => result.issues.map((iss) => finalizeIssue$1(iss, ctx, config$1())))
});
return final;
}
const $ZodUnion$1 = /* @__PURE__ */ $constructor$1("$ZodUnion", (inst, def) => {
$ZodType$1.init(inst, def);
defineLazy$1(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
defineLazy$1(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
defineLazy$1(inst._zod, "values", () => {
if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
});
defineLazy$1(inst._zod, "pattern", () => {
if (def.options.every((o) => o._zod.pattern)) {
const patterns = def.options.map((o) => o._zod.pattern);
return /* @__PURE__ */ new RegExp(`^(${patterns.map((p) => cleanRegex$1(p.source)).join("|")})$`);
}
});
const single = def.options.length === 1;
const first = def.options[0]._zod.run;
inst._zod.parse = (payload, ctx) => {
if (single) return first(payload, ctx);
let async = false;
const results = [];
for (const option of def.options) {
const result = option._zod.run({
value: payload.value,
issues: []
}, ctx);
if (result instanceof Promise) {
results.push(result);
async = true;
} else {
if (result.issues.length === 0) return result;
results.push(result);
}
}
if (!async) return handleUnionResults$1(results, payload, inst, ctx);
return Promise.all(results).then((results$1) => {
return handleUnionResults$1(results$1, payload, inst, ctx);
});
};
});
const $ZodIntersection$1 = /* @__PURE__ */ $constructor$1("$ZodIntersection", (inst, def) => {
$ZodType$1.init(inst, def);
inst._zod.parse = (payload, ctx) => {
const input = payload.value;
const left = def.left._zod.run({
value: input,
issues: []
}, ctx);
const right = def.right._zod.run({
value: input,
issues: []
}, ctx);
if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left$1, right$1]) => {
return handleIntersectionResults$1(payload, left$1, right$1);
});
return handleIntersectionResults$1(payload, left, right);
};
});
function mergeValues$1(a, b) {
if (a === b) return {
valid: true,
data: a
};
if (a instanceof Date && b instanceof Date && +a === +b) return {
valid: true,
data: a
};
if (isPlainObject$1(a) && isPlainObject$1(b)) {
const bKeys = Object.keys(b);
const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
const newObj = {
...a,
...b
};
for (const key of sharedKeys) {
const sharedValue = mergeValues$1(a[key], b[key]);
if (!sharedValue.valid) return {
v