UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

6,613 lines • 201 kB
import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-FEzRldkl.mjs";
import { createAccountListHelpers, hasConfiguredAccountValue, mergeAccountConfig, normalizeAccountId, resolveAccountWithDefaultFallback, resolveListedDefaultAccountId, resolveNormalizedAccountEntry } from "openclaw/plugin-sdk/account-core";
import { asNonArrayRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
import { defineChannelSetupContract } from "openclaw/plugin-sdk/channel-setup";
import { createEnvPatchedAccountSetupAdapter, createSetupTranslator, patchChannelConfigForAccount, promptResolvedAllowFrom, splitSetupEntries } from "openclaw/plugin-sdk/setup-runtime";
import { formatCliCommand, formatDocsLink } from "openclaw/plugin-sdk/setup-tools";
import { DEFAULT_ACCOUNT_ID, formatSetExplicitDefaultInstruction, normalizeAccountId as normalizeAccountId$1, normalizeOptionalAccountId, resolveDefaultAgentBoundAccountId } from "openclaw/plugin-sdk/routing";
import { createSubsystemLogger } from "openclaw/plugin-sdk/runtime-env";
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, normalizeAccountId as normalizeAccountId$2, normalizeOptionalAccountId as normalizeOptionalAccountId$1 } from "openclaw/plugin-sdk/account-id";
import { listAgentIds } from "openclaw/plugin-sdk/agent-scope-runtime";
import { tryReadSecretFileSync } from "openclaw/plugin-sdk/secret-file-runtime";
import { buildSecretInputSchema, coerceSecretRef, hasConfiguredSecretInput, normalizeSecretInputString, registerSensitiveConfigSchema, resolveSecretInputString } from "openclaw/plugin-sdk/secret-input";
import { canResolveEnvSecretRefInReadOnlyPath } from "openclaw/plugin-sdk/secret-ref-readonly";
import { getChatChannelMeta } from "openclaw/plugin-sdk/channel-plugin-common";
import { formatAllowFromLowercase } from "openclaw/plugin-sdk/allow-from";
import { adaptScopedAccountAccessor, createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
import { ChannelPreviewStreamingConfigSchema, ChannelThreadBindingsSchema, DmPolicySchema, GroupPolicySchema, ProviderCommandsSchema, ToolPolicySchema, buildChannelAccountSchemaParts, buildChannelConfigSchema, buildChannelExecApprovalsSchema, buildChannelReactionShape, buildGroupEntrySchema, refineChannelDmPolicy } from "openclaw/plugin-sdk/channel-config-schema";
import { createChannelConfigUiHints } from "openclaw/plugin-sdk/channel-config-ui-hints";
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$2, applySetupAccountConfigPatch, createAllowFromSection, createSetupTranslator as createSetupTranslator$1, createStandardChannelSetupStatus, defineTokenCredential, hasConfiguredSecretInput as hasConfiguredSecretInput$1, patchChannelConfigForAccount as patchChannelConfigForAccount$1, setSetupChannelEnabled, splitSetupEntries as splitSetupEntries$1 } from "openclaw/plugin-sdk/setup";
import { createChannelDmPolicy } from "openclaw/plugin-sdk/channel-dm-policy";
//#region extensions/telegram/src/account-config.ts
function resolveTelegramAccountConfig(e, n) {
	const r = normalizeAccountId(n);
	return resolveNormalizedAccountEntry(e.channels?.telegram?.accounts, r, normalizeAccountId);
}
function mergeTelegramAccountConfig(e, n) {
	const r = e.channels?.telegram;
	const i = Object.keys(r?.accounts ?? {}).length > 1;
	return mergeAccountConfig({
		channelConfig: r,
		accountConfig: resolveTelegramAccountConfig(e, n),
		omitKeys: ["defaultAccount"],
		inheritEmptyKeys: {
			capabilities: "array",
			...i ? {} : { groups: "object" }
		},
		preserveRootAllowFrom: true
	});
}
//#endregion
//#region extensions/telegram/src/account-selection.ts
function resolveTelegramBindingAccountId(e) {
	if (!e || typeof e !== "object") return null;
	const n = e;
	if (normalizeLowercaseStringOrEmpty(n.match?.channel) !== "telegram") return null;
	const r = typeof n.match?.accountId === "string" ? n.match.accountId : "";
	if (!r.trim() || r.trim() === "*") return null;
	return normalizeAccountId$2(r);
}
function hasTelegramAccountConfig(e, n) {
	const r = normalizeAccountId$2(n);
	if (resolveTelegramAccountConfig(e, r)) return true;
	const i = e.channels?.telegram;
	if (r !== DEFAULT_ACCOUNT_ID$1 && (Object.keys(i?.accounts ?? {}).length > 0 || !e.bindings?.some((e) => resolveTelegramBindingAccountId(e) === r))) return false;
	return hasConfiguredAccountValue(i?.botToken) || hasConfiguredAccountValue(i?.tokenFile) || r === DEFAULT_ACCOUNT_ID$1 && hasConfiguredAccountValue(process.env.TELEGRAM_BOT_TOKEN);
}
const { listAccountIds: listTelegramAccountIds } = createAccountListHelpers("telegram", {
	normalizeAccountId: normalizeAccountId$2,
	additionalAccountIds: (e) => [...new Set((e.bindings ?? []).map(resolveTelegramBindingAccountId).filter((e) => e !== null))].toSorted((e, n) => e.localeCompare(n)),
	hasImplicitDefaultAccount: (e) => hasTelegramAccountConfig(e, DEFAULT_ACCOUNT_ID$1)
});
function resolveDefaultTelegramAccountSelection(e) {
	const n = e.agents?.ownership === "explicit" && listAgentIds(e).length !== 1 ? null : resolveDefaultAgentBoundAccountId(e, "telegram");
	if (n) return {
		accountId: n,
		shouldWarnMissingDefault: false
	};
	const r = listTelegramAccountIds(e);
	const i = normalizeOptionalAccountId$1(e.channels?.telegram?.defaultAccount) ?? void 0;
	const a = i ? r.includes(i) : false;
	const o = resolveListedDefaultAccountId({
		accountIds: r,
		configuredDefaultAccountId: i
	});
	return {
		accountId: o,
		shouldWarnMissingDefault: o === r[0] && !a && !r.includes(DEFAULT_ACCOUNT_ID$1) && r.length > 1
	};
}
function resolveDefaultTelegramAccountId$1(e) {
	return resolveDefaultTelegramAccountSelection(e).accountId;
}
//#endregion
//#region extensions/telegram/src/token.ts
function readTelegramTokenFile(e, n, r) {
	const i = tryReadSecretFileSync(e, "Telegram bot token", { rejectSymlink: true }, { configPath: n });
	if (i.status === "available") return {
		token: i.value,
		source: "tokenFile"
	};
	r?.(`${n} is configured but unavailable`);
	return {
		token: "",
		source: "tokenFile",
		credentialDiagnostics: [i.diagnostic]
	};
}
function resolveEnvSecretRefValue(e) {
	if (canResolveEnvSecretRefInReadOnlyPath(e)) return normalizeSecretInputString(process.env[e.id]);
	const n = e.cfg?.secrets?.providers?.[e.provider];
	if (!n) throw new Error(`Secret provider "${e.provider}" is not configured (ref: env:${e.provider}:${e.id}).`);
	if (n.source !== "env") throw new Error(`Secret provider "${e.provider}" has source "${n.source}" but ref requests "env".`);
	throw new Error(`Environment variable "${e.id}" is not allowlisted in secrets.providers.${e.provider}.allowlist.`);
}
function resolveRuntimeTokenValue(e) {
	const n = resolveSecretInputString({
		value: e.value,
		path: e.path,
		defaults: e.cfg?.secrets?.defaults,
		mode: "inspect"
	});
	if (n.status === "available" || n.status === "missing") return n;
	if (n.ref.source === "env") {
		const r = resolveEnvSecretRefValue({
			cfg: e.cfg,
			provider: n.ref.provider,
			id: n.ref.id
		});
		return r ? {
			status: "available",
			value: r
		} : { status: "configured_unavailable" };
	}
	resolveSecretInputString({
		value: e.value,
		path: e.path,
		defaults: e.cfg?.secrets?.defaults,
		mode: "strict"
	});
	return { status: "configured_unavailable" };
}
function resolveTelegramToken(e, n = {}) {
	const r = normalizeOptionalAccountId(n.accountId) ?? (e ? resolveDefaultTelegramAccountId$1(e) : DEFAULT_ACCOUNT_ID);
	const i = e?.channels?.telegram;
	const a = Array.isArray(i?.accounts) ? void 0 : resolveNormalizedAccountEntry(i?.accounts, r, normalizeAccountId$1);
	if (r !== DEFAULT_ACCOUNT_ID && !a && Object.keys(asNonArrayRecord(i?.accounts)).length > 0) {
		n.logMissingFile?.(`channels.telegram.accounts: unknown accountId "${r}" — not found in config, refusing channel-level fallback`);
		return {
			token: "",
			source: "none"
		};
	}
	for (const { config: o, path: s } of [{
		config: a,
		path: `channels.telegram.accounts.${r}`
	}, {
		config: i,
		path: "channels.telegram"
	}]) {
		const r = o?.tokenFile?.trim();
		if (r) return readTelegramTokenFile(r, `${s}.tokenFile`, n.logMissingFile);
		const i = resolveRuntimeTokenValue({
			cfg: e,
			value: o?.botToken,
			path: `${s}.botToken`
		});
		if (i.status === "available") return {
			token: i.value,
			source: "config"
		};
		if (i.status === "configured_unavailable") return {
			token: "",
			source: "none"
		};
	}
	const o = r === DEFAULT_ACCOUNT_ID ? (n.envToken ?? process.env.TELEGRAM_BOT_TOKEN)?.trim() : "";
	if (o) return {
		token: o,
		source: "env"
	};
	return {
		token: "",
		source: "none"
	};
}
//#endregion
//#region extensions/telegram/src/accounts.ts
const log = createSubsystemLogger("telegram/accounts");
let emittedMissingDefaultWarn = false;
function resolveDefaultTelegramAccountId(e) {
	const n = resolveDefaultTelegramAccountSelection(e);
	if (n.shouldWarnMissingDefault && !emittedMissingDefaultWarn) {
		emittedMissingDefaultWarn = true;
		log.warn(`channels.telegram: accounts.default is missing; falling back to "${n.accountId}". ${formatSetExplicitDefaultInstruction("telegram")} to avoid routing surprises in multi-account setups.`);
	}
	return n.accountId;
}
function resolveTelegramAccountFallback(e, n) {
	return resolveAccountWithDefaultFallback({
		accountId: e.accountId ?? resolveDefaultTelegramAccountId(e.cfg),
		normalizeAccountId,
		resolvePrimary: n,
		hasCredential: (e) => e.tokenSource !== "none",
		resolveDefaultAccountId: () => resolveDefaultTelegramAccountId(e.cfg)
	});
}
function resolveTelegramAccount(e) {
	const n = e.cfg.channels?.telegram?.enabled !== false;
	const resolve = (r) => {
		const i = mergeTelegramAccountConfig(e.cfg, r);
		const a = i.enabled !== false;
		const o = n && a;
		const s = resolveTelegramToken(e.cfg, { accountId: r });
		return {
			accountId: r,
			enabled: o,
			name: normalizeOptionalString(i.name),
			token: s.token,
			tokenSource: s.source,
			tokenStatus: s.credentialDiagnostics?.length ? "configured_unavailable" : s.token ? "available" : "missing",
			...s.credentialDiagnostics ? { credentialDiagnostics: s.credentialDiagnostics } : {},
			config: i
		};
	};
	return resolveTelegramAccountFallback(e, resolve);
}
//#endregion
//#region extensions/telegram/src/allow-from.ts
function normalizeTelegramAllowFromEntry(e) {
	return (typeof e === "string" ? e : typeof e === "number" ? String(e) : "").trim().replace(/^(telegram|tg):/i, "").trim();
}
function isNumericTelegramSenderUserId(e) {
	return /^\d+$/.test(e);
}
//#endregion
//#region extensions/telegram/src/setup-contract.ts
const singleAccountKeysToMove = ["streaming", "webhookSecret"];
const namedAccountPromotionKeys = ["botToken", "tokenFile"];
//#endregion
//#region extensions/telegram/src/setup-core.ts
const t$1 = createSetupTranslator();
const channel$2 = "telegram";
function getTelegramTokenHelpLines() {
	return [
		t$1("wizard.telegram.tokenHelpOpenBotFather"),
		t$1("wizard.telegram.tokenHelpNewBot"),
		t$1("wizard.telegram.tokenHelpCopyToken"),
		t$1("wizard.telegram.tokenHelpWebApp", { url: "https://t.me/BotFather?startapp" }),
		t$1("wizard.telegram.tokenEnvTip"),
		t$1("wizard.channels.docs", { link: formatDocsLink("/telegram") }),
		t$1("wizard.telegram.website", { url: "https://openclaw.ai" })
	];
}
function getTelegramUserIdHelpLines() {
	return [
		t$1("wizard.telegram.userIdHelpLogs", { command: formatCliCommand("openclaw logs --follow") }),
		t$1("wizard.telegram.userIdHelpGetUpdates"),
		t$1("wizard.telegram.userIdHelpThirdParty"),
		t$1("wizard.channels.docs", { link: formatDocsLink("/telegram") }),
		t$1("wizard.telegram.website", { url: "https://openclaw.ai" })
	];
}
function parseTelegramAllowFromId(e) {
	const n = normalizeTelegramAllowFromEntry(e);
	return isNumericTelegramSenderUserId(n) ? n : null;
}
async function promptTelegramAllowFromForAccount(e) {
	const n = e.accountId ?? resolveDefaultTelegramAccountId(e.cfg);
	const r = resolveTelegramAccount({
		cfg: e.cfg,
		accountId: n
	});
	await e.prompter.note(getTelegramUserIdHelpLines().join("\n"), t$1("wizard.telegram.userIdTitle"));
	const i = await promptResolvedAllowFrom({
		prompter: e.prompter,
		existing: r.config.allowFrom ?? [],
		message: t$1("wizard.telegram.allowFromPrompt"),
		placeholder: "123456789",
		label: t$1("wizard.telegram.allowlistTitle"),
		parseInputs: splitSetupEntries,
		parseId: parseTelegramAllowFromId,
		invalidWithoutTokenNote: t$1("wizard.telegram.allowFromInvalid"),
		resolveEntries: async ({ entries: e }) => e.map((e) => {
			const n = parseTelegramAllowFromId(e);
			return {
				input: e,
				resolved: Boolean(n),
				id: n
			};
		})
	});
	return applyTelegramAllowFrom(e.cfg, n, i);
}
function applyTelegramAllowFrom(e, n, r) {
	return patchChannelConfigForAccount({
		cfg: e,
		channel: channel$2,
		accountId: n,
		patch: {
			dmPolicy: "allowlist",
			allowFrom: r
		},
		setupSurface: telegramSetupAdapter
	});
}
const telegramSetupAdapter = {
	...createEnvPatchedAccountSetupAdapter({
		channelKey: channel$2,
		defaultAccountOnlyEnvError: "TELEGRAM_BOT_TOKEN can only be used for the default account.",
		missingCredentialError: "Telegram requires token or --token-file (or --use-env).",
		hasCredentials: (e) => Boolean(e.token || e.tokenFile),
		buildPatch: (e) => e.tokenFile ? { tokenFile: e.tokenFile } : e.token ? { botToken: e.token } : {}
	}),
	singleAccountKeysToMove,
	namedAccountPromotionKeys
};
const telegramSetupContract = defineChannelSetupContract({
	fields: {
		token: {
			kind: "string",
			sensitive: true,
			cli: {
				flags: "--token <token>",
				description: "Telegram bot token"
			}
		},
		tokenFile: {
			kind: "string",
			sensitive: true,
			cli: {
				flags: "--token-file <path>",
				description: "Telegram bot token file"
			}
		},
		useEnv: {
			kind: "boolean",
			cli: {
				flags: "--use-env",
				description: "Use TELEGRAM_BOT_TOKEN"
			},
			envVars: ["TELEGRAM_BOT_TOKEN"]
		}
	},
	legacyAdapter: telegramSetupAdapter
});
//#endregion
//#region extensions/telegram/src/account-inspect.ts
function inspectTokenFile(e, n) {
	const r = normalizeOptionalString(e) ?? "";
	if (!r) return null;
	const i = readTelegramTokenFile(r, n);
	return {
		token: i.token,
		tokenSource: i.source,
		tokenStatus: i.credentialDiagnostics ? "configured_unavailable" : "available",
		...i.credentialDiagnostics ? { credentialDiagnostics: i.credentialDiagnostics } : {}
	};
}
function inspectTokenValue(e) {
	const n = coerceSecretRef(e.value, e.cfg.secrets?.defaults);
	if (n?.source === "env") {
		const r = canResolveEnvSecretRefInReadOnlyPath({
			cfg: e.cfg,
			provider: n.provider,
			id: n.id
		}) ? normalizeOptionalString(process.env[n.id]) : void 0;
		return {
			token: r ?? "",
			tokenSource: "env",
			tokenStatus: r ? "available" : "configured_unavailable"
		};
	}
	const r = normalizeSecretInputString(e.value);
	if (r || hasConfiguredSecretInput(e.value, e.cfg.secrets?.defaults)) return {
		token: r || "",
		tokenSource: "config",
		tokenStatus: r ? "available" : "configured_unavailable"
	};
	return null;
}
function readTelegramAccount(e) {
	return resolveTelegramAccountFallback(e, (n) => {
		const r = normalizeAccountId$1(n);
		const i = mergeTelegramAccountConfig(e.cfg, r);
		const a = {
			accountId: r,
			enabled: e.cfg.channels?.telegram?.enabled !== false && i.enabled !== false,
			name: normalizeOptionalString(i.name),
			config: i
		};
		const o = resolveTelegramAccountConfig(e.cfg, r);
		const s = r === DEFAULT_ACCOUNT_ID || Boolean(o) || Object.keys(asNonArrayRecord(e.cfg.channels?.telegram?.accounts)).length === 0;
		const c = [{
			config: o,
			path: `channels.telegram.accounts.${r}`
		}, ...s ? [{
			config: e.cfg.channels?.telegram,
			path: "channels.telegram"
		}] : []];
		for (const { config: n, path: r } of c) {
			const i = inspectTokenFile(n?.tokenFile, `${r}.tokenFile`) ?? inspectTokenValue({
				cfg: e.cfg,
				value: n?.botToken
			});
			if (i) return {
				...a,
				...i,
				configured: i.tokenStatus !== "missing"
			};
		}
		const l = r === DEFAULT_ACCOUNT_ID ? normalizeOptionalString(e.envToken) ?? normalizeOptionalString(process.env.TELEGRAM_BOT_TOKEN) ?? "" : "";
		if (l) return {
			...a,
			token: l,
			tokenSource: "env",
			tokenStatus: "available",
			configured: true
		};
		return {
			...a,
			token: "",
			tokenSource: "none",
			tokenStatus: "missing",
			configured: false,
			stateReason: s ? void 0 : `not configured: unknown accountId "${r}" in multi-bot setup`
		};
	});
}
function findTelegramTokenOwnerAccountId(e) {
	const n = normalizeAccountId$1(e.accountId);
	const r = /* @__PURE__ */ new Map();
	for (const i of listTelegramAccountIds(e.cfg)) {
		const a = readTelegramAccount({
			...e,
			accountId: i
		});
		const o = a.token.trim();
		if (!o) continue;
		const s = r.get(o);
		if (a.accountId === n) return s ?? null;
		if (!s) r.set(o, a.accountId);
	}
	return null;
}
function formatDuplicateTelegramTokenReason(e) {
	return `Duplicate Telegram bot token: account "${e.accountId}" shares a token with account "${e.ownerAccountId}". Keep one owner account per bot token.`;
}
function inspectTelegramAccount(e) {
	const n = readTelegramAccount(e);
	const r = n.token ? findTelegramTokenOwnerAccountId({
		...e,
		accountId: n.accountId
	}) : null;
	const i = resolveTelegramAccountConfig(e.cfg, n.accountId)?.groups ?? e.cfg.channels?.telegram?.groups;
	return {
		...n,
		configured: n.configured && !r,
		stateReason: r ? formatDuplicateTelegramTokenReason({
			accountId: n.accountId,
			ownerAccountId: r
		}) : n.stateReason,
		mode: n.config.webhookUrl ? "webhook" : "polling",
		allowUnmentionedGroups: Object.values(i ?? {}).some((e) => e?.requireMention === false)
	};
}
//#endregion
//#region extensions/telegram/src/config-adapter.ts
function resolveTelegramConfigAccessorAccount(e) {
	const n = normalizeAccountId$2(e.accountId ?? resolveDefaultTelegramAccountId(e.cfg));
	return { config: mergeTelegramAccountConfig(e.cfg, n) };
}
const telegramConfigAdapter = createScopedChannelConfigAdapter({
	sectionKey: "telegram",
	listAccountIds: listTelegramAccountIds,
	resolveAccount: adaptScopedAccountAccessor(resolveTelegramAccount),
	resolveAccessorAccount: resolveTelegramConfigAccessorAccount,
	inspectAccount: adaptScopedAccountAccessor(inspectTelegramAccount),
	defaultAccountId: resolveDefaultTelegramAccountId,
	clearBaseFields: [
		"botToken",
		"tokenFile",
		"name"
	],
	resolveAllowFrom: (e) => e.config.allowFrom,
	formatAllowFrom: (e) => formatAllowFromLowercase({
		allowFrom: e,
		stripPrefixRe: /^(telegram|tg):/i
	}),
	resolveDefaultTo: (e) => e.config.defaultTo
});
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/util.js
function getEnumValues(e) {
	const n = Object.values(e).filter((e) => typeof e === "number");
	return Object.entries(e).filter(([e, r]) => n.indexOf(+e) === -1).map(([e, n]) => n);
}
function joinValues(e, n = "|") {
	return e.map((e) => stringifyPrimitive(e)).join(n);
}
function jsonStringifyReplacer(e, n) {
	if (typeof n === "bigint") return n.toString();
	return n;
}
var Cached = class {
	constructor(e) {
		this._getter = e;
		this._value = void 0;
	}
	get value() {
		const e = this._getter;
		if (e !== void 0) {
			this._value = e();
			this._getter = void 0;
		}
		return this._value;
	}
};
function cached(e) {
	return new Cached(e);
}
function nullish(e) {
	return e === null || e === void 0;
}
function cleanRegex(e) {
	const n = e.startsWith("^") ? 1 : 0;
	const r = e.endsWith("$") ? e.length - 1 : e.length;
	return e.slice(n, r);
}
function floatSafeRemainder(e, n) {
	const r = e / n;
	const i = Math.round(r);
	const a = 4 * Number.EPSILON * Math.max(Math.abs(r), 1);
	if (Math.abs(r - i) < a) return 0;
	return r - i;
}
function assignProp(e, n, r) {
	Object.defineProperty(e, n, {
		value: r,
		writable: true,
		enumerable: true,
		configurable: true
	});
}
/**
* Whichever object a def's `shape` currently answers from: the one the caller passed until the first read, the frozen copy after it.
*
* Its keys and descriptors read without invoking anything, which is what lets a discriminated union check its discriminator, and the cycle walk read a shape, without resolving a getter that references the schema being constructed. A def that answers `shape` from an accessor of its own has none.
*/
function rawShape(e) {
	const n = Object.getOwnPropertyDescriptor(e, "shape");
	return n?.get ? n.get.raw : n?.value;
}
function sourceShape(e) {
	return rawShape(e._zod.def) ?? e._zod.def.shape;
}
function deferProp(e, n, r) {
	Object.defineProperty(e, n, {
		get() {
			const e = r();
			assignProp(this, n, e);
			return e;
		},
		enumerable: true,
		configurable: true
	});
}
function putProp(e, n, r) {
	if (n in e) assignProp(e, n, r);
	else e[n] = r;
}
/**
* Copies `keys` of `source`'s shape onto `target`, each value passed through `wrap`.
*
* A key the source has resolved is copied through now, so the derived shape states it outright and nothing has to resolve it to learn what it holds. A key the source still defers stays deferred, and reads back through the source's own `shape`, so it resolves once and both shapes get that one schema.
*/
function mirrorShape(e, n, r, i) {
	const a = sourceShape(n);
	for (const o of r) {
		const r = Object.getOwnPropertyDescriptor(a, o);
		if (!r.enumerable) continue;
		if (r.get) deferProp(e, o, () => {
			const e = n._zod.def.shape[o];
			return i ? i(e, o) : e;
		});
		else putProp(e, o, i ? i(r.value, o) : r.value);
	}
}
function mirrorProps(e, n) {
	for (const r of Reflect.ownKeys(n)) {
		const i = Object.getOwnPropertyDescriptor(n, r);
		if (!i.enumerable) continue;
		if (i.get) deferProp(e, r, () => n[r]);
		else putProp(e, r, i.value);
	}
}
function mergeDefs(...e) {
	const n = {};
	for (const r of e) {
		const e = Object.getOwnPropertyDescriptors(r);
		Object.assign(n, e);
	}
	return Object.defineProperties({}, n);
}
function esc(e) {
	return JSON.stringify(e);
}
function slugify(e) {
	return e.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
}
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (...e) => {};
function isObject(e) {
	return typeof e === "object" && e !== null && !Array.isArray(e);
}
const allowsEval = /* @__PURE__*/ cached(() => {
	if (globalConfig.jitless) return false;
	if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
	try {
		new Function("");
		return true;
	} catch (e) {
		return false;
	}
});
function isPlainObject(e) {
	if (isObject(e) === false) return false;
	const n = e.constructor;
	if (n === void 0) return true;
	if (typeof n !== "function") return true;
	const r = n.prototype;
	if (isObject(r) === false) return false;
	if (Object.prototype.hasOwnProperty.call(r, "isPrototypeOf") === false) return false;
	return true;
}
function shallowClone(e) {
	if (isPlainObject(e)) return { ...e };
	if (Array.isArray(e)) return [...e];
	if (e instanceof Map) return new Map(e);
	if (e instanceof Set) return new Set(e);
	return e;
}
const propertyKeyTypes = /* @__PURE__*/ new Set([
	"string",
	"number",
	"symbol"
]);
function escapeRegex(e) {
	return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}
