@daydreamsai/ai-sdk-provider
Version:
Dreams Router AI SDK provider (forked from OpenRouter)
1,640 lines (1,632 loc) • 505 kB
JavaScript
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __export = (target, all) => {
for (var name14 in all)
__defProp(target, name14, { get: all[name14], enumerable: true });
};
// node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/dist/index.mjs
var marker = "vercel.ai.error";
var symbol = Symbol.for(marker);
var _a;
var _AISDKError = class _AISDKError2 extends Error {
/**
* Creates an AI SDK Error.
*
* @param {Object} params - The parameters for creating the error.
* @param {string} params.name - The name of the error.
* @param {string} params.message - The error message.
* @param {unknown} [params.cause] - The underlying cause of the error.
*/
constructor({
name: name14,
message,
cause
}) {
super(message);
this[_a] = true;
this.name = name14;
this.cause = cause;
}
/**
* Checks if the given error is an AI SDK Error.
* @param {unknown} error - The error to check.
* @returns {boolean} True if the error is an AI SDK Error, false otherwise.
*/
static isInstance(error43) {
return _AISDKError2.hasMarker(error43, marker);
}
static hasMarker(error43, marker15) {
const markerSymbol = Symbol.for(marker15);
return error43 != null && typeof error43 === "object" && markerSymbol in error43 && typeof error43[markerSymbol] === "boolean" && error43[markerSymbol] === true;
}
};
_a = symbol;
var AISDKError = _AISDKError;
var name = "AI_APICallError";
var marker2 = `vercel.ai.error.${name}`;
var symbol2 = Symbol.for(marker2);
var _a2;
var APICallError = class extends AISDKError {
constructor({
message,
url: url2,
requestBodyValues,
statusCode,
responseHeaders,
responseBody,
cause,
isRetryable = statusCode != null && (statusCode === 408 || // request timeout
statusCode === 409 || // conflict
statusCode === 429 || // too many requests
statusCode >= 500),
// server error
data
}) {
super({ name, message, cause });
this[_a2] = true;
this.url = url2;
this.requestBodyValues = requestBodyValues;
this.statusCode = statusCode;
this.responseHeaders = responseHeaders;
this.responseBody = responseBody;
this.isRetryable = isRetryable;
this.data = data;
}
static isInstance(error43) {
return AISDKError.hasMarker(error43, marker2);
}
};
_a2 = symbol2;
var name2 = "AI_EmptyResponseBodyError";
var marker3 = `vercel.ai.error.${name2}`;
var symbol3 = Symbol.for(marker3);
var _a3;
var EmptyResponseBodyError = class extends AISDKError {
// used in isInstance
constructor({ message = "Empty response body" } = {}) {
super({ name: name2, message });
this[_a3] = true;
}
static isInstance(error43) {
return AISDKError.hasMarker(error43, marker3);
}
};
_a3 = symbol3;
function getErrorMessage(error43) {
if (error43 == null) {
return "unknown error";
}
if (typeof error43 === "string") {
return error43;
}
if (error43 instanceof Error) {
return error43.message;
}
return JSON.stringify(error43);
}
var name3 = "AI_InvalidArgumentError";
var marker4 = `vercel.ai.error.${name3}`;
var symbol4 = Symbol.for(marker4);
var _a4;
var InvalidArgumentError = class extends AISDKError {
constructor({
message,
cause,
argument
}) {
super({ name: name3, message, cause });
this[_a4] = true;
this.argument = argument;
}
static isInstance(error43) {
return AISDKError.hasMarker(error43, marker4);
}
};
_a4 = symbol4;
var name4 = "AI_InvalidPromptError";
var marker5 = `vercel.ai.error.${name4}`;
var symbol5 = Symbol.for(marker5);
var _a5;
var InvalidPromptError = class extends AISDKError {
constructor({
prompt,
message,
cause
}) {
super({ name: name4, message: `Invalid prompt: ${message}`, cause });
this[_a5] = true;
this.prompt = prompt;
}
static isInstance(error43) {
return AISDKError.hasMarker(error43, marker5);
}
};
_a5 = symbol5;
var name5 = "AI_InvalidResponseDataError";
var marker6 = `vercel.ai.error.${name5}`;
var symbol6 = Symbol.for(marker6);
var _a6;
var InvalidResponseDataError = class extends AISDKError {
constructor({
data,
message = `Invalid response data: ${JSON.stringify(data)}.`
}) {
super({ name: name5, message });
this[_a6] = true;
this.data = data;
}
static isInstance(error43) {
return AISDKError.hasMarker(error43, marker6);
}
};
_a6 = symbol6;
var name6 = "AI_JSONParseError";
var marker7 = `vercel.ai.error.${name6}`;
var symbol7 = Symbol.for(marker7);
var _a7;
var JSONParseError = class extends AISDKError {
constructor({ text, cause }) {
super({
name: name6,
message: `JSON parsing failed: Text: ${text}.
Error message: ${getErrorMessage(cause)}`,
cause
});
this[_a7] = true;
this.text = text;
}
static isInstance(error43) {
return AISDKError.hasMarker(error43, marker7);
}
};
_a7 = symbol7;
var name7 = "AI_LoadAPIKeyError";
var marker8 = `vercel.ai.error.${name7}`;
var symbol8 = Symbol.for(marker8);
var _a8;
_a8 = symbol8;
var name8 = "AI_LoadSettingError";
var marker9 = `vercel.ai.error.${name8}`;
var symbol9 = Symbol.for(marker9);
var _a9;
_a9 = symbol9;
var name9 = "AI_NoContentGeneratedError";
var marker10 = `vercel.ai.error.${name9}`;
var symbol10 = Symbol.for(marker10);
var _a10;
_a10 = symbol10;
var name10 = "AI_NoSuchModelError";
var marker11 = `vercel.ai.error.${name10}`;
var symbol11 = Symbol.for(marker11);
var _a11;
_a11 = symbol11;
var name11 = "AI_TooManyEmbeddingValuesForCallError";
var marker12 = `vercel.ai.error.${name11}`;
var symbol12 = Symbol.for(marker12);
var _a12;
_a12 = symbol12;
var name12 = "AI_TypeValidationError";
var marker13 = `vercel.ai.error.${name12}`;
var symbol13 = Symbol.for(marker13);
var _a13;
var _TypeValidationError = class _TypeValidationError2 extends AISDKError {
constructor({ value, cause }) {
super({
name: name12,
message: `Type validation failed: Value: ${JSON.stringify(value)}.
Error message: ${getErrorMessage(cause)}`,
cause
});
this[_a13] = true;
this.value = value;
}
static isInstance(error43) {
return AISDKError.hasMarker(error43, marker13);
}
/**
* Wraps an error into a TypeValidationError.
* If the cause is already a TypeValidationError with the same value, it returns the cause.
* Otherwise, it creates a new TypeValidationError.
*
* @param {Object} params - The parameters for wrapping the error.
* @param {unknown} params.value - The value that failed validation.
* @param {unknown} params.cause - The original error or cause of the validation failure.
* @returns {TypeValidationError} A TypeValidationError instance.
*/
static wrap({
value,
cause
}) {
return _TypeValidationError2.isInstance(cause) && cause.value === value ? cause : new _TypeValidationError2({ value, cause });
}
};
_a13 = symbol13;
var TypeValidationError = _TypeValidationError;
var name13 = "AI_UnsupportedFunctionalityError";
var marker14 = `vercel.ai.error.${name13}`;
var symbol14 = Symbol.for(marker14);
var _a14;
var UnsupportedFunctionalityError = class extends AISDKError {
constructor({
functionality,
message = `'${functionality}' functionality not supported.`
}) {
super({ name: name13, message });
this[_a14] = true;
this.functionality = functionality;
}
static isInstance(error43) {
return AISDKError.hasMarker(error43, marker14);
}
};
_a14 = symbol14;
// node_modules/.pnpm/eventsource-parser@3.0.5/node_modules/eventsource-parser/dist/index.js
var ParseError = class extends Error {
constructor(message, options) {
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
}
};
function noop(_arg) {
}
function createParser(callbacks) {
if (typeof callbacks == "function")
throw new TypeError(
"`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
);
const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = "";
function feed(newChunk) {
const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`);
for (const line of complete)
parseLine(line);
incompleteLine = incomplete, isFirstChunk = false;
}
function parseLine(line) {
if (line === "") {
dispatchEvent();
return;
}
if (line.startsWith(":")) {
onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1));
return;
}
const fieldSeparatorIndex = line.indexOf(":");
if (fieldSeparatorIndex !== -1) {
const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
processField(field, value, line);
return;
}
processField(line, "", line);
}
function processField(field, value, line) {
switch (field) {
case "event":
eventType = value;
break;
case "data":
data = `${data}${value}
`;
break;
case "id":
id = value.includes("\0") ? void 0 : value;
break;
case "retry":
/^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
new ParseError(`Invalid \`retry\` value: "${value}"`, {
type: "invalid-retry",
value,
line
})
);
break;
default:
onError(
new ParseError(
`Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,
{ type: "unknown-field", field, value, line }
)
);
break;
}
}
function dispatchEvent() {
data.length > 0 && onEvent({
id,
event: eventType || void 0,
// If the data buffer's last character is a U+000A LINE FEED (LF) character,
// then remove the last character from the data buffer.
data: data.endsWith(`
`) ? data.slice(0, -1) : data
}), id = void 0, data = "", eventType = "";
}
function reset(options = {}) {
incompleteLine && options.consume && parseLine(incompleteLine), isFirstChunk = true, id = void 0, data = "", eventType = "", incompleteLine = "";
}
return { feed, reset };
}
function splitLines(chunk) {
const lines = [];
let incompleteLine = "", searchIndex = 0;
for (; searchIndex < chunk.length; ) {
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
`, searchIndex);
let lineEnd = -1;
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = Math.min(crIndex, lfIndex) : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) {
incompleteLine = chunk.slice(searchIndex);
break;
} else {
const line = chunk.slice(searchIndex, lineEnd);
lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
` && searchIndex++;
}
}
return [lines, incompleteLine];
}
// node_modules/.pnpm/eventsource-parser@3.0.5/node_modules/eventsource-parser/dist/stream.js
var EventSourceParserStream = class extends TransformStream {
constructor({ onError, onRetry, onComment } = {}) {
let parser;
super({
start(controller) {
parser = createParser({
onEvent: (event) => {
controller.enqueue(event);
},
onError(error43) {
onError === "terminate" ? controller.error(error43) : typeof onError == "function" && onError(error43);
},
onRetry,
onComment
});
},
transform(chunk) {
parser.feed(chunk);
}
});
}
};
// node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/classic/external.js
var external_exports = {};
__export(external_exports, {
$brand: () => $brand,
$input: () => $input,
$output: () => $output,
NEVER: () => NEVER,
TimePrecision: () => TimePrecision,
ZodAny: () => ZodAny,
ZodArray: () => ZodArray,
ZodBase64: () => ZodBase64,
ZodBase64URL: () => ZodBase64URL,
ZodBigInt: () => ZodBigInt,
ZodBigIntFormat: () => ZodBigIntFormat,
ZodBoolean: () => ZodBoolean,
ZodCIDRv4: () => ZodCIDRv4,
ZodCIDRv6: () => ZodCIDRv6,
ZodCUID: () => ZodCUID,
ZodCUID2: () => ZodCUID2,
ZodCatch: () => ZodCatch,
ZodCustom: () => ZodCustom,
ZodCustomStringFormat: () => ZodCustomStringFormat,
ZodDate: () => ZodDate,
ZodDefault: () => ZodDefault,
ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
ZodE164: () => ZodE164,
ZodEmail: () => ZodEmail,
ZodEmoji: () => ZodEmoji,
ZodEnum: () => ZodEnum,
ZodError: () => ZodError,
ZodFile: () => ZodFile,
ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
ZodGUID: () => ZodGUID,
ZodIPv4: () => ZodIPv4,
ZodIPv6: () => ZodIPv6,
ZodISODate: () => ZodISODate,
ZodISODateTime: () => ZodISODateTime,
ZodISODuration: () => ZodISODuration,
ZodISOTime: () => ZodISOTime,
ZodIntersection: () => ZodIntersection,
ZodIssueCode: () => ZodIssueCode,
ZodJWT: () => ZodJWT,
ZodKSUID: () => ZodKSUID,
ZodLazy: () => ZodLazy,
ZodLiteral: () => ZodLiteral,
ZodMap: () => ZodMap,
ZodNaN: () => ZodNaN,
ZodNanoID: () => ZodNanoID,
ZodNever: () => ZodNever,
ZodNonOptional: () => ZodNonOptional,
ZodNull: () => ZodNull,
ZodNullable: () => ZodNullable,
ZodNumber: () => ZodNumber,
ZodNumberFormat: () => ZodNumberFormat,
ZodObject: () => ZodObject,
ZodOptional: () => ZodOptional,
ZodPipe: () => ZodPipe,
ZodPrefault: () => ZodPrefault,
ZodPromise: () => ZodPromise,
ZodReadonly: () => ZodReadonly,
ZodRealError: () => ZodRealError,
ZodRecord: () => ZodRecord,
ZodSet: () => ZodSet,
ZodString: () => ZodString,
ZodStringFormat: () => ZodStringFormat,
ZodSuccess: () => ZodSuccess,
ZodSymbol: () => ZodSymbol,
ZodTemplateLiteral: () => ZodTemplateLiteral,
ZodTransform: () => ZodTransform,
ZodTuple: () => ZodTuple,
ZodType: () => ZodType,
ZodULID: () => ZodULID,
ZodURL: () => ZodURL,
ZodUUID: () => ZodUUID,
ZodUndefined: () => ZodUndefined,
ZodUnion: () => ZodUnion,
ZodUnknown: () => ZodUnknown,
ZodVoid: () => ZodVoid,
ZodXID: () => ZodXID,
_ZodString: () => _ZodString,
_default: () => _default2,
any: () => any,
array: () => array,
base64: () => base642,
base64url: () => base64url2,
bigint: () => bigint2,
boolean: () => boolean2,
catch: () => _catch2,
check: () => check,
cidrv4: () => cidrv42,
cidrv6: () => cidrv62,
clone: () => clone,
coerce: () => coerce_exports,
config: () => config,
core: () => core_exports2,
cuid: () => cuid3,
cuid2: () => cuid22,
custom: () => custom,
date: () => date3,
discriminatedUnion: () => discriminatedUnion,
e164: () => e1642,
email: () => email2,
emoji: () => emoji2,
endsWith: () => _endsWith,
enum: () => _enum2,
file: () => file,
flattenError: () => flattenError,
float32: () => float32,
float64: () => float64,
formatError: () => formatError,
function: () => _function,
getErrorMap: () => getErrorMap,
globalRegistry: () => globalRegistry,
gt: () => _gt,
gte: () => _gte,
guid: () => guid2,
hostname: () => hostname2,
includes: () => _includes,
instanceof: () => _instanceof,
int: () => int,
int32: () => int32,
int64: () => int64,
intersection: () => intersection,
ipv4: () => ipv42,
ipv6: () => ipv62,
iso: () => iso_exports,
json: () => json,
jwt: () => jwt,
keyof: () => keyof,
ksuid: () => ksuid2,
lazy: () => lazy,
length: () => _length,
literal: () => literal,
locales: () => locales_exports,
looseObject: () => looseObject,
lowercase: () => _lowercase,
lt: () => _lt,
lte: () => _lte,
map: () => map,
maxLength: () => _maxLength,
maxSize: () => _maxSize,
mime: () => _mime,
minLength: () => _minLength,
minSize: () => _minSize,
multipleOf: () => _multipleOf,
nan: () => nan,
nanoid: () => nanoid2,
nativeEnum: () => nativeEnum,
negative: () => _negative,
never: () => never,
nonnegative: () => _nonnegative,
nonoptional: () => nonoptional,
nonpositive: () => _nonpositive,
normalize: () => _normalize,
null: () => _null3,
nullable: () => nullable,
nullish: () => nullish2,
number: () => number2,
object: () => object,
optional: () => optional,
overwrite: () => _overwrite,
parse: () => parse2,
parseAsync: () => parseAsync2,
partialRecord: () => partialRecord,
pipe: () => pipe,
positive: () => _positive,
prefault: () => prefault,
preprocess: () => preprocess,
prettifyError: () => prettifyError,
promise: () => promise,
property: () => _property,
readonly: () => readonly,
record: () => record,
refine: () => refine,
regex: () => _regex,
regexes: () => regexes_exports,
registry: () => registry,
safeParse: () => safeParse2,
safeParseAsync: () => safeParseAsync2,
set: () => set,
setErrorMap: () => setErrorMap,
size: () => _size,
startsWith: () => _startsWith,
strictObject: () => strictObject,
string: () => string2,
stringFormat: () => stringFormat,
stringbool: () => stringbool,
success: () => success,
superRefine: () => superRefine,
symbol: () => symbol15,
templateLiteral: () => templateLiteral,
toJSONSchema: () => toJSONSchema,
toLowerCase: () => _toLowerCase,
toUpperCase: () => _toUpperCase,
transform: () => transform,
treeifyError: () => treeifyError,
trim: () => _trim,
tuple: () => tuple,
uint32: () => uint32,
uint64: () => uint64,
ulid: () => ulid2,
undefined: () => _undefined3,
union: () => union,
unknown: () => unknown,
uppercase: () => _uppercase,
url: () => url,
uuid: () => uuid2,
uuidv4: () => uuidv4,
uuidv6: () => uuidv6,
uuidv7: () => uuidv7,
void: () => _void2,
xid: () => xid2
});
// node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/index.js
var core_exports2 = {};
__export(core_exports2, {
$ZodAny: () => $ZodAny,
$ZodArray: () => $ZodArray,
$ZodAsyncError: () => $ZodAsyncError,
$ZodBase64: () => $ZodBase64,
$ZodBase64URL: () => $ZodBase64URL,
$ZodBigInt: () => $ZodBigInt,
$ZodBigIntFormat: () => $ZodBigIntFormat,
$ZodBoolean: () => $ZodBoolean,
$ZodCIDRv4: () => $ZodCIDRv4,
$ZodCIDRv6: () => $ZodCIDRv6,
$ZodCUID: () => $ZodCUID,
$ZodCUID2: () => $ZodCUID2,
$ZodCatch: () => $ZodCatch,
$ZodCheck: () => $ZodCheck,
$ZodCheckBigIntFormat: () => $ZodCheckBigIntFormat,
$ZodCheckEndsWith: () => $ZodCheckEndsWith,
$ZodCheckGreaterThan: () => $ZodCheckGreaterThan,
$ZodCheckIncludes: () => $ZodCheckIncludes,
$ZodCheckLengthEquals: () => $ZodCheckLengthEquals,
$ZodCheckLessThan: () => $ZodCheckLessThan,
$ZodCheckLowerCase: () => $ZodCheckLowerCase,
$ZodCheckMaxLength: () => $ZodCheckMaxLength,
$ZodCheckMaxSize: () => $ZodCheckMaxSize,
$ZodCheckMimeType: () => $ZodCheckMimeType,
$ZodCheckMinLength: () => $ZodCheckMinLength,
$ZodCheckMinSize: () => $ZodCheckMinSize,
$ZodCheckMultipleOf: () => $ZodCheckMultipleOf,
$ZodCheckNumberFormat: () => $ZodCheckNumberFormat,
$ZodCheckOverwrite: () => $ZodCheckOverwrite,
$ZodCheckProperty: () => $ZodCheckProperty,
$ZodCheckRegex: () => $ZodCheckRegex,
$ZodCheckSizeEquals: () => $ZodCheckSizeEquals,
$ZodCheckStartsWith: () => $ZodCheckStartsWith,
$ZodCheckStringFormat: () => $ZodCheckStringFormat,
$ZodCheckUpperCase: () => $ZodCheckUpperCase,
$ZodCustom: () => $ZodCustom,
$ZodCustomStringFormat: () => $ZodCustomStringFormat,
$ZodDate: () => $ZodDate,
$ZodDefault: () => $ZodDefault,
$ZodDiscriminatedUnion: () => $ZodDiscriminatedUnion,
$ZodE164: () => $ZodE164,
$ZodEmail: () => $ZodEmail,
$ZodEmoji: () => $ZodEmoji,
$ZodEnum: () => $ZodEnum,
$ZodError: () => $ZodError,
$ZodFile: () => $ZodFile,
$ZodFunction: () => $ZodFunction,
$ZodGUID: () => $ZodGUID,
$ZodIPv4: () => $ZodIPv4,
$ZodIPv6: () => $ZodIPv6,
$ZodISODate: () => $ZodISODate,
$ZodISODateTime: () => $ZodISODateTime,
$ZodISODuration: () => $ZodISODuration,
$ZodISOTime: () => $ZodISOTime,
$ZodIntersection: () => $ZodIntersection,
$ZodJWT: () => $ZodJWT,
$ZodKSUID: () => $ZodKSUID,
$ZodLazy: () => $ZodLazy,
$ZodLiteral: () => $ZodLiteral,
$ZodMap: () => $ZodMap,
$ZodNaN: () => $ZodNaN,
$ZodNanoID: () => $ZodNanoID,
$ZodNever: () => $ZodNever,
$ZodNonOptional: () => $ZodNonOptional,
$ZodNull: () => $ZodNull,
$ZodNullable: () => $ZodNullable,
$ZodNumber: () => $ZodNumber,
$ZodNumberFormat: () => $ZodNumberFormat,
$ZodObject: () => $ZodObject,
$ZodOptional: () => $ZodOptional,
$ZodPipe: () => $ZodPipe,
$ZodPrefault: () => $ZodPrefault,
$ZodPromise: () => $ZodPromise,
$ZodReadonly: () => $ZodReadonly,
$ZodRealError: () => $ZodRealError,
$ZodRecord: () => $ZodRecord,
$ZodRegistry: () => $ZodRegistry,
$ZodSet: () => $ZodSet,
$ZodString: () => $ZodString,
$ZodStringFormat: () => $ZodStringFormat,
$ZodSuccess: () => $ZodSuccess,
$ZodSymbol: () => $ZodSymbol,
$ZodTemplateLiteral: () => $ZodTemplateLiteral,
$ZodTransform: () => $ZodTransform,
$ZodTuple: () => $ZodTuple,
$ZodType: () => $ZodType,
$ZodULID: () => $ZodULID,
$ZodURL: () => $ZodURL,
$ZodUUID: () => $ZodUUID,
$ZodUndefined: () => $ZodUndefined,
$ZodUnion: () => $ZodUnion,
$ZodUnknown: () => $ZodUnknown,
$ZodVoid: () => $ZodVoid,
$ZodXID: () => $ZodXID,
$brand: () => $brand,
$constructor: () => $constructor,
$input: () => $input,
$output: () => $output,
Doc: () => Doc,
JSONSchema: () => json_schema_exports,
JSONSchemaGenerator: () => JSONSchemaGenerator,
NEVER: () => NEVER,
TimePrecision: () => TimePrecision,
_any: () => _any,
_array: () => _array,
_base64: () => _base64,
_base64url: () => _base64url,
_bigint: () => _bigint,
_boolean: () => _boolean,
_catch: () => _catch,
_check: () => _check,
_cidrv4: () => _cidrv4,
_cidrv6: () => _cidrv6,
_coercedBigint: () => _coercedBigint,
_coercedBoolean: () => _coercedBoolean,
_coercedDate: () => _coercedDate,
_coercedNumber: () => _coercedNumber,
_coercedString: () => _coercedString,
_cuid: () => _cuid,
_cuid2: () => _cuid2,
_custom: () => _custom,
_date: () => _date,
_default: () => _default,
_discriminatedUnion: () => _discriminatedUnion,
_e164: () => _e164,
_email: () => _email,
_emoji: () => _emoji2,
_endsWith: () => _endsWith,
_enum: () => _enum,
_file: () => _file,
_float32: () => _float32,
_float64: () => _float64,
_gt: () => _gt,
_gte: () => _gte,
_guid: () => _guid,
_includes: () => _includes,
_int: () => _int,
_int32: () => _int32,
_int64: () => _int64,
_intersection: () => _intersection,
_ipv4: () => _ipv4,
_ipv6: () => _ipv6,
_isoDate: () => _isoDate,
_isoDateTime: () => _isoDateTime,
_isoDuration: () => _isoDuration,
_isoTime: () => _isoTime,
_jwt: () => _jwt,
_ksuid: () => _ksuid,
_lazy: () => _lazy,
_length: () => _length,
_literal: () => _literal,
_lowercase: () => _lowercase,
_lt: () => _lt,
_lte: () => _lte,
_map: () => _map,
_max: () => _lte,
_maxLength: () => _maxLength,
_maxSize: () => _maxSize,
_mime: () => _mime,
_min: () => _gte,
_minLength: () => _minLength,
_minSize: () => _minSize,
_multipleOf: () => _multipleOf,
_nan: () => _nan,
_nanoid: () => _nanoid,
_nativeEnum: () => _nativeEnum,
_negative: () => _negative,
_never: () => _never,
_nonnegative: () => _nonnegative,
_nonoptional: () => _nonoptional,
_nonpositive: () => _nonpositive,
_normalize: () => _normalize,
_null: () => _null2,
_nullable: () => _nullable,
_number: () => _number,
_optional: () => _optional,
_overwrite: () => _overwrite,
_parse: () => _parse,
_parseAsync: () => _parseAsync,
_pipe: () => _pipe,
_positive: () => _positive,
_promise: () => _promise,
_property: () => _property,
_readonly: () => _readonly,
_record: () => _record,
_refine: () => _refine,
_regex: () => _regex,
_safeParse: () => _safeParse,
_safeParseAsync: () => _safeParseAsync,
_set: () => _set,
_size: () => _size,
_startsWith: () => _startsWith,
_string: () => _string,
_stringFormat: () => _stringFormat,
_stringbool: () => _stringbool,
_success: () => _success,
_superRefine: () => _superRefine,
_symbol: () => _symbol,
_templateLiteral: () => _templateLiteral,
_toLowerCase: () => _toLowerCase,
_toUpperCase: () => _toUpperCase,
_transform: () => _transform,
_trim: () => _trim,
_tuple: () => _tuple,
_uint32: () => _uint32,
_uint64: () => _uint64,
_ulid: () => _ulid,
_undefined: () => _undefined2,
_union: () => _union,
_unknown: () => _unknown,
_uppercase: () => _uppercase,
_url: () => _url,
_uuid: () => _uuid,
_uuidv4: () => _uuidv4,
_uuidv6: () => _uuidv6,
_uuidv7: () => _uuidv7,
_void: () => _void,
_xid: () => _xid,
clone: () => clone,
config: () => config,
flattenError: () => flattenError,
formatError: () => formatError,
function: () => _function,
globalConfig: () => globalConfig,
globalRegistry: () => globalRegistry,
isValidBase64: () => isValidBase64,
isValidBase64URL: () => isValidBase64URL,
isValidJWT: () => isValidJWT,
locales: () => locales_exports,
parse: () => parse,
parseAsync: () => parseAsync,
prettifyError: () => prettifyError,
regexes: () => regexes_exports,
registry: () => registry,
safeParse: () => safeParse,
safeParseAsync: () => safeParseAsync,
toDotPath: () => toDotPath,
toJSONSchema: () => toJSONSchema,
treeifyError: () => treeifyError,
util: () => util_exports,
version: () => version
});
// node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/core.js
var NEVER = Object.freeze({
status: "aborted"
});
// @__NO_SIDE_EFFECTS__
function $constructor(name14, initializer3, params) {
var _a15;
function init(inst, def) {
var _a17, _b;
var _a16;
Object.defineProperty(inst, "_zod", {
value: (_a17 = inst._zod) != null ? _a17 : {},
enumerable: false
});
(_b = (_a16 = inst._zod).traits) != null ? _b : _a16.traits = /* @__PURE__ */ new Set();
inst._zod.traits.add(name14);
initializer3(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 = (_a15 = params == null ? void 0 : params.Parent) != null ? _a15 : Object;
class Definition extends Parent {
}
Object.defineProperty(Definition, "name", { value: name14 });
function _(def) {
var _a17;
var _a16;
const inst = (params == null ? void 0 : params.Parent) ? new Definition() : this;
init(inst, def);
(_a17 = (_a16 = inst._zod).deferred) != null ? _a17 : _a16.deferred = [];
for (const fn of inst._zod.deferred) {
fn();
}
return inst;
}
Object.defineProperty(_, "init", { value: init });
Object.defineProperty(_, Symbol.hasInstance, {
value: (inst) => {
var _a16, _b;
if ((params == null ? void 0 : params.Parent) && inst instanceof params.Parent)
return true;
return (_b = (_a16 = inst == null ? void 0 : inst._zod) == null ? void 0 : _a16.traits) == null ? void 0 : _b.has(name14);
}
});
Object.defineProperty(_, "name", { value: name14 });
return _;
}
var $brand = Symbol("zod_brand");
var $ZodAsyncError = class extends Error {
constructor() {
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
}
};
var globalConfig = {};
function config(newConfig) {
if (newConfig)
Object.assign(globalConfig, newConfig);
return globalConfig;
}
// node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/util.js
var util_exports = {};
__export(util_exports, {
BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
Class: () => Class,
NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
aborted: () => aborted,
allowsEval: () => allowsEval,
assert: () => assert,
assertEqual: () => assertEqual,
assertIs: () => assertIs,
assertNever: () => assertNever,
assertNotEqual: () => assertNotEqual,
assignProp: () => assignProp,
cached: () => cached,
captureStackTrace: () => captureStackTrace,
cleanEnum: () => cleanEnum,
cleanRegex: () => cleanRegex,
clone: () => clone,
cloneDef: () => cloneDef,
createTransparentProxy: () => createTransparentProxy,
defineLazy: () => defineLazy,
esc: () => esc,
escapeRegex: () => escapeRegex,
extend: () => extend,
finalizeIssue: () => finalizeIssue,
floatSafeRemainder: () => floatSafeRemainder,
getElementAtPath: () => getElementAtPath,
getEnumValues: () => getEnumValues,
getLengthableOrigin: () => getLengthableOrigin,
getParsedType: () => getParsedType,
getSizableOrigin: () => getSizableOrigin,
isObject: () => isObject,
isPlainObject: () => isPlainObject,
issue: () => issue,
joinValues: () => joinValues,
jsonStringifyReplacer: () => jsonStringifyReplacer,
merge: () => merge,
mergeDefs: () => mergeDefs,
normalizeParams: () => normalizeParams,
nullish: () => nullish,
numKeys: () => numKeys,
objectClone: () => objectClone,
omit: () => omit,
optionalKeys: () => optionalKeys,
partial: () => partial,
pick: () => pick,
prefixIssues: () => prefixIssues,
primitiveTypes: () => primitiveTypes,
promiseAllObject: () => promiseAllObject,
propertyKeyTypes: () => propertyKeyTypes,
randomString: () => randomString,
required: () => required,
shallowClone: () => shallowClone,
stringifyPrimitive: () => stringifyPrimitive,
unwrapMessage: () => unwrapMessage
});
function assertEqual(val) {
return val;
}
function assertNotEqual(val) {
return val;
}
function assertIs(_arg) {
}
function assertNever(_x) {
throw new Error();
}
function assert(_) {
}
function getEnumValues(entries) {
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
return values;
}
function joinValues(array2, separator = "|") {
return array2.map((val) => stringifyPrimitive(val)).join(separator);
}
function jsonStringifyReplacer(_, value) {
if (typeof value === "bigint")
return value.toString();
return value;
}
function cached(getter) {
const set2 = false;
return {
get value() {
if (!set2) {
const value = getter();
Object.defineProperty(this, "value", { value });
return value;
}
throw new Error("cached value already set");
}
};
}
function nullish(input) {
return input === null || input === void 0;
}
function cleanRegex(source) {
const start = source.startsWith("^") ? 1 : 0;
const end = source.endsWith("$") ? source.length - 1 : source.length;
return source.slice(start, end);
}
function floatSafeRemainder(val, step) {
const valDecCount = (val.toString().split(".")[1] || "").length;
const stepString = step.toString();
let stepDecCount = (stepString.split(".")[1] || "").length;
if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
const match = stepString.match(/\d?e-(\d?)/);
if (match == null ? void 0 : match[1]) {
stepDecCount = Number.parseInt(match[1]);
}
}
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
return valInt % stepInt / 10 ** decCount;
}
var EVALUATING = Symbol("evaluating");
function defineLazy(object2, key, getter) {
let value = void 0;
Object.defineProperty(object2, key, {
get() {
if (value === EVALUATING) {
return void 0;
}
if (value === void 0) {
value = EVALUATING;
value = getter();
}
return value;
},
set(v) {
Object.defineProperty(object2, key, {
value: v
// configurable: true,
});
},
configurable: true
});
}
function objectClone(obj) {
return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
}
function assignProp(target, prop, value) {
Object.defineProperty(target, prop, {
value,
writable: true,
enumerable: true,
configurable: true
});
}
function mergeDefs(...defs) {
const mergedDescriptors = {};
for (const def of defs) {
const descriptors = Object.getOwnPropertyDescriptors(def);
Object.assign(mergedDescriptors, descriptors);
}
return Object.defineProperties({}, mergedDescriptors);
}
function cloneDef(schema) {
return mergeDefs(schema._zod.def);
}
function getElementAtPath(obj, path) {
if (!path)
return obj;
return path.reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
}
function promiseAllObject(promisesObj) {
const keys = Object.keys(promisesObj);
const promises = keys.map((key) => promisesObj[key]);
return Promise.all(promises).then((results) => {
const resolvedObj = {};
for (let i = 0; i < keys.length; i++) {
resolvedObj[keys[i]] = results[i];
}
return resolvedObj;
});
}
function randomString(length = 10) {
const chars = "abcdefghijklmnopqrstuvwxyz";
let str = "";
for (let i = 0; i < length; i++) {
str += chars[Math.floor(Math.random() * chars.length)];
}
return str;
}
function esc(str) {
return JSON.stringify(str);
}
var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
};
function isObject(data) {
return typeof data === "object" && data !== null && !Array.isArray(data);
}
var allowsEval = cached(() => {
var _a15;
if (typeof navigator !== "undefined" && ((_a15 = navigator == null ? void 0 : navigator.userAgent) == null ? void 0 : _a15.includes("Cloudflare"))) {
return false;
}
try {
const F = Function;
new F("");
return true;
} catch (_) {
return false;
}
});
function isPlainObject(o) {
if (isObject(o) === false)
return false;
const ctor = o.constructor;
if (ctor === void 0)
return true;
const prot = ctor.prototype;
if (isObject(prot) === false)
return false;
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
return false;
}
return true;
}
function shallowClone(o) {
if (isPlainObject(o))
return __spreadValues({}, o);
return o;
}
function numKeys(data) {
let keyCount = 0;
for (const key in data) {
if (Object.prototype.hasOwnProperty.call(data, key)) {
keyCount++;
}
}
return keyCount;
}
var getParsedType = (data) => {
const t = typeof data;
switch (t) {
case "undefined":
return "undefined";
case "string":
return "string";
case "number":
return Number.isNaN(data) ? "nan" : "number";
case "boolean":
return "boolean";
case "function":
return "function";
case "bigint":
return "bigint";
case "symbol":
return "symbol";
case "object":
if (Array.isArray(data)) {
return "array";
}
if (data === null) {
return "null";
}
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
return "promise";
}
if (typeof Map !== "undefined" && data instanceof Map) {
return "map";
}
if (typeof Set !== "undefined" && data instanceof Set) {
return "set";
}
if (typeof Date !== "undefined" && data instanceof Date) {
return "date";
}
if (typeof File !== "undefined" && data instanceof File) {
return "file";
}
return "object";
default:
throw new Error(`Unknown data type: ${t}`);
}
};
var propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
var primitiveTypes = /* @__PURE__ */ new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]);
function escapeRegex(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function clone(inst, def, params) {
const cl = new inst._zod.constr(def != null ? def : inst._zod.def);
if (!def || (params == null ? void 0 : params.parent))
cl._zod.parent = inst;
return cl;
}
function normalizeParams(_params) {
const params = _params;
if (!params)
return {};
if (typeof params === "string")
return { error: () => params };
if ((params == null ? void 0 : params.message) !== void 0) {
if ((params == null ? void 0 : 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 __spreadProps(__spreadValues({}, params), { error: () => params.error });
return params;
}
function createTransparentProxy(getter) {
let target;
return new Proxy({}, {
get(_, prop, receiver) {
target != null ? target : target = getter();
return Reflect.get(target, prop, receiver);
},
set(_, prop, value, receiver) {
target != null ? target : target = getter();
return Reflect.set(target, prop, value, receiver);
},
has(_, prop) {
target != null ? target : target = getter();
return Reflect.has(target, prop);
},
deleteProperty(_, prop) {
target != null ? target : target = getter();
return Reflect.deleteProperty(target, prop);
},
ownKeys(_) {
target != null ? target : target = getter();
return Reflect.ownKeys(target);
},
getOwnPropertyDescriptor(_, prop) {
target != null ? target : target = getter();
return Reflect.getOwnPropertyDescriptor(target, prop);
},
defineProperty(_, prop, descriptor) {
target != null ? target : target = getter();
return Reflect.defineProperty(target, prop, descriptor);
}
});
}
function stringifyPrimitive(value) {
if (typeof value === "bigint")
return value.toString() + "n";
if (typeof value === "string")
return `"${value}"`;
return `${value}`;
}
function optionalKeys(shape) {
return Object.keys(shape).filter((k) => {
return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
});
}
var NUMBER_FORMAT_RANGES = {
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]
};
var BIGINT_FORMAT_RANGES = {
int64: [/* @__PURE__ */ BigInt("-9223372036854775808"), /* @__PURE__ */ BigInt("9223372036854775807")],
uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")]
};
function pick(schema, mask) {
const currDef = schema._zod.def;
const def = mergeDefs(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(this, "shape", newShape);
return newShape;
},
checks: []
});
return clone(schema, def);
}
function omit(schema, mask) {
const currDef = schema._zod.def;
const def = mergeDefs(schema._zod.def, {
get shape() {
const newShape = __spreadValues({}, 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(this, "shape", newShape);
return newShape;
},
checks: []
});
return clone(schema, def);
}
function extend(schema, shape) {
if (!isPlainObject(shape)) {
throw new Error("Invalid input to extend: expected a plain object");
}
const def = mergeDefs(schema._zod.def, {
get shape() {
const _shape = __spreadValues(__spreadValues({}, schema._zod.def.shape), shape);
assignProp(this, "shape", _shape);
return _shape;
},
checks: []
});
return clone(schema, def);
}
function merge(a, b) {
const def = mergeDefs(a._zod.def, {
get shape() {
const _shape = __spreadValues(__spreadValues({}, a._zod.def.shape), b._zod.def.shape);
assignProp(this, "shape", _shape);
return _shape;
},
get catchall() {
return b._zod.def.catchall;
},
checks: []
// delete existing checks
});
return clone(a, def);
}
function partial(Class2, schema, mask) {
const def = mergeDefs(schema._zod.def, {
get shape() {
const oldShape = schema._zod.def.shape;
const shape = __spreadValues({}, oldShape);
if (mask) {
for (const key in mask) {
if (!(key in oldShape)) {
throw new Error(`Unrecognized key: "${key}"`);
}
if (!mask[key])
continue;
shape[key] = Class2 ? new Class2({
type: "optional",
innerType: oldShape[key]
}) : oldShape[key];
}
} else {
for (const key in oldShape) {
shape[key] = Class2 ? new Class2({
type: "optional",
innerType: oldShape[key]
}) : oldShape[key];
}
}
assignProp(this, "shape", shape);
return shape;
},
checks: []
});
return clone(schema, def);
}
function required(Class2, schema, mask) {
const def = mergeDefs(schema._zod.def, {
get shape() {
const oldShape = schema._zod.def.shape;
const shape = __spreadValues({}, 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 Class2({
type: "nonoptional",
innerType: oldShape[key]
});
}
} else {
for (const key in oldShape) {
shape[key] = new Class2({
type: "nonoptional",
innerType: oldShape[key]
});
}
}
assignProp(this, "shape", shape);
return shape;
},
checks: []
});
return clone(schema, def);
}
function aborted(x, startIndex = 0) {
var _a15;
for (let i = startIndex; i < x.issues.length; i++) {
if (((_a15 = x.issues[i]) == null ? void 0 : _a15.continue) !== true) {
return true;
}
}
return false;
}
function prefixIssues(path, issues) {
return issues.map((iss) => {
var _a16;
var _a15;
(_a16 = (_a15 = iss).path) != null ? _a16 : _a15.path = [];
iss.path.unshift(path);
return iss;
});
}
function unwrapMessage(message) {
return typeof message === "string" ? message : message == null ? void 0 : message.message;
}
function finalizeIssue(iss, ctx, config2) {
var _a15, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
const full = __spreadProps(__spreadValues({}, iss), { path: (_a15 = iss.path) != null ? _a15 : [] });
if (!iss.message) {
const message = (_k = (_j = (_h = (_f = unwrapMessage((_d = (_c = (_b = iss.inst) == null ? void 0 : _b._zod.def) == null ? void 0 : _c.error) == null ? void 0 : _d.call(_c, iss))) != null ? _f : unwrapMessage((_e = ctx == null ? void 0 : ctx.error) == null ? void 0 : _e.call(ctx, iss))) != null ? _h : unwrapMessage((_g = config2.customError) == null ? void 0 : _g.call(config2, iss))) != null ? _j : unwrapMessage((_i = config2.localeError) == null ? void 0 : _i.call(config2, iss))) != null ? _k : "Invalid input";
full.message = message;
}
delete full.inst;
delete full.continue;
if (!(ctx == null ? void 0 : ctx.reportInput)) {
delete full.input;
}
return full;
}
function getSizableOrigin(input) {
if (input instanceof Set)
return "set";
if (input instanceof Map)
return "map";
if (input instanceof File)
return "file";
return "unknown";
}
function getLengthableOrigin(input) {
if (Array.isArray(input))
return "array";
if (typeof input === "string")
return "string";
return "unknown";
}
function issue(...args) {
const [iss, input, inst] = args;
if (typeof iss === "string") {
return {
message: iss,
code: "custom",
input,
inst
};
}
return __spreadValues({}, iss);
}
function cleanEnum(obj) {
return Object.entries(obj).filter(([k, _]) => {
return Number.isNaN(Number.parseInt(k, 10));
}).map((el) => el[1]);
}
var Class = class {
constructor(..._args) {
}
};
// node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/errors.js
var initializer = (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, 2);
Object.defineProperty(inst, "toString", {
value: () => inst.message,
enumerable: false
});
};
var $ZodError = $constructor("$ZodError", initializer);
var $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error });
function flattenError(error43, mapper = (issue2) => issue2.message) {
const fieldErrors = {};
const formErrors = [];
for (const sub of error43.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(error43, _mapper) {
const mapper = _mapper || function(issue2) {
return issue2.message;
};
const fieldErrors = { _errors: [] };
const processError = (error44) => {
for (const issue2 of error44.issues) {
if (issue2.code === "invalid_union" && issue2.errors.length) {
issue2.errors.map((issues) => processError({ issues }));
} else if (issue2.code === "invalid_key") {
processError({ issues: issue2.issues });
} else if (issue2.code === "invalid_element") {
processError({ issues: issue2.issues });
} else if (issue2.path.length === 0) {
fieldErrors._errors.push(mapper(issue2));
} else {
let curr = fieldErrors;
let i = 0;
while (i < issue2.path.length) {
const el = issue2.path[i];
const terminal = i === issue2.path.length - 1;
if (!terminal) {
curr[el] = curr[el] || { _errors: [] };
} else {
curr[el] = curr[el] || { _errors: [] };
curr[el]._errors.push(mapper(issue2));
}
curr = curr[el];
i++;
}
}
}
};
processError(error43);
return fieldErrors;
}
function treeifyError(error43, _mapper) {
const mapper = _mapper || function(issue2) {
return issue2.message;
};
const result = { errors: [] };
const processError = (error44, path = []) => {
var _a16, _b2, _c, _d;
var _a15, _b;
for (const issue2 of error44.issues) {
if (issue2.code === "invalid_union" && issue2.errors.length) {
issue2.errors.map((issues) => processError({ issues }, issue2.path));
} else if (issue2.code === "invalid_key") {
processError({ issues: issue2.issues }, issue2.path);
} else if (issue2.code === "invalid_element") {
processError({ issues: issue2.issues }, issue2.path);
} else {
const fullpath = [...path, ...issue2.path];
if (fullpath.length === 0) {
result.errors.push(mapper(issue2));
continue;
}
let curr = result;
let i = 0;
while (i < fullpath.length) {
const el = fullpath[i];
const terminal = i === fullpath.length - 1;
if (typeof el === "string") {
(_a16 = curr.properties) != null ? _a16 : curr.properties = {};
(_b2 = (_a15 = curr.properties)[el]) != null ? _b2 : _a15[el] = { errors: [] };
curr = curr.properties[el];
} else {
(_c = curr.items) != null ? _c : curr.items = [];
(_d = (_b = curr.items)[el]) != null ? _d : _b[el] = { errors: [] };
curr = curr.items[el];
}
if (terminal) {
curr.errors.push(mapper(issue2));
}
i++;
}
}
}
};
processError(error43);
return result;
}
function toDotPath(_path) {
const segs = [];
const path = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
for (const seg of path) {
if (typeof seg === "number")
segs.push(`[${seg}]`);
else if (typeof seg === "symbol")
segs.push(`[${JSON.stringify(String(seg))}]`);
else if (/[^\w$]/.test(seg))
segs.push(`[${JSON.stringify(seg)}]`);
else {
if (segs.length)
segs.push(".");
segs.push(seg);
}
}
return segs.join("");
}
function prettifyError(error43) {
var _a15;
const lines = [];
const issues = [...error43.issues].sort((a, b) => {
var _a16, _b;
return (