import { AISDKError, JSONParseError, TypeValidationError } from "../../@ai-sdk/provider/dist/index.js";
import { _enum, _instanceof, _null, array as array$1, boolean, custom, discriminatedUnion, lazy, literal, never, number, object as object$1, record, strictObject, string, union, unknown } from "../../zod/v4/classic/schemas.js";
import { DEFAULT_MAX_DOWNLOAD_SIZE, DownloadError, asSchema, createIdGenerator, getRuntimeEnvironmentUserAgent, jsonSchema, lazySchema, readResponseWithSizeLimit, resolve, safeParseJSON, safeValidateTypes, withUserAgentSuffix, zodSchema } from "../../@ai-sdk/provider-utils/dist/index.js";
var __defProp = Object.defineProperty, __export = (_, K) => {
	for (var q in K) __defProp(_, q, {
		get: K[q],
		enumerable: !0
	});
}, name8 = "AI_NoObjectGeneratedError", marker8 = `vercel.ai.error.${name8}`, symbol8 = Symbol.for(marker8), _a8, NoObjectGeneratedError = class extends AISDKError {
	constructor({ message: _ = "No object generated.", cause: K, text: q, response: J, usage: Y, finishReason: X }) {
		super({
			name: name8,
			message: _,
			cause: K
		}), this[_a8] = !0, this.text = q, this.response = J, this.usage = Y, this.finishReason = X;
	}
	static isInstance(K) {
		return AISDKError.hasMarker(K, marker8);
	}
};
_a8 = symbol8;
var dataContentSchema = union([
	string(),
	_instanceof(Uint8Array),
	_instanceof(ArrayBuffer),
	custom((_) => globalThis.Buffer?.isBuffer(_) ?? !1, { message: "Must be a Buffer" })
]), jsonValueSchema = lazy(() => union([
	_null(),
	string(),
	number(),
	boolean(),
	record(string(), jsonValueSchema.optional()),
	array$1(jsonValueSchema)
])), providerMetadataSchema = record(string(), record(string(), jsonValueSchema.optional())), textPartSchema = object$1({
	type: literal("text"),
	text: string(),
	providerOptions: providerMetadataSchema.optional()
}), imagePartSchema = object$1({
	type: literal("image"),
	image: union([dataContentSchema, _instanceof(URL)]),
	mediaType: string().optional(),
	providerOptions: providerMetadataSchema.optional()
}), filePartSchema = object$1({
	type: literal("file"),
	data: union([dataContentSchema, _instanceof(URL)]),
	filename: string().optional(),
	mediaType: string(),
	providerOptions: providerMetadataSchema.optional()
}), reasoningPartSchema = object$1({
	type: literal("reasoning"),
	text: string(),
	providerOptions: providerMetadataSchema.optional()
}), toolCallPartSchema = object$1({
	type: literal("tool-call"),
	toolCallId: string(),
	toolName: string(),
	input: unknown(),
	providerOptions: providerMetadataSchema.optional(),
	providerExecuted: boolean().optional()
}), outputSchema = discriminatedUnion("type", [
	object$1({
		type: literal("text"),
		value: string(),
		providerOptions: providerMetadataSchema.optional()
	}),
	object$1({
		type: literal("json"),
		value: jsonValueSchema,
		providerOptions: providerMetadataSchema.optional()
	}),
	object$1({
		type: literal("execution-denied"),
		reason: string().optional(),
		providerOptions: providerMetadataSchema.optional()
	}),
	object$1({
		type: literal("error-text"),
		value: string(),
		providerOptions: providerMetadataSchema.optional()
	}),
	object$1({
		type: literal("error-json"),
		value: jsonValueSchema,
		providerOptions: providerMetadataSchema.optional()
	}),
	object$1({
		type: literal("content"),
		value: array$1(union([
			object$1({
				type: literal("text"),
				text: string(),
				providerOptions: providerMetadataSchema.optional()
			}),
			object$1({
				type: literal("media"),
				data: string(),
				mediaType: string()
			}),
			object$1({
				type: literal("file-data"),
				data: string(),
				mediaType: string(),
				filename: string().optional(),
				providerOptions: providerMetadataSchema.optional()
			}),
			object$1({
				type: literal("file-url"),
				url: string(),
				providerOptions: providerMetadataSchema.optional()
			}),
			object$1({
				type: literal("file-id"),
				fileId: union([string(), record(string(), string())]),
				providerOptions: providerMetadataSchema.optional()
			}),
			object$1({
				type: literal("image-data"),
				data: string(),
				mediaType: string(),
				providerOptions: providerMetadataSchema.optional()
			}),
			object$1({
				type: literal("image-url"),
				url: string(),
				providerOptions: providerMetadataSchema.optional()
			}),
			object$1({
				type: literal("image-file-id"),
				fileId: union([string(), record(string(), string())]),
				providerOptions: providerMetadataSchema.optional()
			}),
			object$1({
				type: literal("custom"),
				providerOptions: providerMetadataSchema.optional()
			})
		]))
	})
]), toolResultPartSchema = object$1({
	type: literal("tool-result"),
	toolCallId: string(),
	toolName: string(),
	output: outputSchema,
	providerOptions: providerMetadataSchema.optional()
}), toolApprovalRequestSchema = object$1({
	type: literal("tool-approval-request"),
	approvalId: string(),
	toolCallId: string()
}), toolApprovalResponseSchema = object$1({
	type: literal("tool-approval-response"),
	approvalId: string(),
	approved: boolean(),
	reason: string().optional()
});
union([
	object$1({
		role: literal("system"),
		content: string(),
		providerOptions: providerMetadataSchema.optional()
	}),
	object$1({
		role: literal("user"),
		content: union([string(), array$1(union([
			textPartSchema,
			imagePartSchema,
			filePartSchema
		]))]),
		providerOptions: providerMetadataSchema.optional()
	}),
	object$1({
		role: literal("assistant"),
		content: union([string(), array$1(union([
			textPartSchema,
			filePartSchema,
			reasoningPartSchema,
			toolCallPartSchema,
			toolResultPartSchema,
			toolApprovalRequestSchema
		]))]),
		providerOptions: providerMetadataSchema.optional()
	}),
	object$1({
		role: literal("tool"),
		content: array$1(union([toolResultPartSchema, toolApprovalResponseSchema])),
		providerOptions: providerMetadataSchema.optional()
	})
]), __export({}, {
	array: () => array,
	choice: () => choice,
	json: () => json,
	object: () => object,
	text: () => text
});
function fixJson(_) {
	let K = ["ROOT"], q = -1, J = null;
	function Y(_, Y, X) {
		switch (_) {
			case "\"":
				q = Y, K.pop(), K.push(X), K.push("INSIDE_STRING");
				break;
			case "f":
			case "t":
			case "n":
				q = Y, J = Y, K.pop(), K.push(X), K.push("INSIDE_LITERAL");
				break;
			case "-":
				K.pop(), K.push(X), K.push("INSIDE_NUMBER");
				break;
			case "0":
			case "1":
			case "2":
			case "3":
			case "4":
			case "5":
			case "6":
			case "7":
			case "8":
			case "9":
				q = Y, K.pop(), K.push(X), K.push("INSIDE_NUMBER");
				break;
			case "{":
				q = Y, K.pop(), K.push(X), K.push("INSIDE_OBJECT_START");
				break;
			case "[":
				q = Y, K.pop(), K.push(X), K.push("INSIDE_ARRAY_START");
				break;
		}
	}
	function X(_, J) {
		switch (_) {
			case ",":
				K.pop(), K.push("INSIDE_OBJECT_AFTER_COMMA");
				break;
			case "}":
				q = J, K.pop();
				break;
		}
	}
	function Z(_, J) {
		switch (_) {
			case ",":
				K.pop(), K.push("INSIDE_ARRAY_AFTER_COMMA");
				break;
			case "]":
				q = J, K.pop();
				break;
		}
	}
	for (let Q = 0; Q < _.length; Q++) {
		let $ = _[Q];
		switch (K[K.length - 1]) {
			case "ROOT":
				Y($, Q, "FINISH");
				break;
			case "INSIDE_OBJECT_START":
				switch ($) {
					case "\"":
						K.pop(), K.push("INSIDE_OBJECT_KEY");
						break;
					case "}":
						q = Q, K.pop();
						break;
				}
				break;
			case "INSIDE_OBJECT_AFTER_COMMA":
				switch ($) {
					case "\"":
						K.pop(), K.push("INSIDE_OBJECT_KEY");
						break;
				}
				break;
			case "INSIDE_OBJECT_KEY":
				switch ($) {
					case "\"":
						K.pop(), K.push("INSIDE_OBJECT_AFTER_KEY");
						break;
				}
				break;
			case "INSIDE_OBJECT_AFTER_KEY":
				switch ($) {
					case ":":
						K.pop(), K.push("INSIDE_OBJECT_BEFORE_VALUE");
						break;
				}
				break;
			case "INSIDE_OBJECT_BEFORE_VALUE":
				Y($, Q, "INSIDE_OBJECT_AFTER_VALUE");
				break;
			case "INSIDE_OBJECT_AFTER_VALUE":
				X($, Q);
				break;
			case "INSIDE_STRING":
				switch ($) {
					case "\"":
						K.pop(), q = Q;
						break;
					case "\\":
						K.push("INSIDE_STRING_ESCAPE");
						break;
					default: q = Q;
				}
				break;
			case "INSIDE_ARRAY_START":
				switch ($) {
					case "]":
						q = Q, K.pop();
						break;
					default:
						q = Q, Y($, Q, "INSIDE_ARRAY_AFTER_VALUE");
						break;
				}
				break;
			case "INSIDE_ARRAY_AFTER_VALUE":
				switch ($) {
					case ",":
						K.pop(), K.push("INSIDE_ARRAY_AFTER_COMMA");
						break;
					case "]":
						q = Q, K.pop();
						break;
					default:
						q = Q;
						break;
				}
				break;
			case "INSIDE_ARRAY_AFTER_COMMA":
				Y($, Q, "INSIDE_ARRAY_AFTER_VALUE");
				break;
			case "INSIDE_STRING_ESCAPE":
				K.pop(), q = Q;
				break;
			case "INSIDE_NUMBER":
				switch ($) {
					case "0":
					case "1":
					case "2":
					case "3":
					case "4":
					case "5":
					case "6":
					case "7":
					case "8":
					case "9":
						q = Q;
						break;
					case "e":
					case "E":
					case "-":
					case ".": break;
					case ",":
						K.pop(), K[K.length - 1] === "INSIDE_ARRAY_AFTER_VALUE" && Z($, Q), K[K.length - 1] === "INSIDE_OBJECT_AFTER_VALUE" && X($, Q);
						break;
					case "}":
						K.pop(), K[K.length - 1] === "INSIDE_OBJECT_AFTER_VALUE" && X($, Q);
						break;
					case "]":
						K.pop(), K[K.length - 1] === "INSIDE_ARRAY_AFTER_VALUE" && Z($, Q);
						break;
					default:
						K.pop();
						break;
				}
				break;
			case "INSIDE_LITERAL": {
				let Y = _.substring(J, Q + 1);
				!"false".startsWith(Y) && !"true".startsWith(Y) && !"null".startsWith(Y) ? (K.pop(), K[K.length - 1] === "INSIDE_OBJECT_AFTER_VALUE" ? X($, Q) : K[K.length - 1] === "INSIDE_ARRAY_AFTER_VALUE" && Z($, Q)) : q = Q;
				break;
			}
		}
	}
	let Q = _.slice(0, q + 1);
	for (let q = K.length - 1; q >= 0; q--) switch (K[q]) {
		case "INSIDE_STRING":
			Q += "\"";
			break;
		case "INSIDE_OBJECT_KEY":
		case "INSIDE_OBJECT_AFTER_KEY":
		case "INSIDE_OBJECT_AFTER_COMMA":
		case "INSIDE_OBJECT_START":
		case "INSIDE_OBJECT_BEFORE_VALUE":
		case "INSIDE_OBJECT_AFTER_VALUE":
			Q += "}";
			break;
		case "INSIDE_ARRAY_START":
		case "INSIDE_ARRAY_AFTER_COMMA":
		case "INSIDE_ARRAY_AFTER_VALUE":
			Q += "]";
			break;
		case "INSIDE_LITERAL": {
			let K = _.substring(J, _.length);
			"true".startsWith(K) ? Q += "true".slice(K.length) : "false".startsWith(K) ? Q += "false".slice(K.length) : "null".startsWith(K) && (Q += "null".slice(K.length));
		}
	}
	return Q;
}
async function parsePartialJson(_) {
	if (_ === void 0) return {
		value: void 0,
		state: "undefined-input"
	};
	let K = await safeParseJSON({ text: _ });
	return K.success ? {
		value: K.value,
		state: "successful-parse"
	} : (K = await safeParseJSON({ text: fixJson(_) }), K.success ? {
		value: K.value,
		state: "repaired-parse"
	} : {
		value: void 0,
		state: "failed-parse"
	});
}
var text = () => ({
	name: "text",
	responseFormat: Promise.resolve({ type: "text" }),
	async parseCompleteOutput({ text: _ }) {
		return _;
	},
	async parsePartialOutput({ text: _ }) {
		return { partial: _ };
	},
	createElementStreamTransform() {}
}), object = ({ schema: _, name: K, description: q }) => {
	let J = asSchema(_);
	return {
		name: "object",
		responseFormat: resolve(J.jsonSchema).then((_) => ({
			type: "json",
			schema: _,
			...K != null && { name: K },
			...q != null && { description: q }
		})),
		async parseCompleteOutput({ text: _ }, K) {
			let q = await safeParseJSON({ text: _ });
			if (!q.success) throw new NoObjectGeneratedError({
				message: "No object generated: could not parse the response.",
				cause: q.error,
				text: _,
				response: K.response,
				usage: K.usage,
				finishReason: K.finishReason
			});
			let Y = await safeValidateTypes({
				value: q.value,
				schema: J
			});
			if (!Y.success) throw new NoObjectGeneratedError({
				message: "No object generated: response did not match schema.",
				cause: Y.error,
				text: _,
				response: K.response,
				usage: K.usage,
				finishReason: K.finishReason
			});
			return Y.value;
		},
		async parsePartialOutput({ text: _ }) {
			let K = await parsePartialJson(_);
			switch (K.state) {
				case "failed-parse":
				case "undefined-input": return;
				case "repaired-parse":
				case "successful-parse": return { partial: K.value };
			}
		},
		createElementStreamTransform() {}
	};
}, array = ({ element: _, name: K, description: J }) => {
	let Y = asSchema(_);
	return {
		name: "array",
		responseFormat: resolve(Y.jsonSchema).then((_) => {
			let { $schema: q, ...Y } = _;
			return {
				type: "json",
				schema: {
					$schema: "http://json-schema.org/draft-07/schema#",
					type: "object",
					properties: { elements: {
						type: "array",
						items: Y
					} },
					required: ["elements"],
					additionalProperties: !1
				},
				...K != null && { name: K },
				...J != null && { description: J }
			};
		}),
		async parseCompleteOutput({ text: _ }, K) {
			let J = await safeParseJSON({ text: _ });
			if (!J.success) throw new NoObjectGeneratedError({
				message: "No object generated: could not parse the response.",
				cause: J.error,
				text: _,
				response: K.response,
				usage: K.usage,
				finishReason: K.finishReason
			});
			let X = J.value;
			if (typeof X != "object" || !X || !("elements" in X) || !Array.isArray(X.elements)) throw new NoObjectGeneratedError({
				message: "No object generated: response did not match schema.",
				cause: new TypeValidationError({
					value: X,
					cause: "response must be an object with an elements array"
				}),
				text: _,
				response: K.response,
				usage: K.usage,
				finishReason: K.finishReason
			});
			for (let q of X.elements) {
				let J = await safeValidateTypes({
					value: q,
					schema: Y
				});
				if (!J.success) throw new NoObjectGeneratedError({
					message: "No object generated: response did not match schema.",
					cause: J.error,
					text: _,
					response: K.response,
					usage: K.usage,
					finishReason: K.finishReason
				});
			}
			return X.elements;
		},
		async parsePartialOutput({ text: _ }) {
			let K = await parsePartialJson(_);
			switch (K.state) {
				case "failed-parse":
				case "undefined-input": return;
				case "repaired-parse":
				case "successful-parse": {
					let _ = K.value;
					if (typeof _ != "object" || !_ || !("elements" in _) || !Array.isArray(_.elements)) return;
					let q = K.state === "repaired-parse" && _.elements.length > 0 ? _.elements.slice(0, -1) : _.elements, J = [];
					for (let _ of q) {
						let K = await safeValidateTypes({
							value: _,
							schema: Y
						});
						K.success && J.push(K.value);
					}
					return { partial: J };
				}
			}
		},
		createElementStreamTransform() {
			let _ = 0;
			return new TransformStream({ transform({ partialOutput: K }, q) {
				if (K != null) for (; _ < K.length; _++) q.enqueue(K[_]);
			} });
		}
	};
}, choice = ({ options: _, name: K, description: J }) => ({
	name: "choice",
	responseFormat: Promise.resolve({
		type: "json",
		schema: {
			$schema: "http://json-schema.org/draft-07/schema#",
			type: "object",
			properties: { result: {
				type: "string",
				enum: _
			} },
			required: ["result"],
			additionalProperties: !1
		},
		...K != null && { name: K },
		...J != null && { description: J }
	}),
	async parseCompleteOutput({ text: K }, J) {
		let Y = await safeParseJSON({ text: K });
		if (!Y.success) throw new NoObjectGeneratedError({
			message: "No object generated: could not parse the response.",
			cause: Y.error,
			text: K,
			response: J.response,
			usage: J.usage,
			finishReason: J.finishReason
		});
		let X = Y.value;
		if (typeof X != "object" || !X || !("result" in X) || typeof X.result != "string" || !_.includes(X.result)) throw new NoObjectGeneratedError({
			message: "No object generated: response did not match schema.",
			cause: new TypeValidationError({
				value: X,
				cause: "response must be an object that contains a choice value."
			}),
			text: K,
			response: J.response,
			usage: J.usage,
			finishReason: J.finishReason
		});
		return X.result;
	},
	async parsePartialOutput({ text: K }) {
		let q = await parsePartialJson(K);
		switch (q.state) {
			case "failed-parse":
			case "undefined-input": return;
			case "repaired-parse":
			case "successful-parse": {
				let K = q.value;
				if (typeof K != "object" || !K || !("result" in K) || typeof K.result != "string") return;
				let J = _.filter((_) => _.startsWith(K.result));
				return q.state === "successful-parse" ? J.includes(K.result) ? { partial: K.result } : void 0 : J.length === 1 ? { partial: J[0] } : void 0;
			}
		}
	},
	createElementStreamTransform() {}
}), json = ({ name: _, description: K } = {}) => ({
	name: "json",
	responseFormat: Promise.resolve({
		type: "json",
		..._ != null && { name: _ },
		...K != null && { description: K }
	}),
	async parseCompleteOutput({ text: _ }, K) {
		let q = await safeParseJSON({ text: _ });
		if (!q.success) throw new NoObjectGeneratedError({
			message: "No object generated: could not parse the response.",
			cause: q.error,
			text: _,
			response: K.response,
			usage: K.usage,
			finishReason: K.finishReason
		});
		return q.value;
	},
	async parsePartialOutput({ text: _ }) {
		let K = await parsePartialJson(_);
		switch (K.state) {
			case "failed-parse":
			case "undefined-input": return;
			case "repaired-parse":
			case "successful-parse": return K.value === void 0 ? void 0 : { partial: K.value };
		}
	},
	createElementStreamTransform() {}
});
createIdGenerator({
	prefix: "aitxt",
	size: 24
}), lazySchema(() => zodSchema(union([
	strictObject({
		type: literal("text-start"),
		id: string(),
		providerMetadata: providerMetadataSchema.optional()
	}),
	strictObject({
		type: literal("text-delta"),
		id: string(),
		delta: string(),
		providerMetadata: providerMetadataSchema.optional()
	}),
	strictObject({
		type: literal("text-end"),
		id: string(),
		providerMetadata: providerMetadataSchema.optional()
	}),
	strictObject({
		type: literal("error"),
		errorText: string()
	}),
	strictObject({
		type: literal("tool-input-start"),
		toolCallId: string(),
		toolName: string(),
		providerExecuted: boolean().optional(),
		providerMetadata: providerMetadataSchema.optional(),
		dynamic: boolean().optional(),
		title: string().optional()
	}),
	strictObject({
		type: literal("tool-input-delta"),
		toolCallId: string(),
		inputTextDelta: string()
	}),
	strictObject({
		type: literal("tool-input-available"),
		toolCallId: string(),
		toolName: string(),
		input: unknown(),
		providerExecuted: boolean().optional(),
		providerMetadata: providerMetadataSchema.optional(),
		dynamic: boolean().optional(),
		title: string().optional()
	}),
	strictObject({
		type: literal("tool-input-error"),
		toolCallId: string(),
		toolName: string(),
		input: unknown(),
		providerExecuted: boolean().optional(),
		providerMetadata: providerMetadataSchema.optional(),
		dynamic: boolean().optional(),
		errorText: string(),
		title: string().optional()
	}),
	strictObject({
		type: literal("tool-approval-request"),
		approvalId: string(),
		toolCallId: string()
	}),
	strictObject({
		type: literal("tool-output-available"),
		toolCallId: string(),
		output: unknown(),
		providerExecuted: boolean().optional(),
		dynamic: boolean().optional(),
		preliminary: boolean().optional()
	}),
	strictObject({
		type: literal("tool-output-error"),
		toolCallId: string(),
		errorText: string(),
		providerExecuted: boolean().optional(),
		dynamic: boolean().optional()
	}),
	strictObject({
		type: literal("tool-output-denied"),
		toolCallId: string()
	}),
	strictObject({
		type: literal("reasoning-start"),
		id: string(),
		providerMetadata: providerMetadataSchema.optional()
	}),
	strictObject({
		type: literal("reasoning-delta"),
		id: string(),
		delta: string(),
		providerMetadata: providerMetadataSchema.optional()
	}),
	strictObject({
		type: literal("reasoning-end"),
		id: string(),
		providerMetadata: providerMetadataSchema.optional()
	}),
	strictObject({
		type: literal("source-url"),
		sourceId: string(),
		url: string(),
		title: string().optional(),
		providerMetadata: providerMetadataSchema.optional()
	}),
	strictObject({
		type: literal("source-document"),
		sourceId: string(),
		mediaType: string(),
		title: string(),
		filename: string().optional(),
		providerMetadata: providerMetadataSchema.optional()
	}),
	strictObject({
		type: literal("file"),
		url: string(),
		mediaType: string(),
		providerMetadata: providerMetadataSchema.optional()
	}),
	strictObject({
		type: custom((_) => typeof _ == "string" && _.startsWith("data-"), { message: "Type must start with \"data-\"" }),
		id: string().optional(),
		data: unknown(),
		transient: boolean().optional()
	}),
	strictObject({ type: literal("start-step") }),
	strictObject({ type: literal("finish-step") }),
	strictObject({
		type: literal("start"),
		messageId: string().optional(),
		messageMetadata: unknown().optional()
	}),
	strictObject({
		type: literal("finish"),
		finishReason: _enum([
			"stop",
			"length",
			"content-filter",
			"tool-calls",
			"error",
			"other"
		]).optional(),
		messageMetadata: unknown().optional()
	}),
	strictObject({
		type: literal("abort"),
		reason: string().optional()
	}),
	strictObject({
		type: literal("message-metadata"),
		messageMetadata: unknown()
	})
])));
function isTextUIPart(_) {
	return _.type === "text";
}
function isReasoningUIPart(_) {
	return _.type === "reasoning";
}
function isStaticToolUIPart(_) {
	return _.type.startsWith("tool-");
}
function isDynamicToolUIPart(_) {
	return _.type === "dynamic-tool";
}
function isToolUIPart(_) {
	return isStaticToolUIPart(_) || isDynamicToolUIPart(_);
}
var isToolOrDynamicToolUIPart = isToolUIPart;
function getStaticToolName(_) {
	return _.type.split("-").slice(1).join("-");
}
function getToolName(_) {
	return isDynamicToolUIPart(_) ? _.toolName : getStaticToolName(_);
}
var getToolOrDynamicToolName = getToolName;
createIdGenerator({
	prefix: "aitxt",
	size: 24
}), lazySchema(() => zodSchema(array$1(object$1({
	id: string(),
	role: _enum([
		"system",
		"user",
		"assistant"
	]),
	metadata: unknown().optional(),
	parts: array$1(union([
		object$1({
			type: literal("text"),
			text: string(),
			state: _enum(["streaming", "done"]).optional(),
			providerMetadata: providerMetadataSchema.optional()
		}),
		object$1({
			type: literal("reasoning"),
			text: string(),
			state: _enum(["streaming", "done"]).optional(),
			providerMetadata: providerMetadataSchema.optional()
		}),
		object$1({
			type: literal("source-url"),
			sourceId: string(),
			url: string(),
			title: string().optional(),
			providerMetadata: providerMetadataSchema.optional()
		}),
		object$1({
			type: literal("source-document"),
			sourceId: string(),
			mediaType: string(),
			title: string(),
			filename: string().optional(),
			providerMetadata: providerMetadataSchema.optional()
		}),
		object$1({
			type: literal("file"),
			mediaType: string(),
			filename: string().optional(),
			url: string(),
			providerMetadata: providerMetadataSchema.optional()
		}),
		object$1({ type: literal("step-start") }),
		object$1({
			type: string().startsWith("data-"),
			id: string().optional(),
			data: unknown()
		}),
		object$1({
			type: literal("dynamic-tool"),
			toolName: string(),
			toolCallId: string(),
			state: literal("input-streaming"),
			input: unknown().optional(),
			providerExecuted: boolean().optional(),
			callProviderMetadata: providerMetadataSchema.optional(),
			output: never().optional(),
			errorText: never().optional(),
			approval: never().optional()
		}),
		object$1({
			type: literal("dynamic-tool"),
			toolName: string(),
			toolCallId: string(),
			state: literal("input-available"),
			input: unknown(),
			providerExecuted: boolean().optional(),
			output: never().optional(),
			errorText: never().optional(),
			callProviderMetadata: providerMetadataSchema.optional(),
			approval: never().optional()
		}),
		object$1({
			type: literal("dynamic-tool"),
			toolName: string(),
			toolCallId: string(),
			state: literal("approval-requested"),
			input: unknown(),
			providerExecuted: boolean().optional(),
			output: never().optional(),
			errorText: never().optional(),
			callProviderMetadata: providerMetadataSchema.optional(),
			approval: object$1({
				id: string(),
				approved: never().optional(),
				reason: never().optional()
			})
		}),
		object$1({
			type: literal("dynamic-tool"),
			toolName: string(),
			toolCallId: string(),
			state: literal("approval-responded"),
			input: unknown(),
			providerExecuted: boolean().optional(),
			output: never().optional(),
			errorText: never().optional(),
			callProviderMetadata: providerMetadataSchema.optional(),
			approval: object$1({
				id: string(),
				approved: boolean(),
				reason: string().optional()
			})
		}),
		object$1({
			type: literal("dynamic-tool"),
			toolName: string(),
			toolCallId: string(),
			state: literal("output-available"),
			input: unknown(),
			providerExecuted: boolean().optional(),
			output: unknown(),
			errorText: never().optional(),
			callProviderMetadata: providerMetadataSchema.optional(),
			preliminary: boolean().optional(),
			approval: object$1({
				id: string(),
				approved: literal(!0),
				reason: string().optional()
			}).optional()
		}),
		object$1({
			type: literal("dynamic-tool"),
			toolName: string(),
			toolCallId: string(),
			state: literal("output-error"),
			input: unknown(),
			rawInput: unknown().optional(),
			providerExecuted: boolean().optional(),
			output: never().optional(),
			errorText: string(),
			callProviderMetadata: providerMetadataSchema.optional(),
			approval: object$1({
				id: string(),
				approved: literal(!0),
				reason: string().optional()
			}).optional()
		}),
		object$1({
			type: literal("dynamic-tool"),
			toolName: string(),
			toolCallId: string(),
			state: literal("output-denied"),
			input: unknown(),
			providerExecuted: boolean().optional(),
			output: never().optional(),
			errorText: never().optional(),
			callProviderMetadata: providerMetadataSchema.optional(),
			approval: object$1({
				id: string(),
				approved: literal(!1),
				reason: string().optional()
			})
		}),
		object$1({
			type: string().startsWith("tool-"),
			toolCallId: string(),
			state: literal("input-streaming"),
			providerExecuted: boolean().optional(),
			callProviderMetadata: providerMetadataSchema.optional(),
			input: unknown().optional(),
			output: never().optional(),
			errorText: never().optional(),
			approval: never().optional()
		}),
		object$1({
			type: string().startsWith("tool-"),
			toolCallId: string(),
			state: literal("input-available"),
			providerExecuted: boolean().optional(),
			input: unknown(),
			output: never().optional(),
			errorText: never().optional(),
			callProviderMetadata: providerMetadataSchema.optional(),
			approval: never().optional()
		}),
		object$1({
			type: string().startsWith("tool-"),
			toolCallId: string(),
			state: literal("approval-requested"),
			input: unknown(),
			providerExecuted: boolean().optional(),
			output: never().optional(),
			errorText: never().optional(),
			callProviderMetadata: providerMetadataSchema.optional(),
			approval: object$1({
				id: string(),
				approved: never().optional(),
				reason: never().optional()
			})
		}),
		object$1({
			type: string().startsWith("tool-"),
			toolCallId: string(),
			state: literal("approval-responded"),
			input: unknown(),
			providerExecuted: boolean().optional(),
			output: never().optional(),
			errorText: never().optional(),
			callProviderMetadata: providerMetadataSchema.optional(),
			approval: object$1({
				id: string(),
				approved: boolean(),
				reason: string().optional()
			})
		}),
		object$1({
			type: string().startsWith("tool-"),
			toolCallId: string(),
			state: literal("output-available"),
			providerExecuted: boolean().optional(),
			input: unknown(),
			output: unknown(),
			errorText: never().optional(),
			callProviderMetadata: providerMetadataSchema.optional(),
			preliminary: boolean().optional(),
			approval: object$1({
				id: string(),
				approved: literal(!0),
				reason: string().optional()
			}).optional()
		}),
		object$1({
			type: string().startsWith("tool-"),
			toolCallId: string(),
			state: literal("output-error"),
			providerExecuted: boolean().optional(),
			input: unknown(),
			rawInput: unknown().optional(),
			output: never().optional(),
			errorText: string(),
			callProviderMetadata: providerMetadataSchema.optional(),
			approval: object$1({
				id: string(),
				approved: literal(!0),
				reason: string().optional()
			}).optional()
		}),
		object$1({
			type: string().startsWith("tool-"),
			toolCallId: string(),
			state: literal("output-denied"),
			providerExecuted: boolean().optional(),
			input: unknown(),
			output: never().optional(),
			errorText: never().optional(),
			callProviderMetadata: providerMetadataSchema.optional(),
			approval: object$1({
				id: string(),
				approved: literal(!1),
				reason: string().optional()
			})
		})
	])).nonempty("Message must contain at least one part")
})).nonempty("Messages array must not be empty"))), createIdGenerator({
	prefix: "aiobj",
	size: 24
}), createIdGenerator({
	prefix: "aiobj",
	size: 24
});
export { getToolOrDynamicToolName, isReasoningUIPart, isTextUIPart, isToolOrDynamicToolUIPart };