function clone(e, n, r) {
	const i = new e._zod.constr(n ?? e._zod.def);
	if (!n || r?.parent) i._zod.parent = e;
	return i;
}
function normalizeParams(e) {
	const n = e;
	if (!n) return {};
	if (typeof n === "string") return { error: () => n };
	if (n?.message !== void 0) {
		if (n?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
		n.error = n.message;
	}
	delete n.message;
	if (typeof n.error === "string") return {
		...n,
		error: () => n.error
	};
	return n;
}
function stringifyPrimitive(e) {
	if (typeof e === "bigint") return e.toString() + "n";
	if (typeof e === "string") return `"${e}"`;
	return `${e}`;
}
function optionalKeys(e) {
	return Object.keys(e).filter((n) => {
		return e[n]._zod.optin !== void 0 && e[n]._zod.optout === "optional";
	});
}
const NUMBER_FORMAT_RANGES = /*@__PURE__*/ (() => ({
	safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
	int32: [-2147483648, 2147483647],
	uint32: [0, 4294967295],
	float32: [-34028234663852886e22, 34028234663852886e22],
	float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
}))();
const BIGINT_FORMAT_RANGES = {
	int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
	uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")]
};
function pick(e, n) {
	const r = e._zod.def;
	const i = r.checks;
	if (i && i.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
	const a = {};
	mirrorShape(a, e, maskedKeys(e, n));
	return clone(e, mergeDefs(r, {
		shape: a,
		checks: []
	}));
}
function maskedKeys(e, n) {
	const r = sourceShape(e);
	const i = [];
	for (const e of Reflect.ownKeys(n)) {
		if (!Object.getOwnPropertyDescriptor(r, e)?.enumerable) throw new Error(`Unrecognized key: "${String(e)}"`);
		if (n[e]) i.push(e);
	}
	return i;
}
function omit(e, n) {
	const r = e._zod.def;
	const i = r.checks;
	if (i && i.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
	const a = new Set(maskedKeys(e, n));
	const o = {};
	mirrorShape(o, e, Reflect.ownKeys(sourceShape(e)).filter((e) => !a.has(e)));
	return clone(e, mergeDefs(r, {
		shape: o,
		checks: []
	}));
}
function extend(e, n) {
	if (!isPlainObject(n)) throw new Error("Invalid input to extend: expected a plain object");
	const r = e._zod.def.checks;
	if (r && r.length > 0) {
		const r = sourceShape(e);
		for (const e of Reflect.ownKeys(n)) if (Object.getOwnPropertyDescriptor(r, e) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
	}
	return clone(e, mergeDefs(e._zod.def, { shape: extended(e, n) }));
}
function extended(e, n) {
	const r = {};
	mirrorShape(r, e, Reflect.ownKeys(sourceShape(e)));
	mirrorProps(r, n);
	return r;
}
function safeExtend(e, n) {
	if (!isPlainObject(n)) throw new Error("Invalid input to safeExtend: expected a plain object");
	return clone(e, mergeDefs(e._zod.def, { shape: extended(e, n) }));
}
function merge(e, n) {
	if (!n?._zod?.def) throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
	if (e._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
	const r = {};
	mirrorShape(r, e, Reflect.ownKeys(sourceShape(e)));
	mirrorShape(r, n, Reflect.ownKeys(sourceShape(n)));
	return clone(e, mergeDefs(e._zod.def, {
		shape: r,
		get catchall() {
			return n._zod.def.catchall;
		},
		checks: n._zod.def.checks ?? []
	}));
}
function partial(e, n, r, i = "partial") {
	const a = n._zod.def.checks;
	if (a && a.length > 0) throw new Error(`.${i}() cannot be used on object schemas containing refinements`);
	const o = r ? new Set(maskedKeys(n, r)) : void 0;
	const s = {};
	mirrorShape(s, n, Reflect.ownKeys(sourceShape(n)), e && ((n, r) => o && !o.has(r) ? n : new e({
		type: "optional",
		innerType: n
	})));
	return clone(n, mergeDefs(n._zod.def, {
		shape: s,
		checks: []
	}));
}
function required(e, n, r) {
	const i = r ? new Set(maskedKeys(n, r)) : void 0;
	const a = {};
	mirrorShape(a, n, Reflect.ownKeys(sourceShape(n)), (n, r) => i && !i.has(r) ? n : new e({
		type: "nonoptional",
		innerType: n
	}));
	return clone(n, mergeDefs(n._zod.def, { shape: a }));
}
function aborted(e, n = 0) {
	if (e.aborted === true) return true;
	for (let r = n; r < e.issues.length; r++) if (e.issues[r]?.continue !== true) return true;
	return false;
}
function explicitlyAborted(e, n = 0) {
	if (e.aborted === true) return true;
	for (let r = n; r < e.issues.length; r++) if (e.issues[r]?.continue === false) return true;
	return false;
}
function prefixIssues(e, n) {
	return n.map((n) => {
		var r;
		(r = n).path ?? (r.path = []);
		n.path.unshift(e);
		return n;
	});
}
function unwrapMessage(e) {
	return typeof e === "string" ? e : e?.message;
}
/** The leading size checks of `defChecks` that set an upper bound, each paired with it. */
function sizeCaps(e) {
	const n = [];
	for (const r of e ?? []) {
		const e = r._zod.def;
		if (!/_(length|size)$|_equals$/.test(e.check)) break;
		const i = e.maximum ?? e.length ?? e.size;
		if (i >= 0) n.push([i, r]);
	}
	return n;
}
function attachSchema(e, n, r) {
	var i;
	for (let a = n; a < e.length; a++) (i = e[a]).schema ?? (i.schema = r);
}
function finalizeIssue(e, n, r) {
	var i;
	const a = e.inst?._zod?.traits;
	if (a?.has("$ZodType")) {
		if (a.has("$ZodCheck")) (i = e).schema ?? (i.schema = e.inst);
		else e.schema = e.inst;
	}
	const o = e.schema !== e.inst ? e.schema?._zod.def?.error : void 0;
	const s = e.message ? e.message : unwrapMessage(e.inst?._zod.def?.error?.(e)) ?? unwrapMessage(o?.(e)) ?? unwrapMessage(n?.error?.(e)) ?? unwrapMessage(r.customError?.(e)) ?? unwrapMessage(r.localeError?.(e)) ?? "Invalid input";
	const c = {};
	for (const n of Object.keys(e)) {
		if (n === "inst" || n === "schema" || n === "continue" || n === "input" || n === "__proto__") continue;
		c[n] = e[n];
	}
	c.path ?? (c.path = []);
	c.message = s;
	if (n?.reportInput) c.input = e.input;
	return c;
}
const highSurrogate = /[\uD800-\uDBFF]/;
function codePointLength(e) {
	const n = e.length;
	if (!highSurrogate.test(e)) return n;
	let r = n;
	for (let i = 0; i < n - 1; i++) if ((e.charCodeAt(i) & 64512) === 55296 && (e.charCodeAt(i + 1) & 64512) === 56320) {
		r--;
		i++;
	}
	return r;
}
function getLengthableOrigin(e) {
	if (Array.isArray(e)) return "array";
	if (typeof e === "string") return "string";
	return "unknown";
}
function parsedType(e) {
	const n = typeof e;
	switch (n) {
		case "number": return Number.isNaN(e) ? "nan" : "number";
		case "object": {
			if (e === null) return "null";
			if (Array.isArray(e)) return "array";
			const n = e;
			if (n && Object.getPrototypeOf(n) !== Object.prototype && "constructor" in n && n.constructor) return n.constructor.name;
		}
	}
	return n;
}
function issue(...e) {
	const [n, r, i] = e;
	if (typeof n === "string") return {
		message: n,
		code: "custom",
		input: r,
		inst: i
	};
	return { ...n };
}
/**
* Installs a trait's members on its prototype. Each value builds that member for the instance on first read; the built value shadows the accessor as an own property, so a detached `const { parse } = schema` keeps working.
*
* Call this from a `proto` initializer, which runs once per prototype — never per instance.
*/
function members(e, n) {
	for (const r in n) {
		const i = Object.getOwnPropertyDescriptor(n, r);
		if (i.get) Object.defineProperty(e, r, {
			...i,
			enumerable: false
		});
		else defineBound(e, r, i.value);
	}
}
/** Shadows a prototype member with an own value, so a getter that builds from the instance runs once. */
function own(e, n, r, i = true) {
	Object.defineProperty(e, n, {
		configurable: true,
		writable: true,
		enumerable: i,
		value: r
	});
	return r;
}
/** Like {@link own}, for a member that was never an own data property and has to stay out of `Object.keys`. */
function hide(e, n, r) {
	return own(e, n, r, false);
}
/** Adds members a table derives from the instance: each builds on first read and shadows as own data, and assignment shadows the same way, as when these were own properties. */
/* @__NO_SIDE_EFFECTS__ */
function derived(e, n) {
	for (const r in e) {
		const i = e[r];
		Object.defineProperty(n, r, {
			configurable: true,
			enumerable: true,
			get() {
				return own(this, r, i(this));
			},
			set(e) {
				own(this, r, e);
			}
		});
	}
	return n;
}
function defineBound(e, n, r) {
	Object.defineProperty(e, n, {
		configurable: true,
		get() {
			return this == null ? r : own(this, n, r.bind(this));
		},
		set(e) {
			own(this, n, e);
		}
	});
}
/** Returns the prototype to install on, or `undefined` if this group is already installed on it. */
function claim(e, n) {
	const r = Object.getPrototypeOf(e);
	return n in r ? void 0 : r;
}
let installing;
let broke = false;
const breaker = {
	configurable: true,
	get() {
		broke = true;
	}
};
/**
* Installs a lazily-derived internal on the `_zod` prototype of `inst`'s
* constructor, computed from the internals object itself and cached there on
* first read. One accessor per constructor rather than one per instance.
*/
function defineLazyInternal(e, n, r) {
	const i = Object.getPrototypeOf(e._zod);
	if (n in i && installing !== e._zod) {
		installing = void 0;
		return;
	}
	installing = e._zod;
	Object.defineProperty(i, n, {
		configurable: true,
		get() {
			Object.defineProperty(this, n, breaker);
			const e = broke;
			broke = false;
			try {
				const i = r(this);
				if (broke) delete this[n];
				else Object.defineProperty(this, n, {
					configurable: true,
					writable: true,
					value: i
				});
				broke = broke || e;
				return i;
			} catch (r) {
				delete this[n];
				broke = broke || e;
				throw r;
			}
		},
		set(e) {
			Object.defineProperty(this, n, {
				configurable: true,
				writable: true,
				value: e
			});
		}
	});
}
/**
* Installs `key` on `inst`'s prototype, computed by `make` on first read and cached there as an own
* data property. One accessor per constructor rather than one per instance, because an own accessor
* puts every instance after the first into v8 dictionary mode. The key doubles as the sentinel.
*/
function installLazyProp(e, n, r, i) {
	const a = claim(e, n);
	if (!a) return;
	Object.defineProperty(a, n, {
		configurable: true,
		get() {
			const e = {
				configurable: true,
				writable: true,
				enumerable: i,
				value: void 0
			};
			Object.defineProperty(this, n, e);
			e.value = r(this);
			Object.defineProperty(this, n, e);
			return e.value;
		},
		set(e) {
			Object.defineProperty(this, n, {
				configurable: true,
				writable: true,
				enumerable: i,
				value: e
			});
		}
	});
}
/** Marks the thunk `_catch` synthesises for a constant catch value. `Function.length` cannot tell that thunk from a user callback — rest and defaulted parameters both report arity 0 — and a user callback reads `ctx.error`, whose issues only finalize correctly against the caller's per-parse error map. Provenance can say what arity cannot. A plain string key rather than `Symbol.for`, whose call at module scope no bundler can prove pure — the same shape that anchored `urlCanParse` into every build. */
const CONSTANT_CATCH = "~constantCatch";
/** Wraps a constant catch value in a thunk tagged with {@link CONSTANT_CATCH}. */
function constantCatch(e) {
	const fn = () => e;
	fn[CONSTANT_CATCH] = true;
	return fn;
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/core.js
var _a$1;
const _zodDesc = {
	value: void 0,
	enumerable: false
};
let _E = "captureStackTrace" in Error ? Error : null;
function newError(e) {
	const n = _E;
	if (n) {
		const r = n.stackTraceLimit;
		if (typeof r === "number") {
			try {
				n.stackTraceLimit = 0;
			} catch {
				_E = null;
				return new e();
			}
			try {
				return new e();
			} finally {
				n.stackTraceLimit = r;
			}
		}
	}
	return new e();
}
/* @__NO_SIDE_EFFECTS__ */
function $constructor(e, n, r, i) {
	const a = {};
	function Internals(e) {
		this.def = e;
		this.constr = _;
		this.traits = /* @__PURE__ */ new Set();
	}
	Internals.prototype = a;
	const o = r;
	const s = o && /* @__PURE__ */ new WeakSet();
	function init(r, i) {
		if (!r._zod) {
			_zodDesc.value = new Internals(i);
			try {
				Object.defineProperty(r, "_zod", _zodDesc);
			} finally {
				_zodDesc.value = void 0;
			}
		} else if (r._zod.traits.has(e)) return;
		r._zod.traits.add(e);
		n(r, i);
		if (s) {
			const e = Object.getPrototypeOf(r);
			const n = r._zod.constr.prototype;
			let i = e;
			while (i && i !== n) i = Object.getPrototypeOf(i);
			const a = i ?? e;
			if (!s.has(a)) {
				s.add(a);
				members(a, o);
			}
		}
		const a = _.prototype;
		for (const e in a) {
			if (!Object.prototype.hasOwnProperty.call(a, e)) continue;
			if (!(e in r)) r[e] = a[e].bind(r);
		}
	}
	const c = i?.Parent ?? Object;
	class Definition extends c {}
	Object.defineProperty(Definition, "name", { value: e });
	function _(e) {
		const n = i?.Parent ? newError(Definition) : this;
		init(n, e);
		const r = n._zod.deferred;
		if (r) {
			for (const e of r) e();
			n._zod.deferred = void 0;
		}
		const a = globalThis.__zod_globalConfig?.postProcessor;
		if (a) a(n);
		return n;
	}
	Object.defineProperty(_, "init", { value: init });
	Object.defineProperty(_, Symbol.hasInstance, { value: (n) => {
		if (i?.Parent && n instanceof i.Parent) return true;
		return n?._zod?.traits?.has(e);
	} });
	Object.defineProperty(_, "name", { value: e });
	return _;
}
var $ZodAsyncError = class extends Error {
	constructor() {
		super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
	}
};
var $ZodEncodeError = class extends Error {
	constructor(e) {
		super(`Encountered unidirectional transform during encode: ${e}`);
		this.name = "ZodEncodeError";
	}
};
(_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
const globalConfig = globalThis.__zod_globalConfig;
function config(e) {
	if (e) Object.assign(globalConfig, e);
	return globalConfig;
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/errors.js
function _getMessage() {
	const e = this._zod;
	e.message ?? (e.message = JSON.stringify(e.def, jsonStringifyReplacer, 2));
	return e.message;
}
function _setMessage(e) {
	this._zod.message = e;
}
const _messageDesc = {
	get: _getMessage,
	set: _setMessage,
	enumerable: true,
	configurable: true
};
const _issuesDesc = {
	value: void 0,
	enumerable: false
};
const _installedToString = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
const initializer$1 = (e, n) => {
	e.name = "$ZodError";
	_issuesDesc.value = n;
	Object.defineProperty(e, "issues", _issuesDesc);
	_issuesDesc.value = void 0;
	Object.defineProperty(e, "message", _messageDesc);
	const r = Object.getPrototypeOf(e);
	if (!_installedToString.has(r)) {
		_installedToString.add(r);
		Object.defineProperty(r, "toString", {
			configurable: true,
			enumerable: false,
			get() {
				const value = () => this.message;
				Object.defineProperty(this, "toString", {
					value,
					configurable: true,
					writable: true
				});
				return value;
			},
			set(e) {
				Object.defineProperty(this, "toString", {
					value: e,
					configurable: true,
					writable: true
				});
			}
		});
	}
};
const $ZodError = /* @__PURE__ */ $constructor("$ZodError", initializer$1);
/** Get-or-create `obj[key]` as an own data property. A path segment naming an inherited member
* ("toString", "constructor") would otherwise read through to the prototype, and assigning
* "__proto__" would hit the setter instead of creating a key. */
function node(e, n, r) {
	if (!Object.prototype.hasOwnProperty.call(e, n)) {
		if (n === "__proto__") Object.defineProperty(e, n, {
			value: r(),
			writable: true,
			enumerable: true,
			configurable: true
		});
		else e[n] = r();
	}
	return e[n];
}
function flattenError(e, n = (e) => e.message) {
	const r = {};
	const i = [];
	for (const a of e.issues) if (a.path.length > 0) node(r, a.path[0], () => []).push(n(a));
	else i.push(n(a));
	return {
		formErrors: i,
		fieldErrors: r
	};
}
function formatError(e, n = (e) => e.message) {
	const r = { _errors: [] };
	const processError = (e, i = []) => {
		for (const a of e.issues) if (a.code === "invalid_union" && a.errors.length) a.errors.map((e) => processError({ issues: e }, [...i, ...a.path]));
		else if (a.code === "invalid_key") processError({ issues: a.issues }, [...i, ...a.path]);
		else if (a.code === "invalid_element") processError({ issues: a.issues }, [...i, ...a.path]);
		else {
			const e = [...i, ...a.path];
			if (e.length === 0) r._errors.push(n(a));
			else {
				let i = r;
				let o = 0;
				while (o < e.length) {
					const r = e[o];
					const s = o === e.length - 1;
					if (r === "_errors") {
						if (s) i._errors.push(n(a));
						o++;
						continue;
					}
					if (!Object.prototype.hasOwnProperty.call(i, r)) Object.defineProperty(i, r, {
						value: { _errors: [] },
						enumerable: true,
						writable: true,
						configurable: true
					});
					const c = i[r];
					if (s) c._errors.push(n(a));
					i = c;
					o++;
				}
			}
		}
	};
	processError(e);
	return r;
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/parse.js
function finalizeParams(e, n) {
	return {
		callee: n?.callee ?? e,
		Err: n?.Err
	};
}
const _parse = (e) => {
	const fn = (n, r, i, a) => {
		const o = i ? {
			...i,
			async: false
		} : { async: false };
		const s = n._zod.run({
			value: r,
			issues: []
		}, o);
		if (s instanceof Promise) throw new $ZodAsyncError();
		if (s.issues.length) {
			const n = new ((a?.Err) ?? e)(s.issues.map((e) => finalizeIssue(e, o, config())));
			captureStackTrace(n, a?.callee ?? fn);
			throw n;
		}
		return s.value;
	};
	return fn;
};
const _parseAsync = (e) => {
	const fn = async (n, r, i, a) => {
		const o = i ? {
			...i,
			async: true
		} : { async: true };
		let s = n._zod.run({
			value: r,
			issues: []
		}, o);
		if (s instanceof Promise) s = await s;
		if (s.issues.length) {
			const n = new ((a?.Err) ?? e)(s.issues.map((e) => finalizeIssue(e, o, config())));
			captureStackTrace(n, a?.callee ?? fn);
			throw n;
		}
		return s.value;
	};
	return fn;
};
const _safeParse = (e) => (n, r, i) => {
	const a = i ? {
		...i,
		async: false
	} : { async: false };
	const o = n._zod.run({
		value: r,
		issues: []
	}, a);
	if (o instanceof Promise) throw new $ZodAsyncError();
	return o.issues.length ? failure(e, o.issues, a) : {
		success: true,
		data: o.value
	};
};
function failure(e, n, r) {
	let i;
	return {
		success: false,
		get error() {
			if (!i) {
				i = new e(n.map((e) => finalizeIssue(e, r, config())));
				n = void 0;
				r = void 0;
			}
			return i;
		},
		set error(e) {
			i = e;
			n = void 0;
			r = void 0;
		}
	};
}
const _safeParseAsync = (e) => async (n, r, i) => {
	const a = i ? {
		...i,
		async: true
	} : { async: true };
	let o = n._zod.run({
		value: r,
		issues: []
	}, a);
	if (o instanceof Promise) o = await o;
	return o.issues.length ? failure(e, o.issues, a) : {
		success: true,
		data: o.value
	};
};
const COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
const COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
const validate = ((e, n, r) => {
	const i = e._zod.bag.validator;
	if (i !== void 0) {
		if (i(n) !== COMPILE_INVALID) return true;
		if (i.definite === true && r === void 0) return false;
	}
	return validateFallback(e, n, r);
});
function validateFallback(e, n, r) {
	const i = r ? {
		...r,
		async: false,
		abortEarly: true
	} : {
		async: false,
		abortEarly: true
	};
	const a = e._zod.bag.fallbackRun;
	let o;
	if (a) {
		i[COMPILE_FALLBACK] = true;
		o = a({
			value: n,
			issues: []
		}, i);
	} else o = e._zod.run({
		value: n,
		issues: []
	}, i);
	if (o instanceof Promise) throw new $ZodAsyncError();
	return o.issues.length === 0;
}
const validateAsync$1 = async (e, n, r) => {
	const i = r ? {
		...r,
		async: true,
		abortEarly: true
	} : {
		async: true,
		abortEarly: true
	};
	let a = e._zod.run({
		value: n,
		issues: []
	}, i);
	if (a instanceof Promise) a = await a;
	return a.issues.length === 0;
};
const _encode = (e) => {
	const n = _parse(e);
	const fn = (e, r, i, a) => {
		const o = i ? {
			...i,
			direction: "backward"
		} : { direction: "backward" };
		return n(e, r, o, finalizeParams(fn, a));
	};
	return fn;
};
const _decode = (e) => {
	const n = _parse(e);
	const fn = (e, r, i, a) => {
		return n(e, r, i, finalizeParams(fn, a));
	};
	return fn;
};
const _encodeAsync = (e) => {
	const n = _parseAsync(e);
	const fn = async (e, r, i, a) => {
		const o = i ? {
			...i,
			direction: "backward"
		} : { direction: "backward" };
		return await n(e, r, o, finalizeParams(fn, a));
	};
	return fn;
};
const _decodeAsync = (e) => {
	const n = _parseAsync(e);
	const fn = async (e, r, i, a) => {
		return await n(e, r, i, finalizeParams(fn, a));
	};
	return fn;
};
const _safeEncode = (e) => (n, r, i) => {
	const a = i ? {
		...i,
		direction: "backward"
	} : { direction: "backward" };
	return _safeParse(e)(n, r, a);
};
const _safeDecode = (e) => (n, r, i) => {
	return _safeParse(e)(n, r, i);
};
const _safeEncodeAsync = (e) => async (n, r, i) => {
	const a = i ? {
		...i,
		direction: "backward"
	} : { direction: "backward" };
	return _safeParseAsync(e)(n, r, a);
};
const _safeDecodeAsync = (e) => async (n, r, i) => {
	return _safeParseAsync(e)(n, r, i);
};
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/regexes.js
/**
* @deprecated CUID v1 is deprecated by its authors due to information leakage
* (timestamps embedded in the id). Use {@link cuid2} instead.
* See https://github.com/paralleldrive/cuid.
*/
const cuid = /^[cC][0-9a-z]{6,}$/;
const cuid2 = /^[0-9a-z]+$/;
const ulid = /^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/;
const xid = /^[0-9a-vA-V]{20}$/;
const ksuid = /^[A-Za-z0-9]{27}$/;
const nanoid = /^[a-zA-Z0-9_-]{21}$/;
function nanoidOfLength(e) {
	return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`);
}
/** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
const duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
/** Returns a regex for validating an RFC 9562/4122 UUID.
*
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
const uuid = (e) => {
	if (!e) return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
	return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
};
/** Practical email validation */
const email = /^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
const _emoji$1 = `^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;
function emoji() {
	return new RegExp(_emoji$1, "u");
}
const ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
const base64url = /^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;
const httpProtocol = /^https?$/;
const e164 = /^\+[1-9]\d{6,14}$/;
const dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
/** Anchors a pattern source. The interpolation lives here rather than at the call site because
* esbuild will not drop a `@__PURE__` call whose own argument interpolates a variable, but it
* will drop `anchor(dateSource)`. Keeping it inline pinned `date` into every bundle. */
function anchor(e) {
	return new RegExp(`^${e}$`);
}
const date = /*@__PURE__*/ anchor(dateSource);
function timeSource(e) {
	const n = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
	return typeof e.precision === "number" ? e.precision === -1 ? `${n}` : e.precision === 0 ? `${n}:[0-5]\\d` : `${n}:[0-5]\\d\\.\\d{${e.precision}}` : e.seconds ? `${n}:[0-5]\\d(?:\\.\\d+)?` : `${n}(?::[0-5]\\d(?:\\.\\d+)?)?`;
}
function time(e) {
	return new RegExp(`^${timeSource(e)}$`);
}
function datetime(e) {
	const n = ["Z"];
	if (e.offset) n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
	const r = `${timeSource({
		precision: e.precision,
		seconds: true
	})}(?:${n.join("|")})`;
	const i = e.local ? `${r}|${timeSource({ precision: e.precision })}` : r;
	return new RegExp(`^${dateSource}T(?:${i})$`);
}
const anyString = /^[\s\S]{0,}$/;
const integer = /^-?\d+$/;
const number$1 = /^-?\d+(?:\.\d+)?$/;
const boolean$1 = /^(?:true|false)$/i;
const lowercase = /^[^A-Z]*$/;
const uppercase = /^[^a-z]*$/;
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/checks.js
const $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (e, n) => {
	var r;
	e._zod ?? (e._zod = {});
	e._zod.def = n;
	(r = e._zod).onattach ?? (r.onattach = []);
});
/** Default `when` for length-based checks: run only on non-nullish values with a `length`. */
const _whenHasLength = (e) => {
	const n = e.value;
	return !nullish(n) && n.length !== void 0;
};
const numericOriginMap = {
	number: "number",
	bigint: "bigint",
	object: "date"
};
const $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (e, n) => {
	$ZodCheck.init(e, n);
	const r = numericOriginMap[typeof n.value];
	e._zod.check = (i) => {
		if (n.inclusive ? i.value <= n.value : i.value < n.value) return;
		i.issues.push({
			origin: numericOriginMap[typeof i.value] ?? r,
			code: "too_big",
			maximum: typeof n.value === "object" ? n.value.getTime() : n.value,
			input: i.value,
			inclusive: n.inclusive,
			inst: e,
			continue: !n.abort
		});
	};
});
const $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (e, n) => {
	$ZodCheck.init(e, n);
	const r = numericOriginMap[typeof n.value];
	e._zod.check = (i) => {
		if (n.inclusive ? i.value >= n.value : i.value > n.value) return;
		i.issues.push({
			origin: numericOriginMap[typeof i.value] ?? r,
			code: "too_small",
			minimum: typeof n.value === "object" ? n.value.getTime() : n.value,
			input: i.value,
			inclusive: n.inclusive,
			inst: e,
			continue: !n.abort
		});
	};
});
const $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (e, n) => {
	$ZodCheck.init(e, n);
	e._zod.check = (r) => {
		if (typeof r.value !== typeof n.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
		if (typeof r.value === "bigint" ? n.value !== BigInt(0) && r.value % n.value === BigInt(0) : floatSafeRemainder(r.value, n.value) === 0) return;
		r.issues.push({
			origin: typeof r.value,
			code: "not_multiple_of",
			divisor: n.value,
			input: r.value,
			inst: e,
			continue: !n.abort
		});
	};
});
const $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat", (e, n) => {
	$ZodCheck.init(e, n);
	n.format = n.format || "float64";
	const r = n.format?.includes("int");
	const i = r ? "int" : "number";
	const [a, o] = NUMBER_FORMAT_RANGES[n.format];
	e._zod.check = (s) => {
		const c = s.value;
		if (r) {
			if (!Number.isInteger(c)) {
				s.issues.push({
					expected: i,
					format: n.format,
					code: "invalid_type",
					continue: false,
					input: c,
					inst: e
				});
				return;
			}
			if (!Number.isSafeInteger(c)) {
				if (c > 0) s.issues.push({
					input: c,
					code: "too_big",
					maximum: Number.MAX_SAFE_INTEGER,
					note: "Integers must be within the safe integer range.",
					inst: e,
					origin: i,
					inclusive: true,
					continue: !n.abort
				});
				else s.issues.push({
					input: c,
					code: "too_small",
					minimum: Number.MIN_SAFE_INTEGER,
					note: "Integers must be within the safe integer range.",
					inst: e,
					origin: i,
					inclusive: true,
					continue: !n.abort
				});
				return;
			}
		}
		if (c < a) s.issues.push({
			origin: "number",
			input: c,
			code: "too_small",
			minimum: a,
			inclusive: true,
			inst: e,
			continue: !n.abort
		});
		if (c > o) s.issues.push({
			origin: "number",
			input: c,
			code: "too_big",
			maximum: o,
			inclusive: true,
			inst: e,
			continue: !n.abort
		});
	};
});
const $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (e, n) => {
	var r;
	$ZodCheck.init(e, n);
	(r = e._zod.def).when ?? (r.when = _whenHasLength);
	e._zod.check = (r) => {
		const i = r.value;
		const a = i.length;
		if ((typeof i === "string" && a > n.maximum ? codePointLength(i) : a) <= n.maximum) return;
		const o = getLengthableOrigin(i);
		r.issues.push({
			origin: o,
			code: "too_big",
			maximum: n.maximum,
			inclusive: true,
			input: i,
			inst: e,
			continue: !n.abort
		});
	};
});
const $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (e, n) => {
	var r;
	$ZodCheck.init(e, n);
	(r = e._zod.def).when ?? (r.when = _whenHasLength);
	e._zod.check = (r) => {
		const i = r.value;
		const a = i.length;
		if ((typeof i === "string" && a >= n.minimum && a < n.minimum * 2 ? codePointLength(i) : a) >= n.minimum) return;
		const o = getLengthableOrigin(i);
		r.issues.push({
			origin: o,
			code: "too_small",
			minimum: n.minimum,
			inclusive: true,
			input: i,
			inst: e,
			continue: !n.abort
		});
	};
});
const $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (e, n) => {
	var r;
	$ZodCheck.init(e, n);
	(r = e._zod.def).when ?? (r.when = _whenHasLength);
	e._zod.check = (r) => {
		const i = r.value;
		const a = i.length;
		const o = typeof i === "string" && a >= n.length && a <= n.length * 2 ? codePointLength(i) : a;
		if (o === n.length) return;
		const s = getLengthableOrigin(i);
		const c = o > n.length;
		r.issues.push({
			origin: s,
			...c ? {
				code: "too_big",
				maximum: n.length
			} : {
				code: "too_small",
				minimum: n.length
			},
			inclusive: true,
			exact: true,
			input: r.value,
			inst: e,
			continue: !n.abort
		});
	};
});
const $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (e, n) => {
	var r, i;
	$ZodCheck.init(e, n);
	if (n.pattern) (r = e._zod).check ?? (r.check = (r) => {
		n.pattern.lastIndex = 0;
		if (n.pattern.test(r.value)) return;
		r.issues.push({
			origin: "string",
			code: "invalid_format",
			format: n.format,
			input: r.value,
			...n.pattern ? { pattern: n.pattern.toString() } : {},
			inst: e,
			continue: !n.abort
		});
	});
	else (i = e._zod).check ?? (i.check = () => {});
});
const $ZodCheckRegex = /*@__PURE__*/ $constructor("$ZodCheckRegex", (e, n) => {
	$ZodCheckStringFormat.init(e, n);
	e._zod.check = (r) => {
		n.pattern.lastIndex = 0;
		if (n.pattern.test(r.value)) return;
		r.issues.push({
			origin: "string",
			code: "invalid_format",
			format: "regex",
			input: r.value,
			pattern: n.pattern.toString(),
			inst: e,
			continue: !n.abort
		});
	};
});
const $ZodCheckLowerCase = /*@__PURE__*/ $constructor("$ZodCheckLowerCase", (e, n) => {
	n.pattern ?? (n.pattern = lowercase);
	$ZodCheckStringFormat.init(e, n);
});
const $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (e, n) => {
	n.pattern ?? (n.pattern = uppercase);
	$ZodCheckStringFormat.init(e, n);
});
const $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (e, n) => {
	$ZodCheck.init(e, n);
	const r = escapeRegex(n.includes);
	n.pattern = new RegExp(typeof n.position === "number" ? `^.{${n.position},}${r}` : r);
	e._zod.check = (r) => {
		if (r.value.includes(n.includes, n.position)) return;
		r.issues.push({
			origin: "string",
			code: "invalid_format",
			format: "includes",
			includes: n.includes,
			input: r.value,
			inst: e,
			continue: !n.abort
		});
	};
});
const $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (e, n) => {
	$ZodCheck.init(e, n);
	const r = new RegExp(`^${escapeRegex(n.prefix)}.*`);
	n.pattern ?? (n.pattern = r);
	e._zod.check = (r) => {
		if (r.value.startsWith(n.prefix)) return;
		r.issues.push({
			origin: "string",
			code: "invalid_format",
			format: "starts_with",
			prefix: n.prefix,
			input: r.value,
			inst: e,
			continue: !n.abort
		});
	};
});
const $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (e, n) => {
	$ZodCheck.init(e, n);
	const r = new RegExp(`.*${escapeRegex(n.suffix)}$`);
	n.pattern ?? (n.pattern = r);
	e._zod.check = (r) => {
		if (r.value.endsWith(n.suffix)) return;
		r.issues.push({
			origin: "string",
			code: "invalid_format",
			format: "ends_with",
			suffix: n.suffix,
			input: r.value,
			inst: e,
			continue: !n.abort
		});
	};
});
const $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (e, n) => {
	$ZodCheck.init(e, n);
	e._zod.check = (e) => {
		e.value = n.tx(e.value);
	};
});
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/doc.js
var Doc = class {
	constructor(e = [], n = {}) {
		this.content = [];
		this.indent = 0;
		this.args = e;
		this.closed = n;
	}
	indented(e) {
		this.indent += 1;
		try {
			e(this);
		} finally {
			this.indent -= 1;
		}
	}
	write(e) {
		if (typeof e === "function") {
			e(this, { execution: "sync" });
			e(this, { execution: "async" });
			return;
		}
		const n = e.split("\n").filter((e) => e);
		const r = Math.min(...n.map((e) => e.length - e.trimStart().length));
		const i = n.map((e) => e.slice(r)).map((e) => " ".repeat(this.indent * 2) + e);
		for (const e of i) this.content.push(e);
	}
	compile() {
		const e = Function;
		const n = this?.content ?? [``];
		return new e(...Object.keys(this.closed), `return function (${this.args.join(", ")}) {\n${n.join("\n")}\n};`)(...Object.values(this.closed));
	}
};
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/versions.js
const version = {
	major: 4,
	minor: 6,
	patch: 7
};
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/schemas.js
const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (e, n) => {
	var r;
	e ?? (e = {});
	e._zod.def = n;
	e._zod.bag = e._zod.bag || {};
	e._zod.version = version;
	const i = e._zod.def.checks;
	const a = e._zod.traits.has("$ZodCheck") ? [e, ...i ?? []] : i?.length ? [...i] : [];
	for (const n of a) for (const r of n._zod.onattach) r(e);
	if (a.length === 0) {
		(r = e._zod).deferred ?? (r.deferred = []);
		e._zod.deferred?.push(() => {
			e._zod.run = e._zod.parse;
		});
	} else {
		const runChecks = (n, r, i) => {
			if (n.memo) return n;
			let a = aborted(n);
			let o;
			for (const s of r) {
				if (s._zod.def.when) {
					if (explicitlyAborted(n)) continue;
					if (!s._zod.def.when(n)) continue;
				} else if (a) continue;
				const r = n.issues.length;
				const c = s._zod.check(n);
				if (c instanceof Promise && i?.async === false) throw new $ZodAsyncError();
				if (o || c instanceof Promise) o = (o ?? Promise.resolve()).then(async () => {
					await c;
					if (n.issues.length === r) return;
					attachSchema(n.issues, r, e);
					if (!a) a = aborted(n, r);
				});
				else {
					if (n.issues.length === r) continue;
					attachSchema(n.issues, r, e);
					if (!a) a = aborted(n, r);
				}
			}
			if (o) return o.then(() => {
				return n;
			});
			return n;
		};
		const handleCanaryResult = (n, r, i) => {
			if (aborted(n)) {
				n.aborted = true;
				return n;
			}
			const o = runChecks(r, a, i);
			if (o instanceof Promise) {
				if (i.async === false) throw new $ZodAsyncError();
				return o.then((n) => e._zod.parse(n, i));
			}
			return e._zod.parse(o, i);
		};
		e._zod.run = (n, r) => {
			if (r.skipChecks) return e._zod.parse(n, r);
			if (r.direction === "backward") {
				const i = e._zod.parse({
					value: n.value,
					issues: []
				}, {
					...r,
					skipChecks: true
				});
				if (i instanceof Promise) return i.then((e) => {
					return handleCanaryResult(e, n, r);
				});
				return handleCanaryResult(i, n, r);
			}
			const i = e._zod.parse(n, r);
			if (i instanceof Promise) {
				if (r.async === false) throw new $ZodAsyncError();
				return i.then((e) => runChecks(e, a, r));
			}
			return runChecks(i, a, r);
		};
	}
}, {
	get "~standard"() {
		return hide(this, "~standard", standardProps(this));
	},
	set "~standard"(e) {
		own(this, "~standard", e);
	}
});
/** The Standard Schema surface for `inst`. Shared so wrappers can extend it without forcing it. */
const toStandardResult = (e, n) => e.issues.length ? { issues: e.issues.map((e) => finalizeIssue(e, n, config())) } : { value: e.value };
async function validateAsync(e, n) {
	const r = { async: true };
	return toStandardResult(await e._zod.run({
		value: n,
		issues: []
	}, r), r);
}
function standardProps(e) {
	return {
		validate: (n) => {
			const r = { async: false };
			try {
				const i = e._zod.run({
					value: n,
					issues: []
				}, r);
				if (!(i instanceof Promise)) return toStandardResult(i, r);
			} catch (e) {}
			return validateAsync(e, n);
		},
		vendor: "zod",
		version: 1
	};
}
const $ZodString = /*@__PURE__*/ $constructor("$ZodString", (e, n) => {
	$ZodType.init(e, n);
	e._zod.pattern = n.pattern ?? anyString;
	e._zod.parse = (r, i) => {
		if (n.coerce) try {
			r.value = String(r.value);
		} catch (e) {}
		if (typeof r.value === "string") return r;
		r.issues.push({
			expected: "string",
			code: "invalid_type",
			input: r.value,
			inst: e
		});
		return r;
	};
});
const $ZodStringFormat = /*@__PURE__*/ $constructor("$ZodStringFormat", (e, n) => {
	$ZodCheckStringFormat.init(e, n);
	$ZodString.init(e, n);
});
const $ZodGUID = /*@__PURE__*/ $constructor("$ZodGUID", (e, n) => {
	n.pattern ?? (n.pattern = guid);
	$ZodStringFormat.init(e, n);
});
const $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (e, n) => {
	if (n.version) {
		const e = {
			v1: 1,
			v2: 2,
			v3: 3,
			v4: 4,
			v5: 5,
			v6: 6,
			v7: 7,
			v8: 8
		}[n.version];
		if (e === void 0) throw new Error(`Invalid UUID version: "${n.version}"`);
		n.pattern ?? (n.pattern = uuid(e));
	} else n.pattern ?? (n.pattern = uuid());
	$ZodStringFormat.init(e, n);
});
const $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (e, n) => {
	n.pattern ?? (n.pattern = email);
	$ZodStringFormat.init(e, n);
});
/** The `://` guard rejected the input before the URL constructor saw it. */
const URL_BAD_FORMAT = 1;
/** The URL parser rejected the input. */
const URL_UNPARSEABLE = 2;
function canParseURL(e) {
	try {
		if (typeof URL !== "undefined" && typeof URL.canParse === "function") return URL.canParse(e);
		new URL(e);
		return true;
	} catch {
		return false;
	}
}
function validateURL(e, n) {
	if (!("normalize" in n) && !("hostname" in n) && !("protocol" in n)) return canParseURL(e) || 2;
	return parseURLObject(e, n);
}
/** Parses a URL while preserving the non-normalizing HTTP guard. */
function parseURLObject(e, n) {
	if (!n.normalize && n.protocol?.source === httpProtocol.source && !/^https?:\/\//i.test(e)) return 1;
	try {
		if (typeof URL !== "undefined") {
			const n = URL;
			if (typeof n.parse === "function") return n.parse(e) ?? 2;
		}
		return new URL(e);
	} catch {
		return 2;
	}
}
const asciiTabOrNewline = /[\t\n\r]/g;
/** The URL parser deletes every ASCII tab, LF and CR from its input before it parses, so `new URL("https://exa\nmple.com")` reports on `example.com`. Applying the same deletion to the returned value closes the half of that divergence which can move the host; the parser's other rewrite, stripping C0 controls at the edges, cannot. */
function stripTabAndNewline(e) {
	return e.replace(asciiTabOrNewline, "");
}
function urlHostnameOk(e, n) {
	n.lastIndex = 0;
	return n.test(e.hostname);
}
function urlProtocolOk(e, n) {
	n.lastIndex = 0;
	return n.test(e.protocol.endsWith(":") ? e.protocol.slice(0, -1) : e.protocol);
}
const $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (e, n) => {
	$ZodStringFormat.init(e, n);
	e._zod.check = (r) => {
		try {
			const i = r.value.trim();
			const a = validateURL(i, n);
			if (a === 1) {
				r.issues.push({
					code: "invalid_format",
					format: "url",
					note: "Invalid URL format",
					input: r.value,
					inst: e,
					continue: !n.abort
				});
				return;
			}
			if (a === 2) {
				r.issues.push({
					code: "invalid_format",
					format: "url",
					input: r.value,
					inst: e,
					continue: !n.abort
				});
				return;
			}
			if (a === true) {
				r.value = stripTabAndNewline(i);
				return;
			}
			if (n.hostname && !urlHostnameOk(a, n.hostname)) r.issues.push({
				code: "invalid_format",
				format: "url",
				note: "Invalid hostname",
				pattern: n.hostname.source,
				input: r.value,
				inst: e,
				continue: !n.abort
			});
			if (n.protocol && !urlProtocolOk(a, n.protocol)) r.issues.push({
				code: "invalid_format",
				format: "url",
				note: "Invalid protocol",
				pattern: n.protocol.source,
				input: r.value,
				inst: e,
				continue: !n.abort
			});
			r.value = n.normalize ? a.href : stripTabAndNewline(i);
			return;
		} catch (i) {
			r.issues.push({
				code: "invalid_format",
				format: "url",
				input: r.value,
				inst: e,
				continue: !n.abort
			});
		}
	};
});
const $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (e, n) => {
	n.pattern ?? (n.pattern = emoji());
	$ZodStringFormat.init(e, n);
});
const $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (e, n) => {
	if (n.length !== void 0 && (!Number.isInteger(n.length) || n.length < 1)) throw new Error(`Invalid nanoid length: ${n.length}`);
	n.pattern ?? (n.pattern = n.length === void 0 ? nanoid : nanoidOfLength(n.length));
	$ZodStringFormat.init(e, n);
});
/**
* @deprecated CUID v1 is deprecated by its authors due to information leakage
* (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
* See https://github.com/paralleldrive/cuid.
*/
const $ZodCUID = /*@__PURE__*/ $constructor("$ZodCUID", (e, n) => {
	n.pattern ?? (n.pattern = cuid);
	$ZodStringFormat.init(e, n);
});
const $ZodCUID2 = /*@__PURE__*/ $constructor("$ZodCUID2", (e, n) => {
	n.pattern ?? (n.pattern = cuid2);
	$ZodStringFormat.init(e, n);
});
const $ZodULID = /*@__PURE__*/ $constructor("$ZodULID", (e, n) => {
	n.pattern ?? (n.pattern = ulid);
	$ZodStringFormat.init(e, n);
});
const $ZodXID = /*@__PURE__*/ $constructor("$ZodXID", (e, n) => {
	n.pattern ?? (n.pattern = xid);
	$ZodStringFormat.init(e, n);
});
const $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (e, n) => {
	n.pattern ?? (n.pattern = ksuid);
	$ZodStringFormat.init(e, n);
});
const $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (e, n) => {
	n.pattern ?? (n.pattern = datetime(n));
	$ZodStringFormat.init(e, n);
});
const $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (e, n) => {
	n.pattern ?? (n.pattern = date);
	$ZodStringFormat.init(e, n);
});
const $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (e, n) => {
	n.pattern ?? (n.pattern = time(n));
	$ZodStringFormat.init(e, n);
});
const $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (e, n) => {
	n.pattern ?? (n.pattern = duration);
	$ZodStringFormat.init(e, n);
});
const $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (e, n) => {
	n.pattern ?? (n.pattern = ipv4);
	$ZodStringFormat.init(e, n);
});
/** An IPv6 address is written with hex digits, colons and dots, and nothing else. The guard is what makes the check below an IPv6 check: `new URL("http://[...]")` parses an authority, not an address, so `@` and `\` re-delimit it and `"::@1\\"` validates against the host `0.0.0.1`. The URL parser also deletes ASCII tab, LF and CR rather than failing, which is how `"::1\n"` validated as `::1`. */
const ipv6Alphabet = /^[0-9a-fA-F:.]+$/;
function isValidIPv6(e) {
	if (!ipv6Alphabet.test(e)) return false;
	return canParseURL(`http://[${e}]`);
}
const $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (e, n) => {
	n.pattern ?? (n.pattern = ipv6);
	$ZodStringFormat.init(e, n);
	e._zod.check = (r) => {
		if (!isValidIPv6(r.value)) r.issues.push({
			code: "invalid_format",
			format: "ipv6",
			input: r.value,
			inst: e,
			continue: !n.abort
		});
	};
});
const $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (e, n) => {
	n.pattern ?? (n.pattern = cidrv4);
	$ZodStringFormat.init(e, n);
});
function isValidCIDRv6(e) {
	const n = e.split("/");
	if (n.length !== 2) return false;
	const [r, i] = n;
	if (!i) return false;
	const a = Number(i);
	if (`${a}` !== i) return false;
	if (a < 0 || a > 128) return false;
	return isValidIPv6(r);
}
const $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (e, n) => {
	n.pattern ?? (n.pattern = cidrv6);
	$ZodStringFormat.init(e, n);
	e._zod.check = (r) => {
		if (!isValidCIDRv6(r.value)) r.issues.push({
			code: "invalid_format",
			format: "cidrv6",
			input: r.value,
			inst: e,
			continue: !n.abort
		});
	};
});
function isValidBase64(e) {
	if (e === "") return true;
	if (/\s/.test(e)) return false;
	if (e.length % 4 !== 0) return false;
	try {
		atob(e);
		return true;
	} catch {
		return false;
	}
}
const base64Charset = /^[0-9a-zA-Z+/]*={0,2}$/;
const $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (e, n) => {
	n.pattern ?? (n.pattern = base64Charset);
	$ZodStringFormat.init(e, n);
	e._zod.check = (r) => {
		if (isValidBase64(r.value)) return;
		r.issues.push({
			code: "invalid_format",
			format: "base64",
			input: r.value,
			inst: e,
			continue: !n.abort
		});
	};
});
const base64urlCharset = /^[A-Za-z0-9_-]*$/;
function isValidBase64URL(e) {
	if (!base64urlCharset.test(e)) return false;
	const n = e.replace(/[-_]/g, (e) => e === "-" ? "+" : "/");
	return isValidBase64(n.padEnd(Math.ceil(n.length / 4) * 4, "="));
}
const $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (e, n) => {
	n.pattern ?? (n.pattern = base64urlCharset);
	$ZodStringFormat.init(e, n);
	e._zod.check = (r) => {
		if (isValidBase64URL(r.value)) return;
		r.issues.push({
			code: "invalid_format",
			format: "base64url",
			input: r.value,
			inst: e,
			continue: !n.abort
		});
	};
});
const $ZodE164 = /*@__PURE__*/ $constructor("$ZodE164", (e, n) => {
	n.pattern ?? (n.pattern = e164);
	$ZodStringFormat.init(e, n);
});
function isValidJWT(e, n = null) {
	try {
		const r = e.split(".");
		if (r.length !== 3) return false;
		const [i] = r;
		if (!i) return false;
		const a = JSON.parse(atob(i));
		if ("typ" in a && a?.typ !== "JWT") return false;
		if (!a.alg) return false;
		if (n && (!("alg" in a) || a.alg !== n)) return false;
		return true;
	} catch {
		return false;
	}
}
const $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (e, n) => {
	$ZodStringFormat.init(e, n);
	e._zod.check = (r) => {
		if (isValidJWT(r.value, n.alg)) return;
		r.issues.push({
			code: "invalid_format",
			format: "jwt",
			input: r.value,
			inst: e,
			continue: !n.abort
		});
	};
});
const $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (e, n) => {
	$ZodType.init(e, n);
	e._zod.pattern = number$1;
	e._zod.parse = (r, i) => {
		if (n.coerce) try {
			r.value = Number(r.value);
		} catch (e) {}
		const a = r.value;
		if (typeof a === "number" && !Number.isNaN(a) && Number.isFinite(a)) return r;
		const o = typeof a === "number" ? Number.isNaN(a) ? "NaN" : !Number.isFinite(a) ? String(a) : void 0 : void 0;
		r.issues.push({
			expected: "number",
			code: "invalid_type",
			input: a,
			inst: e,
			...o ? { received: o } : {}
		});
		return r;
	};
});
const $ZodNumberFormat = /*@__PURE__*/ $constructor("$ZodNumberFormat", (e, n) => {
	$ZodCheckNumberFormat.init(e, n);
	$ZodNumber.init(e, n);
});
const $ZodBoolean = /*@__PURE__*/ $constructor("$ZodBoolean", (e, n) => {
	$ZodType.init(e, n);
	e._zod.pattern = boolean$1;
	e._zod.parse = (r, i) => {
		if (n.coerce) try {
			r.value = Boolean(r.value);
		} catch (e) {}
		const a = r.value;
		if (typeof a === "boolean") return r;
		r.issues.push({
			expected: "boolean",
			code: "invalid_type",
			input: a,
			inst: e
		});
		return r;
	};
});
const $ZodUnknown = /*@__PURE__*/ $constructor("$ZodUnknown", (e, n) => {
	$ZodType.init(e, n);
	e._zod.parse = (e) => e;
});
const $ZodNever = /*@__PURE__*/ $constructor("$ZodNever", (e, n) => {
	$ZodType.init(e, n);
	e._zod.parse = (n, r) => {
		n.issues.push({
			expected: "never",
			code: "invalid_type",
			input: n.value,
			inst: e
		});
		return n;
	};
});
function capSize(e, n) {
	const r = sizeCaps(e._zod.def.checks);
	if (!r.length) return;
	const i = Math.min(...r.map((e) => e[0]));
	const a = e._zod.parse;
	e._zod.parse = (r, o) => {
		const s = n(r.value);
		if (s > i && !o?.skipChecks && o?.direction !== "backward") {
			for (const [n, i] of sizeCaps(e._zod.def.checks)) if (s > n && i._zod.def.when(r)) {
				const n = r.issues.length;
				i._zod.check(r);
				r.issues[n].continue = false;
				attachSchema(r.issues, n, e);
				return r;
			}
		}
		return a(r, o);
	};
}
const arraySize = (e) => Array.isArray(e) ? e.length : -1;
function handleArrayResult(e, n, r) {
	if (e.issues.length) n.issues.push(...prefixIssues(r, e.issues));
	n.value[r] = e.value;
}
const $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (e, n) => {
	$ZodType.init(e, n);
	const r = globalConfig.memoizer;
	r?.attach(e);
	e._zod.parse = (i, a) => {
		const o = i.value;
		if (!Array.isArray(o)) {
			i.issues.push({
				expected: "array",
				code: "invalid_type",
				input: o,
				inst: e
			});
			return i;
		}
		i.value = r ? r.alloc(e, i, Array(o.length), a) : Array(o.length);
		const s = [];
		const c = a?.abortEarly;
		for (let e = 0; e < o.length; e++) {
			const r = o[e];
			const l = n.element._zod.run({
				value: r,
				issues: []
			}, a);
			if (l instanceof Promise) s.push(l.then((n) => handleArrayResult(n, i, e)));
			else {
				handleArrayResult(l, i, e);
				if (c && l.issues.length !== 0 && aborted(l)) break;
			}
		}
		if (s.length) return Promise.all(s).then(() => i);
		return i;
	};
	capSize(e, arraySize);
});
function handlePropertyResult(e, n, r, i, a, o) {
	const s = r in i;
	const c = o === "optional";
	if (!s && c && a === "optional") return;
	if (e.issues.length) {
		if (a !== void 0 && c && !s) return;
		n.issues.push(...prefixIssues(r, e.issues));
	}
	if (!s && a === void 0) {
		if (!e.issues.length) n.issues.push({
			code: "invalid_type",
			expected: "nonoptional",
			input: void 0,
			path: [r]
		});
		return;
	}
	if (e.value === void 0) {
		if (s || a === "defaulted" && !c) n.value[r] = void 0;
	} else n.value[r] = e.value;
}
const NO_SYMBOL_KEYS = [];
function normalizeDef(e) {
	const n = Object.keys(e.shape);
	const r = Object.getOwnPropertySymbols(e.shape);
	const i = r.length ? r : NO_SYMBOL_KEYS;
	const a = i.length ? [...n, ...i] : n;
	for (const n of a) if (!e.shape?.[n]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${String(n)}": expected a Zod schema`);
	const o = optionalKeys(e.shape);
	return {
		...e,
		allKeys: a,
		symbolKeys: i,
		keySet: new Set(n),
		numKeys: n.length,
		optionalKeys: new Set(o)
	};
}
function handleCatchall(e, n, r, i, a, o, s) {
	const c = [];
	const l = a.keySet;
	const u = a.catchall._zod;
	const d = u.def.type;
	const f = u.optin;
	const p = u.optout;
	let m = 0;
	for (const a in n) {
		if (s && r.issues.length !== m) {
			if (aborted(r, m)) break;
			m = r.issues.length;
		}
		if (l.has(a)) continue;
		if (a === "__proto__") {
			if (d === "never") c.push(a);
			continue;
		}
		if (d === "never") {
			c.push(a);
			continue;
		}
		const o = u.run({
			value: n[a],
			issues: []
		}, i);
		if (o instanceof Promise) e.push(o.then((e) => handlePropertyResult(e, r, a, n, f, p)));
		else handlePropertyResult(o, r, a, n, f, p);
	}
	if (c.length) r.issues.push({
		code: "unrecognized_keys",
		keys: c,
		input: n,
		inst: o,
		continue: true
	});
	if (!e.length) return r;
	return Promise.all(e).then(() => {
		return r;
	});
}
const $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (e, n) => {
	$ZodType.init(e, n);
	const r = Object.getOwnPropertyDescriptor(n, "shape");
	const i = r?.get ? r.get.raw : n.shape ?? {};
	if (i) {
		const get = () => {
			const e = { ...i };
			Object.defineProperty(n, "shape", { value: e });
			get.raw = e;
			return e;
		};
		get.raw = i;
		Object.defineProperty(n, "shape", { get });
	}
	const a = cached(() => normalizeDef(n));
	defineLazyInternal(e, "propValues", (e) => {
		const n = e.def.shape;
		const r = {};
		for (const e in n) {
			const i = n[e]._zod;
			if (i.values) {
				if (!Object.prototype.hasOwnProperty.call(r, e)) assignProp(r, e, /* @__PURE__ */ new Set());
				for (const n of i.values) r[e].add(n);
				if (i.optin !== void 0) r[e].add(void 0);
			}
		}
		return r;
	});
	const o = isObject;
	const s = n.catchall;
	let c;
	const l = globalConfig.memoizer;
	l?.attach(e);
	e._zod.parse = (n, r) => {
		c ?? (c = a.value);
		const i = n.value;
		if (!o(i)) {
			n.issues.push({
				expected: "object",
				code: "invalid_type",
				input: i,
				inst: e
			});
			return n;
		}
		n.value = l ? l.alloc(e, n, {}, r) : {};
		const u = [];
		const d = c.shape;
		const f = r?.abortEarly;
		let p = n.issues.length;
		for (const e of c.allKeys) {
			if (f && n.issues.length !== p) {
				if (aborted(n, p)) break;
				p = n.issues.length;
			}
			if (e === "__proto__") continue;
			const a = d[e];
			const o = a._zod.optin;
			const s = a._zod.optout;
			const c = a._zod.run({
				value: i[e],
				issues: []
			}, r);
			if (c instanceof Promise) u.push(c.then((r) => handlePropertyResult(r, n, e, i, o, s)));
			else handlePropertyResult(c, n, e, i, o, s);
		}
		if (!s) return u.length ? Promise.all(u).then(() => n) : n;
		return handleCatchall(u, i, n, r, a.value, e, f === true);
	};
});
const $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (e, n) => {
	$ZodObject.init(e, n);
	const r = e._zod.parse;
	const i = cached(() => normalizeDef(n));
	const a = globalConfig.memoizer;
	const generateFastpass = (n) => {
		const r = i.value;
		const o = r.symbolKeys;
		const s = new Doc(["payload", "ctx"], {
			shape: n,
			inst: e,
			memo: a,
			syms: o
		});
		const parseStr = (e) => `shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`;
		const prefixStr = (e, n) => `
          let ${e}_ab = false;
          for (let i = 0; i < ${e}.issues.length; i++) {
            const iss = ${e}.issues[i];
            iss.path = iss.path ? [${n}, ...iss.path] : [${n}];
            payload.issues.push(iss);
            if (iss.continue !== true) ${e}_ab = true;
          }
          if (${e}_ab && ctx && ctx.abortEarly) {
            payload.value = newResult;
            return payload;
          }`;
		s.write(`const input = payload.value;`);
		const c = Object.create(null);
		let l = 0;
		for (const e of r.allKeys) c[e] = `key_${l++}`;
		s.write(a ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
		for (const e of r.allKeys) {
			if (e === "__proto__") continue;
			const r = c[e];
			const i = typeof e === "symbol" ? `syms[${o.indexOf(e)}]` : esc(e);
			const a = `${i} in input`;
			const l = n[e];
			const u = l?._zod?.optin;
			const d = u !== void 0;
			const f = l?._zod?.optout === "optional";
			s.write(`const ${r} = ${parseStr(i)};`);
			if (d && f) {
				const e = u === "optional" ? `${r}_present` : `${r}.value !== undefined || ${r}_present`;
				s.write(`
        const ${r}_present = ${a};
        if (!${r}.issues.length || ${r}_present) {
          if (${r}.issues.length) {${prefixStr(r, i)}
          }

          if (${e}) {
            newResult[${i}] = ${r}.value;
          }
        }

      `);
			} else if (!d) s.write(`
        const ${r}_present = ${a};
        if (${r}.issues.length) {${prefixStr(r, i)}
        }
        if (!${r}_present && !${r}.issues.length) {
          payload.issues.push({
            code: "invalid_type",
            expected: "nonoptional",
            input: undefined,
            path: [${i}]
          });
          if (ctx && ctx.abortEarly) {
            payload.value = newResult;
            return payload;
          }
        }

        if (${r}_present) {
          newResult[${i}] = ${r}.value;
        }

      `);
			else {
				s.write(`
        if (${r}.issues.length) {${prefixStr(r, i)}
        }
      `);
				if (u === "defaulted") s.write(`newResult[${i}] = ${r}.value;`);
				else s.write(`
        if (${r}.value !== undefined || ${a}) {
          newResult[${i}] = ${r}.value;
        }
      `);
			}
		}
		s.write(`payload.value = newResult;`);
		s.write(`return payload;`);
		return s.compile();
	};
	let o;
	const s = isObject;
	const c = !globalConfig.jitless;
	const l = allowsEval;
	const u = c && l.value;
	const d = n.catchall;
	let f;
	e._zod.parse = (a, l) => {
		f ?? (f = i.value);
		const p = a.value;
		if (!s(p)) {
			a.issues.push({
				expected: "object",
				code: "invalid_type",
				input: p,
				inst: e
			});
			return a;
		}
		if (c && u && l?.async === false && l.jitless !== true) {
			if (!o) o = generateFastpass(n.shape);
			a = o(a, l);
			if (!d) return a;
			return handleCatchall([], p, a, l, f, e, l?.abortEarly === true);
		}
		return r(a, l);
	};
});
function handleUnionResults(e, n, r, i) {
	for (const r of e) if (r.issues.length === 0) {
		n.value = r.value;
		return n;
	}
	const a = e.filter((e) => !aborted(e));
	if (a.length === 1) {
		n.value = a[0].value;
		return a[0];
	}
	n.issues.push({
		code: "invalid_union",
		input: n.value,
		inst: r,
		errors: e.map((e) => e.issues.map((e) => finalizeIssue(e, i, config())))
	});
	return n;
}
const $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (e, n) => {
	$ZodType.init(e, n);
	defineLazyInternal(e, "optin", (e) => e.def.options.some((e) => e._zod.optin === "defaulted") ? "defaulted" : e.def.options.some((e) => e._zod.optin !== void 0) ? "optional" : void 0);
	defineLazyInternal(e, "optout", (e) => e.def.options.some((e) => e._zod.optout === "optional") ? "optional" : void 0);
	defineLazyInternal(e, "values", (e) => {
		if (e.def.options.every((e) => e._zod.values)) return new Set(e.def.options.flatMap((e) => Array.from(e._zod.values)));
	});
	defineLazyInternal(e, "pattern", (e) => {
		if (e.def.options.every((e) => e._zod.pattern)) {
			const n = e.def.options.map((e) => e._zod.pattern);
			return new RegExp(`^(${n.map((e) => cleanRegex(e.source)).join("|")})$`);
		}
	});
	const r = n.options.length === 1 ? n.options[0]._zod.run : null;
	e._zod.parse = (i, a) => {
		if (r) return r(i, a);
		let o = false;
		const s = [];
		for (const e of n.options) {
			const n = e._zod.run({
				value: i.value,
				issues: []
			}, a);
			if (n instanceof Promise) {
				s.push(n);
				o = true;
			} else {
				if (n.issues.length === 0) return n;
				s.push(n);
			}
		}
		if (!o) return handleUnionResults(s, i, e, a);
		return Promise.all(s).then((n) => {
			return handleUnionResults(n, i, e, a);
		});
	};
});
const $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (e, n) => {
	$ZodType.init(e, n);
	e._zod.parse = (e, r) => {
		const i = e.value;
		const a = n.left._zod.run({
			value: i,
			issues: []
		}, r);
		const o = n.right._zod.run({
			value: i,
			issues: []
		}, r);
		if (a instanceof Promise || o instanceof Promise) return Promise.all([a, o]).then(([n, r]) => {
			return handleIntersectionResults(e, n, r);
		});
		return handleIntersectionResults(e, a, o);
	};
});
function mergeValues(e, n) {
	if (e === n) return {
		valid: true,
		data: e
	};
	if (e instanceof Date && n instanceof Date && +e === +n) return {
		valid: true,
		data: e
	};
	if (isPlainObject(e) && isPlainObject(n)) {
		const r = Object.keys(n);
		const i = Object.keys(e).filter((e) => r.indexOf(e) !== -1);
		const a = {
			...e,
			...n
		};
		if (Object.prototype.hasOwnProperty.call(a, "__proto__")) delete a.__proto__;
		for (const r of i) {
			if (r === "__proto__") continue;
			const i = mergeValues(e[r], n[r]);
			if (!i.valid) return {
				valid: false,
				mergeErrorPath: [r, ...i.mergeErrorPath]
			};
			a[r] = i.data;
		}
		return {
			valid: true,
			data: a
		};
	}
	if (Array.isArray(e) && Array.isArray(n)) {
		if (e.length !== n.length) return {
			valid: false,
			mergeErrorPath: []
		};
		const r = [];
		for (let i = 0; i < e.length; i++) {
			const a = e[i];
			const o = n[i];
			const s = mergeValues(a, o);
			if (!s.valid) return {
				valid: false,
				mergeErrorPath: [i, ...s.mergeErrorPath]
			};
			r.push(s.data);
		}
		return {
			valid: true,
			data: r
		};
	}
	return {
		valid: false,
		mergeErrorPath: []
	};
}
function handleIntersectionResults(e, n, r) {
	const i = /* @__PURE__ */ new Map();
	let a;
	const o = /* @__PURE__ */ new Map();
	const collect = (e, n) => {
		let r;
		if (e.code === "unrecognized_keys" && !e.path?.length) {
			a ?? (a = e);
			r = e.keys;
		} else if (e.code === "invalid_key" && e.origin === "record" && e.path?.length === 1) {
			const n = String(e.path[0]);
			if (!o.has(n)) o.set(n, e);
			r = [n];
		} else return false;
		for (const e of r) {
			if (!i.has(e)) i.set(e, {});
			i.get(e)[n] = true;
		}
		return true;
	};
	for (const r of n.issues) if (!collect(r, "l")) e.issues.push(r);
	for (const n of r.issues) if (!collect(n, "r")) e.issues.push(n);
	const s = [...i].filter(([, e]) => e.l && e.r).map(([e]) => e);
	if (s.length) {
		const n = a ? s.filter((e) => a.keys.includes(e)) : [];
		if (n.length) e.issues.push({
			...a,
			keys: n
		});
		for (const r of s) if (!n.includes(r) && o.has(r)) e.issues.push(o.get(r));
	}
	const c = mergeValues(n.value, r.value);
	if (!c.valid) {
		if (aborted(e)) return e;
		throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`);
	}
	e.value = c.data;
	return e;
}
const $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (e, n) => {
	$ZodType.init(e, n);
	const r = globalConfig.memoizer;
	r?.attach(e);
	e._zod.parse = (i, a) => {
		const o = i.value;
		if (!isPlainObject(o)) {
			i.issues.push({
				expected: "record",
				code: "invalid_type",
				input: o,
				inst: e
			});
			return i;
		}
		const s = [];
		const c = n.keyType._zod.values;
		if (c && !n.partial) {
			i.value = r ? r.alloc(e, i, {}, a) : {};
			const l = /* @__PURE__ */ new Set();
			for (const r of c) if (typeof r === "string" || typeof r === "number" || typeof r === "symbol") {
				l.add(typeof r === "number" ? r.toString() : r);
				if (r === "__proto__") continue;
				const c = n.keyType._zod.run({
					value: r,
					issues: []
				}, a);
				if (c instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
				if (c.issues.length) {
					i.issues.push({
						code: "invalid_key",
						origin: "record",
						issues: c.issues.map((e) => finalizeIssue(e, a, config())),
						input: r,
						path: [r],
						inst: e
					});
					continue;
				}
				const u = c.value;
				if (u === "__proto__") continue;
				const d = n.valueType._zod.run({
					value: o[r],
					issues: []
				}, a);
				if (d instanceof Promise) s.push(d.then((e) => {
					if (e.issues.length) i.issues.push(...prefixIssues(r, e.issues));
					i.value[u] = e.value;
				}));
				else {
					if (d.issues.length) i.issues.push(...prefixIssues(r, d.issues));
					i.value[u] = d.value;
				}
			}
			let u;
			for (const e in o) if (!l.has(e)) {
				if (n.mode === "loose") {
					if (e === "__proto__") continue;
					i.value[e] = o[e];
				} else {
					u = u ?? [];
					u.push(e);
				}
			}
			if (u && u.length > 0) i.issues.push({
				code: "unrecognized_keys",
				input: o,
				inst: e,
				keys: u,
				continue: true
			});
		} else {
			i.value = r ? r.alloc(e, i, {}, a) : {};
			let l;
			for (const r of Reflect.ownKeys(o)) {
				if (r === "__proto__") continue;
				if (!Object.prototype.propertyIsEnumerable.call(o, r)) continue;
				let u = n.keyType._zod.run({
					value: r,
					issues: []
				}, a);
				if (u instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
				if (typeof r === "string" && number$1.test(r) && u.issues.length) {
					const e = n.keyType._zod.run({
						value: Number(r),
						issues: []
					}, a);
					if (e instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
					if (e.issues.length === 0) u = e;
				}
				if (u.issues.length) {
					if (n.mode === "loose") i.value[r] = o[r];
					else if (c) {
						l = l ?? [];
						l.push(r);
					} else i.issues.push({
						code: "invalid_key",
						origin: "record",
						issues: u.issues.map((e) => finalizeIssue(e, a, config())),
						input: r,
						path: [r],
						inst: e
					});
					continue;
				}
				const d = u.value;
				if (d === "__proto__") continue;
				const f = n.valueType._zod.run({
					value: o[r],
					issues: []
				}, a);
				if (f instanceof Promise) s.push(f.then((e) => {
					if (e.issues.length) i.issues.push(...prefixIssues(r, e.issues));
					i.value[d] = e.value;
				}));
				else {
					if (f.issues.length) i.issues.push(...prefixIssues(r, f.issues));
					i.value[d] = f.value;
				}
			}
			if (l && l.length > 0) i.issues.push({
				code: "unrecognized_keys",
				input: o,
				inst: e,
				keys: l,
				continue: true
			});
		}
		if (s.length) return Promise.all(s).then(() => i);
		return i;
	};
});
const $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (e, n) => {
	$ZodType.init(e, n);
	const r = getEnumValues(n.entries);
	const i = new Set(r);
	e._zod.values = i;
	defineLazyInternal(e, "pattern", (e) => {
		const n = getEnumValues(e.def.entries).filter((e) => propertyKeyTypes.has(typeof e));
		return new RegExp(n.length ? `^(${n.map((e) => escapeRegex(e.toString())).join("|")})$` : "^[^\\s\\S]$");
	});
	e._zod.parse = (n, a) => {
		const o = n.value;
		if (i.has(o)) return n;
		n.issues.push({
			code: "invalid_value",
			values: r,
			input: o,
			inst: e
		});
		return n;
	};
});
const $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (e, n) => {
	$ZodType.init(e, n);
	const r = new Set(n.values);
	e._zod.values = r;
	defineLazyInternal(e, "pattern", (e) => {
		const n = e.def.values;
		return new RegExp(n.length ? `^(${n.map((e) => typeof e === "string" ? escapeRegex(e) : e ? escapeRegex(e.toString()) : String(e)).join("|")})$` : "^[^\\s\\S]$");
	});
	e._zod.parse = (i, a) => {
		const o = i.value;
		if (r.has(o)) return i;
		i.issues.push({
			code: "invalid_value",
			values: n.values,
			input: o,
			inst: e
		});
		return i;
	};
});
const $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (e, n) => {
	$ZodType.init(e, n);
	e._zod.optin = "optional";
	globalConfig.memoizer?.guard(e);
	e._zod.parse = (r, i) => {
		if (i.direction === "backward") throw new $ZodEncodeError(e.constructor.name);
		const a = n.transform(r.value, r);
		if (i.async) return (a instanceof Promise ? a : Promise.resolve(a)).then((e) => {
			r.value = e;
			return r;
		});
		if (a instanceof Promise) throw new $ZodAsyncError();
		r.value = a;
		return r;
	};
});
function handleOptionalResult(e, n) {
	e.value = n.issues.length ? void 0 : n.value;
	return e;
}
const $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (e, n) => {
	$ZodType.init(e, n);
	defineLazyInternal(e, "optin", (e) => e.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
	e._zod.optout = "optional";
	defineLazyInternal(e, "values", (e) => {
		const n = e.def.innerType._zod.values;
		return n ? /* @__PURE__ */ new Set([...n, void 0]) : void 0;
	});
	defineLazyInternal(e, "pattern", (e) => {
		const n = e.def.innerType._zod.pattern;
		return n ? new RegExp(`^(${cleanRegex(n.source)})?$`) : void 0;
	});
	e._zod.parse = (e, r) => {
		if (e.value === void 0) {
			if (n.innerType._zod.optin !== "defaulted") return e;
			const i = n.innerType._zod.run({
				value: e.value,
				issues: []
			}, r);
			if (i instanceof Promise) return i.then((n) => handleOptionalResult(e, n));
			return handleOptionalResult(e, i);
		}
		return n.innerType._zod.run(e, r);
	};
});
const $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (e, n) => {
	$ZodOptional.init(e, n);
	defineLazyInternal(e, "values", (e) => e.def.innerType._zod.values);
	defineLazyInternal(e, "pattern", (e) => e.def.innerType._zod.pattern);
	e._zod.parse = (e, r) => {
		return n.innerType._zod.run(e, r);
	};
});
const $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (e, n) => {
	$ZodType.init(e, n);
	defineLazyInternal(e, "optin", (e) => e.def.innerType._zod.optin);
	defineLazyInternal(e, "optout", (e) => e.def.innerType._zod.optout);
	defineLazyInternal(e, "pattern", (e) => {
		const n = e.def.innerType._zod.pattern;
		return n ? new RegExp(`^(${cleanRegex(n.source)}|null)$`) : void 0;
	});
	defineLazyInternal(e, "values", (e) => {
		return e.def.innerType._zod.values ? /* @__PURE__ */ new Set([...e.def.innerType._zod.values, null]) : void 0;
	});
	e._zod.parse = (e, r) => {
		if (e.value === null) return e;
		return n.innerType._zod.run(e, r);
	};
});
const $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (e, n) => {
	$ZodType.init(e, n);
	e._zod.optin = "defaulted";
	defineLazyInternal(e, "values", (e) => e.def.innerType._zod.values);
	e._zod.parse = (e, r) => {
		if (r.direction === "backward") return n.innerType._zod.run(e, r);
		if (e.value === void 0) {
			e.value = n.defaultValue;
			/**
			* $ZodDefault returns the default value immediately in forward direction.
			* It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe.   */
			return e;
		}
		const i = n.innerType._zod.run(e, r);
		if (i instanceof Promise) return i.then((e) => handleDefaultResult(e, n));
		return handleDefaultResult(i, n);
	};
});
function handleDefaultResult(e, n) {
	if (e.value === void 0) e.value = n.defaultValue;
	return e;
}
const $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (e, n) => {
	$ZodType.init(e, n);
	e._zod.optin = "defaulted";
	defineLazyInternal(e, "values", (e) => e.def.innerType._zod.values);
	e._zod.parse = (e, r) => {
		if (r.direction === "backward") return n.innerType._zod.run(e, r);
		if (e.value === void 0) e.value = n.defaultValue;
		return n.innerType._zod.run(e, r);
	};
});
const $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (e, n) => {
	$ZodType.init(e, n);
	defineLazyInternal(e, "values", (e) => {
		const n = e.def.innerType._zod.values;
		return n ? new Set([...n].filter((e) => e !== void 0)) : void 0;
	});
	e._zod.parse = (r, i) => {
		const a = n.innerType._zod.run(r, i);
		if (a instanceof Promise) return a.then((n) => handleNonOptionalResult(n, e));
		return handleNonOptionalResult(a, e);
	};
});
function handleNonOptionalResult(e, n) {
	if (!e.issues.length && e.value === void 0) e.issues.push({
		code: "invalid_type",
		expected: "nonoptional",
		input: e.value,
		inst: n
	});
	return e;
}
function handleCatchResult(e, n, r, i) {
	if (!n.issues.length) {
		e.value = n.value;
		if (n.memo) e.memo = true;
		return e;
	}
	e.value = r.catchValue({
		...n,
		value: e.value,
		error: { issues: n.issues.map((e) => finalizeIssue(e, i, config())) },
		input: e.value
	});
	return e;
}
const $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (e, n) => {
	$ZodType.init(e, n);
	defineLazyInternal(e, "optin", (e) => e.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
	defineLazyInternal(e, "optout", (e) => e.def.innerType._zod.optout);
	defineLazyInternal(e, "values", (e) => e.def.innerType._zod.values);
	e._zod.parse = (e, r) => {
		if (r.direction === "backward") return n.innerType._zod.run(e, r);
		const i = n.innerType._zod.run({
			value: e.value,
			issues: []
		}, r);
		if (i instanceof Promise) return i.then((i) => handleCatchResult(e, i, n, r));
		return handleCatchResult(e, i, n, r);
	};
});
const $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (e, n) => {
	$ZodType.init(e, n);
	defineLazyInternal(e, "values", (e) => e.def.in._zod.values);
	defineLazyInternal(e, "optin", (e) => e.def.in._zod.optin);
	defineLazyInternal(e, "optout", (e) => e.def.out._zod.optout);
	defineLazyInternal(e, "propValues", (e) => e.def.in._zod.propValues);
	e._zod.parse = (e, r) => {
		if (r.direction === "backward") {
			const i = n.out._zod.run(e, r);
			if (i instanceof Promise) return i.then((e) => handlePipeResult(e, n.in, r));
			return handlePipeResult(i, n.in, r);
		}
		const i = n.in._zod.run(e, r);
		if (i instanceof Promise) return i.then((e) => handlePipeResult(e, n.out, r));
		return handlePipeResult(i, n.out, r);
	};
});
function handlePipeResult(e, n, r) {
	if (e.issues.some((e) => e.code !== "unrecognized_keys")) {
		e.aborted = true;
		return e;
	}
	return n._zod.run({
		value: e.value,
		issues: e.issues
	}, r);
}
const $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (e, n) => {
	$ZodType.init(e, n);
	defineLazyInternal(e, "propValues", (e) => e.def.innerType._zod.propValues);
	defineLazyInternal(e, "values", (e) => e.def.innerType._zod.values);
	defineLazyInternal(e, "optin", (e) => e.def.innerType?._zod?.optin);
	defineLazyInternal(e, "optout", (e) => e.def.innerType?._zod?.optout);
	e._zod.parse = (e, r) => {
		if (r.direction === "backward") return n.innerType._zod.run(e, r);
		const i = n.innerType._zod.run(e, r);
		if (i instanceof Promise) return i.then(handleReadonlyResult);
		return handleReadonlyResult(i);
	};
});
function handleReadonlyResult(e) {
	if (!e.memo) e.value = Object.freeze(e.value);
	return e;
}
const $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (e, n) => {
	$ZodCheck.init(e, n);
	$ZodType.init(e, n);
	e._zod.parse = (e, n) => {
		return e;
	};
	e._zod.check = (r) => {
		const i = r.value;
		const a = n.fn(i);
		if (a instanceof Promise) return a.then((n) => handleRefineResult(n, r, i, e));
		handleRefineResult(a, r, i, e);
	};
});
function handleRefineResult(e, n, r, i) {
	if (!e) {
		const e = {
			code: "custom",
			input: r,
			inst: i,
			path: [...i._zod.def.path ?? []],
			continue: !i._zod.def.abort
		};
		if (i._zod.def.params) e.params = i._zod.def.params;
		n.issues.push(issue(e));
	}
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/memoizer.js
var $ZodCyclicError = class extends Error {
	constructor() {
		super(`Cannot parse a reference cycle that closes through a transform`);
		this.name = "ZodCyclicError";
	}
};
/** Keyed off the context object every schema in one parse call already shares. */
const STATE = "~memo";
const NO_ISSUES = [];
function isRef(e) {
	return e !== null && typeof e === "object";
}
function cloneIssues(e) {
	return e.map((e) => e.path ? {
		...e,
		path: e.path.slice()
	} : { ...e });
}
const recursive = /*@__PURE__*/ new WeakMap();
/** What the walk established, in order of certainty: ordered so the strongest answer among children wins. */
const NONE = 0;
const ASSUMED = 1;
const PROVEN = 2;
/** Whether this schema's subtree contains a cycle, so one parse can re-enter it. */
function isRecursive(e, n, r) {
	const i = recursive.get(e);
	if (i !== void 0) return i ? PROVEN : NONE;
	if (n.has(e)) return PROVEN;
	n.add(e);
	let a = NONE;
	const check = (e) => {
		if (a !== PROVEN && e?._zod) {
			const i = isRecursive(e, n, r);
			if (i > a) a = i;
		}
	};
	const shape = (e, i) => {
		let a = NONE;
		for (const o of Reflect.ownKeys(e)) {
			const s = Object.getOwnPropertyDescriptor(e, o);
			if (i && !s.enumerable) continue;
			const c = s.get ? ASSUMED : s.value?._zod ? isRecursive(s.value, n, r) : NONE;
			if (c > a) a = c;
		}
		return a;
	};
	const merge = (e) => {
		if (e > a) a = e;
	};
	const o = e._zod.def;
	switch (o.type) {
		case "object": {
			const e = rawShape(o);
			merge(e ? shape(e, true) : ASSUMED);
			check(o.catchall);
			break;
		}
		case "array":
			check(o.element);
			break;
		case "tuple":
			for (const e of o.items) check(e);
			check(o.rest);
			break;
		case "record":
		case "map":
			check(o.keyType);
			check(o.valueType);
			break;
		case "set":
			check(o.valueType);
			break;
		case "union":
			for (const e of o.options) check(e);
			break;
		case "intersection":
			check(o.left);
			check(o.right);
			break;
		case "optional":
		case "nullable":
		case "default":
		case "prefault":
		case "catch":
		case "readonly":
		case "nonoptional":
		case "promise":
		case "success":
			check(o.innerType);
			break;
		case "pipe":
			check(o.in);
			check(o.out);
			break;
		case "function":
			check(o.input);
			check(o.output);
			break;
		case "lazy": {
			const i = o._cachedInner ?? (r ? e._zod.innerType : void 0);
			merge(i ? isRecursive(i, n, false) : ASSUMED);
			break;
		}
		case "template_literal":
		case "string":
		case "number":
		case "int":
		case "boolean":
		case "bigint":
		case "symbol":
		case "undefined":
		case "null":
		case "void":
		case "never":
		case "any":
		case "unknown":
		case "date":
		case "nan":
		case "enum":
		case "literal":
		case "file":
		case "transform":
		case "custom": break;
		default: for (const e in o) {
			const n = Object.getOwnPropertyDescriptor(o, e);
			if (!n || n.get) continue;
			const r = n.value;
			if (!r || typeof r !== "object") continue;
			if (r._zod) check(r);
			else if (Array.isArray(r)) for (const e of r) check(e);
		}
	}
	n.delete(e);
	return settle(e, a);
}
/** An assumed answer must not outlive the resolution that settles it, so only a certain one is cached. */
function settle(e, n) {
	if (n !== ASSUMED) recursive.set(e, n === PROVEN);
	return n;
}
function bucketFor(e, n) {
	let r = e.buckets.get(n);
	if (!r) {
		r = /* @__PURE__ */ new WeakMap();
		e.buckets.set(n, r);
	}
	return r;
}
let handoff;
const open = [];
const memo = {
	alloc(e, n, r) {
		const i = handoff;
		if (!i) return r;
		handoff = void 0;
		const a = {
			value: r,
			issues: null
		};
		i.set(n.value, a);
		open.push(a);
		return r;
	},
	guard(e) {
		var n;
		(n = e._zod).deferred ?? (n.deferred = []);
		e._zod.deferred.push(() => {
			const n = e._zod.parse;
			const wrapped = (e, r) => {
				if (r.direction !== "backward" && isBackEdge(r, e.value)) throw new $ZodCyclicError();
				return n(e, r);
			};
			e._zod.parse = wrapped;
			if (e._zod.run === n) e._zod.run = wrapped;
		});
	},
	attach(e) {
		var n;
		let r;
		let i = false;
		let a;
		let o;
		(n = e._zod).deferred ?? (n.deferred = []);
		e._zod.deferred.push(() => {
			const n = e._zod.parse;
			const wrapped = (s, c) => {
				if (r === void 0) {
					const a = isRecursive(e, /* @__PURE__ */ new Set(), false);
					if (a === NONE) {
						e._zod.parse = n;
						if (e._zod.run === wrapped) e._zod.run = n;
						return n(s, c);
					}
					if (a === PROVEN || i) r = true;
					else i = true;
				}
				const l = s.value;
				if (!isRef(l)) return n(s, c);
				let u = c[STATE];
				if (!u) {
					u = {
						buckets: /* @__PURE__ */ new WeakMap(),
						backEdges: void 0
					};
					c[STATE] = u;
				}
				let d;
				if (a === c) d = o;
				else {
					d = bucketFor(u, e);
					a = c;
					o = d;
				}
				const f = d.get(l);
				if (f) {
					s.value = f.value;
					if (f.issues) {
						if (f.issues.length) s.issues.push(...cloneIssues(f.issues));
					} else {
						s.memo = true;
						u.backEdges ?? (u.backEdges = /* @__PURE__ */ new WeakSet());
						u.backEdges.add(f.value);
					}
					return s;
				}
				handoff = d;
				const p = open.length;
				const m = n(s, c);
				handoff = void 0;
				const h = open.length > p ? open.pop() : void 0;
				if (m instanceof Promise) return m.then((e) => {
					if (h) h.issues = e.issues.length ? cloneIssues(e.issues) : NO_ISSUES;
					return e;
				});
				if (h) h.issues = m.issues.length ? cloneIssues(m.issues) : NO_ISSUES;
				return m;
			};
			e._zod.parse = wrapped;
			if (e._zod.run === n) e._zod.run = wrapped;
		});
	}
};
/** The memoizer that gives containers cycle support. `zod` installs it by default; `zod/mini` opts in with `config({ memoizer: memoizer() })`. */
function memoizer() {
	return memo;
}
/** Whether this value is a node a back-edge resolved to before it finished. */
function isBackEdge(e, n) {
	const r = e[STATE]?.backEdges;
	return r !== void 0 && isRef(n) && r.has(n);
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/locales/en.js
const error = () => {
	const e = {
		string: {
			unit: "characters",
			verb: "to have"
		},
		file: {
			unit: "bytes",
			verb: "to have"
		},
		array: {
			unit: "items",
			verb: "to have"
		},
		set: {
			unit: "items",
			verb: "to have"
		},
		map: {
			unit: "entries",
			verb: "to have"
		}
	};
	function getSizing(n) {
		return e[n] ?? null;
	}
	const n = {
		regex: "input",
		email: "email address",
		url: "URL",
		emoji: "emoji",
		uuid: "UUID",
		uuidv4: "UUIDv4",
		uuidv6: "UUIDv6",
		nanoid: "nanoid",
		guid: "GUID",
		cuid: "cuid",
		cuid2: "cuid2",
		ulid: "ULID",
		xid: "XID",
		ksuid: "KSUID",
		datetime: "ISO datetime",
		date: "ISO date",
		time: "ISO time",
		duration: "ISO duration",
		ipv4: "IPv4 address",
		ipv6: "IPv6 address",
		mac: "MAC address",
		cidrv4: "IPv4 range",
		cidrv6: "IPv6 range",
		base64: "base64-encoded string",
		base64url: "base64url-encoded string",
		json_string: "JSON string",
		e164: "E.164 number",
		currency_code: "currency code",
		credit_card: "credit card number",
		iban: "IBAN",
		jwt: "JWT",
		template_literal: "input"
	};
	const r = { nan: "NaN" };
	function getTypeName(e, n) {
		if (e === "number" && typeof n === "number" && !Number.isFinite(n)) return String(n);
		return r[e] ?? e;
	}
	return (e) => {
		switch (e.code) {
			case "invalid_type": return `Invalid input: expected ${getTypeName(e.expected)}, received ${getTypeName(parsedType(e.input), e.input)}`;
			case "invalid_value":
				if (e.values.length === 1) return `Invalid input: expected ${stringifyPrimitive(e.values[0])}`;
				return `Invalid option: expected one of ${joinValues(e.values, "|")}`;
			case "too_big": {
				const n = e.exact ? "exactly " : e.inclusive ? "<=" : "<";
				const r = getSizing(e.origin);
				if (r) return `Too big: expected ${e.origin ?? "value"} to have ${n}${e.maximum.toString()} ${r.unit ?? "elements"}`;
				return `Too big: expected ${e.origin ?? "value"} to be ${n}${e.maximum.toString()}`;
			}
			case "too_small": {
				const n = e.exact ? "exactly " : e.inclusive ? ">=" : ">";
				const r = getSizing(e.origin);
				if (r) return `Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`;
				return `Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`;
			}
			case "invalid_format": {
				const r = e;
				if (r.format === "starts_with") return `Invalid string: must start with "${r.prefix}"`;
				if (r.format === "ends_with") return `Invalid string: must end with "${r.suffix}"`;
				if (r.format === "includes") return `Invalid string: must include "${r.includes}"`;
				if (r.format === "regex") return `Invalid string: must match pattern ${r.pattern}`;
				return `Invalid ${n[r.format] ?? e.format}`;
			}
			case "not_multiple_of": return `Invalid number: must be a multiple of ${e.divisor}`;
			case "unrecognized_keys": return `Unrecognized key${e.keys.length > 1 ? "s" : ""}: ${joinValues(e.keys, ", ")}`;
			case "invalid_key": return `Invalid key in ${e.origin}`;
			case "invalid_union":
				if (e.options && Array.isArray(e.options) && e.options.length > 0) return `Invalid discriminator value. Expected ${e.options.map((e) => `'${e}'`).join(" | ")}`;
				if (e.inclusive === false) return "Invalid input: more than one option matched";
				return "Invalid input";
			case "invalid_element": return `Invalid value in ${e.origin}`;
			default: return `Invalid input`;
		}
	};
};
function en_default() {
	return { localeError: error() };
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/registries.js
var _a;
var $ZodRegistry = class {
	constructor() {
		this._map = /* @__PURE__ */ new WeakMap();
		this._idmap = /* @__PURE__ */ new Map();
	}
	add(e, ...n) {
		const r = n[0];
		this._map.set(e, r);
		if (r && typeof r === "object" && "id" in r) this._idmap.set(r.id, e);
		return this;
	}
	clear() {
		this._map = /* @__PURE__ */ new WeakMap();
		this._idmap = /* @__PURE__ */ new Map();
		return this;
	}
	remove(e) {
		const n = this._map.get(e);
		if (n && typeof n === "object" && "id" in n) this._idmap.delete(n.id);
		this._map.delete(e);
		return this;
	}
	get(e) {
		const n = e._zod.parent;
		if (n) {
			const r = { ...this.get(n) ?? {} };
			delete r.id;
			const i = {
				...r,
				...this._map.get(e)
			};
			return Object.keys(i).length ? i : void 0;
		}
		return this._map.get(e);
	}
	has(e) {
		return this._map.has(e);
	}
};
function registry() {
	return new $ZodRegistry();
}
(_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
const globalRegistry = globalThis.__zod_globalRegistry;
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/api.js
function snapshotChecks(e) {
	if (e.checks) e.checks = [...e.checks];
	return e;
}
// @__NO_SIDE_EFFECTS__
function _string(e, n) {
	return new e(snapshotChecks({
		type: "string",
		...normalizeParams(n)
	}));
}
// @__NO_SIDE_EFFECTS__
function _email(e, n) {
	return new e({
		type: "string",
		format: "email",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _guid(e, n) {
	return new e({
		type: "string",
		format: "guid",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _uuid(e, n) {
	return new e({
		type: "string",
		format: "uuid",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _uuidv4(e, n) {
	return new e({
		type: "string",
		format: "uuid",
		check: "string_format",
		abort: false,
		version: "v4",
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _uuidv6(e, n) {
	return new e({
		type: "string",
		format: "uuid",
		check: "string_format",
		abort: false,
		version: "v6",
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _uuidv7(e, n) {
	return new e({
		type: "string",
		format: "uuid",
		check: "string_format",
		abort: false,
		version: "v7",
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _url(e, n) {
	return new e({
		type: "string",
		format: "url",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _emoji(e, n) {
	return new e({
		type: "string",
		format: "emoji",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _nanoid(e, n) {
	return new e({
		type: "string",
		format: "nanoid",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
/**
* @deprecated CUID v1 is deprecated by its authors due to information leakage
* (timestamps embedded in the id). Use {@link _cuid2} instead.
* See https://github.com/paralleldrive/cuid.
*/
// @__NO_SIDE_EFFECTS__
function _cuid(e, n) {
	return new e({
		type: "string",
		format: "cuid",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _cuid2(e, n) {
	return new e({
		type: "string",
		format: "cuid2",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _ulid(e, n) {
	return new e({
		type: "string",
		format: "ulid",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _xid(e, n) {
	return new e({
		type: "string",
		format: "xid",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _ksuid(e, n) {
	return new e({
		type: "string",
		format: "ksuid",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _ipv4(e, n) {
	return new e({
		type: "string",
		format: "ipv4",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _ipv6(e, n) {
	return new e({
		type: "string",
		format: "ipv6",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _cidrv4(e, n) {
	return new e({
		type: "string",
		format: "cidrv4",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _cidrv6(e, n) {
	return new e({
		type: "string",
		format: "cidrv6",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _base64(e, n) {
	return new e({
		type: "string",
		format: "base64",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _base64url(e, n) {
	return new e({
		type: "string",
		format: "base64url",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _e164(e, n) {
	return new e({
		type: "string",
		format: "e164",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _jwt(e, n) {
	return new e({
		type: "string",
		format: "jwt",
		check: "string_format",
		abort: false,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _isoDateTime(e, n) {
	return new e({
		type: "string",
		format: "datetime",
		check: "string_format",
		offset: false,
		local: false,
		precision: null,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _isoDate(e, n) {
	return new e({
		type: "string",
		format: "date",
		check: "string_format",
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _isoTime(e, n) {
	return new e({
		type: "string",
		format: "time",
		check: "string_format",
		precision: null,
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _isoDuration(e, n) {
	return new e({
		type: "string",
		format: "duration",
		check: "string_format",
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _number(e, n) {
	return new e(snapshotChecks({
		type: "number",
		checks: [],
		...normalizeParams(n)
	}));
}
// @__NO_SIDE_EFFECTS__
function _int(e, n) {
	return new e({
		type: "number",
		check: "number_format",
		abort: false,
		format: "safeint",
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _boolean(e, n) {
	return new e({
		type: "boolean",
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _unknown(e) {
	return new e({ type: "unknown" });
}
// @__NO_SIDE_EFFECTS__
function _never(e, n) {
	return new e({
		type: "never",
		...normalizeParams(n)
	});
}
// @__NO_SIDE_EFFECTS__
function _lt(e, n) {
	return new $ZodCheckLessThan({
		check: "less_than",
		...normalizeParams(n),
		value: e,
		inclusive: false
	});
}
// @__NO_SIDE_EFFECTS__
function _lte(e, n) {
	return new $ZodCheckLessThan({
		check: "less_than",
		...normalizeParams(n),
		value: e,
		inclusive: true
	});
}
// @__NO_SIDE_EFFECTS__
function _gt(e, n) {
	return new $ZodCheckGreaterThan({
		check: "greater_than",
		...normalizeParams(n),
		value: e,
		inclusive: false
	});
}
// @__NO_SIDE_EFFECTS__
function _gte(e, n) {
	return new $ZodCheckGreaterThan({
		check: "greater_than",
		...normalizeParams(n),
		value: e,
		inclusive: true
	});
}
// @__NO_SIDE_EFFECTS__
function _multipleOf(e, n) {
	return new $ZodCheckMultipleOf({
		check: "multiple_of",
		...normalizeParams(n),
		value: e
	});
}
// @__NO_SIDE_EFFECTS__
function _maxLength(e, n) {
	return new $ZodCheckMaxLength({
		check: "max_length",
		...normalizeParams(n),
		maximum: e
	});
}
// @__NO_SIDE_EFFECTS__
function _minLength(e, n) {
	return new $ZodCheckMinLength({
		check: "min_length",
		...normalizeParams(n),
		minimum: e
	});
}
// @__NO_SIDE_EFFECTS__
function _length(e, n) {
	return new $ZodCheckLengthEquals({
		check: "length_equals",
		...normalizeParams(n),
		length: e
	});
}
// @__NO_SIDE_EFFECTS__
function _regex(e, n) {
	return new $ZodCheckRegex({
		check: "string_format",
		format: "regex",
		...normalizeParams(n),
		pattern: e
	});
}
// @__NO_SIDE_EFFECTS__
function _lowercase(e) {
	return new $ZodCheckLowerCase({
		check: "string_format",
		format: "lowercase",
		...normalizeParams(e)
	});
}
// @__NO_SIDE_EFFECTS__
function _uppercase(e) {
	return new $ZodCheckUpperCase({
		check: "string_format",
		format: "uppercase",
		...normalizeParams(e)
	});
}
// @__NO_SIDE_EFFECTS__
function _includes(e, n) {
	return new $ZodCheckIncludes({
		check: "string_format",
		format: "includes",
		...normalizeParams(n),
		includes: e
	});
}
// @__NO_SIDE_EFFECTS__
function _startsWith(e, n) {
	return new $ZodCheckStartsWith({
		check: "string_format",
		format: "starts_with",
		...normalizeParams(n),
		prefix: e
	});
}
// @__NO_SIDE_EFFECTS__
function _endsWith(e, n) {
	return new $ZodCheckEndsWith({
		check: "string_format",
		format: "ends_with",
		...normalizeParams(n),
		suffix: e
	});
}
// @__NO_SIDE_EFFECTS__
function _overwrite(e) {
	return new $ZodCheckOverwrite({
		check: "overwrite",
		tx: e
	});
}
// @__NO_SIDE_EFFECTS__
function _normalize(e) {
	return /* @__PURE__ */ _overwrite((n) => n.normalize(e));
}
// @__NO_SIDE_EFFECTS__
function _trim() {
	return /* @__PURE__ */ _overwrite((e) => e.trim());
}
// @__NO_SIDE_EFFECTS__
function _toLowerCase() {
	return /* @__PURE__ */ _overwrite((e) => e.toLowerCase());
}
// @__NO_SIDE_EFFECTS__
function _toUpperCase() {
	return /* @__PURE__ */ _overwrite((e) => e.toUpperCase());
}
// @__NO_SIDE_EFFECTS__
function _slugify() {
	return /* @__PURE__ */ _overwrite((e) => slugify(e));
}
// @__NO_SIDE_EFFECTS__
function _array(e, n, r) {
	return new e({
		type: "array",
		element: n,
		...normalizeParams(r)
	});
}
// @__NO_SIDE_EFFECTS__
function _refine(e, n, r) {
	return new e({
		type: "custom",
		check: "custom",
		fn: n,
		...normalizeParams(r)
	});
}
// @__NO_SIDE_EFFECTS__
function _superRefine(e, n) {
	const r = /* @__PURE__ */ _check((n) => {
		n.addIssue = (e) => {
			if (typeof e === "string") n.issues.push(issue(e, n.value, r._zod.def));
			else {
				const i = e;
				if (i.fatal) i.continue = false;
				i.code ?? (i.code = "custom");
				if (!("input" in i)) i.input = n.value;
				i.inst ?? (i.inst = r);
				i.continue ?? (i.continue = !r._zod.def.abort);
				n.issues.push(issue(i));
			}
		};
		return e(n.value, n);
	}, n);
	return r;
}
// @__NO_SIDE_EFFECTS__
function _check(e, n) {
	const r = new $ZodCheck({
		check: "custom",
		...normalizeParams(n)
	});
	r._zod.check = e;
	return r;
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/to-json-schema.js
function assignProps(e, ...n) {
	for (const r of n) for (const n of Reflect.ownKeys(r)) if (Object.prototype.propertyIsEnumerable.call(r, n)) assignProp(e, n, r[n]);
	return e;
}
function initializeContext(e) {
	let n = e?.target ?? "draft-2020-12";
	if (n === "draft-4") n = "draft-04";
	if (n === "draft-7") n = "draft-07";
	return {
		processors: e.processors ?? {},
		metadataRegistry: e?.metadata ?? globalRegistry,
		target: n,
		unrepresentable: e?.unrepresentable ?? "throw",
		override: e?.override ?? (() => {}),
		io: e?.io ?? "output",
		counter: 0,
		seen: /* @__PURE__ */ new Map(),
		sharedDefsExtractedFor: void 0,
		sharedEmitDoneFor: void 0,
		cycles: e?.cycles ?? "ref",
		reused: e?.reused ?? "inline",
		intersections: [],
		deferred: [],
		external: e?.external ?? void 0
	};
}
/**
* Applies the `unrepresentable` setting at a site that has no JSON Schema equivalent. Throws
* `message` unless the setting (or the handler's return value) says otherwise. Returns `true` if a
* custom JSON Schema was written into `json`, in which case the caller must not write its own.
*/
function handleUnrepresentable(e, n, r, i, a) {
	const o = typeof n.unrepresentable === "function" ? n.unrepresentable({
		zodSchema: e,
		path: i.path,
		message: a
	}) : n.unrepresentable;
	if (o === "any") return false;
	if (o === void 0 || o === "throw") throw new Error(a);
	Object.assign(r, o);
	return true;
}
function processSchema(e, n, r = {
	path: [],
	schemaPath: []
}) {
	var i;
	const a = e._zod.def;
	const o = n.seen.get(e);
	if (o) {
		o.count++;
		if (r.schemaPath.includes(e)) o.cycle = r.path;
		return o.schema;
	}
	const s = {
		schema: {},
		count: 1,
		cycle: void 0,
		path: r.path
	};
	n.seen.set(e, s);
	n.sharedDefsExtractedFor = void 0;
	n.sharedEmitDoneFor = void 0;
	const c = e._zod.toJSONSchema?.();
	if (c) s.schema = c;
	else {
		const i = {
			...r,
			schemaPath: [...r.schemaPath, e],
			path: r.path
		};
		if (e._zod.processJSONSchema) e._zod.processJSONSchema(n, s.schema, i);
		else {
			const r = s.schema;
			const o = n.processors[a.type];
			if (!o) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${a.type}`);
			o(e, n, r, i);
		}
		const o = e._zod.parent;
		if (o) {
			if (!s.ref) s.ref = o;
			processSchema(o, n, i);
			n.seen.get(o).isParent = true;
		}
	}
	const l = n.metadataRegistry.get(e);
	if (l) assignProps(s.schema, l);
	if (n.io === "input" && isTransforming(e)) {
		delete s.schema.examples;
		delete s.schema.default;
	}
	if (n.io === "input" && "_prefault" in s.schema) (i = s.schema).default ?? (i.default = s.schema._prefault);
	delete s.schema._prefault;
	return n.seen.get(e).schema;
}
function encodeJSONPointerSegment(e) {
	return e.replace(/~/g, "~0").replace(/\//g, "~1");
}
function extractDefs(e, n) {
	const r = e.seen.get(n);
	if (!r) throw new Error("Unprocessed schema. This is a bug in Zod.");
	if (e.external && e.sharedDefsExtractedFor === e.external) return;
	const i = /* @__PURE__ */ new Map();
	for (const n of e.seen.entries()) {
		const r = e.metadataRegistry.get(n[0])?.id;
		if (r) {
			const e = i.get(r);
			if (e && e !== n[0]) throw new Error(`Duplicate schema id "${r}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
			i.set(r, n[0]);
		}
	}
	const makeURI = (n) => {
		const i = e.target === "draft-2020-12" ? "$defs" : "definitions";
		if (e.external) {
			const r = e.external.registry.get(n[0])?.id;
			const a = e.external.uri ?? ((e) => e);
			if (r) return { ref: a(r) };
			const o = n[1].defId ?? n[1].schema.id ?? `schema${e.counter++}`;
			n[1].defId = o;
			return {
				defId: o,
				ref: `${a("__shared")}#/${i}/${encodeJSONPointerSegment(o)}`
			};
		}
		const a = `#`;
		const o = `${a}/${i}/`;
		if (n[1] === r && !n[1].schema.id) return { ref: a };
		const s = n[1].schema.id ?? `__schema${e.counter++}`;
		return {
			defId: s,
			ref: o + encodeJSONPointerSegment(s)
		};
	};
	const extractToDef = (e) => {
		if (e[1].schema.$ref) return;
		const n = e[1];
		const { ref: r, defId: i } = makeURI(e);
		n.def = { ...n.schema };
		if (i) n.defId = i;
		const a = n.schema;
		for (const e in a) delete a[e];
		a.$ref = r;
	};
	if (e.cycles === "throw") for (const n of e.seen.entries()) {
		const e = n[1];
		if (e.cycle) throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>

Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
	}
	for (const r of e.seen.entries()) {
		const i = r[1];
		if (n === r[0]) {
			extractToDef(r);
			continue;
		}
		if (e.external) {
			const i = e.external.registry.get(r[0])?.id;
			if (n !== r[0] && i) {
				extractToDef(r);
				continue;
			}
		}
		if (e.metadataRegistry.get(r[0])?.id) {
			extractToDef(r);
			continue;
		}
		if (i.cycle) {
			extractToDef(r);
			continue;
		}
		if (i.count > 1) {
			if (e.reused === "ref") extractToDef(r);
		}
	}
	if (e.external) e.sharedDefsExtractedFor = e.external;
}
/** Rewrites `anyOf: [{type: "a"}, {type: "b"}]` to `type: ["a", "b"]`, which every JSON Schema draft treats as equivalent and most consumers render far better for the nullable case. Only branches that are a bare type assertion qualify — anything carrying a constraint, `$ref`, `const` or metadata is left alone. Runs after `flattenRef`, so a branch an override decorated or `$defs` extraction turned into a `$ref` is no longer bare and correctly stays in `anyOf`. `oneOf` is excluded: `integer` and `number` overlap, so "exactly one" and "at least one" are not the same there. OpenAPI 3.0 is excluded: its `type` must be a single string. */
function compactTypeUnion(e) {
	const n = e.anyOf;
	if (!Array.isArray(n) || n.length === 0 || e.type !== void 0) return;
	const r = [];
	for (const e of n) {
		if (!e || typeof e !== "object") return;
		compactTypeUnion(e);
		const n = Object.keys(e);
		if (n.length !== 1 || n[0] !== "type") return;
		const i = e.type;
		for (const e of Array.isArray(i) ? i : [i]) {
			if (typeof e !== "string") return;
			if (!r.includes(e)) r.push(e);
		}
	}
	delete e.anyOf;
	e.type = r.length === 1 ? r[0] : r;
}
/** Keywords `foldIntersection` knows how to combine. Anything else — `$ref`, `patternProperties`,
* an annotation like `description` — makes a member unfoldable, so a constraint this does not
* understand leaves the `allOf` alone instead of being silently dropped or misattributed. */
const FOLDABLE_KEYS = /* @__PURE__ */ new Set([
	"type",
	"properties",
	"required",
	"additionalProperties"
]);
const UNION_KEYS = ["oneOf", "anyOf"];
/** A member's constraint on a key it does not declare itself. A `catchall` states one; `false`, an absent `additionalProperties`, and the empty schema a loose object emits state nothing. */
function undeclaredConstraint(e) {
	const n = e.additionalProperties;
	if (n === void 0 || n === false || typeof n !== "object" || n === null) return null;
	return Object.keys(n).length ? n : null;
}
/** Combines object members into the single object they describe together, or returns `null` if any of them carries a keyword outside {@link FOLDABLE_KEYS}. */
function foldObjects(e) {
	const n = [];
	for (const r of e) {
		if (typeof r !== "object" || r.type !== "object") return null;
		for (const e in r) if (!FOLDABLE_KEYS.has(e)) return null;
		n.push(r);
	}
	const r = {};
	const i = /* @__PURE__ */ new Set();
	for (const e of n) {
		for (const i in e.properties) {
			if (Object.prototype.hasOwnProperty.call(r, i)) continue;
			const e = [];
			for (const r of n) {
				const n = r.properties?.[i] ?? undeclaredConstraint(r);
				if (n === null || n === void 0) continue;
				if (!e.some((e) => JSON.stringify(e) === JSON.stringify(n))) e.push(n);
			}
			const a = e.length === 1 ? e[0] : foldObjects(e) ?? { allOf: e };
			assignProp(r, i, a);
		}
		for (const n of e.required ?? []) i.add(n);
	}
	const a = {
		type: "object",
		properties: r
	};
	if (i.size) a.required = [...i];
	if (n.every((e) => e.additionalProperties === false)) a.additionalProperties = false;
	else {
		const e = [];
		for (const r of n) {
			const n = undeclaredConstraint(r);
			if (n && !e.some((e) => JSON.stringify(e) === JSON.stringify(n))) e.push(n);
		}
		if (e.length === 1) a.additionalProperties = e[0];
		else if (e.length > 1) a.additionalProperties = { allOf: e };
	}
	return a;
}
/** `additionalProperties` in an `allOf` member sees only that member's own `properties`, so two
* closed object members reject each other's keys and the schema validates nothing. Zod's parser
* pools the key sets instead — `handleIntersectionResults` reports a key as unrecognized only when
* *every* side rejects it — so the emitted schema has to pool them too, and folding the members
* into one object is the encoding that says so on every target.
*
* This runs from `finalize`, after `extractDefs`, which is what keeps it clear of the `$ref`
* machinery: a member extracted into `$defs` is already a `$ref` by now and declines to fold, so it
* keeps its reference and its own closedness rather than being inlined as a stale copy. */
function foldIntersection(e) {
	const n = e.allOf;
	if (!Array.isArray(n) || n.length < 2) return;
	for (const n of FOLDABLE_KEYS) if (n in e) return;
	const r = n.filter((e) => UNION_KEYS.some((n) => Array.isArray(e[n])));
	let i = null;
	if (!r.length) i = foldObjects(n);
	else {
		const e = r[0];
		const a = UNION_KEYS.find((n) => Array.isArray(e[n]));
		if (Object.keys(e).length !== 1) return;
		const o = n.filter((n) => n !== e);
		const s = e[a].map((e) => foldObjects([...o, e]));
		if (s.some((e) => !e)) return;
		i = { [a]: s };
	}
	if (!i) return;
	delete e.allOf;
	assignProps(e, i);
}
function finalize(e, n) {
	const r = e.seen.get(n);
	if (!r) throw new Error("Unprocessed schema. This is a bug in Zod.");
	const flattenRef = (n) => {
		const r = e.seen.get(n);
		if (r.ref === null) return;
		const i = r.def ?? r.schema;
		const a = { ...i };
		const o = r.ref;
		r.ref = null;
		if (o) {
			flattenRef(o);
			const r = e.seen.get(o);
			const s = r.schema;
			if (s.$ref && (e.target === "draft-07" || e.target === "draft-04" || e.target === "openapi-3.0")) {
				i.allOf = i.allOf ?? [];
				i.allOf.push(s);
			} else assignProps(i, s);
			assignProps(i, a);
			if (n._zod.parent === o) for (const e in i) {
				if (e === "$ref" || e === "allOf") continue;
				if (!(e in a)) delete i[e];
			}
			if (s.$ref && r.def) for (const e in i) {
				if (e === "$ref" || e === "allOf") continue;
				if (e in r.def && JSON.stringify(i[e]) === JSON.stringify(r.def[e])) delete i[e];
			}
		}
		const s = n._zod.parent;
		if (s && s !== o) {
			flattenRef(s);
			const n = e.seen.get(s);
			if (n?.schema.$ref) {
				i.$ref = n.schema.$ref;
				if (n.def) for (const e in i) {
					if (e === "$ref" || e === "allOf") continue;
					if (e in n.def && JSON.stringify(i[e]) === JSON.stringify(n.def[e])) delete i[e];
				}
			}
		}
		e.override({
			zodSchema: n,
			jsonSchema: i,
			path: r.path ?? []
		});
	};
	if (!e.external || e.sharedEmitDoneFor !== e.external) {
		for (const n of [...e.seen.entries()].reverse()) flattenRef(n[0]);
		if (e.target !== "openapi-3.0") for (const n of e.seen.entries()) compactTypeUnion(n[1].def ?? n[1].schema);
		for (const n of e.deferred) n();
		if (e.intersections.length) {
			const n = /* @__PURE__ */ new Map();
			for (const r of e.seen.values()) for (const e of [r.schema, r.def]) {
				const r = e?.allOf;
				if (!Array.isArray(r)) continue;
				const i = n.get(r);
				if (i) i.push(e);
				else n.set(r, [e]);
			}
			for (const r of e.intersections) for (const e of n.get(r) ?? []) foldIntersection(e);
		}
	}
	const i = {};
	if (e.target === "draft-2020-12") i.$schema = "https://json-schema.org/draft/2020-12/schema";
	else if (e.target === "draft-07") i.$schema = "http://json-schema.org/draft-07/schema#";
	else if (e.target === "draft-04") i.$schema = "http://json-schema.org/draft-04/schema#";
	else if (e.target === "openapi-3.0") {}
	if (e.external?.uri) {
		const r = e.external.registry.get(n)?.id;
		if (!r) throw new Error("Schema is missing an `id` property");
		i.$id = e.external.uri(r);
	}
	assignProps(i, r.defId ? r.schema : r.def ?? r.schema);
	const a = e.metadataRegistry.get(n)?.id;
	if (a !== void 0 && i.id === a) delete i.id;
	const o = e.external?.defs ?? {};
	if (!e.external || e.sharedEmitDoneFor !== e.external) for (const n of e.seen.entries()) {
		const e = n[1];
		if (e.def && e.defId) {
			if (e.def.id === e.defId) delete e.def.id;
			assignProp(o, e.defId, e.def);
		}
	}
	if (e.external) e.sharedEmitDoneFor = e.external;
	if (e.external) {} else if (Object.keys(o).length > 0) {
		if (e.target === "draft-2020-12") i.$defs = o;
		else i.definitions = o;
	}
	try {
		const r = JSON.parse(JSON.stringify(i));
		Object.defineProperty(r, "~standard", {
			value: {
				...n["~standard"],
				jsonSchema: {
					input: createStandardJSONSchemaMethod(n, "input", e.processors),
					output: createStandardJSONSchemaMethod(n, "output", e.processors)
				}
			},
			enumerable: false,
			writable: false
		});
		return r;
	} catch (e) {
		throw new Error("Error converting schema to JSON.");
	}
}
function isTransforming(e, n) {
	const r = n ?? { seen: /* @__PURE__ */ new Set() };
	if (r.seen.has(e)) return false;
	r.seen.add(e);
	const i = e._zod.def;
	if (i.type === "transform") return true;
	if (i.type === "array") return isTransforming(i.element, r);
	if (i.type === "set") return isTransforming(i.valueType, r);
	if (i.type === "lazy") return isTransforming(i.getter(), r);
	if (i.type === "promise" || i.type === "optional" || i.type === "nonoptional" || i.type === "nullable" || i.type === "readonly" || i.type === "default" || i.type === "prefault" || i.type === "catch") return isTransforming(i.innerType, r);
	if (i.type === "intersection") return isTransforming(i.left, r) || isTransforming(i.right, r);
	if (i.type === "record" || i.type === "map") return isTransforming(i.keyType, r) || isTransforming(i.valueType, r);
	if (i.type === "pipe") {
		if (e._zod.traits.has("$ZodCodec")) return true;
		return isTransforming(i.in, r) || isTransforming(i.out, r);
	}
	if (i.type === "object") {
		for (const e in i.shape) if (isTransforming(i.shape[e], r)) return true;
		return false;
	}
	if (i.type === "union") {
		for (const e of i.options) if (isTransforming(e, r)) return true;
		return false;
	}
	if (i.type === "tuple") {
		for (const e of i.items) if (isTransforming(e, r)) return true;
		if (i.rest && isTransforming(i.rest, r)) return true;
		return false;
	}
	return false;
}
/**
* Creates a toJSONSchema method for a schema instance.
* This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
*/
const createToJSONSchemaMethod = (e, n = {}) => (r) => {
	const i = initializeContext({
		...r,
		processors: n
	});
	processSchema(e, i);
	extractDefs(i, e);
	return finalize(i, e);
};
const createStandardJSONSchemaMethod = (e, n, r = {}) => (i) => {
	const { libraryOptions: a, target: o } = i ?? {};
	const s = initializeContext({
		...a ?? {},
		target: o,
		io: n,
		processors: r
	});
	processSchema(e, s);
	extractDefs(s, e);
	return finalize(s, e);
};
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/core/json-schema-processors.js
const narrowMin = (e, n, r) => {
	if (e[n] === void 0 || r > e[n]) e[n] = r;
};
const narrowMax = (e, n, r) => {
	if (e[n] === void 0 || r < e[n]) e[n] = r;
};
const narrowBoth = (e, n) => {
	narrowMin(e, "minimum", n);
	narrowMax(e, "maximum", n);
};
const addDivisor = (e, n) => {
	e.multipleOf ?? (e.multipleOf = []);
	if (!e.multipleOf.includes(n)) e.multipleOf.push(n);
};
const addPattern = (e, n) => {
	e.patterns ?? (e.patterns = /* @__PURE__ */ new Set());
	e.patterns.add(n);
};
const intersectMime = (e, n) => {
	e.mime = e.mime ? e.mime.filter((e) => n.includes(e)) : [...n];
};
const setFormat = (e, n) => {
	e.format = n;
	if (n.includes("int")) e.isInt = true;
};
const minContributor = (e, n) => narrowMin(e, "minimum", n.minimum);
const maxContributor = (e, n) => narrowMax(e, "maximum", n.maximum);
const formatContributor = (e) => (n, r) => {
	setFormat(n, r.format);
	const [i, a] = e[r.format];
	narrowMin(n, "minimum", i);
	narrowMax(n, "maximum", a);
};
const contributors = {
	greater_than: (e, n) => narrowMin(e, n.inclusive ? "minimum" : "exclusiveMinimum", n.value),
	less_than: (e, n) => narrowMax(e, n.inclusive ? "maximum" : "exclusiveMaximum", n.value),
	multiple_of: (e, n) => addDivisor(e, n.value),
	number_format: formatContributor(NUMBER_FORMAT_RANGES),
	bigint_format: formatContributor(BIGINT_FORMAT_RANGES),
	min_length: minContributor,
	max_length: maxContributor,
	length_equals: (e, n) => narrowBoth(e, n.length),
	min_size: minContributor,
	max_size: maxContributor,
	size_equals: (e, n) => narrowBoth(e, n.size),
	string_format: (e, n) => {
		setFormat(e, n.format);
		if (n.pattern) addPattern(e, n.pattern);
		if (n.format === "base64" || n.format === "base64url") e.contentEncoding = n.format;
		if (n.local || n.precision === -1) e.laxFormat = true;
	},
	mime_type: (e, n) => intersectMime(e, n.mime)
};
function aggregateChecks(e) {
	const n = {};
	const r = e._zod.def;
	const i = e._zod.traits.has("$ZodCheck") ? [e, ...r.checks ?? []] : r.checks ?? [];
	for (const e of i) contributors[e._zod.def.check]?.(n, e._zod.def);
	const a = e._zod.bag;
	if (a.minimum !== void 0) narrowMin(n, "minimum", a.minimum);
	if (a.exclusiveMinimum !== void 0) narrowMin(n, "exclusiveMinimum", a.exclusiveMinimum);
	if (a.maximum !== void 0) narrowMax(n, "maximum", a.maximum);
	if (a.exclusiveMaximum !== void 0) narrowMax(n, "exclusiveMaximum", a.exclusiveMaximum);
	if (a.multipleOf !== void 0) addDivisor(n, a.multipleOf);
	if (a.format !== void 0) {
		n.format ?? (n.format = a.format);
		if (a.format.includes("int")) n.isInt = true;
	}
	if (a.mime) intersectMime(n, a.mime);
	for (const e of a.patterns ?? []) addPattern(n, e);
	return n;
}
const formatMap = {
	guid: "uuid",
	url: "uri",
	datetime: "date-time",
	json_string: "json-string",
	regex: ""
};
const exactPatterns = /* @__PURE__ */ new Map([[base64Charset, base64], [base64urlCharset, base64url]]);
const exactPattern = (e) => exactPatterns.get(e) ?? e;
const stringProcessor = (e, n, r, i) => {
	const a = r;
	a.type = "string";
	const { minimum: o, maximum: s, format: c, patterns: l, contentEncoding: u, laxFormat: d } = aggregateChecks(e);
	if (typeof o === "number") a.minLength = o;
	if (typeof s === "number") a.maxLength = s;
	if (c) {
		a.format = formatMap[c] ?? c;
		if (a.format === "") delete a.format;
		if (c === "time" || d) delete a.format;
	}
	if (u) a.contentEncoding = u;
	if (l && l.size > 0) {
		const e = [...l].map(exactPattern);
		if (e.length === 1) a.pattern = e[0].source;
		else if (e.length > 1) a.allOf = [...e.map((e) => ({
			...n.target === "draft-07" || n.target === "draft-04" || n.target === "openapi-3.0" ? { type: "string" } : {},
			pattern: e.source
		}))];
	}
};
const numberProcessor = (e, n, r, i) => {
	const a = r;
	const { minimum: o, maximum: s, multipleOf: c, exclusiveMaximum: l, exclusiveMinimum: u, isInt: d } = aggregateChecks(e);
	a.type = d ? "integer" : "number";
	const f = typeof u === "number" && u >= (o ?? Number.NEGATIVE_INFINITY);
	const p = typeof l === "number" && l <= (s ?? Number.POSITIVE_INFINITY);
	const m = n.target === "draft-04" || n.target === "openapi-3.0";
	if (f) {
		if (m) {
			a.minimum = u;
			a.exclusiveMinimum = true;
		} else a.exclusiveMinimum = u;
	} else if (typeof o === "number") a.minimum = o;
	if (p) {
		if (m) {
			a.maximum = l;
			a.exclusiveMaximum = true;
		} else a.exclusiveMaximum = l;
	} else if (typeof s === "number") a.maximum = s;
	if (c) {
		const r = /* @__PURE__ */ new Set();
		for (const o of c) if (Number.isFinite(o) && o !== 0) r.add(Math.abs(o));
		else handleUnrepresentable(e, n, a, i, `A multipleOf divisor of ${o} cannot be represented in JSON Schema`);
		const [o, ...s] = r;
		if (o !== void 0) a.multipleOf = o;
		if (s.length) a.allOf = [...a.allOf ?? [], ...s.map((e) => ({ multipleOf: e }))];
	}
};
const booleanProcessor = (e, n, r, i) => {
	r.type = "boolean";
};
const neverProcessor = (e, n, r, i) => {
	r.not = {};
};
const unknownProcessor = (e, n, r, i) => {};
const enumProcessor = (e, n, r, i) => {
	const a = e._zod.def;
	const o = getEnumValues(a.entries);
	if (o.length === 0) {
		r.not = {};
		return;
	}
	if (o.every((e) => typeof e === "number")) r.type = "number";
	if (o.every((e) => typeof e === "string")) r.type = "string";
	r.enum = o;
};
const literalProcessor = (e, n, r, i) => {
	const a = e._zod.def;
	if (a.values.length === 0) {
		r.not = {};
		return;
	}
	const o = [];
	for (const s of a.values) if (s === void 0) {
		if (handleUnrepresentable(e, n, r, i, "Literal `undefined` cannot be represented in JSON Schema")) return;
	} else if (typeof s === "bigint") {
		if (handleUnrepresentable(e, n, r, i, "BigInt literals cannot be represented in JSON Schema")) return;
		o.push(Number(s));
	} else o.push(s);
	if (o.length === 0) {} else if (o.length === 1) {
		const e = o[0];
		r.type = e === null ? "null" : typeof e;
		if (n.target === "draft-04" || n.target === "openapi-3.0") r.enum = [e];
		else r.const = e;
	} else {
		if (o.every((e) => typeof e === "number")) r.type = "number";
		if (o.every((e) => typeof e === "string")) r.type = "string";
		if (o.every((e) => typeof e === "boolean")) r.type = "boolean";
		if (o.every((e) => e === null)) r.type = "null";
		r.enum = o;
	}
};
const customProcessor = (e, n, r, i) => {
	handleUnrepresentable(e, n, r, i, "Custom types cannot be represented in JSON Schema");
};
const transformProcessor = (e, n, r, i) => {
	handleUnrepresentable(e, n, r, i, "Transforms cannot be represented in JSON Schema");
};
const arrayProcessor = (e, n, r, i) => {
	const a = r;
	const o = e._zod.def;
	const { minimum: s, maximum: c } = aggregateChecks(e);
	if (typeof s === "number") a.minItems = s;
	if (typeof c === "number") a.maxItems = c;
	a.type = "array";
	a.items = processSchema(o.element, n, {
		...i,
		path: [...i.path, "items"]
	});
};
function inputOptin(e) {
	const n = e._zod.def;
	if (n.type === "pipe" && n.in._zod.traits.has("$ZodTransform")) return inputOptin(n.out);
	if (n.type === "catch") return inputOptin(n.innerType);
	return e._zod.optin;
}
const objectProcessor = (e, n, r, i) => {
	const a = r;
	const o = e._zod.def;
	const s = o.shape;
	if (Object.getOwnPropertySymbols(s).length && handleUnrepresentable(e, n, a, i, "Symbol keys cannot be represented in JSON Schema")) return;
	a.type = "object";
	a.properties = {};
	for (const e in s) assignProp(a.properties, e, processSchema(s[e], n, {
		...i,
		path: [
			...i.path,
			"properties",
			e
		]
	}));
	const c = [];
	for (const e of Object.keys(s)) {
		const r = o.shape[e];
		if (n.io === "input" ? inputOptin(r) === void 0 : r._zod.optout === void 0) c.push(e);
	}
	if (c.length > 0) a.required = c;
	if (o.catchall?._zod.def.type === "never") a.additionalProperties = false;
	else if (!o.catchall) {
		if (n.io === "output") a.additionalProperties = false;
	} else if (o.catchall) a.additionalProperties = processSchema(o.catchall, n, {
		...i,
		path: [...i.path, "additionalProperties"]
	});
};
const unionProcessor = (e, n, r, i) => {
	const a = e._zod.def;
	const o = a.inclusive === false;
	const s = a.options.map((e, r) => processSchema(e, n, {
		...i,
		path: [
			...i.path,
			o ? "oneOf" : "anyOf",
			r
		]
	}));
	if (o) r.oneOf = s;
	else r.anyOf = s;
};
const intersectionProcessor = (e, n, r, i) => {
	const a = e._zod.def;
	const o = processSchema(a.left, n, {
		...i,
		path: [
			...i.path,
			"allOf",
			0
		]
	});
	const s = processSchema(a.right, n, {
		...i,
		path: [
			...i.path,
			"allOf",
			1
		]
	});
	const isSimpleIntersection = (e) => "allOf" in e && Object.keys(e).length === 1;
	const c = [...isSimpleIntersection(o) ? o.allOf : [o], ...isSimpleIntersection(s) ? s.allOf : [s]];
	r.allOf = c;
	n.intersections.push(c);
};
/** JSON object keys are always strings, so a numeric record key schema is re-expressed over the
* numeric-string form the record parser matches. Deferred to `finalize`, after the flatten: a key
* behind a wrapper only carries its own `type` before then, and a union key only has its branches.
*
* A numeric bound cannot apply to a property name, so `minimum` and its siblings are dropped rather
* than carried over: keeping them beside `type: "string"` reproduces the match-nothing schema this
* exists to fix. A key that carries one therefore emits wider than the record parses — `z.record(z.number().min(5), V)`
* accepts `"3"` — which is the deliberate trade, since throwing on it would reject an ordinary schema
* outright. */
function stringifyKeyNames(e, n, r) {
	if (n.$ref) {
		if (r.has(n)) return n;
		r.add(n);
		const i = e.get(n)?.def;
		if (!i) return n;
		const a = stringifyKeyNames(e, i, r);
		return a === i ? n : a;
	}
	for (const i of ["anyOf", "oneOf"]) {
		const a = n[i];
		if (!Array.isArray(a)) continue;
		const o = a.map((n) => stringifyKeyNames(e, n, r));
		if (o.some((e, n) => e !== a[n])) n = {
			...n,
			[i]: o
		};
	}
	const i = Array.isArray(n.type) ? n.type : [n.type];
	const a = !i.includes("string") && i.some((e) => e === "number" || e === "integer");
	const o = n.enum ?? (n.const !== void 0 ? [n.const] : void 0);
	if (!a && !o?.some((e) => typeof e === "number")) return n;
	const { minimum: s, maximum: c, exclusiveMinimum: l, exclusiveMaximum: u, multipleOf: d, format: f, id: p, ...m } = n;
	if (m.enum) m.enum = m.enum.map((e) => typeof e === "number" ? String(e) : e);
	else if (typeof m.const === "number") m.const = String(m.const);
	if (!a) return m;
	m.type = "string";
	if (!o) m.pattern = (i.includes("number") ? number$1 : integer).source;
	return m;
}
/** Every record of one conversion, so the carriers are found in a single pass rather than once per record. */
const pendingRecords = /* @__PURE__ */ new WeakMap();
function rewriteKeyNames(e) {
	const n = /* @__PURE__ */ new Map();
	for (const r of e.seen.values()) if (r.def && !n.has(r.schema)) n.set(r.schema, r);
	const r = /* @__PURE__ */ new Map();
	for (const i of pendingRecords.get(e) ?? []) {
		const a = e.seen.get(i);
		const o = (a?.def ?? a?.schema)?.propertyNames;
		if (!o || o === true || r.has(o)) continue;
		const s = stringifyKeyNames(n, o, /* @__PURE__ */ new Set());
		if (s !== o) r.set(o, s);
	}
	if (!r.size) return;
	for (const n of e.seen.values()) for (const e of [n.schema, n.def]) {
		const n = e && r.get(e.propertyNames);
		if (n) e.propertyNames = n;
	}
}
const recordProcessor = (e, n, r, i) => {
	const a = r;
	const o = e._zod.def;
	a.type = "object";
	const s = o.keyType;
	const c = aggregateChecks(s).patterns;
	if (o.mode === "loose" && c && c.size > 0) {
		const e = processSchema(o.valueType, n, {
			...i,
			path: [
				...i.path,
				"patternProperties",
				"*"
			]
		});
		a.patternProperties = {};
		for (const n of c) assignProp(a.patternProperties, exactPattern(n).source, e);
	} else {
		if (n.target === "draft-07" || n.target === "draft-2020-12") {
			a.propertyNames = processSchema(o.keyType, n, {
				...i,
				path: [...i.path, "propertyNames"]
			});
			let r = pendingRecords.get(n);
			if (!r) {
				r = [];
				pendingRecords.set(n, r);
				n.deferred.push(() => rewriteKeyNames(n));
			}
			r.push(e);
		}
		a.additionalProperties = processSchema(o.valueType, n, {
			...i,
			path: [...i.path, "additionalProperties"]
		});
	}
	const l = s._zod.values;
	const u = n.io === "input" && inputOptin(o.valueType) !== void 0;
	if (l && !o.partial && !u) {
		const e = [...l].filter((e) => typeof e === "string" || typeof e === "number");
		if (e.length > 0) a.required = e.map(String);
	}
};
const nullableProcessor = (e, n, r, i) => {
	const a = e._zod.def;
	const o = processSchema(a.innerType, n, i);
	const s = n.seen.get(e);
	if (n.target === "openapi-3.0") {
		s.ref = a.innerType;
		r.nullable = true;
	} else r.anyOf = [o, { type: "null" }];
};
const nonoptionalProcessor = (e, n, r, i) => {
	const a = e._zod.def;
	processSchema(a.innerType, n, i);
	const o = n.seen.get(e);
	o.ref = a.innerType;
};
/** Round-trips a default value through JSON so the emitted schema is guaranteed to be valid JSON.
* A BigInt has no reliable encoding, so it goes through `unrepresentable` like any other
* unrepresentable value. Returns a sentinel when the caller must not write a default of its own. */
const UNREPRESENTABLE_DEFAULT = Symbol();
function serializeDefaultValue(e, n, r, i, a) {
	let o = false;
	const s = JSON.stringify(e, (e, n) => {
		if (typeof n !== "bigint") return n;
		o = true;
		return null;
	});
	if (!o) return JSON.parse(s);
	handleUnrepresentable(n, r, i, a, "BigInt defaults cannot be represented in JSON Schema");
	return UNREPRESENTABLE_DEFAULT;
}
const defaultProcessor = (e, n, r, i) => {
	const a = e._zod.def;
	processSchema(a.innerType, n, i);
	const o = n.seen.get(e);
	o.ref = a.innerType;
	const s = serializeDefaultValue(a.defaultValue, e, n, r, i);
	if (s !== UNREPRESENTABLE_DEFAULT) r.default = s;
};
const prefaultProcessor = (e, n, r, i) => {
	const a = e._zod.def;
	processSchema(a.innerType, n, i);
	const o = n.seen.get(e);
	o.ref = a.innerType;
	if (n.io !== "input") return;
	const s = serializeDefaultValue(a.defaultValue, e, n, r, i);
	if (s !== UNREPRESENTABLE_DEFAULT) r._prefault = s;
};
const catchProcessor = (e, n, r, i) => {
	const a = e._zod.def;
	processSchema(a.innerType, n, i);
	const o = n.seen.get(e);
	o.ref = a.innerType;
	let s;
	try {
		s = a.catchValue(void 0);
	} catch {
		handleUnrepresentable(e, n, r, i, "Dynamic catch values are not supported in JSON Schema");
		return;
	}
	r.default = s;
};
const pipeProcessor = (e, n, r, i) => {
	const a = e._zod.def;
	const o = a.in._zod.traits.has("$ZodTransform");
	const s = n.io === "input" ? o ? a.out : a.in : a.out;
	processSchema(s, n, i);
	const c = n.seen.get(e);
	c.ref = s;
};
const readonlyProcessor = (e, n, r, i) => {
	const a = e._zod.def;
	processSchema(a.innerType, n, i);
	const o = n.seen.get(e);
	o.ref = a.innerType;
	r.readOnly = true;
};
const optionalProcessor = (e, n, r, i) => {
	const a = e._zod.def;
	processSchema(a.innerType, n, i);
	const o = n.seen.get(e);
	o.ref = a.innerType;
};
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/errors.js
const _installedErrorProtos = /* @__PURE__ */ new WeakSet([Object.prototype, Error.prototype]);
function _lazyMethod(e, n, r) {
	Object.defineProperty(e, n, {
		configurable: true,
		enumerable: false,
		get() {
			const e = r(this);
			Object.defineProperty(this, n, {
				value: e,
				configurable: true,
				writable: true
			});
			return e;
		},
		set(e) {
			Object.defineProperty(this, n, {
				value: e,
				configurable: true,
				writable: true
			});
		}
	});
}
const initializer = (e, n) => {
	$ZodError.init(e, n);
	e.name = "ZodError";
	const r = Object.getPrototypeOf(e);
	if (_installedErrorProtos.has(r)) return;
	_installedErrorProtos.add(r);
	_lazyMethod(r, "format", (e) => (n) => formatError(e, n));
	_lazyMethod(r, "flatten", (e) => (n) => flattenError(e, n));
	_lazyMethod(r, "addIssue", (e) => (n) => {
		e.issues.push(n);
		e.message = JSON.stringify(e.issues, jsonStringifyReplacer, 2);
	});
	_lazyMethod(r, "addIssues", (e) => (n) => {
		e.issues.push(...n);
		e.message = JSON.stringify(e.issues, jsonStringifyReplacer, 2);
	});
	Object.defineProperty(r, "isEmpty", {
		configurable: true,
		enumerable: false,
		get() {
			return this.issues.length === 0;
		}
	});
};
const ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, void 0, { Parent: Error });
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/parse.js
const parse = /* @__PURE__ */ _parse(ZodRealError);
const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
const encode = /* @__PURE__ */ _encode(ZodRealError);
const decode = /* @__PURE__ */ _decode(ZodRealError);
const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/schemas.js
function _ensureDefaultLocale() {
	if (!globalConfig.localeError) config(en_default());
}
function _ensureDefaultMemoizer() {
	if (!globalConfig.memoizer) config({ memoizer: memoizer() });
}
const ZodType = /*@__PURE__*/ $constructor("ZodType", (e, n) => {
	_ensureDefaultLocale();
	$ZodType.init(e, n);
	e.def = n;
	e.type = n.type;
	return e;
}, {
	check(...e) {
		const n = this.def;
		return this.clone(mergeDefs(n, { checks: [...n.checks ?? [], ...e.map((e) => typeof e === "function" ? { _zod: {
			check: e,
			def: { check: "custom" },
			onattach: []
		} } : e)] }), { parent: true });
	},
	with(...e) {
		return this.check(...e);
	},
	clone(e, n) {
		return clone(this, e, n);
	},
	brand() {
		return this;
	},
	register(e, n) {
		e.add(this, n);
		return this;
	},
	refine(e, n) {
		return this.check(refine(e, n));
	},
	superRefine(e, n) {
		return this.check(superRefine(e, n));
	},
	overwrite(e) {
		return this.check(_overwrite(e));
	},
	optional() {
		return optional(this);
	},
	exactOptional() {
		return exactOptional(this);
	},
	nullable() {
		return nullable(this);
	},
	nullish() {
		return optional(nullable(this));
	},
	nonoptional(e) {
		return nonoptional(this, e);
	},
	array() {
		return array(this);
	},
	or(e) {
		return union([this, e]);
	},
	and(e) {
		return intersection(this, e);
	},
	transform(e) {
		return pipe(this, transform(e));
	},
	default(e) {
		return _default(this, e);
	},
	prefault(e) {
		return prefault(this, e);
	},
	catch(e) {
		return _catch(this, e);
	},
	pipe(e) {
		return pipe(this, e);
	},
	readonly() {
		return readonly(this);
	},
	describe(e) {
		const n = this.clone();
		globalRegistry.add(n, { description: e });
		return n;
	},
	meta(...e) {
		if (e.length === 0) return globalRegistry.get(this);
		const n = this.clone();
		globalRegistry.add(n, e[0]);
		return n;
	},
	isOptional() {
		return this.safeParse(void 0).success;
	},
	isNullable() {
		return this.safeParse(null).success;
	},
	apply(e, ...n) {
		return n.length === 0 ? e(this) : e(this, ...n);
	},
	get "~standard"() {
		return hide(this, "~standard", {
			...standardProps(this),
			jsonSchema: {
				input: createStandardJSONSchemaMethod(this, "input"),
				output: createStandardJSONSchemaMethod(this, "output")
			}
		});
	},
	set "~standard"(e) {
		own(this, "~standard", e);
	},
	parse: function _parse(e, n) {
		return parse(this, e, n, { callee: _parse });
	},
	parseAsync: async function _parseAsync(e, n) {
		return await parseAsync(this, e, n, { callee: _parseAsync });
	},
	safeParse(e, n) {
		return safeParse(this, e, n);
	},
	async safeParseAsync(e, n) {
		return safeParseAsync(this, e, n);
	},
	get spa() {
		return this?.safeParseAsync;
	},
	set spa(e) {
		own(this, "spa", e);
	},
	validate(e, n) {
		return validate(this, e, n);
	},
	validateAsync(e, n) {
		return validateAsync$1(this, e, n);
	},
	encode: function _encode(e, n) {
		return encode(this, e, n, { callee: _encode });
	},
	decode: function _decode(e, n) {
		return decode(this, e, n, { callee: _decode });
	},
	encodeAsync: async function _encodeAsync(e, n) {
		return await encodeAsync(this, e, n, { callee: _encodeAsync });
	},
	decodeAsync: async function _decodeAsync(e, n) {
		return await decodeAsync(this, e, n, { callee: _decodeAsync });
	},
	safeEncode(e, n) {
		return safeEncode(this, e, n);
	},
	safeDecode(e, n) {
		return safeDecode(this, e, n);
	},
	async safeEncodeAsync(e, n) {
		return safeEncodeAsync(this, e, n);
	},
	async safeDecodeAsync(e, n) {
		return safeDecodeAsync(this, e, n);
	},
	toJSONSchema(e) {
		return createToJSONSchemaMethod(this, {})(e);
	},
	get description() {
		return globalRegistry.get(this)?.description;
	},
	get _def() {
		return this._zod.def;
	}
});
/** @internal */
const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (e, n) => {
	$ZodString.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => stringProcessor(e, n, r, i);
}, /*@__PURE__*/ derived({
	format: (e) => aggregateChecks(e).format ?? null,
	minLength: (e) => aggregateChecks(e).minimum ?? null,
	maxLength: (e) => aggregateChecks(e).maximum ?? null
}, {
	regex(...e) {
		return this.check(_regex(...e));
	},
	includes(...e) {
		return this.check(_includes(...e));
	},
	startsWith(...e) {
		return this.check(_startsWith(...e));
	},
	endsWith(...e) {
		return this.check(_endsWith(...e));
	},
	min(...e) {
		return this.check(_minLength(...e));
	},
	max(...e) {
		return this.check(_maxLength(...e));
	},
	length(...e) {
		return this.check(_length(...e));
	},
	nonempty(...e) {
		return this.check(_minLength(1, ...e));
	},
	lowercase(e) {
		return this.check(_lowercase(e));
	},
	uppercase(e) {
		return this.check(_uppercase(e));
	},
	trim() {
		return this.check(_trim());
	},
	normalize(...e) {
		return this.check(_normalize(...e));
	},
	toLowerCase() {
		return this.check(_toLowerCase());
	},
	toUpperCase() {
		return this.check(_toUpperCase());
	},
	slugify() {
		return this.check(_slugify());
	}
}));
const ZodString = /*@__PURE__*/ $constructor("ZodString", (e, n) => {
	$ZodString.init(e, n);
	_ZodString.init(e, n);
}, {
	email(e) {
		return this.check(_email(ZodEmail, e));
	},
	url(e) {
		return this.check(_url(ZodURL, e));
	},
	jwt(e) {
		return this.check(_jwt(ZodJWT, e));
	},
	emoji(e) {
		return this.check(_emoji(ZodEmoji, e));
	},
	guid(e) {
		return this.check(_guid(ZodGUID, e));
	},
	uuid(e) {
		return this.check(_uuid(ZodUUID, e));
	},
	uuidv4(e) {
		return this.check(_uuidv4(ZodUUID, e));
	},
	uuidv6(e) {
		return this.check(_uuidv6(ZodUUID, e));
	},
	uuidv7(e) {
		return this.check(_uuidv7(ZodUUID, e));
	},
	nanoid(e) {
		return this.check(_nanoid(ZodNanoID, e));
	},
	cuid(e) {
		return this.check(_cuid(ZodCUID, e));
	},
	cuid2(e) {
		return this.check(_cuid2(ZodCUID2, e));
	},
	ulid(e) {
		return this.check(_ulid(ZodULID, e));
	},
	base64(e) {
		return this.check(_base64(ZodBase64, e));
	},
	base64url(e) {
		return this.check(_base64url(ZodBase64URL, e));
	},
	xid(e) {
		return this.check(_xid(ZodXID, e));
	},
	ksuid(e) {
		return this.check(_ksuid(ZodKSUID, e));
	},
	ipv4(e) {
		return this.check(_ipv4(ZodIPv4, e));
	},
	ipv6(e) {
		return this.check(_ipv6(ZodIPv6, e));
	},
	cidrv4(e) {
		return this.check(_cidrv4(ZodCIDRv4, e));
	},
	cidrv6(e) {
		return this.check(_cidrv6(ZodCIDRv6, e));
	},
	e164(e) {
		return this.check(_e164(ZodE164, e));
	},
	datetime(e) {
		return this.check(_isoDateTime(ZodISODateTime, e));
	},
	date(e) {
		return this.check(_isoDate(ZodISODate, e));
	},
	time(e) {
		return this.check(_isoTime(ZodISOTime, e));
	},
	duration(e) {
		return this.check(_isoDuration(ZodISODuration, e));
	}
});
function string(e) {
	return _string(ZodString, e);
}
const ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (e, n) => {
	$ZodStringFormat.init(e, n);
	_ZodString.init(e, n);
});
const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (e, n) => {
	$ZodISODateTime.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (e, n) => {
	$ZodISODate.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (e, n) => {
	$ZodISOTime.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (e, n) => {
	$ZodISODuration.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (e, n) => {
	$ZodEmail.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (e, n) => {
	$ZodGUID.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (e, n) => {
	$ZodUUID.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodURL = /*@__PURE__*/ $constructor("ZodURL", (e, n) => {
	$ZodURL.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (e, n) => {
	$ZodEmoji.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (e, n) => {
	$ZodNanoID.init(e, n);
	ZodStringFormat.init(e, n);
});
/**
* @deprecated CUID v1 is deprecated by its authors due to information leakage
* (timestamps embedded in the id). Use {@link ZodCUID2} instead.
* See https://github.com/paralleldrive/cuid.
*/
const ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (e, n) => {
	$ZodCUID.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodCUID2 = /*@__PURE__*/ $constructor("ZodCUID2", (e, n) => {
	$ZodCUID2.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodULID = /*@__PURE__*/ $constructor("ZodULID", (e, n) => {
	$ZodULID.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodXID = /*@__PURE__*/ $constructor("ZodXID", (e, n) => {
	$ZodXID.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodKSUID = /*@__PURE__*/ $constructor("ZodKSUID", (e, n) => {
	$ZodKSUID.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodIPv4 = /*@__PURE__*/ $constructor("ZodIPv4", (e, n) => {
	$ZodIPv4.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodIPv6 = /*@__PURE__*/ $constructor("ZodIPv6", (e, n) => {
	$ZodIPv6.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodCIDRv4 = /*@__PURE__*/ $constructor("ZodCIDRv4", (e, n) => {
	$ZodCIDRv4.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodCIDRv6 = /*@__PURE__*/ $constructor("ZodCIDRv6", (e, n) => {
	$ZodCIDRv6.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodBase64 = /*@__PURE__*/ $constructor("ZodBase64", (e, n) => {
	$ZodBase64.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodBase64URL = /*@__PURE__*/ $constructor("ZodBase64URL", (e, n) => {
	$ZodBase64URL.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (e, n) => {
	$ZodE164.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (e, n) => {
	$ZodJWT.init(e, n);
	ZodStringFormat.init(e, n);
});
const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (e, n) => {
	$ZodNumber.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => numberProcessor(e, n, r, i);
	e.isFinite = true;
}, /*@__PURE__*/ derived({
	minValue: (e) => {
		const { minimum: n, exclusiveMinimum: r } = aggregateChecks(e);
		return Math.max(n ?? Number.NEGATIVE_INFINITY, r ?? Number.NEGATIVE_INFINITY);
	},
	maxValue: (e) => {
		const { maximum: n, exclusiveMaximum: r } = aggregateChecks(e);
		return Math.min(n ?? Number.POSITIVE_INFINITY, r ?? Number.POSITIVE_INFINITY);
	},
	isInt: (e) => {
		const { isInt: n, multipleOf: r } = aggregateChecks(e);
		return !!n || !!r?.some(Number.isSafeInteger);
	},
	format: (e) => aggregateChecks(e).format ?? null
}, {
	gt(e, n) {
		return this.check(_gt(e, n));
	},
	gte(e, n) {
		return this.check(_gte(e, n));
	},
	min(e, n) {
		return this.check(_gte(e, n));
	},
	lt(e, n) {
		return this.check(_lt(e, n));
	},
	lte(e, n) {
		return this.check(_lte(e, n));
	},
	max(e, n) {
		return this.check(_lte(e, n));
	},
	int(e) {
		return this.check(int(e));
	},
	safe(e) {
		return this.check(int(e));
	},
	positive(e) {
		return this.check(_gt(0, e));
	},
	nonnegative(e) {
		return this.check(_gte(0, e));
	},
	negative(e) {
		return this.check(_lt(0, e));
	},
	nonpositive(e) {
		return this.check(_lte(0, e));
	},
	multipleOf(e, n) {
		return this.check(_multipleOf(e, n));
	},
	step(e, n) {
		return this.check(_multipleOf(e, n));
	},
	finite() {
		return this;
	}
}));
function number(e) {
	return _number(ZodNumber, e);
}
const ZodNumberFormat = /*@__PURE__*/ $constructor("ZodNumberFormat", (e, n) => {
	$ZodNumberFormat.init(e, n);
	ZodNumber.init(e, n);
});
function int(e) {
	return _int(ZodNumberFormat, e);
}
const ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (e, n) => {
	$ZodBoolean.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => booleanProcessor(e, n, r, i);
});
function boolean(e) {
	return _boolean(ZodBoolean, e);
}
const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (e, n) => {
	$ZodUnknown.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => unknownProcessor(e, n, r, i);
});
function unknown() {
	return _unknown(ZodUnknown);
}
const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (e, n) => {
	$ZodNever.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => neverProcessor(e, n, r, i);
});
function never(e) {
	return _never(ZodNever, e);
}
const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (e, n) => {
	_ensureDefaultMemoizer();
	$ZodArray.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => arrayProcessor(e, n, r, i);
	e.element = n.element;
}, {
	min(e, n) {
		return this.check(_minLength(e, n));
	},
	nonempty(e) {
		return this.check(_minLength(1, e));
	},
	max(e, n) {
		return this.check(_maxLength(e, n));
	},
	length(e, n) {
		return this.check(_length(e, n));
	},
	unwrap() {
		return this.element;
	}
});
function array(e, n) {
	return _array(ZodArray, e, n);
}
const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (e, n) => {
	_ensureDefaultMemoizer();
	$ZodObjectJIT.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => objectProcessor(e, n, r, i);
	installLazyProp(e, "shape", (e) => e._zod.def.shape, false);
}, {
	keyof() {
		return _enum(Object.keys(this._zod.def.shape));
	},
	catchall(e) {
		return this.clone(mergeDefs(this._zod.def, { catchall: e }));
	},
	passthrough() {
		return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
	},
	loose() {
		return this.clone(mergeDefs(this._zod.def, { catchall: unknown() }));
	},
	strict() {
		return this.clone(mergeDefs(this._zod.def, { catchall: never() }));
	},
	strip() {
		return this.clone(mergeDefs(this._zod.def, { catchall: void 0 }));
	},
	extend(e) {
		return extend(this, e);
	},
	safeExtend(e) {
		return safeExtend(this, e);
	},
	merge(e) {
		return merge(this, e);
	},
	pick(e) {
		return pick(this, e);
	},
	omit(e) {
		return omit(this, e);
	},
	partial(...e) {
		return partial(ZodOptional, this, e[0]);
	},
	exactPartial(...e) {
		return partial(ZodExactOptional, this, e[0], "exactPartial");
	},
	required(...e) {
		return required(ZodNonOptional, this, e[0]);
	}
});
function object(e, n) {
	const r = {
		type: "object",
		shape: e ?? {},
		...normalizeParams(n)
	};
	return new ZodObject(r);
}
const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (e, n) => {
	$ZodUnion.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => unionProcessor(e, n, r, i);
	e.options = n.options;
});
function union(e, n) {
	return new ZodUnion({
		type: "union",
		options: e,
		...normalizeParams(n)
	});
}
const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (e, n) => {
	$ZodIntersection.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => intersectionProcessor(e, n, r, i);
});
function intersection(e, n) {
	return new ZodIntersection({
		type: "intersection",
		left: e,
		right: n
	});
}
const ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (e, n) => {
	_ensureDefaultMemoizer();
	$ZodRecord.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => recordProcessor(e, n, r, i);
	e.keyType = n.keyType;
	e.valueType = n.valueType;
});
function record(e, n, r) {
	if (!n || !n._zod) return new ZodRecord({
		type: "record",
		keyType: string(),
		valueType: e,
		...normalizeParams(n)
	});
	return new ZodRecord({
		type: "record",
		keyType: e,
		valueType: n,
		...normalizeParams(r)
	});
}
const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (e, n) => {
	$ZodEnum.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => enumProcessor(e, n, r, i);
	e.enum = n.entries;
	e.options = [...e._zod.values];
	const r = new Set(Object.keys(n.entries));
	e.extract = (e, i) => {
		const a = {};
		for (const i of e) if (r.has(i)) a[i] = n.entries[i];
		else throw new Error(`Key ${i} not found in enum`);
		return new ZodEnum({
			...n,
			checks: [],
			...normalizeParams(i),
			entries: a
		});
	};
	e.exclude = (e, i) => {
		const a = { ...n.entries };
		for (const n of e) if (r.has(n)) delete a[n];
		else throw new Error(`Key ${n} not found in enum`);
		return new ZodEnum({
			...n,
			checks: [],
			...normalizeParams(i),
			entries: a
		});
	};
});
function _enum(e, n) {
	const r = Array.isArray(e) ? Object.fromEntries(e.map((e) => [e, e])) : e;
	return new ZodEnum({
		type: "enum",
		entries: r,
		...normalizeParams(n)
	});
}
const ZodLiteral = /*@__PURE__*/ $constructor("ZodLiteral", (e, n) => {
	$ZodLiteral.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => literalProcessor(e, n, r, i);
	e.values = new Set(n.values);
	Object.defineProperty(e, "value", { get() {
		if (n.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
		return n.values[0];
	} });
});
function literal(e, n) {
	return new ZodLiteral({
		type: "literal",
		values: Array.isArray(e) ? e : [e],
		...normalizeParams(n)
	});
}
const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (e, n) => {
	_ensureDefaultMemoizer();
	$ZodTransform.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => transformProcessor(e, n, r, i);
	e._zod.parse = (r, i) => {
		if (i.direction === "backward") throw new $ZodEncodeError(e.constructor.name);
		r.addIssue = (i) => {
			if (typeof i === "string") r.issues.push(issue(i, r.value, n));
			else {
				const n = i;
				if (n.fatal) n.continue = false;
				n.code ?? (n.code = "custom");
				if (!("input" in n)) n.input = r.value;
				n.inst ?? (n.inst = e);
				r.issues.push(issue(n));
			}
		};
		const a = n.transform(r.value, r);
		if (a instanceof Promise) return a.then((e) => {
			r.value = e;
			return r;
		});
		r.value = a;
		return r;
	};
});
function transform(e) {
	return new ZodTransform({
		type: "transform",
		transform: e
	});
}
const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (e, n) => {
	$ZodOptional.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => optionalProcessor(e, n, r, i);
	e.unwrap = () => e._zod.def.innerType;
});
function optional(e) {
	return new ZodOptional({
		type: "optional",
		innerType: e
	});
}
const ZodExactOptional = /*@__PURE__*/ $constructor("ZodExactOptional", (e, n) => {
	$ZodExactOptional.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => optionalProcessor(e, n, r, i);
	e.unwrap = () => e._zod.def.innerType;
});
function exactOptional(e) {
	return new ZodExactOptional({
		type: "optional",
		innerType: e
	});
}
const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (e, n) => {
	$ZodNullable.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => nullableProcessor(e, n, r, i);
	e.unwrap = () => e._zod.def.innerType;
});
function nullable(e) {
	return new ZodNullable({
		type: "nullable",
		innerType: e
	});
}
const ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (e, n) => {
	$ZodDefault.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => defaultProcessor(e, n, r, i);
	e.unwrap = () => e._zod.def.innerType;
	e.removeDefault = e.unwrap;
});
function _default(e, n) {
	return new ZodDefault({
		type: "default",
		innerType: e,
		get defaultValue() {
			return typeof n === "function" ? n() : shallowClone(n);
		}
	});
}
const ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (e, n) => {
	$ZodPrefault.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => prefaultProcessor(e, n, r, i);
	e.unwrap = () => e._zod.def.innerType;
});
function prefault(e, n) {
	return new ZodPrefault({
		type: "prefault",
		innerType: e,
		get defaultValue() {
			return typeof n === "function" ? n() : shallowClone(n);
		}
	});
}
const ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (e, n) => {
	$ZodNonOptional.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => nonoptionalProcessor(e, n, r, i);
	e.unwrap = () => e._zod.def.innerType;
});
function nonoptional(e, n) {
	return new ZodNonOptional({
		type: "nonoptional",
		innerType: e,
		...normalizeParams(n)
	});
}
const ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (e, n) => {
	$ZodCatch.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => catchProcessor(e, n, r, i);
	e.unwrap = () => e._zod.def.innerType;
	e.removeCatch = e.unwrap;
});
function _catch(e, n) {
	return new ZodCatch({
		type: "catch",
		innerType: e,
		catchValue: typeof n === "function" ? n : constantCatch(n)
	});
}
const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (e, n) => {
	$ZodPipe.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => pipeProcessor(e, n, r, i);
	e.in = n.in;
	e.out = n.out;
});
function pipe(e, n) {
	return new ZodPipe({
		type: "pipe",
		in: e,
		out: n
	});
}
const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (e, n) => {
	$ZodReadonly.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => readonlyProcessor(e, n, r, i);
	e.unwrap = () => e._zod.def.innerType;
});
function readonly(e) {
	return new ZodReadonly({
		type: "readonly",
		innerType: e
	});
}
const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (e, n) => {
	$ZodCustom.init(e, n);
	ZodType.init(e, n);
	e._zod.processJSONSchema = (n, r, i) => customProcessor(e, n, r, i);
});
function refine(e, n = {}) {
	return _refine(ZodCustom, e, n);
}
function superRefine(e, n) {
	return _superRefine(e, n);
}
//#endregion
//#region node_modules/.pnpm/zod@4.6.7/node_modules/zod/v4/classic/compat.js
/** @deprecated Use the raw string literal codes instead, e.g. "invalid_type". */
const ZodIssueCode = {
	invalid_type: "invalid_type",
	too_big: "too_big",
	too_small: "too_small",
	invalid_format: "invalid_format",
	not_multiple_of: "not_multiple_of",
	unrecognized_keys: "unrecognized_keys",
	invalid_union: "invalid_union",
	invalid_key: "invalid_key",
	invalid_element: "invalid_element",
	invalid_value: "invalid_value",
	custom: "custom"
};
/** @deprecated Do not use. Stub definition, only included for zod-to-json-schema compatibility. */
var ZodFirstPartyTypeKind;
ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
//#endregion
//#region extensions/telegram/src/command-config.ts
const TELEGRAM_COMMAND_NAME_PATTERN = /^[a-z0-9_]{1,32}$/;
function normalizeTelegramCommandName(e) {
	return e.trim().replace(/^\//, "").trim().toLowerCase().replace(/-/g, "_");
}
function normalizeTelegramCommandDescription(e) {
	return e.trim();
}
function resolveTelegramCustomCommands(e) {
	const n = Array.isArray(e.commands) ? e.commands : [];
	const r = e.checkReserved !== false;
	const i = e.checkDuplicates !== false;
	const a = /* @__PURE__ */ new Set();
	const o = [];
	const s = [];
	for (let c = 0; c < n.length; c += 1) {
		const l = n[c];
		const u = normalizeTelegramCommandName(l?.command ?? "");
		const d = !u ? "Telegram custom command is missing a command name." : !TELEGRAM_COMMAND_NAME_PATTERN.test(u) ? `Telegram custom command "/${u}" is invalid (use a-z, 0-9, underscore; max 32 chars).` : r && e.reservedCommands?.has(u) ? `Telegram custom command "/${u}" conflicts with a native command.` : i && a.has(u) ? `Telegram custom command "/${u}" is duplicated.` : void 0;
		if (d) {
			s.push({
				index: c,
				field: "command",
				message: d
			});
			continue;
		}
		const f = normalizeTelegramCommandDescription(l?.description ?? "");
		if (!f) {
			s.push({
				index: c,
				field: "description",
				message: `Telegram custom command "/${u}" is missing a description.`
			});
			continue;
		}
		if (i) a.add(u);
		o.push({
			command: u,
			description: f
		});
	}
	return {
		commands: o,
		issues: s
	};
}
//#endregion
//#region extensions/telegram/src/config-ui-hints.ts
const observedGroupHistoryHint = { help: "Automatic observed-message context uses a default of 50 and a maximum of 200 messages; 0 disables automatic injection. The JSON integer maximum selects the 50-message default. Session transcript trimming separately counts user turns, where 0 means no trimming. The observed-message cap does not rewrite saved values." };
const observedDmHistoryHint = { help: "Automatic observed-DM context uses a default of 10 and a maximum of 200 messages; 0 disables that extra context. The JSON integer maximum selects the 10-message default. Session transcript trimming separately counts user turns, where 0 means no trimming. The observed-message cap does not rewrite saved values." };
const botThreadMentionHint = {
	label: "Telegram Bot Topic Mention Requirement",
	help: "Override mention gating in forum topics created by this bot. False allows unmentioned messages; true requires a mention even for replies to the bot. Topic settings override group settings. Omit to preserve existing behavior. Unknown or evicted topic ownership keeps the normal policy. Telegram privacy mode must allow ordinary group messages; sender and visible-reply policies still apply."
};
const telegramChannelConfigUiHints = {
	historyLimit: observedGroupHistoryHint,
	"accounts.*.historyLimit": observedGroupHistoryHint,
	dmHistoryLimit: observedDmHistoryHint,
	"accounts.*.dmHistoryLimit": observedDmHistoryHint,
	"dms.*.historyLimit": observedDmHistoryHint,
	"accounts.*.dms.*.historyLimit": observedDmHistoryHint,
	"groups.*.requireMentionInBotThreads": botThreadMentionHint,
	"groups.*.topics.*.requireMentionInBotThreads": botThreadMentionHint,
	"accounts.*.groups.*.requireMentionInBotThreads": botThreadMentionHint,
	"accounts.*.groups.*.topics.*.requireMentionInBotThreads": botThreadMentionHint,
	"": {
		label: "Telegram",
		help: "Telegram channel provider configuration including auth tokens, retry behavior, and message rendering controls. Use this section to tune bot behavior for Telegram-specific API semantics."
	},
	customCommands: {
		label: "Telegram Custom Commands",
		help: "Additional Telegram bot menu commands (merged with native; conflicts ignored)."
	},
	botToken: {
		label: "Telegram Bot Token",
		help: "Telegram bot token used to authenticate Bot API requests for this account/provider config. Use secret/env substitution and rotate tokens if exposure is suspected."
	},
	joinIntro: {
		label: "Telegram Group Join Introduction",
		help: "Send one room-aware introduction when the bot joins an allowed group or supergroup (default: true). Telegram cannot provide message history from before the bot joined."
	},
	...createChannelConfigUiHints({
		channelLabel: "Telegram",
		dmPolicy: { channelKey: "telegram" },
		configWrites: true,
		mentionPatterns: {
			targetDescription: "Telegram group chat IDs or chatId:topic:threadId topic IDs",
			policyNote: "Native Telegram bot mentions still trigger even when regex patterns are denied.",
			denyNote: "Native bot mentions still trigger."
		},
		nativeCommands: true,
		streaming: {
			"": "Unified Telegram stream preview mode: \"off\" | \"partial\" | \"block\" | \"progress\" (default: \"progress\"). \"progress\" keeps a single editable progress draft until final delivery. Legacy boolean/streamMode keys are detected; run doctor --fix to migrate.",
			mode: "Telegram preview mode: \"off\" | \"partial\" | \"block\" | \"progress\" (default: \"progress\").",
			chunkMode: "Chunking mode for outbound Telegram text delivery: \"length\" (default) or \"newline\".",
			"block.enabled": "Enable normal Telegram block replies. This takes precedence over editable preview delivery.",
			"block.coalesce": "Merge streamed Telegram block replies before sending final delivery.",
			"preview.chunk.minChars": "Minimum chars before emitting a Telegram block preview chunk when channels.telegram.streaming.mode=\"block\".",
			"preview.chunk.maxChars": "Target max size for a Telegram block preview chunk when channels.telegram.streaming.mode=\"block\".",
			"preview.chunk.breakPreference": "Preferred breakpoints for Telegram draft chunks (paragraph | newline | sentence).",
			"preview.toolProgress": "Show tool/progress activity in the live draft preview message (default: true when preview streaming is active). Set false to keep tool updates out of the edited Telegram preview.",
			"preview.commandText": "Command/exec detail in preview tool-progress lines: \"status\" is the safe default; \"raw\" opts into command text."
		},
		progress: {
			includeCommentary: true,
			commentaryOrder: "after-command"
		}
	}),
	richMessages: {
		label: "Telegram Rich Messages",
		help: "Opt into Bot API 10.3 rich text sends and edits, including native tables and rich media. Default: false because some current Telegram clients render these messages as unsupported."
	},
	widgets: {
		label: "Telegram Message Widgets",
		help: "Opt into Bot API 10.4 message widgets: show_widget sends interactive widgets in private chats, and taps update them in place. Default: false because older Telegram clients cannot render widgets."
	},
	"network.autoSelectFamily": {
		label: "Telegram autoSelectFamily",
		help: "Override Node autoSelectFamily for Telegram (true=enable, false=disable)."
	},
	"network.dangerouslyAllowPrivateNetwork": {
		label: "Telegram Dangerously Allow Private Network",
		help: "Dangerous opt-in for trusted fake-IP or transparent-proxy environments where Telegram media downloads resolve api.telegram.org to private/internal/special-use addresses."
	},
	silentErrorReplies: {
		label: "Telegram Silent Error Replies",
		help: "When true, Telegram bot replies marked as errors are sent silently (no notification sound). Default: false."
	},
	apiRoot: {
		label: "Telegram API Root URL",
		help: "Custom Telegram Bot API root URL. Use the API root only (for example https://api.telegram.org), not a full /bot<TOKEN> endpoint. Use for self-hosted Bot API servers (https://github.com/tdlib/telegram-bot-api) or reverse proxies in regions where api.telegram.org is blocked."
	},
	trustedLocalFileRoots: {
		label: "Telegram Trusted Local File Roots",
		help: "Trusted local filesystem roots for self-hosted Telegram Bot API file_path values. Exact in-root paths are read directly; container paths under /var/lib/telegram-bot-api can map into a host volume mount. Other absolute paths are rejected."
	},
	autoTopicLabel: {
		label: "Telegram Auto Topic Label",
		help: "Auto-rename DM forum topics on first message using LLM. Default: true. Set to false to disable, or use object form { enabled: true, prompt: '...' } for custom prompt."
	},
	"autoTopicLabel.enabled": {
		label: "Telegram Auto Topic Label Enabled",
		help: "Whether auto topic labeling is enabled. Default: true."
	},
	"autoTopicLabel.prompt": {
		label: "Telegram Auto Topic Label Prompt",
		help: "Custom prompt for LLM-based topic naming. The user message is appended after the prompt."
	},
	"capabilities.inlineButtons": {
		label: "Telegram Inline Buttons",
		help: "Enable Telegram inline button components for supported command and interaction surfaces. Disable if your deployment needs plain-text-only compatibility behavior."
	},
	execApprovals: {
		label: "Telegram Exec Approvals",
		help: "Telegram-native exec approval routing and approver authorization. When unset, OpenClaw auto-enables DM-first native approvals if approvers can be resolved for the selected bot account."
	},
	"execApprovals.enabled": {
		label: "Telegram Exec Approvals Enabled",
		help: "Controls Telegram native exec approvals for this account: unset or \"auto\" enables DM-first native approvals when approvers can be resolved, true forces native approvals on, and false disables them."
	},
	"execApprovals.approvers": {
		label: "Telegram Exec Approval Approvers",
		help: "Telegram user IDs allowed to approve exec requests for this bot account. Use numeric Telegram user IDs. If you leave this unset, OpenClaw falls back to numeric owner IDs inferred from commands.ownerAllowFrom when possible."
	},
	"execApprovals.agentFilter": {
		label: "Telegram Exec Approval Agent Filter",
		help: "Optional allowlist of agent IDs eligible for Telegram exec approvals, for example `[\"main\", \"ops-agent\"]`. Use this to keep approval prompts scoped to the agents you actually operate from Telegram."
	},
	"execApprovals.sessionFilter": {
		label: "Telegram Exec Approval Session Filter",
		help: "Optional session-key filters matched as substring or regex-style patterns before Telegram approval routing is used. Use narrow patterns so Telegram approvals only appear for intended sessions."
	},
	"execApprovals.target": {
		label: "Telegram Exec Approval Target",
		help: "Controls where Telegram approval prompts are sent: \"dm\" sends to approver DMs (default), \"channel\" sends to the originating Telegram chat/topic, and \"both\" sends to both. Channel delivery exposes the command text to the chat, so only use it in trusted groups/topics."
	},
	"threadBindings.enabled": {
		label: "Telegram Thread Binding Enabled",
		help: "Enable Telegram conversation-bound session spawning, routing, and delivery. Manage bindings with /agents and /session unbind|idle|max-age. Overrides session.threadBindings.enabled when set."
	},
	"threadBindings.idleHours": {
		label: "Telegram Thread Binding Idle Timeout (hours)",
		help: "Inactivity window in hours for Telegram bound sessions. Set 0 to disable idle expiry (default: 24). Overrides session.threadBindings.idleHours when set."
	},
	"threadBindings.maxAgeHours": {
		label: "Telegram Thread Binding Max Age (hours)",
		help: "Optional hard max age in hours for Telegram bound sessions. Set 0 to disable hard cap (default: 0). Overrides session.threadBindings.maxAgeHours when set."
	},
	"threadBindings.spawnSessions": {
		label: "Telegram Thread-Bound Session Spawn",
		help: "Allow /acp spawn --thread to bind Telegram topics when supported. Agent sessions_spawn(thread=true) never binds a Telegram conversation; it needs a channel that opens a separate thread."
	},
	"threadBindings.defaultSpawnContext": {
		label: "Telegram Thread Spawn Context",
		help: "Default native subagent context for thread-bound spawns. \"fork\" starts from the requester transcript; \"isolated\" starts clean. Default: \"fork\". Telegram cannot host agent-spawned thread sessions, so this has no effect for Telegram requests."
	}
};
//#endregion
//#region extensions/telegram/src/config-schema.ts
const SecretInputSchema = buildSecretInputSchema();
const ToolPolicyBySenderSchema = record(string(), ToolPolicySchema).optional();
function validateTelegramWebhookSecretRequirements(e, n) {
	const r = normalizeOptionalString(e.webhookUrl) ?? "";
	const i = hasConfiguredSecretInput(e.webhookSecret);
	if (r && !i) n.addIssue({
		code: ZodIssueCode.custom,
		message: "channels.telegram.webhookUrl requires channels.telegram.webhookSecret",
		path: ["webhookSecret"]
	});
	for (const [r, a] of Object.entries(e.accounts ?? {})) {
		if (!a || a.enabled === false) continue;
		if (!(normalizeOptionalString(a.webhookUrl) ?? "")) continue;
		if (!hasConfiguredSecretInput(a.webhookSecret) && !i) n.addIssue({
			code: ZodIssueCode.custom,
			message: "channels.telegram.accounts.*.webhookUrl requires channels.telegram.webhookSecret or channels.telegram.accounts.*.webhookSecret",
			path: [
				"accounts",
				r,
				"webhookSecret"
			]
		});
	}
}
const TelegramInlineButtonsScopeSchema = _enum([
	"off",
	"dm",
	"group",
	"all",
	"allowlist"
]);
const TelegramCapabilitiesSchema = union([array(string()), object({ inlineButtons: TelegramInlineButtonsScopeSchema.optional() }).strict()]);
const TelegramErrorPolicySchema = _enum([
	"always",
	"once",
	"silent"
]).optional();
const TelegramTopicSchema = object({
	requireMention: boolean().optional(),
	requireMentionInBotThreads: boolean().optional(),
	ingest: boolean().optional(),
	disableAudioPreflight: boolean().optional(),
	groupPolicy: GroupPolicySchema.optional(),
	skills: array(string()).optional(),
	enabled: boolean().optional(),
	allowFrom: array(union([string(), number()])).optional(),
	systemPrompt: string().optional(),
	agentId: string().optional(),
	errorPolicy: TelegramErrorPolicySchema
}).strict();
const TelegramGroupSchema = buildGroupEntrySchema({
	requireMentionInBotThreads: boolean().optional(),
	ingest: boolean().optional(),
	disableAudioPreflight: boolean().optional(),
	groupPolicy: GroupPolicySchema.optional(),
	topics: record(string(), TelegramTopicSchema.optional()).optional(),
	errorPolicy: TelegramErrorPolicySchema
});
const AutoTopicLabelSchema = union([boolean(), object({
	enabled: boolean().optional(),
	prompt: string().optional()
}).strict()]).optional();
const TelegramDirectSchema = object({
	dmPolicy: DmPolicySchema.optional(),
	tools: ToolPolicySchema,
	toolsBySender: ToolPolicyBySenderSchema,
	skills: array(string()).optional(),
	enabled: boolean().optional(),
	allowFrom: array(union([string(), number()])).optional(),
	systemPrompt: string().optional(),
	topics: record(string(), TelegramTopicSchema.omit({ requireMentionInBotThreads: true }).optional()).optional(),
	errorPolicy: TelegramErrorPolicySchema,
	requireTopic: boolean().optional(),
	autoTopicLabel: AutoTopicLabelSchema
}).strict();
const TelegramCustomCommandSchema = object({
	command: string().overwrite(normalizeTelegramCommandName),
	description: string().overwrite(normalizeTelegramCommandDescription)
}).strict();
const validateTelegramCustomCommands = (e, n) => {
	if (!e.customCommands || e.customCommands.length === 0) return;
	const { issues: r } = resolveTelegramCustomCommands({
		commands: e.customCommands,
		checkReserved: false,
		checkDuplicates: false
	});
	for (const e of r) n.addIssue({
		code: ZodIssueCode.custom,
		path: [
			"customCommands",
			e.index,
			e.field
		],
		message: e.message
	});
};
const { accountShape, rootPolicyShape } = buildChannelAccountSchemaParts({
	capabilities: TelegramCapabilitiesSchema.optional(),
	defaultTo: union([string(), number()]).optional(),
	streaming: ChannelPreviewStreamingConfigSchema.optional()
});
const TelegramAccountSchemaBase = object({
	...accountShape,
	joinIntro: boolean().optional(),
	execApprovals: buildChannelExecApprovalsSchema(union([string(), number()])),
	commands: ProviderCommandsSchema,
	customCommands: array(TelegramCustomCommandSchema).optional(),
	botToken: registerSensitiveConfigSchema(SecretInputSchema.optional()),
	tokenFile: string().optional(),
	groups: record(string(), TelegramGroupSchema.optional()).optional(),
	direct: record(string(), TelegramDirectSchema.optional()).optional(),
	richMessages: boolean().optional(),
	widgets: boolean().optional(),
	network: object({
		autoSelectFamily: boolean().optional(),
		dnsResultOrder: _enum(["ipv4first", "verbatim"]).optional(),
		dangerouslyAllowPrivateNetwork: boolean().optional().describe("Dangerous opt-in for trusted Telegram fake-IP or transparent-proxy environments where api.telegram.org resolves to private/internal/special-use addresses during media downloads.")
	}).strict().optional(),
	proxy: string().optional(),
	webhookUrl: string().optional().describe("Public HTTPS webhook URL registered with Telegram for inbound updates. This must be internet-reachable and requires channels.telegram.webhookSecret."),
	webhookSecret: registerSensitiveConfigSchema(SecretInputSchema.optional().describe("Secret token sent to Telegram during webhook registration and verified on inbound webhook requests. Telegram returns this value for verification; this is not the gateway auth token and not the bot token.")),
	webhookPath: string().optional().describe("Local webhook route path served by the gateway listener. Defaults to /telegram-webhook."),
	legacyWebhook: union([literal(false), object({
		port: number().int().nonnegative().max(65535),
		host: string().optional()
	}).strict()]).optional().describe("Explicit webhook forwarding endpoint. Doctor pins existing proxy endpoints once; remove the pin after moving the proxy to the Gateway, or set false to disable inherited forwarding."),
	webhookCertPath: string().optional().describe("Path to the self-signed certificate (PEM) to upload to Telegram during webhook registration. Required for self-signed certs (direct IP or no domain)."),
	actions: object({
		reactions: boolean().optional(),
		sendMessage: boolean().optional(),
		poll: boolean().optional(),
		deleteMessage: boolean().optional(),
		editMessage: boolean().optional(),
		sticker: boolean().optional(),
		createForumTopic: boolean().optional(),
		editForumTopic: boolean().optional()
	}).strict().optional(),
	threadBindings: ChannelThreadBindingsSchema.optional(),
	...buildChannelReactionShape({
		notificationModes: [
			"off",
			"own",
			"all"
		],
		reactionLevels: [
			"off",
			"ack",
			"minimal",
			"extensive"
		],
		ackReaction: string().optional()
	}),
	linkPreview: boolean().optional(),
	silentErrorReplies: boolean().optional(),
	errorPolicy: TelegramErrorPolicySchema,
	apiRoot: string().url().optional(),
	trustedLocalFileRoots: array(string()).optional().describe("Trusted local filesystem roots for self-hosted Telegram Bot API absolute file_path values. Only absolute paths under these roots are read directly; all other absolute paths are rejected."),
	autoTopicLabel: AutoTopicLabelSchema
}).strict();
const TelegramAccountSchema = TelegramAccountSchemaBase.superRefine(validateTelegramCustomCommands);
const TelegramConfigSchema = TelegramAccountSchemaBase.extend({
	...rootPolicyShape,
	accounts: record(string(), TelegramAccountSchema.optional()).optional(),
	defaultAccount: string().optional()
}).superRefine((e, n) => {
	refineChannelDmPolicy({
		channelId: "telegram",
		value: e,
		ctx: n
	});
	validateTelegramCustomCommands(e, n);
	if (e.accounts) for (const [r, i] of Object.entries(e.accounts)) {
		if (!i) continue;
		refineChannelDmPolicy({
			channelId: "telegram",
			value: e,
			accountId: r,
			ctx: n
		});
	}
	validateTelegramWebhookSecretRequirements(e, n);
});
const TelegramChannelConfigSchema = buildChannelConfigSchema(TelegramConfigSchema, { uiHints: telegramChannelConfigUiHints });
//#endregion
//#region extensions/telegram/src/setup-plugin.ts
const TELEGRAM_CHANNEL = "telegram";
function createTelegramSetupPluginBase(e) {
	return {
		id: TELEGRAM_CHANNEL,
		setupContract: e.setupContract,
		meta: {
			...getChatChannelMeta(TELEGRAM_CHANNEL),
			quickstartAllowFrom: true
		},
		setupWizard: e.setupWizard,
		capabilities: {
			chatTypes: [
				"direct",
				"group",
				"channel",
				"thread"
			],
			reactions: true,
			reactionSlots: "single",
			threads: true,
			media: true,
			tts: { voice: {
				synthesisTarget: "voice-note",
				captionedFinalText: true
			} },
			polls: true,
			nativeCommands: true,
			blockStreaming: true
		},
		reload: {
			configPrefixes: ["channels.telegram"],
			noopPrefixes: [
				"messages.inbound",
				"messages.ackReactionScope",
				...[
					"dmPolicy",
					"allowFrom",
					"groupAllowFrom",
					"groupPolicy",
					"replyToMode",
					"streaming",
					"textChunkLimit"
				].flatMap((e) => [`channels.telegram.${e}`, `channels.telegram.accounts.*.${e}`])
			]
		},
		configSchema: TelegramChannelConfigSchema,
		config: {
			...telegramConfigAdapter,
			hasConfiguredState: ({ env: e }) => typeof e?.TELEGRAM_BOT_TOKEN === "string" && e.TELEGRAM_BOT_TOKEN.trim().length > 0,
			isConfigured: (e, n) => {
				const r = inspectTelegramAccount({
					cfg: n,
					accountId: e.accountId
				});
				return r.configured && Boolean(r.token.trim());
			},
			unconfiguredReason: (e, n) => {
				const r = inspectTelegramAccount({
					cfg: n,
					accountId: e.accountId
				});
				return r.stateReason ?? (r.tokenStatus === "configured_unavailable" ? `not configured: token ${r.tokenSource} is configured but unavailable` : "not configured");
			},
			describeAccount: (e, n) => {
				const r = inspectTelegramAccount({
					cfg: n,
					accountId: e.accountId
				});
				return {
					accountId: e.accountId,
					name: e.name,
					enabled: e.enabled,
					configured: r.configured,
					tokenSource: r.tokenSource,
					tokenStatus: r.tokenStatus
				};
			}
		},
		secrets: {
			secretTargetRegistryEntries,
			collectRuntimeConfigAssignments
		}
	};
}
//#endregion
//#region extensions/telegram/src/setup-surface.helpers.ts
const channel$1 = "telegram";
function ensureTelegramDefaultGroupMentionGate(e, n) {
	const r = resolveTelegramAccount({
		cfg: e,
		accountId: n
	});
	const i = r.config.groups?.["*"];
	if (i?.requireMention !== void 0) return e;
	return patchChannelConfigForAccount$1({
		cfg: e,
		channel: channel$1,
		accountId: n,
		patch: { groups: {
			...r.config.groups,
			"*": {
				...i,
				requireMention: true
			}
		} },
		setupSurface: telegramSetupAdapter
	});
}
function shouldShowTelegramDmAccessWarning(e, n) {
	const r = mergeTelegramAccountConfig(e, n);
	const i = Array.isArray(r.allowFrom) && r.allowFrom.some((e) => normalizeOptionalString(String(e)));
	return (r.dmPolicy ?? "pairing") === "pairing" && !i;
}
function buildTelegramDmAccessWarningLines(e) {
	const n = e === DEFAULT_ACCOUNT_ID$2 ? "channels.telegram" : `channels.telegram.accounts.${e}`;
	return [
		"Your bot is using DM policy: pairing.",
		"Any Telegram user who discovers the bot can send pairing requests.",
		"For private use, configure an allowlist with your Telegram user id:",
		"  " + formatCliCommand(`openclaw config set ${n}.dmPolicy "allowlist"`),
		"  " + formatCliCommand(`openclaw config set ${n}.allowFrom '["YOUR_USER_ID"]'`),
		`Docs: ${formatDocsLink("/channels/pairing", "channels/pairing")}`
	];
}
const telegramSetupDmPolicy = createChannelDmPolicy({
	label: "Telegram",
	channel: channel$1,
	resolveAccount: (e, n) => {
		const r = n ?? resolveDefaultTelegramAccountId(e);
		return {
			accountId: r,
			config: mergeTelegramAccountConfig(e, r)
		};
	},
	applyPatch: ({ cfg: e, requestedAccountId: n, account: r, patch: i }) => n == null && r.accountId !== DEFAULT_ACCOUNT_ID$2 ? applySetupAccountConfigPatch({
		cfg: e,
		channelKey: channel$1,
		accountId: r.accountId,
		patch: i
	}) : patchChannelConfigForAccount$1({
		cfg: e,
		channel: channel$1,
		accountId: r.accountId,
		patch: i,
		setupSurface: telegramSetupAdapter
	}),
	promptAllowFrom: promptTelegramAllowFromForAccount
});
//#endregion
//#region extensions/telegram/src/setup-surface.ts
const t = createSetupTranslator$1();
const channel = "telegram";
const telegramSetupWizard = {
	channel,
	status: createStandardChannelSetupStatus({
		channelLabel: "Telegram",
		configuredLabel: t("wizard.channels.statusConfigured"),
		unconfiguredLabel: t("wizard.channels.statusNeedsToken"),
		configuredHint: t("wizard.channels.statusRecommendedConfigured"),
		unconfiguredHint: t("wizard.channels.statusRecommendedNewcomerFriendly"),
		configuredScore: 1,
		unconfiguredScore: 10,
		resolveConfigured: ({ cfg: e, accountId: n }) => (n ? [n] : listTelegramAccountIds(e)).some((n) => inspectTelegramAccount({
			cfg: e,
			accountId: n
		}).configured)
	}),
	prepare: async ({ cfg: e, accountId: n, credentialValues: r }) => ({
		cfg: ensureTelegramDefaultGroupMentionGate(e, n),
		credentialValues: r
	}),
	credentials: [defineTokenCredential({
		inputKey: "token",
		configKey: "botToken",
		configuredFields: ["botToken", "tokenFile"],
		providerHint: channel,
		credentialLabel: t("wizard.telegram.botToken"),
		preferredEnvVar: "TELEGRAM_BOT_TOKEN",
		helpTitle: t("wizard.telegram.botToken"),
		helpLines: getTelegramTokenHelpLines(),
		envPrompt: t("wizard.telegram.tokenEnvPrompt"),
		keepPrompt: t("wizard.telegram.tokenKeepPrompt"),
		inputPrompt: t("wizard.telegram.tokenInputPrompt"),
		allowEnv: ({ accountId: e }) => e === DEFAULT_ACCOUNT_ID$2,
		resolveAccount: ({ cfg: e, accountId: n }) => resolveTelegramAccount({
			cfg: e,
			accountId: n
		}),
		hasConfiguredValue: (e) => hasConfiguredSecretInput$1(e.config.botToken) || Boolean(e.config.tokenFile?.trim()),
		resolvedValue: (e) => normalizeOptionalString(e.token),
		envValue: ({ accountId: e }) => e === DEFAULT_ACCOUNT_ID$2 ? normalizeOptionalString(process.env.TELEGRAM_BOT_TOKEN) : void 0
	})],
	allowFrom: createAllowFromSection({
		helpTitle: t("wizard.telegram.userIdTitle"),
		helpLines: getTelegramUserIdHelpLines(),
		message: t("wizard.telegram.allowFromPrompt"),
		placeholder: "123456789",
		invalidWithoutCredentialNote: t("wizard.telegram.allowFromInvalid"),
		parseInputs: splitSetupEntries$1,
		parseId: parseTelegramAllowFromId,
		apply: async ({ cfg: e, accountId: n, allowFrom: r }) => applyTelegramAllowFrom(e, n, r)
	}),
	finalize: async ({ cfg: e, accountId: n, prompter: r }) => {
		if (!shouldShowTelegramDmAccessWarning(e, n)) return;
		await r.note(buildTelegramDmAccessWarningLines(n).join("\n"), "Telegram DM access warning");
	},
	dmPolicy: telegramSetupDmPolicy,
	disable: (e) => setSetupChannelEnabled(e, channel, false)
};
//#endregion
//#region extensions/telegram/src/channel.setup.ts
const telegramSetupPlugin = createTelegramSetupPluginBase({
	setupWizard: telegramSetupWizard,
	setupContract: telegramSetupContract
});
//#endregion
export { telegramSetupPlugin };