@inox-tools/content-utils
Version:
Utilities to work with content collections on an Astro project from an integration or library.
1,604 lines (1,588 loc) • 542 kB
JavaScript
import { AstroUserError } from './chunk-4ZDJCWDV.js';
import { getDebug, debug, setProjectRoot, collectGitInfoForContentFiles } from './chunk-JOKBL6FV.js';
import { __export } from './chunk-PZ5AY32C.js';
import { withApi, onHook, registerGlobalHooks } from '@inox-tools/modular-station';
import { defineIntegration, addVitePlugin, defineUtility, createResolver } from 'astro-integration-kit';
import { mkdirSync, writeFileSync, existsSync, readFileSync, readdirSync, lstatSync, cpSync } from 'fs';
import { fileURLToPath } from 'url';
import { walk } from 'estree-walker';
import * as assert from 'assert';
import MagicString from 'magic-string';
import { dirname, resolve, join } from 'path';
import * as devalue from 'devalue';
// src/integration/state.ts
function emptyState() {
return {
injectedCollectionsEntrypoints: [],
staticOnlyCollections: [],
cleanups: []
};
}
var possibleConfigs = [
"content.config.ts",
"content.config.mjs",
"content.config.js",
"content.config.mts",
"content/config.ts",
"content/config.mjs",
"content/config.js",
"content/config.mts"
];
function resolveContentPaths(config2) {
const baseResolver = createResolver(fileURLToPath(config2.srcDir));
const contentPath = baseResolver.resolve("content");
const resolver = createResolver(contentPath);
const validConfigPaths = possibleConfigs.map(
(configPath) => baseResolver.resolve(`${configPath}`)
);
const existingConfig = validConfigPaths.find((configPath) => existsSync(configPath));
const configFile = existingConfig ?? validConfigPaths[0];
return {
projectRoot: fileURLToPath(config2.root),
contentPath,
configPath: configFile,
configExists: existingConfig !== void 0,
resolve: resolver.resolve
};
}
var debug2 = getDebug("injector-plugin");
var thisFile = fileURLToPath(import.meta.url);
var thisDir = dirname(thisFile);
debug2("Resolution base:", { thisFile, thisDir });
var INJECTOR_VIRTUAL_MODULE = "@it-astro:content/injector";
var RESOLVED_INJECTOR_VIRTUAL_MODULE = `\0${INJECTOR_VIRTUAL_MODULE}`;
var CONTENT_VIRTUAL_MODULE = "@it-astro:content";
var RESOLVED_CONTENT_VIRTUAL_MODULE = `\0${CONTENT_VIRTUAL_MODULE}`;
var injectorPlugin = (state) => {
const {
logger,
injectedCollectionsEntrypoints: entrypoints,
contentPaths: { configPath: configFile }
} = state;
return {
name: "@inox-tools/content-utils/injector",
resolveId(id) {
switch (id) {
case INJECTOR_VIRTUAL_MODULE:
return RESOLVED_INJECTOR_VIRTUAL_MODULE;
case CONTENT_VIRTUAL_MODULE:
return RESOLVED_CONTENT_VIRTUAL_MODULE;
}
},
load(id) {
switch (id) {
case RESOLVED_INJECTOR_VIRTUAL_MODULE:
debug2("Generating injected collection modole from:", entrypoints);
return [
...entrypoints.map(
(entrypoint, index) => `import {collections as __collections${index}} from '${entrypoint}';`
),
"export const injectedCollections = {",
...entrypoints.map((_, index) => `...__collections${index},`),
"};"
].join("\n");
case RESOLVED_CONTENT_VIRTUAL_MODULE:
debug2("Generating fancy content module");
return [
`export {defineCollection} from ${JSON.stringify(resolve(thisDir, "runtime/fancyContent.js"))};`,
'export {z, reference} from "astro:content";'
].join("\n");
}
},
transform(code, id) {
if (id !== configFile) return;
debug2("Transforming config file");
const ast = this.parse(code);
const s = new MagicString(code);
function update(node, updater) {
assert.ok(isBryceNode(node), "Ping Bryce, he lied!");
const { start, end } = node;
const oldCode = s.slice(start, end);
const newCode = updater(oldCode);
if (oldCode === newCode) {
debug2("Code is unnafected by transformation.");
return;
}
s.update(start, end, newCode);
}
debug2("Adding import for collection injection runtime");
s.prepend(
`import {injectCollections as $$inox_tools__injectCollection} from ${JSON.stringify(resolve(thisDir, "runtime/injector.js"))};`
);
walk(ast, {
enter(node, parent) {
if (parent?.type !== "ExportNamedDeclaration" || node.type !== "VariableDeclaration")
return;
const collectionDeclaration = node.declarations.find((value) => {
return value.id.type === "Identifier" && value.id.name === "collections";
});
if (collectionDeclaration?.init == null) {
throw new AstroUserError(
"Exported collections is not initialized.",
`Change your ${configFile} to initialize the value of "collections".`
);
}
if (node.kind !== "const") {
logger.warn(
`Exporting collections config using "let" may have unintended consequences. Prefer "export const collections" in your "${configFile}".`
);
}
const sourceInit = collectionDeclaration.init;
debug2("Wrapping collection definition with collection injection");
update(sourceInit, (code2) => `$$inox_tools__injectCollection(${code2})`);
}
});
return {
code: s.toString(),
map: s.generateMap()
};
},
writeBundle(info, bundle) {
if (!info.dir) return;
for (const chunk of Object.values(bundle)) {
if (chunk.type !== "chunk") continue;
if (chunk.moduleIds.length === 1 && chunk.moduleIds[0] === "\0astro:data-layer-content") {
state.contentDataEntrypoint = join(info.dir, chunk.fileName);
break;
}
}
}
};
};
function isBryceNode(node) {
return typeof node.start === "number" && typeof node.end === "number";
}
var debug3 = getDebug("seeding");
function seedCollections(state, options) {
debug3("Collecting collection templates from:", options.templateDirectory);
const collectionTemplates = readdirSync(options.templateDirectory).map((entry) => [entry, resolve(options.templateDirectory, entry)]).filter(([, path]) => lstatSync(path).isDirectory());
for (const [collectionName, templatePath] of collectionTemplates) {
const collectionPath = state.contentPaths.resolve(collectionName);
if (existsSync(collectionPath)) {
debug3(`Collection ${collectionName} already present, not seeding.`);
continue;
}
debug3(`Seeding collection ${collectionName} from ${templatePath}`);
cpSync(templatePath, collectionPath, {
recursive: true,
dereference: true,
preserveTimestamps: false
});
}
}
var MODULE_ID = "@it-astro:content/git";
var RESOLVED_MODULE_ID = "\0@it-astro:content/git";
var INNER_MODULE_ID = "@it-astro:content/git/internal";
var RESOLVED_INNER_MODULE_ID = "\0@it-astro:content/git/internal";
var debug4 = getDebug("git-time-plugin");
var thisFile2 = fileURLToPath(import.meta.url);
var thisDir2 = dirname(thisFile2);
debug4("Resolution base:", { thisFile: thisFile2, thisDir: thisDir2 });
var gitDevPlugin = ({ contentPaths: { projectRoot } }) => ({
name: "@inox-tools/content-utils/gitTimes",
resolveId(id) {
if (id === MODULE_ID) return RESOLVED_MODULE_ID;
},
load(id, { ssr } = {}) {
if (id !== RESOLVED_MODULE_ID || !ssr) return;
debug4(`Generated dev mode git time plugin for ${projectRoot}`);
return `
import {setProjectRoot} from ${JSON.stringify(resolve(thisDir2, "runtime/git.js"))};
export {
getLatestCommitDate,
getOldestCommitDate,
getEntryGitInfo,
} from ${JSON.stringify(resolve(thisDir2, "runtime/liveGit.js"))};
setProjectRoot(${JSON.stringify(projectRoot)});
`;
}
});
var gitBuildPlugin = (state) => {
const {
contentPaths: { projectRoot }
} = state;
return {
name: "@inox-tools/content-utils/gitTimes",
resolveId(id) {
if (id === MODULE_ID) return RESOLVED_MODULE_ID;
if (id === INNER_MODULE_ID) return RESOLVED_INNER_MODULE_ID;
},
writeBundle(info, bundle) {
if (!info.dir) return;
let contentDataEntrypoint;
let gitStateEntrypoint;
for (const chunk of Object.values(bundle)) {
if (chunk.type !== "chunk") continue;
if (chunk.moduleIds.length !== 1) continue;
switch (chunk.moduleIds[0]) {
case RESOLVED_INNER_MODULE_ID:
gitStateEntrypoint = join(info.dir, chunk.fileName);
break;
case "\0astro:data-layer-content":
contentDataEntrypoint = join(info.dir, chunk.fileName);
break;
}
}
if (contentDataEntrypoint && gitStateEntrypoint) {
state.cleanups.push(() => cleanupState(contentDataEntrypoint, gitStateEntrypoint));
}
},
async load(id, { ssr } = {}) {
if (!ssr) return;
if (id === RESOLVED_MODULE_ID) return buildFacade;
if (id === RESOLVED_INNER_MODULE_ID) {
debug4("Registering project root:", projectRoot);
setProjectRoot(projectRoot);
const trackedFiles = await collectGitInfoForContentFiles();
debug4("Git tracked file dates:", trackedFiles);
return `const trackedFiles = ${devalue.stringify(new Map(trackedFiles))};
export { trackedFiles as default };`;
}
}
};
};
async function cleanupState(contentData, gitState) {
if (!existsSync(contentData) || !existsSync(gitState)) return;
const originalContent = readFileSync(gitState, "utf-8");
if (!originalContent.includes("export")) return;
const { default: contentValue } = await import(
/*@vite-ignore*/
contentData
);
const { default: gitValue } = await import(
/*@vite-ignore*/
gitState
);
const contentMap = devalue.unflatten(contentValue);
const gitInformation = devalue.unflatten(gitValue);
const usedFiles = /* @__PURE__ */ new Set();
for (const collection of contentMap.values()) {
for (const entry of collection.values()) {
if (typeof entry === "object" && entry && "filePath" in entry && entry.filePath) {
usedFiles.add(entry.filePath);
}
}
}
const cleanedMap = new Map(
Array.from(gitInformation.entries()).filter(([path]) => usedFiles.has(path))
);
const newContent = [
`const trackedFiles = ${devalue.stringify(cleanedMap)}`,
"\nexport { trackedFiles as default }"
].join("\n");
writeFileSync(gitState, newContent, "utf-8");
}
var buildFacade = `
import {getEntry} from 'astro:content';
import {unflatten} from ${JSON.stringify(import.meta.resolve("devalue"))};
const trackedFiles = unflatten((await import(${JSON.stringify(INNER_MODULE_ID)})).default);
export async function getEntryGitInfo(...args) {
const params = args.length > 1 ? args : [args[0].collection, args[0].slug ?? args[0].id];
const entry = await getEntry(...params);
const rawInfo = trackedFiles.get(entry.filePath);
if (!rawInfo) return;
return {
earliest: new Date(rawInfo.earliest),
latest: new Date(rawInfo.latest),
authors: Array.from(rawInfo.authors),
coAuthors: Array.from(rawInfo.coAuthors),
};
}
const latestCommits = new Map(
Array.from(trackedFiles.entries())
.map(([file, fileInfo]) => [file, new Date(fileInfo.latest)])
);
export async function getLatestCommitDate(...args) {
const params = args.length > 1 ? args : [args[0].collection, args[0].slug ?? args[0].id];
const entry = await getEntry(...params);
const cached = latestCommits.get(entry.filePath);
if (cached !== undefined) return cached;
const now = new Date();
latestCommits.set(entry.filePath, now);
return now;
}
const oldestCommits = new Map(
Array.from(trackedFiles.entries())
.map(([file, fileInfo]) => [file, new Date(fileInfo.earliest)])
);
export async function getOldestCommitDate(...args) {
const params = args.length > 1 ? args : [args[0].collection, args[0].slug ?? args[0].id];
const entry = await getEntry(...params);
const cached = oldestCommits.get(entry.filePath);
if (cached !== undefined) return cached;
const now = new Date();
oldestCommits.set(entry.filePath, now);
return now;
}
`;
// ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/index.js
var v4_exports = {};
__export(v4_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,
ZodCodec: () => ZodCodec,
ZodCustom: () => ZodCustom,
ZodCustomStringFormat: () => ZodCustomStringFormat,
ZodDate: () => ZodDate,
ZodDefault: () => ZodDefault,
ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
ZodE164: () => ZodE164,
ZodEmail: () => ZodEmail,
ZodEmoji: () => ZodEmoji,
ZodEnum: () => ZodEnum,
ZodError: () => ZodError,
ZodExactOptional: () => ZodExactOptional,
ZodFile: () => ZodFile,
ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
ZodFunction: () => ZodFunction,
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,
ZodMAC: () => ZodMAC,
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,
ZodXor: () => ZodXor,
_ZodString: () => _ZodString,
_default: () => _default2,
_function: () => _function,
any: () => any,
array: () => array,
base64: () => base642,
base64url: () => base64url2,
bigint: () => bigint2,
boolean: () => boolean2,
catch: () => _catch2,
check: () => check,
cidrv4: () => cidrv42,
cidrv6: () => cidrv62,
clone: () => clone,
codec: () => codec,
coerce: () => coerce_exports,
config: () => config,
core: () => core_exports2,
cuid: () => cuid3,
cuid2: () => cuid22,
custom: () => custom,
date: () => date3,
decode: () => decode2,
decodeAsync: () => decodeAsync2,
default: () => v4_default,
describe: () => describe2,
discriminatedUnion: () => discriminatedUnion,
e164: () => e1642,
email: () => email2,
emoji: () => emoji2,
encode: () => encode2,
encodeAsync: () => encodeAsync2,
endsWith: () => _endsWith,
enum: () => _enum2,
exactOptional: () => exactOptional,
file: () => file,
flattenError: () => flattenError,
float32: () => float32,
float64: () => float64,
formatError: () => formatError,
fromJSONSchema: () => fromJSONSchema,
function: () => _function,
getErrorMap: () => getErrorMap,
globalRegistry: () => globalRegistry,
gt: () => _gt,
gte: () => _gte,
guid: () => guid2,
hash: () => hash,
hex: () => hex2,
hostname: () => hostname2,
httpUrl: () => httpUrl,
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,
looseRecord: () => looseRecord,
lowercase: () => _lowercase,
lt: () => _lt,
lte: () => _lte,
mac: () => mac2,
map: () => map,
maxLength: () => _maxLength,
maxSize: () => _maxSize,
meta: () => meta2,
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,
safeDecode: () => safeDecode2,
safeDecodeAsync: () => safeDecodeAsync2,
safeEncode: () => safeEncode2,
safeEncodeAsync: () => safeEncodeAsync2,
safeParse: () => safeParse2,
safeParseAsync: () => safeParseAsync2,
set: () => set,
setErrorMap: () => setErrorMap,
size: () => _size,
slugify: () => _slugify,
startsWith: () => _startsWith,
strictObject: () => strictObject,
string: () => string2,
stringFormat: () => stringFormat,
stringbool: () => stringbool,
success: () => success,
superRefine: () => superRefine,
symbol: () => symbol,
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,
util: () => util_exports,
uuid: () => uuid2,
uuidv4: () => uuidv4,
uuidv6: () => uuidv6,
uuidv7: () => uuidv7,
void: () => _void2,
xid: () => xid2,
xor: () => xor,
z: () => external_exports
});
// ../../node_modules/.pnpm/zod@4.3.6/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,
ZodCodec: () => ZodCodec,
ZodCustom: () => ZodCustom,
ZodCustomStringFormat: () => ZodCustomStringFormat,
ZodDate: () => ZodDate,
ZodDefault: () => ZodDefault,
ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
ZodE164: () => ZodE164,
ZodEmail: () => ZodEmail,
ZodEmoji: () => ZodEmoji,
ZodEnum: () => ZodEnum,
ZodError: () => ZodError,
ZodExactOptional: () => ZodExactOptional,
ZodFile: () => ZodFile,
ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
ZodFunction: () => ZodFunction,
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,
ZodMAC: () => ZodMAC,
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,
ZodXor: () => ZodXor,
_ZodString: () => _ZodString,
_default: () => _default2,
_function: () => _function,
any: () => any,
array: () => array,
base64: () => base642,
base64url: () => base64url2,
bigint: () => bigint2,
boolean: () => boolean2,
catch: () => _catch2,
check: () => check,
cidrv4: () => cidrv42,
cidrv6: () => cidrv62,
clone: () => clone,
codec: () => codec,
coerce: () => coerce_exports,
config: () => config,
core: () => core_exports2,
cuid: () => cuid3,
cuid2: () => cuid22,
custom: () => custom,
date: () => date3,
decode: () => decode2,
decodeAsync: () => decodeAsync2,
describe: () => describe2,
discriminatedUnion: () => discriminatedUnion,
e164: () => e1642,
email: () => email2,
emoji: () => emoji2,
encode: () => encode2,
encodeAsync: () => encodeAsync2,
endsWith: () => _endsWith,
enum: () => _enum2,
exactOptional: () => exactOptional,
file: () => file,
flattenError: () => flattenError,
float32: () => float32,
float64: () => float64,
formatError: () => formatError,
fromJSONSchema: () => fromJSONSchema,
function: () => _function,
getErrorMap: () => getErrorMap,
globalRegistry: () => globalRegistry,
gt: () => _gt,
gte: () => _gte,
guid: () => guid2,
hash: () => hash,
hex: () => hex2,
hostname: () => hostname2,
httpUrl: () => httpUrl,
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,
looseRecord: () => looseRecord,
lowercase: () => _lowercase,
lt: () => _lt,
lte: () => _lte,
mac: () => mac2,
map: () => map,
maxLength: () => _maxLength,
maxSize: () => _maxSize,
meta: () => meta2,
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,
safeDecode: () => safeDecode2,
safeDecodeAsync: () => safeDecodeAsync2,
safeEncode: () => safeEncode2,
safeEncodeAsync: () => safeEncodeAsync2,
safeParse: () => safeParse2,
safeParseAsync: () => safeParseAsync2,
set: () => set,
setErrorMap: () => setErrorMap,
size: () => _size,
slugify: () => _slugify,
startsWith: () => _startsWith,
strictObject: () => strictObject,
string: () => string2,
stringFormat: () => stringFormat,
stringbool: () => stringbool,
success: () => success,
superRefine: () => superRefine,
symbol: () => symbol,
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,
util: () => util_exports,
uuid: () => uuid2,
uuidv4: () => uuidv4,
uuidv6: () => uuidv6,
uuidv7: () => uuidv7,
void: () => _void2,
xid: () => xid2,
xor: () => xor
});
// ../../node_modules/.pnpm/zod@4.3.6/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,
$ZodCodec: () => $ZodCodec,
$ZodCustom: () => $ZodCustom,
$ZodCustomStringFormat: () => $ZodCustomStringFormat,
$ZodDate: () => $ZodDate,
$ZodDefault: () => $ZodDefault,
$ZodDiscriminatedUnion: () => $ZodDiscriminatedUnion,
$ZodE164: () => $ZodE164,
$ZodEmail: () => $ZodEmail,
$ZodEmoji: () => $ZodEmoji,
$ZodEncodeError: () => $ZodEncodeError,
$ZodEnum: () => $ZodEnum,
$ZodError: () => $ZodError,
$ZodExactOptional: () => $ZodExactOptional,
$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,
$ZodMAC: () => $ZodMAC,
$ZodMap: () => $ZodMap,
$ZodNaN: () => $ZodNaN,
$ZodNanoID: () => $ZodNanoID,
$ZodNever: () => $ZodNever,
$ZodNonOptional: () => $ZodNonOptional,
$ZodNull: () => $ZodNull,
$ZodNullable: () => $ZodNullable,
$ZodNumber: () => $ZodNumber,
$ZodNumberFormat: () => $ZodNumberFormat,
$ZodObject: () => $ZodObject,
$ZodObjectJIT: () => $ZodObjectJIT,
$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,
$ZodXor: () => $ZodXor,
$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,
_decode: () => _decode,
_decodeAsync: () => _decodeAsync,
_default: () => _default,
_discriminatedUnion: () => _discriminatedUnion,
_e164: () => _e164,
_email: () => _email,
_emoji: () => _emoji2,
_encode: () => _encode,
_encodeAsync: () => _encodeAsync,
_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,
_mac: () => _mac,
_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,
_safeDecode: () => _safeDecode,
_safeDecodeAsync: () => _safeDecodeAsync,
_safeEncode: () => _safeEncode,
_safeEncodeAsync: () => _safeEncodeAsync,
_safeParse: () => _safeParse,
_safeParseAsync: () => _safeParseAsync,
_set: () => _set,
_size: () => _size,
_slugify: () => _slugify,
_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,
_xor: () => _xor,
clone: () => clone,
config: () => config,
createStandardJSONSchemaMethod: () => createStandardJSONSchemaMethod,
createToJSONSchemaMethod: () => createToJSONSchemaMethod,
decode: () => decode,
decodeAsync: () => decodeAsync,
describe: () => describe,
encode: () => encode,
encodeAsync: () => encodeAsync,
extractDefs: () => extractDefs,
finalize: () => finalize,
flattenError: () => flattenError,
formatError: () => formatError,
globalConfig: () => globalConfig,
globalRegistry: () => globalRegistry,
initializeContext: () => initializeContext,
isValidBase64: () => isValidBase64,
isValidBase64URL: () => isValidBase64URL,
isValidJWT: () => isValidJWT,
locales: () => locales_exports,
meta: () => meta,
parse: () => parse,
parseAsync: () => parseAsync,
prettifyError: () => prettifyError,
process: () => process,
regexes: () => regexes_exports,
registry: () => registry,
safeDecode: () => safeDecode,
safeDecodeAsync: () => safeDecodeAsync,
safeEncode: () => safeEncode,
safeEncodeAsync: () => safeEncodeAsync,
safeParse: () => safeParse,
safeParseAsync: () => safeParseAsync,
toDotPath: () => toDotPath,
toJSONSchema: () => toJSONSchema,
treeifyError: () => treeifyError,
util: () => util_exports,
version: () => version
});
// ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/core.js
var NEVER = Object.freeze({
status: "aborted"
});
// @__NO_SIDE_EFFECTS__
function $constructor(name, initializer3, params) {
function init(inst, def) {
if (!inst._zod) {
Object.defineProperty(inst, "_zod", {
value: {
def,
constr: _,
traits: /* @__PURE__ */ new Set()
},
enumerable: false
});
}
if (inst._zod.traits.has(name)) {
return;
}
inst._zod.traits.add(name);
initializer3(inst, def);
const proto = _.prototype;
const keys = Object.keys(proto);
for (let i = 0; i < keys.length; i++) {
const k = keys[i];
if (!(k in inst)) {
inst[k] = proto[k].bind(inst);
}
}
}
const Parent = params?.Parent ?? Object;
class Definition extends Parent {
}
Object.defineProperty(Definition, "name", { value: name });
function _(def) {
var _a2;
const inst = params?.Parent ? new Definition() : this;
init(inst, def);
(_a2 = inst._zod).deferred ?? (_a2.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 _;
}
var $brand = /* @__PURE__ */ Symbol("zod_brand");
var $ZodAsyncError = class extends Error {
constructor() {
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
}
};
var $ZodEncodeError = class extends Error {
constructor(name) {
super(`Encountered unidirectional transform during encode: ${name}`);
this.name = "ZodEncodeError";
}
};
var globalConfig = {};
function config(newConfig) {
if (newConfig)
Object.assign(globalConfig, newConfig);
return globalConfig;
}
// ../../node_modules/.pnpm/zod@4.3.6/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: () => assert2,
assertEqual: () => assertEqual,
assertIs: () => assertIs,
assertNever: () => assertNever,
assertNotEqual: () => assertNotEqual,
assignProp: () => assignProp,
base64ToUint8Array: () => base64ToUint8Array,
base64urlToUint8Array: () => base64urlToUint8Array,
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,
hexToUint8Array: () => hexToUint8Array,
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,
parsedType: () => parsedType,
partial: () => partial,
pick: () => pick,
prefixIssues: () => prefixIssues,
primitiveTypes: () => primitiveTypes,
promiseAllObject: () => promiseAllObject,
propertyKeyTypes: () => propertyKeyTypes,
randomString: () => randomString,
required: () => required,
safeExtend: () => safeExtend,
shallowClone: () => shallowClone,
slugify: () => slugify,
stringifyPrimitive: () => stringifyPrimitive,
uint8ArrayToBase64: () => uint8ArrayToBase64,
uint8ArrayToBase64url: () => uint8ArrayToBase64url,
uint8ArrayToHex: () => uint8ArrayToHex,
unwrapMessage: () => unwrapMessage
});
function assertEqual(val) {
return val;
}
function assertNotEqual(val) {
return val;
}
function assertIs(_arg) {
}
function assertNever(_x) {
throw new Error("Unexpected value in exhaustive check");
}
function assert2(_) {
}
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) {
return {
get value() {
{
const value = getter();
Object.defineProperty(this, "value", { value });
return value;
}
}
};
}
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?.[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 = /* @__PURE__ */ 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?.[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);
}
function slugify(input) {
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
}
var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
};
function isObject(data) {
return typeof data === "object" && data !== null && !Array.isArray(data);
}
var allowsEval = cached(() => {
if (typeof navigator !== "undefined" && navigator?.userAgent?.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;
if (typeof ctor !== "function")
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 { ...o };
if (Array.isArray(o))
return [...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 ?? inst._zod.def);
if (!def || 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?.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 createTransparentProxy(getter) {
let target;
return new Proxy({}, {
get(_, prop, receiver) {
target ?? (target = getter());
return Reflect.get(target, prop, receiver);
},
set(_, prop, value, receiver) {
target ?? (target = getter());
return Reflect.set(target, prop, value, receiver);
},
has(_, prop) {
target ?? (target = getter());
return Reflect.has(target, prop);
},
deleteProperty(_, prop) {
target ?? (target = getter());
return Reflect.deleteProperty(target, prop);
},
ownKeys(_) {
target ?? (target = getter());
return Reflect.ownKeys(target);
},
getOwnPropertyDescriptor(_, prop) {
target ?? (target = getter());
return Reflect.getOwnPropertyDescriptor(target, prop);
},
defineProperty(_, prop, descriptor) {
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 checks = currDef.checks;
const hasChecks = checks && checks.length > 0;
if (hasChecks) {
throw new Error(".pick() cannot be used on object schemas containing refinements");
}
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 checks = currDef.checks;
const hasChecks = checks && checks.length > 0;
if (hasChecks) {
throw new Error(".omit() cannot be used on object schemas containing refinements");
}
const def = mergeDefs(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(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 checks = schema._zod.def.checks;
const hasChecks = checks && checks.length > 0;
if (hasChecks) {
const existingShape = schema._zod.def.shape;
for (const key in shape) {
if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) {
throw new Error("Cannot overwrite keys