@daydreamsai/ai-sdk-provider
Version:
Dreams Router AI SDK provider (forked from OpenRouter)
1 lines • 976 kB
Source Map (JSON)
{"version":3,"sources":["../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/src/errors/ai-sdk-error.ts","../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/src/errors/api-call-error.ts","../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/src/errors/empty-response-body-error.ts","../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/src/errors/get-error-message.ts","../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/src/errors/invalid-argument-error.ts","../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/src/errors/invalid-prompt-error.ts","../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/src/errors/invalid-response-data-error.ts","../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/src/errors/json-parse-error.ts","../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/src/errors/load-api-key-error.ts","../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/src/errors/load-setting-error.ts","../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/src/errors/no-content-generated-error.ts","../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/src/errors/no-such-model-error.ts","../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/src/errors/too-many-embedding-values-for-call-error.ts","../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/src/errors/type-validation-error.ts","../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/src/errors/unsupported-functionality-error.ts","../../node_modules/.pnpm/@ai-sdk+provider@2.0.0/node_modules/@ai-sdk/provider/src/json-value/is-json.ts","../../node_modules/.pnpm/eventsource-parser@3.0.5/node_modules/eventsource-parser/src/errors.ts","../../node_modules/.pnpm/eventsource-parser@3.0.5/node_modules/eventsource-parser/src/parse.ts","../../node_modules/.pnpm/eventsource-parser@3.0.5/node_modules/eventsource-parser/src/stream.ts","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/classic/external.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/index.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/core.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/util.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/errors.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/parse.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/regexes.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/checks.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/doc.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/versions.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/schemas.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/index.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/ar.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/az.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/be.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/ca.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/cs.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/da.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/de.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/en.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/eo.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/es.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/fa.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/fi.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/fr.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/fr-CA.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/he.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/hu.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/id.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/is.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/it.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/ja.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/kh.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/ko.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/mk.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/ms.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/nl.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/no.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/ota.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/ps.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/pl.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/pt.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/ru.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/sl.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/sv.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/ta.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/th.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/tr.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/ua.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/ur.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/vi.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/zh-CN.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/zh-TW.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/locales/yo.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/registries.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/api.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/function.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/to-json-schema.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/core/json-schema.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/classic/iso.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/classic/errors.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/classic/parse.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/classic/schemas.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/classic/compat.js","../../node_modules/.pnpm/zod@4.0.17/node_modules/zod/v4/classic/coerce.js","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/combine-headers.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/convert-async-iterator-to-readable-stream.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/delay.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/extract-response-headers.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/generate-id.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/get-error-message.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/get-from-api.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/handle-fetch-error.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/is-abort-error.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/remove-undefined-entries.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/inject-json-instruction.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/is-url-supported.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/load-api-key.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/load-optional-setting.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/load-setting.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/media-type-to-extension.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/parse-json.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/secure-json-parse.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/validate-types.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/validator.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/parse-json-event-stream.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/parse-provider-options.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/post-to-api.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/types/tool.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/provider-defined-tool-factory.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/resolve.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/response-handler.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-schema.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/get-relative-path.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/options.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/select-parser.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/any.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/array.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/bigint.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/boolean.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/branded.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/catch.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/date.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/default.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/effects.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/enum.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/intersection.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/literal.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/record.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/string.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/map.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/native-enum.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/never.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/null.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/union.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/nullable.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/number.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/object.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/optional.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/pipeline.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/promise.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/set.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/tuple.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/undefined.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/unknown.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parsers/readonly.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/parse-def.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/refs.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/zod-to-json-schema.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/zod-to-json-schema/index.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/schema.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/uint8-utils.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/without-trailing-slash.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/is-async-iterable.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/types/execute-tool.ts","../../node_modules/.pnpm/@ai-sdk+provider-utils@3.0.7_zod@4.0.17/node_modules/@ai-sdk/provider-utils/src/index.ts","../../src/schemas/reasoning-details.ts","../../src/schemas/error-response.ts","../../src/utils/map-finish-reason.ts","../../src/chat/is-url.ts","../../src/chat/file-url-utils.ts","../../src/chat/convert-to-openrouter-chat-messages.ts","../../src/chat/get-tool-choice.ts","../../src/chat/schemas.ts","../../src/chat/index.ts","../../src/completion/convert-to-openrouter-completion-prompt.ts","../../src/completion/schemas.ts","../../src/completion/index.ts"],"sourcesContent":["/**\n * Symbol used for identifying AI SDK Error instances.\n * Enables checking if an error is an instance of AISDKError across package versions.\n */\nconst marker = 'vercel.ai.error';\nconst symbol = Symbol.for(marker);\n\n/**\n * Custom error class for AI SDK related errors.\n * @extends Error\n */\nexport class AISDKError extends Error {\n private readonly [symbol] = true; // used in isInstance\n\n /**\n * The underlying cause of the error, if any.\n */\n readonly cause?: unknown;\n\n /**\n * Creates an AI SDK Error.\n *\n * @param {Object} params - The parameters for creating the error.\n * @param {string} params.name - The name of the error.\n * @param {string} params.message - The error message.\n * @param {unknown} [params.cause] - The underlying cause of the error.\n */\n constructor({\n name,\n message,\n cause,\n }: {\n name: string;\n message: string;\n cause?: unknown;\n }) {\n super(message);\n\n this.name = name;\n this.cause = cause;\n }\n\n /**\n * Checks if the given error is an AI SDK Error.\n * @param {unknown} error - The error to check.\n * @returns {boolean} True if the error is an AI SDK Error, false otherwise.\n */\n static isInstance(error: unknown): error is AISDKError {\n return AISDKError.hasMarker(error, marker);\n }\n\n protected static hasMarker(error: unknown, marker: string): boolean {\n const markerSymbol = Symbol.for(marker);\n return (\n error != null &&\n typeof error === 'object' &&\n markerSymbol in error &&\n typeof error[markerSymbol] === 'boolean' &&\n error[markerSymbol] === true\n );\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_APICallError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class APICallError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly url: string;\n readonly requestBodyValues: unknown;\n readonly statusCode?: number;\n\n readonly responseHeaders?: Record<string, string>;\n readonly responseBody?: string;\n\n readonly isRetryable: boolean;\n readonly data?: unknown;\n\n constructor({\n message,\n url,\n requestBodyValues,\n statusCode,\n responseHeaders,\n responseBody,\n cause,\n isRetryable = statusCode != null &&\n (statusCode === 408 || // request timeout\n statusCode === 409 || // conflict\n statusCode === 429 || // too many requests\n statusCode >= 500), // server error\n data,\n }: {\n message: string;\n url: string;\n requestBodyValues: unknown;\n statusCode?: number;\n responseHeaders?: Record<string, string>;\n responseBody?: string;\n cause?: unknown;\n isRetryable?: boolean;\n data?: unknown;\n }) {\n super({ name, message, cause });\n\n this.url = url;\n this.requestBodyValues = requestBodyValues;\n this.statusCode = statusCode;\n this.responseHeaders = responseHeaders;\n this.responseBody = responseBody;\n this.isRetryable = isRetryable;\n this.data = data;\n }\n\n static isInstance(error: unknown): error is APICallError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_EmptyResponseBodyError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class EmptyResponseBodyError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({ message = 'Empty response body' }: { message?: string } = {}) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is EmptyResponseBodyError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","export function getErrorMessage(error: unknown | undefined) {\n if (error == null) {\n return 'unknown error';\n }\n\n if (typeof error === 'string') {\n return error;\n }\n\n if (error instanceof Error) {\n return error.message;\n }\n\n return JSON.stringify(error);\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_InvalidArgumentError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * A function argument is invalid.\n */\nexport class InvalidArgumentError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly argument: string;\n\n constructor({\n message,\n cause,\n argument,\n }: {\n argument: string;\n message: string;\n cause?: unknown;\n }) {\n super({ name, message, cause });\n\n this.argument = argument;\n }\n\n static isInstance(error: unknown): error is InvalidArgumentError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_InvalidPromptError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * A prompt is invalid. This error should be thrown by providers when they cannot\n * process a prompt.\n */\nexport class InvalidPromptError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly prompt: unknown;\n\n constructor({\n prompt,\n message,\n cause,\n }: {\n prompt: unknown;\n message: string;\n cause?: unknown;\n }) {\n super({ name, message: `Invalid prompt: ${message}`, cause });\n\n this.prompt = prompt;\n }\n\n static isInstance(error: unknown): error is InvalidPromptError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_InvalidResponseDataError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\n * Server returned a response with invalid data content.\n * This should be thrown by providers when they cannot parse the response from the API.\n */\nexport class InvalidResponseDataError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly data: unknown;\n\n constructor({\n data,\n message = `Invalid response data: ${JSON.stringify(data)}.`,\n }: {\n data: unknown;\n message?: string;\n }) {\n super({ name, message });\n\n this.data = data;\n }\n\n static isInstance(error: unknown): error is InvalidResponseDataError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\nimport { getErrorMessage } from './get-error-message';\n\nconst name = 'AI_JSONParseError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n// TODO v5: rename to ParseError\nexport class JSONParseError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly text: string;\n\n constructor({ text, cause }: { text: string; cause: unknown }) {\n super({\n name,\n message:\n `JSON parsing failed: ` +\n `Text: ${text}.\\n` +\n `Error message: ${getErrorMessage(cause)}`,\n cause,\n });\n\n this.text = text;\n }\n\n static isInstance(error: unknown): error is JSONParseError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_LoadAPIKeyError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class LoadAPIKeyError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({ message }: { message: string }) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is LoadAPIKeyError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_LoadSettingError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class LoadSettingError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({ message }: { message: string }) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is LoadSettingError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_NoContentGeneratedError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\n/**\nThrown when the AI provider fails to generate any content.\n */\nexport class NoContentGeneratedError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n constructor({\n message = 'No content generated.',\n }: { message?: string } = {}) {\n super({ name, message });\n }\n\n static isInstance(error: unknown): error is NoContentGeneratedError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_NoSuchModelError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class NoSuchModelError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly modelId: string;\n readonly modelType:\n | 'languageModel'\n | 'textEmbeddingModel'\n | 'imageModel'\n | 'transcriptionModel'\n | 'speechModel';\n\n constructor({\n errorName = name,\n modelId,\n modelType,\n message = `No such ${modelType}: ${modelId}`,\n }: {\n errorName?: string;\n modelId: string;\n modelType:\n | 'languageModel'\n | 'textEmbeddingModel'\n | 'imageModel'\n | 'transcriptionModel'\n | 'speechModel';\n message?: string;\n }) {\n super({ name: errorName, message });\n\n this.modelId = modelId;\n this.modelType = modelType;\n }\n\n static isInstance(error: unknown): error is NoSuchModelError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_TooManyEmbeddingValuesForCallError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class TooManyEmbeddingValuesForCallError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly provider: string;\n readonly modelId: string;\n readonly maxEmbeddingsPerCall: number;\n readonly values: Array<unknown>;\n\n constructor(options: {\n provider: string;\n modelId: string;\n maxEmbeddingsPerCall: number;\n values: Array<unknown>;\n }) {\n super({\n name,\n message:\n `Too many values for a single embedding call. ` +\n `The ${options.provider} model \"${options.modelId}\" can only embed up to ` +\n `${options.maxEmbeddingsPerCall} values per call, but ${options.values.length} values were provided.`,\n });\n\n this.provider = options.provider;\n this.modelId = options.modelId;\n this.maxEmbeddingsPerCall = options.maxEmbeddingsPerCall;\n this.values = options.values;\n }\n\n static isInstance(\n error: unknown,\n ): error is TooManyEmbeddingValuesForCallError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { AISDKError } from './ai-sdk-error';\nimport { getErrorMessage } from './get-error-message';\n\nconst name = 'AI_TypeValidationError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class TypeValidationError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly value: unknown;\n\n constructor({ value, cause }: { value: unknown; cause: unknown }) {\n super({\n name,\n message:\n `Type validation failed: ` +\n `Value: ${JSON.stringify(value)}.\\n` +\n `Error message: ${getErrorMessage(cause)}`,\n cause,\n });\n\n this.value = value;\n }\n\n static isInstance(error: unknown): error is TypeValidationError {\n return AISDKError.hasMarker(error, marker);\n }\n\n /**\n * Wraps an error into a TypeValidationError.\n * If the cause is already a TypeValidationError with the same value, it returns the cause.\n * Otherwise, it creates a new TypeValidationError.\n *\n * @param {Object} params - The parameters for wrapping the error.\n * @param {unknown} params.value - The value that failed validation.\n * @param {unknown} params.cause - The original error or cause of the validation failure.\n * @returns {TypeValidationError} A TypeValidationError instance.\n */\n static wrap({\n value,\n cause,\n }: {\n value: unknown;\n cause: unknown;\n }): TypeValidationError {\n return TypeValidationError.isInstance(cause) && cause.value === value\n ? cause\n : new TypeValidationError({ value, cause });\n }\n}\n","import { AISDKError } from './ai-sdk-error';\n\nconst name = 'AI_UnsupportedFunctionalityError';\nconst marker = `vercel.ai.error.${name}`;\nconst symbol = Symbol.for(marker);\n\nexport class UnsupportedFunctionalityError extends AISDKError {\n private readonly [symbol] = true; // used in isInstance\n\n readonly functionality: string;\n\n constructor({\n functionality,\n message = `'${functionality}' functionality not supported.`,\n }: {\n functionality: string;\n message?: string;\n }) {\n super({ name, message });\n this.functionality = functionality;\n }\n\n static isInstance(error: unknown): error is UnsupportedFunctionalityError {\n return AISDKError.hasMarker(error, marker);\n }\n}\n","import { JSONArray, JSONObject, JSONValue } from './json-value';\n\nexport function isJSONValue(value: unknown): value is JSONValue {\n if (\n value === null ||\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean'\n ) {\n return true;\n }\n\n if (Array.isArray(value)) {\n return value.every(isJSONValue);\n }\n\n if (typeof value === 'object') {\n return Object.entries(value).every(\n ([key, val]) => typeof key === 'string' && isJSONValue(val),\n );\n }\n\n return false;\n}\n\nexport function isJSONArray(value: unknown): value is JSONArray {\n return Array.isArray(value) && value.every(isJSONValue);\n}\n\nexport function isJSONObject(value: unknown): value is JSONObject {\n return (\n value != null &&\n typeof value === 'object' &&\n Object.entries(value).every(\n ([key, val]) => typeof key === 'string' && isJSONValue(val),\n )\n );\n}\n","/**\n * The type of error that occurred.\n * @public\n */\nexport type ErrorType = 'invalid-retry' | 'unknown-field'\n\n/**\n * Error thrown when encountering an issue during parsing.\n *\n * @public\n */\nexport class ParseError extends Error {\n /**\n * The type of error that occurred.\n */\n type: ErrorType\n\n /**\n * In the case of an unknown field encountered in the stream, this will be the field name.\n */\n field?: string | undefined\n\n /**\n * In the case of an unknown field encountered in the stream, this will be the value of the field.\n */\n value?: string | undefined\n\n /**\n * The line that caused the error, if available.\n */\n line?: string | undefined\n\n constructor(\n message: string,\n options: {type: ErrorType; field?: string; value?: string; line?: string},\n ) {\n super(message)\n this.name = 'ParseError'\n this.type = options.type\n this.field = options.field\n this.value = options.value\n this.line = options.line\n }\n}\n","/**\n * EventSource/Server-Sent Events parser\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html\n */\nimport {ParseError} from './errors.ts'\nimport type {EventSourceParser, ParserCallbacks} from './types.ts'\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction noop(_arg: unknown) {\n // intentional noop\n}\n\n/**\n * Creates a new EventSource parser.\n *\n * @param callbacks - Callbacks to invoke on different parsing events:\n * - `onEvent` when a new event is parsed\n * - `onError` when an error occurs\n * - `onRetry` when a new reconnection interval has been sent from the server\n * - `onComment` when a comment is encountered in the stream\n *\n * @returns A new EventSource parser, with `parse` and `reset` methods.\n * @public\n */\nexport function createParser(callbacks: ParserCallbacks): EventSourceParser {\n if (typeof callbacks === 'function') {\n throw new TypeError(\n '`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?',\n )\n }\n\n const {onEvent = noop, onError = noop, onRetry = noop, onComment} = callbacks\n\n let incompleteLine = ''\n\n let isFirstChunk = true\n let id: string | undefined\n let data = ''\n let eventType = ''\n\n function feed(newChunk: string) {\n // Strip any UTF8 byte order mark (BOM) at the start of the stream\n const chunk = isFirstChunk ? newChunk.replace(/^\\xEF\\xBB\\xBF/, '') : newChunk\n\n // If there was a previous incomplete line, append it to the new chunk,\n // so we may process it together as a new (hopefully complete) chunk.\n const [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`)\n\n for (const line of complete) {\n parseLine(line)\n }\n\n incompleteLine = incomplete\n isFirstChunk = false\n }\n\n function parseLine(line: string) {\n // If the line is empty (a blank line), dispatch the event\n if (line === '') {\n dispatchEvent()\n return\n }\n\n // If the line starts with a U+003A COLON character (:), ignore the line.\n if (line.startsWith(':')) {\n if (onComment) {\n onComment(line.slice(line.startsWith(': ') ? 2 : 1))\n }\n return\n }\n\n // If the line contains a U+003A COLON character (:)\n const fieldSeparatorIndex = line.indexOf(':')\n if (fieldSeparatorIndex !== -1) {\n // Collect the characters on the line before the first U+003A COLON character (:),\n // and let `field` be that string.\n const field = line.slice(0, fieldSeparatorIndex)\n\n // Collect the characters on the line after the first U+003A COLON character (:),\n // and let `value` be that string. If value starts with a U+0020 SPACE character,\n // remove it from value.\n const offset = line[fieldSeparatorIndex + 1] === ' ' ? 2 : 1\n const value = line.slice(fieldSeparatorIndex + offset)\n\n processField(field, value, line)\n return\n }\n\n // Otherwise, the string is not empty but does not contain a U+003A COLON character (:)\n // Process the field using the whole line as the field name, and an empty string as the field value.\n // 👆 This is according to spec. That means that a line that has the value `data` will result in\n // a newline being added to the current `data` buffer, for instance.\n processField(line, '', line)\n }\n\n function processField(field: string, value: string, line: string) {\n // Field names must be compared literally, with no case folding performed.\n switch (field) {\n case 'event':\n // Set the `event type` buffer to field value\n eventType = value\n break\n case 'data':\n // Append the field value to the `data` buffer, then append a single U+000A LINE FEED(LF)\n // character to the `data` buffer.\n data = `${data}${value}\\n`\n break\n case 'id':\n // If the field value does not contain U+0000 NULL, then set the `ID` buffer to\n // the field value. Otherwise, ignore the field.\n id = value.includes('\\0') ? undefined : value\n break\n case 'retry':\n // If the field value consists of only ASCII digits, then interpret the field value as an\n // integer in base ten, and set the event stream's reconnection time to that integer.\n // Otherwise, ignore the field.\n if (/^\\d+$/.test(value)) {\n onRetry(parseInt(value, 10))\n } else {\n onError(\n new ParseError(`Invalid \\`retry\\` value: \"${value}\"`, {\n type: 'invalid-retry',\n value,\n line,\n }),\n )\n }\n break\n default:\n // Otherwise, the field is ignored.\n onError(\n new ParseError(\n `Unknown field \"${field.length > 20 ? `${field.slice(0, 20)}…` : field}\"`,\n {type: 'unknown-field', field, value, line},\n ),\n )\n break\n }\n }\n\n function dispatchEvent() {\n const shouldDispatch = data.length > 0\n if (shouldDispatch) {\n onEvent({\n id,\n event: eventType || undefined,\n // If the data buffer's last character is a U+000A LINE FEED (LF) character,\n // then remove the last character from the data buffer.\n data: data.endsWith('\\n') ? data.slice(0, -1) : data,\n })\n }\n\n // Reset for the next event\n id = undefined\n data = ''\n eventType = ''\n }\n\n function reset(options: {consume?: boolean} = {}) {\n if (incompleteLine && options.consume) {\n parseLine(incompleteLine)\n }\n\n isFirstChunk = true\n id = undefined\n data = ''\n eventType = ''\n incompleteLine = ''\n }\n\n return {feed, reset}\n}\n\n/**\n * For the given `chunk`, split it into lines according to spec, and return any remaining incomplete line.\n *\n * @param chunk - The chunk to split into lines\n * @returns A tuple containing an array of complete lines, and any remaining incomplete line\n * @internal\n */\nfunction splitLines(chunk: string): [complete: Array<string>, incomplete: string] {\n /**\n * According to the spec, a line is terminated by either:\n * - U+000D CARRIAGE RETURN U+000A LINE FEED (CRLF) character pair\n * - a single U+000A LINE FEED(LF) character not preceded by a U+000D CARRIAGE RETURN(CR) character\n * - a single U+000D CARRIAGE RETURN(CR) character not followed by a U+000A LINE FEED(LF) character\n */\n const lines: Array<string> = []\n let incompleteLine = ''\n let searchIndex = 0\n\n while (searchIndex < chunk.length) {\n // Find next line terminator\n const crIndex = chunk.indexOf('\\r', searchIndex)\n const lfIndex = chunk.indexOf('\\n', searchIndex)\n\n // Determine line end\n let lineEnd = -1\n if (crIndex !== -1 && lfIndex !== -1) {\n // CRLF case\n lineEnd = Math.min(crIndex, lfIndex)\n } else if (crIndex !== -1) {\n // CR at the end of a chunk might be part of a CRLF sequence that spans chunks,\n // so we shouldn't treat it as a line terminator (yet)\n if (crIndex === chunk.length - 1) {\n lineEnd = -1\n } else {\n lineEnd = crIndex\n }\n } else if (lfIndex !== -1) {\n lineEnd = lfIndex\n }\n\n // Extract line if terminator found\n if (lineEnd === -1) {\n // No terminator found, rest is incomplete\n incompleteLine = chunk.slice(searchIndex)\n break\n } else {\n const line = chunk.slice(searchIndex, lineEnd)\n lines.push(line)\n\n // Move past line terminator\n searchIndex = lineEnd + 1\n if (chunk[searchIndex - 1] === '\\r' && chunk[searchIndex] === '\\n') {\n searchIndex++\n }\n }\n }\n\n return [lines, incompleteLine]\n}\n","import {createParser} from './parse.ts'\nimport type {EventSourceMessage, EventSourceParser} from './types.ts'\n\n/**\n * Options for the EventSourceParserStream.\n *\n * @public\n */\nexport interface StreamOptions {\n /**\n * Behavior when a parsing error occurs.\n *\n * - A custom function can be provided to handle the error.\n * - `'terminate'` will error the stream and stop parsing.\n * - Any other value will ignore the error and continue parsing.\n *\n * @defaultValue `undefined`\n */\n onError?: ('terminate' | ((error: Error) => void)) | undefined\n\n /**\n * Callback for when a reconnection interval is sent from the server.\n *\n * @param retry - The number of milliseconds to wait before reconnecting.\n */\n onRetry?: ((retry: number) => void) | undefined\n\n /**\n * Callback for when a comment is encountered in the stream.\n *\n * @param comment - The comment encountered in the stream.\n */\n onComment?: ((comment: string) => void) | undefined\n}\n\n/**\n * A TransformStream that ingests a stream of strings and produces a stream of `EventSourceMessage`.\n *\n * @example Basic usage\n * ```\n * const eventStream =\n * response.body\n * .pipeThrough(new TextDecoderStream())\n * .pipeThrough(new EventSourceParserStream())\n * ```\n *\n * @example Terminate stream on parsing errors\n * ```\n * const eventStream =\n * response.body\n * .pipeThrough(new TextDecoderStream())\n * .pipeThrough(new EventSourceParserStream({terminateOnError: true}))\n * ```\n *\n * @public\n */\nexport class EventSourceParserStream extends TransformStream<string, EventSourceMessage> {\n constructor({onError, onRetry, onComment}: StreamOptions = {}) {\n let parser!: EventSourceParser\n\n super({\n start(controller) {\n parser = createParser({\n onEvent: (event) => {\n controller.enqueue(event)\n },\n onError(error) {\n if (onError === 'terminate') {\n controller.error(error)\n } else if (typeof onError === 'function') {\n onError(error)\n }\n\n // Ignore by default\n },\n onRetry,\n onComment,\n })\n },\n transform(chunk) {\n parser.feed(chunk)\n },\n })\n }\n}\n\nexport {type ErrorType, ParseError} from './errors.ts'\nexport type {EventSourceMessage} from './types.ts'\n","export * as core from \"../core/index.js\";\nexport * from \"./schemas.js\";\nexport * from \"./checks.js\";\nexport * from \"./errors.js\";\nexport * from \"./parse.js\";\nexport * from \"./compat.js\";\n// zod-specified\nimport { config } from \"../core/index.js\";\nimport en from \"../locales/en.js\";\nconfig(en());\nexport { globalRegistry, registry, config, function, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, toJSONSchema, TimePrecision, NEVER, } from \"../core/index.js\";\nexport * as locales from \"../locales/index.js\";\n// iso\n// must be exported from top-level\n// https://github.com/colinhacks/zod/issues/4491\nexport { ZodISODateTime, ZodISODate, ZodISOTime, ZodISODuration } from \"./iso.js\";\nexport * as iso from \"./iso.js\";\nexport * as coerce from \"./coerce.js\";\n","export * from \"./core.js\";\nexport * from \"./parse.js\";\nexport * from \"./errors.js\";\nexport * from \"./schemas.js\";\nexport * from \"./checks.js\";\nexport * from \"./versions.js\";\nexport * as util from \"./util.js\";\nexport * as regexes from \"./regexes.js\";\nexport * as locales from \"../locales/index.js\";\nexport * from \"./registries.js\";\nexport * from \"./doc.js\";\nexport * from \"./function.js\";\nexport * from \"./api.js\";\nexport * from \"./to-json-schema.js\";\nexport * as JSONSchema from \"./json-schema.js\";\n","/** A special constant with type `never` */\nexport const NEVER = Object.freeze({\n status: \"aborted\",\n});\nexport /*@__NO_SIDE_EFFECTS__*/ function $constructor(name, initializer, params) {\n function init(inst, def) {\n var _a;\n Object.defineProperty(inst, \"_zod\", {\n value: inst._zod ?? {},\n enumerable: false,\n });\n (_a = inst._zod).traits ?? (_a.traits = new Set());\n inst._zod.traits.add(name);\n initializer(inst, def);\n // support prototype modifications\n for (const k in _.prototype) {\n if (!(k in inst))\n Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });\n }\n inst._zod.constr = _;\n inst._zod.def = def;\n }\n // doesn't work if Parent has a constructor with arguments\n const Parent = params?.Parent ?? Object;\n class Definition extends Parent {\n }\n Object.defineProperty(Definition, \"name\", { value: name });\n function _(def) {\n var _a;\n const inst = params?.Parent ? new Definition() : this;\n init(inst, def);\n (_a = inst._zod).deferred ?? (_a.deferred = []);\n for (const fn of inst._zod.deferred) {\n fn();\n }\n return inst;\n }\n Object.defineProperty(_, \"init\", { value: init });\n Object.defineProperty(_, Symbol.hasInstance, {\n value: (inst) => {\n if (params?.Parent && inst instanceof params.Parent)\n return true;\n return inst?._zod?.traits?.has(name);\n },\n });\n Object.defineProperty(_, \"name\", { value: name });\n return _;\n}\n////////////////////////////// UTILITIES ///////////////////////////////////////\nexport const $brand = Symbol(\"zod_brand\");\nexport class $ZodAsyncError extends Error {\n constructor() {\n super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);\n }\n}\nexport const globalConfig = {};\nexport function config(newConfig) {\n if (newConfig)\n Object.assign(globalConfig, newConfig);\n return globalConfig;\n}\n","// functions\nexport function assertEqual(val) {\n return val;\n}\nexport function assertNotEqual(val) {\n return val;\n}\nexport function assertIs(_arg) { }\nexport function assertNever(_x) {\n throw new Error();\n}\nexport function assert(_) { }\nexport function getEnumValues(entries) {\n const numericValues = Object.values(entries).filter((v) => typeof v === \"number\");\n const values = Object.entries(entries)\n .filter(([k, _]) => numericValues.indexOf(+k) === -1)\n .map(([_, v]) => v);\n return values;\n}\nexport function joinValues(array, separator = \"|\") {\n return array.map((val) => stringifyPrimitive(val)).join(separator);\n}\nexport function jsonStringifyReplacer(_, value) {\n if (typeof value === \"bigint\")\n return value.toString();\n return value;\n}\nexport function cached(getter) {\n const set = false;\n return {\n get value() {\n if (!set) {\n const value = getter();\n Object.defineProperty(this, \"value\", { value });\n return value;\n }\n throw new Error(\"cached value already set\");\n },\n };\n}\nexport function nullish(input) {\n return input === null || input === undefined;\n}\nexport function cleanRegex(source) {\n const start = source.startsWith(\"^\") ? 1 : 0;\n const end = source.endsWith(\"$\") ? source.length - 1 : source.length;\n return source.slice(start, end);\n}\nexport function floatSafeRemainder(val, step) {\n const valDecCount = (val.toString().split(\".\")[1] || \"\").length;\n const stepString = step.toString();\n let stepDecCount = (stepString.split(\".\")[1] || \"\").length;\n if (stepDecCount === 0 && /\\d?e-\\d?/.test(stepString)) {\n const match = stepString.match(/\\d?e-(\\d?)/);\n if (match?.[1]) {\n stepDecCount = Number.parseInt(match[1]);\n }\n }\n const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;\n const valInt = Number.parseInt(val.toFixed(decCount).replace(\".\", \"\"));\n const stepInt = Number.parseInt(step.toFixed(decCount).replace(\".\", \"\"));\n return (valInt % stepInt) / 10 ** decCount;\n}\nconst EVALUATING = Symbol(\"evaluating\");\nexport function defineLazy(object, key, getter) {\n let value = undefined;\n Object.defineProperty(object, key, {\n get() {\n if (value === EVALUATING) {\n // Circular reference detected, return undefined to break the cycle\n return undefined;\n }\n if (value === undefined) {\n value = EVALUATING;\n value = getter();\n }\n return value;\n },\n set(v) {\n Object.defineProperty(object, key, {\n value: v,\n // configurable: true,\n });\n // object[key] = v;\n },\n configurable: true,\n });\n}\nexport function objectClone(obj) {\n return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));\n}\nexport function assignProp(target, prop, value) {\n Object.defineProperty(target, prop, {\n value,\n writable: true,\n enumerable: true,\n configurable: true,\n });\n}\nexport function mergeDefs(...defs) {\n const mergedDescriptors = {};\n for (const def of defs) {\n const descriptors = Object.getOwnPropertyDescriptors(def);\n Object.assign(mergedDescriptors, descriptors);\n }\n return Object.defineProperties({}, mergedDescriptors);\n}\nexport function cloneDef(schema) {\n return mergeDefs(schema._zod.def);\n}\nexport function getElement