@omnivoice/page-agent 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -3
- package/dist/esm/PageAgent.d.ts +134 -0
- package/dist/esm/page-agent.js +397 -1
- package/dist/esm/page-agent.js.map +1 -1
- package/dist/iife/page-agent.demo.js +4 -4
- package/package.json +10 -6
- package/server/agent-gateway.mjs +215 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-agent.js","names":[],"sources":["../../src/PageAgent.ts"],"sourcesContent":["/**\n * Copyright (C) 2025 Alibaba Group Holding Limited\n * All rights reserved.\n */\nimport { type AgentConfig, PageAgentCore } from '@omnivoice/core'\nimport { PageController, type PageControllerConfig } from '@omnivoice/page-controller'\nimport { Panel, type PanelConfig } from '@omnivoice/ui'\n\nexport * from '@omnivoice/core'\n\nexport type PageAgentConfig = AgentConfig & PageControllerConfig & Omit<PanelConfig, 'language'>\n\nexport class PageAgent extends PageAgentCore {\n\tpanel: Panel\n\n\tconstructor(config: PageAgentConfig) {\n\t\tconst pageController = new PageController({\n\t\t\t...config,\n\t\t\tenableMask: config.enableMask ?? true,\n\t\t})\n\n\t\tsuper({ ...config, pageController })\n\n\t\tthis.panel = new Panel(this, {\n\t\t\tlanguage: config.language,\n\t\t\tpromptForNextTask: config.promptForNextTask,\n\t\t})\n\t}\n}\n"],"mappings":";;;;;;;;;AAYA,IAAa,YAAb,cAA+B,cAAc;CAC5C;CAEA,YAAY,QAAyB;EACpC,MAAM,iBAAiB,IAAI,eAAe;GACzC,GAAG;GACH,YAAY,OAAO,cAAc;EAClC,CAAC;EAED,MAAM;GAAE,GAAG;GAAQ;EAAe,CAAC;EAEnC,KAAK,QAAQ,IAAI,MAAM,MAAM;GAC5B,UAAU,OAAO;GACjB,mBAAmB,OAAO;EAC3B,CAAC;CACF;AACD"}
|
|
1
|
+
{"version":3,"file":"page-agent.js","names":[],"sources":["../../src/voice.ts","../../src/widget.ts","../../src/PageAgent.ts"],"sourcesContent":["/**\n * FORK: módulo de voz do widget. Zero dependências — usa apenas a Web Speech API nativa do\n * navegador (reconhecimento + síntese), o que mantém o bundle leve e funciona offline/sem rede\n * além das chamadas do próprio agente.\n *\n * Filosofia (regras do laboratório):\n * - Degrada sem quebrar: se o navegador não tem mic nem síntese, `supported` informa e os\n * métodos viram no-op silenciosos — a UI decide esconder os botões, o agente segue funcionando.\n * - Espera por condição, nunca por relógio: `listen()` resolve quando chega o resultado final;\n * o timeout é só uma trava de segurança contra um reconhecimento que \"prende\" a UI.\n * - Nada de rede própria: o reconhecimento/síntese são do navegador (Chrome/Edge/Safari enviam\n * apenas o áudio necessário para o serviço de voz do SO; em rede limitada isso é mínimo).\n */\n\ntype VoiceStatus = 'idle' | 'listening' | 'speaking'\n\ninterface VoiceRecognitionLike {\n\tlang: string\n\tcontinuous: boolean\n\tinterimResults: boolean\n\tmaxAlternatives: number\n\tabort(): void\n\tstart(): void\n\tstop(): void\n\tonresult: ((event: { resultIndex: number; results: ArrayLike<ArrayLike<{ transcript: string }> & { isFinal: boolean }> }) => void) | null\n\tonerror: ((event: { error?: string }) => void) | null\n\tonend: (() => void) | null\n\tonstart: (() => void) | null\n}\n\nfunction getRecognitionCtor(): (new () => VoiceRecognitionLike) | null {\n\tconst w = globalThis as unknown as {\n\t\tSpeechRecognition?: new () => VoiceRecognitionLike\n\t\twebkitSpeechRecognition?: new () => VoiceRecognitionLike\n\t}\n\treturn w.SpeechRecognition ?? w.webkitSpeechRecognition ?? null\n}\n\nexport interface VoiceOptions {\n\t/** Idioma BCP-47 do reconhecimento e da síntese. @default 'pt-BR' */\n\tlang?: string\n\t/** Habilita o reconhecimento de fala (botão de microfone). @default true */\n\tinput?: boolean\n\t/** Habilita a síntese de fala (agente fala o resultado). @default false */\n\toutput?: boolean\n\t/** URI de uma voz específica do speechSynthesis (deixa o módulo escolher quando ausente). */\n\tvoiceURI?: string\n\t/** Velocidade da síntese (0.1–10). @default 1 */\n\trate?: number\n\t/** Tom da síntese (0–2). @default 1 */\n\tpitch?: number\n\t/** Trava de segurança para `listen()`: ms até rejeitar se o reconhecimento não terminar. @default 30000 */\n\tlistenTimeoutMs?: number\n}\n\nexport interface Voice {\n\t/** O que o navegador realmente oferece. A UI usa isto para mostrar/ocultar controles. */\n\treadonly supported: { input: boolean; output: boolean }\n\t/**\n\t * Escuta uma vez e resolve com a transcrição final. Rejeita em erro real; resolve com \"\"\n\t * quando o usuário não fala nada ('no-speech') — não é falha, é \"nada foi dito\".\n\t */\n\tlisten(): Promise<string>\n\t/** Interrompe a escuta em andamento. */\n\tstopListening(): void\n\t/** Fala um texto. `interrupt` corta o que estiver sendo dito antes de começar. */\n\tspeak(text: string, opts?: { interrupt?: boolean }): void\n\t/** Para a síntese em andamento. */\n\tstopSpeaking(): void\n\t/** Observa transições de estado (a UI mostra o indicador de \"ouvindo/falando\"). */\n\tonStatus(cb: (status: VoiceStatus) => void): () => void\n}\n\nconst STATUS_LISTENING = 'listening'\nconst STATUS_SPEAKING = 'speaking'\nconst STATUS_IDLE = 'idle'\n\nexport function createVoice(options: VoiceOptions = {}): Voice {\n\tconst lang = options.lang ?? 'pt-BR'\n\tconst rate = options.rate ?? 1\n\tconst pitch = options.pitch ?? 1\n\tconst inputEnabled = options.input ?? true\n\tconst outputEnabled = options.output ?? false\n\tconst listenTimeoutMs = options.listenTimeoutMs ?? 30_000\n\n\tconst Recognition = inputEnabled ? getRecognitionCtor() : null\n\tconst synth = typeof window !== 'undefined' ? window.speechSynthesis : undefined\n\n\tconst supported: Voice['supported'] = {\n\t\tinput: Boolean(inputEnabled && Recognition),\n\t\toutput: Boolean(outputEnabled && synth),\n\t}\n\n\tlet status: VoiceStatus = STATUS_IDLE\n\tconst statusListeners = new Set<(s: VoiceStatus) => void>()\n\tfunction setStatus(next: VoiceStatus) {\n\t\tif (status === next) return\n\t\tstatus = next\n\t\tstatusListeners.forEach(cb => {\n\t\t\ttry {\n\t\t\t\tcb(next)\n\t\t\t} catch {\n\t\t\t\t// ouvinte quebrado não derruba o módulo de voz\n\t\t\t}\n\t\t})\n\t}\n\n\tlet activeRecognition: VoiceRecognitionLike | null = null\n\tlet currentVoice: SpeechSynthesisVoice | null = null\n\n\t// A lista de vozes carrega de forma assíncrona em alguns navegadores; escolhe a melhor pt-BR\n\t// (ou a língua pedida) quando ela ficar disponível.\n\tif (synth) {\n\t\tconst pickVoice = () => {\n\t\t\tif (options.voiceURI) {\n\t\t\t\tcurrentVoice = synth.getVoices().find(v => v.voiceURI === options.voiceURI) ?? null\n\t\t\t} else {\n\t\t\t\tconst voices = synth.getVoices()\n\t\t\t\tconst prefix = lang.split('-')[0].toLowerCase()\n\t\t\t\tcurrentVoice =\n\t\t\t\t\tvoices.find(v => v.lang?.toLowerCase() === lang.toLowerCase()) ??\n\t\t\t\t\tvoices.find(v => v.lang?.toLowerCase().startsWith(prefix)) ??\n\t\t\t\t\tnull\n\t\t\t}\n\t\t}\n\t\tpickVoice()\n\t\tsynth.onvoiceschanged = pickVoice\n\t}\n\n\tfunction speak(text: string, opts?: { interrupt?: boolean }) {\n\t\tif (!synth || !outputEnabled) return\n\t\tconst clean = (text ?? '').trim()\n\t\tif (!clean) return\n\t\tif (opts?.interrupt !== false) {\n\t\t\tsynth.cancel()\n\t\t}\n\t\tconst utterance = new SpeechSynthesisUtterance(clean)\n\t\tutterance.lang = lang\n\t\tutterance.rate = rate\n\t\tutterance.pitch = pitch\n\t\tif (currentVoice) utterance.voice = currentVoice\n\t\tutterance.onend = () => setStatus(STATUS_IDLE)\n\t\tutterance.onerror = () => setStatus(STATUS_IDLE)\n\t\tsetStatus(STATUS_SPEAKING)\n\t\tsynth.speak(utterance)\n\t}\n\n\tfunction listen(): Promise<string> {\n\t\tif (!Recognition) {\n\t\t\treturn Promise.reject(new Error('Voz de entrada não suportada neste navegador'))\n\t\t}\n\t\treturn new Promise<string>((resolve, reject) => {\n\t\t\tconst recognition = new Recognition()\n\t\t\tactiveRecognition = recognition\n\t\t\tlet finalText = ''\n\t\t\tlet settled = false\n\t\t\tlet timer: ReturnType<typeof setTimeout> | undefined\n\n\t\t\tconst finish = (fn: () => void) => {\n\t\t\t\tif (settled) return\n\t\t\t\tsettled = true\n\t\t\t\tif (timer) clearTimeout(timer)\n\t\t\t\tif (activeRecognition === recognition) activeRecognition = null\n\t\t\t\tsetStatus(STATUS_IDLE)\n\t\t\t\tfn()\n\t\t\t}\n\n\t\t\t// Trava de segurança: nunca deixar a UI presa num reconhecimento que não termina.\n\t\t\ttimer = setTimeout(() => {\n\t\t\t\ttry {\n\t\t\t\t\trecognition.stop()\n\t\t\t\t} catch {\n\t\t\t\t\t/* já parado */\n\t\t\t\t}\n\t\t\t\tfinish(() => reject(new Error('Tempo de escuta esgotado')))\n\t\t\t}, listenTimeoutMs)\n\n\t\t\trecognition.lang = lang\n\t\t\trecognition.continuous = false\n\t\t\trecognition.interimResults = true\n\t\t\trecognition.maxAlternatives = 1\n\n\t\t\trecognition.onstart = () => setStatus(STATUS_LISTENING)\n\t\t\trecognition.onresult = event => {\n\t\t\t\tfor (let i = event.resultIndex; i < event.results.length; i++) {\n\t\t\t\t\tconst result = event.results[i]\n\t\t\t\t\tif (result?.isFinal) finalText = result[0]?.transcript ?? finalText\n\t\t\t\t}\n\t\t\t}\n\t\t\trecognition.onerror = event => {\n\t\t\t\tconst code = event?.error\n\t\t\t\t// 'no-speech' e 'aborted' não são falhas: o usuário não falou / cancelou.\n\t\t\t\tif (code === 'no-speech' || code === 'aborted') {\n\t\t\t\t\tfinish(() => resolve(finalText.trim()))\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tfinish(() => reject(new Error(`Erro de reconhecimento de voz: ${code ?? 'desconhecido'}`)))\n\t\t\t}\n\t\t\trecognition.onend = () => {\n\t\t\t\tfinish(() => resolve(finalText.trim()))\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\trecognition.start()\n\t\t\t} catch (error) {\n\t\t\t\tfinish(() => reject(error instanceof Error ? error : new Error(String(error))))\n\t\t\t}\n\t\t})\n\t}\n\n\treturn {\n\t\tsupported,\n\t\tlisten,\n\t\tstopListening() {\n\t\t\ttry {\n\t\t\t\tactiveRecognition?.stop()\n\t\t\t} catch {\n\t\t\t\t/* já parado */\n\t\t\t}\n\t\t\tactiveRecognition = null\n\t\t\tsetStatus(STATUS_IDLE)\n\t\t},\n\t\tspeak,\n\t\tstopSpeaking() {\n\t\t\tif (!synth) return\n\t\t\tsynth.cancel()\n\t\t\tsetStatus(STATUS_IDLE)\n\t\t},\n\t\tonStatus(cb) {\n\t\t\tstatusListeners.add(cb)\n\t\t\treturn () => statusListeners.delete(cb)\n\t\t},\n\t}\n}\n","/**\n * FORK: widget central do page-agent. É o ÚNICO ponto de integração para um projeto host:\n * uma chamada `mountWidget(config)` centraliza agente + painel + voz + config, com defaults\n * sensatos, criação lazy do agente (a página não paga startup até o widget abrir) e degradação\n * graciosa de voz. Pensado para mobile/desktop e rede limitada/offline: arquivo único, sem\n * assets externos, agente criado sob demanda.\n *\n * Uso em projeto host (npm):\n * import { mountWidget } from \"@omnivoice/page-agent\";\n * const w = mountWidget({ model, baseURL, apiKey, voice: { input: true, output: true } });\n *\n * Uso via CDN (IIFE):\n * <script src=\".../page-agent.demo.js\" data-auto-init=\"false\"></script>\n * <script>PageAgent.mountWidget({ model, baseURL, apiKey })</script>\n */\nimport { PageAgent, type PageAgentConfig } from './PageAgent'\nimport type { ExecutionResult } from '@omnivoice/core'\nimport { createVoice, type Voice, type VoiceOptions } from './voice'\nimport './widget.css'\n\nexport type { Voice, VoiceOptions }\nexport { createVoice }\n\nexport interface WidgetVoiceOptions extends VoiceOptions {\n\t/** Fala o resultado quando a tarefa termina (requer `output: true`). @default true */\n\tspeakOnComplete?: boolean\n\t/** Fala o próximo objetivo a cada passo (mais falante; útil para mãos-livres). @default false */\n\tspeakSteps?: boolean\n}\n\nexport interface WidgetOptions {\n\t// --- LLM (config central; um lugar só) ---\n\t/** Modelo. Ex.: \"gpt-4o-mini\". */\n\tmodel?: string\n\t/** Endpoint OpenAI-compatible. */\n\tbaseURL?: string\n\t/**\n\t * Chave da API. Só para uso local/sem gateway (ex.: laboratório). Em produção, prefira\n\t * `configUrl` + gateway: a chave fica no servidor e não aparece no front-end.\n\t */\n\tapiKey?: string\n\t/**\n\t * URL de uma config pública servida pelo gateway do projeto (ex.: \"/api/agent/config\").\n\t * O widget busca model/idioma/passos/voz DE LÁ — o front nunca precisa da chave. O gateway\n\t * é a autoridade: ele injeta a `apiKey` no servidor e força o modelo configurado.\n\t */\n\tconfigUrl?: string\n\t/** Customiza o corpo da request (providers específicos). */\n\ttransformRequestBody?: PageAgentConfig['transformRequestBody']\n\t/** `fetch` custom (proxy, credentials, baixa latência). */\n\tcustomFetch?: PageAgentConfig['customFetch']\n\tmaxRetries?: number\n\n\t// --- Agente ---\n\t/** Idioma da interface e do raciocínio. @default 'pt-BR' */\n\tlanguage?: PageAgentConfig['language']\n\t/** Máximo de passos por tarefa. @default 30 */\n\tmaxSteps?: number\n\t/** Instruções globais/por página. */\n\tinstructions?: PageAgentConfig['instructions']\n\t/** Ferramentas customizadas. */\n\tcustomTools?: PageAgentConfig['customTools']\n\t/** Máscula sobre a página durante a execução. @default true */\n\tenableMask?: boolean\n\t/** Expansão da viewport ao enumerar elementos. @default 0 (só o que está visível) */\n\tviewportExpansion?: number\n\t/** Pergunta pela próxima tarefa ao concluir. @default true */\n\tpromptForNextTask?: boolean\n\n\t// --- UI ---\n\t/** Posição do botão-lançador. @default 'bottom-right' */\n\tposition?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left'\n\t/** Rótulo acessível do botão-lançador. @default 'Abrir assistente da página' */\n\tlauncherLabel?: string\n\t/** Começa com o painel aberto (em vez de só o botão). @default false */\n\topen?: boolean\n\n\t// --- Voz ---\n\tvoice?: WidgetVoiceOptions\n}\n\nexport interface Widget {\n\t/** Agente centralizado (mesma instância que o painel controla). `null` até a primeira abertura. */\n\treadonly agent: PageAgent | null\n\t/** Voz centralizada (reconhecimento + síntese). `null` até a primeira abertura. */\n\treadonly voice: Voice | null\n\t/** Posição do botão-lançador. */\n\treadonly launcher: HTMLElement\n\t/** Garante config (busca o `configUrl`) + voz + agente prontos. Idempotente; devolve o agente. */\n\tready(): Promise<PageAgent>\n\t/** Executa uma tarefa programaticamente. */\n\trun(task: string): Promise<ExecutionResult>\n\t/** Para a tarefa em andamento (o agente segue reutilizável). */\n\tstop(): Promise<void>\n\t/** Abre o painel (propaga erro de config). `hide()`/`toggle()` para fechar/alternar. */\n\tshow(): Promise<void>\n\thide(): void\n\ttoggle(): void\n\t/** Atualiza config em runtime (recria o agente quando muda algo de LLM/agente). */\n\tsetConfig(patch: Partial<WidgetOptions>): void\n\t/** Remove launcher, painel e voz da página. */\n\tunmount(): void\n}\n\nconst DEFAULTS = {\n\tlanguage: 'pt-BR' as const,\n\tmaxSteps: 30,\n\tenableMask: true,\n\tviewportExpansion: 0,\n\tpromptForNextTask: true,\n\tposition: 'bottom-right' as const,\n\tlauncherLabel: 'Abrir assistente da página',\n\topen: false,\n}\n\nconst LAUNCHER_ICON =\n\t'<svg viewBox=\"0 0 24 24\" width=\"24\" height=\"24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><path d=\"M12 3l1.9 4.6L18.5 9l-4.6 1.9L12 15.5l-1.9-4.6L5.5 9l4.6-1.4L12 3z\"/><path d=\"M19 14l.8 2 2 .8-2 .8-.8 2-.8-2-2-.8 2-.8.8-2z\"/></svg>'\n\nconst MIC_ICON =\n\t'<svg viewBox=\"0 0 24 24\" width=\"18\" height=\"18\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\"><rect x=\"9\" y=\"3\" width=\"6\" height=\"11\" rx=\"3\"/><path d=\"M5 11a7 7 0 0 0 14 0M12 18v3\"/></svg>'\n\ntype LauncherPosition = { top?: string; bottom?: string; left?: string; right?: string }\n\nfunction positionCss(position: WidgetOptions['position']): LauncherPosition {\n\tswitch (position) {\n\t\tcase 'bottom-left':\n\t\t\treturn { bottom: '20px', left: '20px', right: 'auto', top: 'auto' }\n\t\tcase 'top-right':\n\t\t\treturn { top: '20px', right: '20px', bottom: 'auto', left: 'auto' }\n\t\tcase 'top-left':\n\t\t\treturn { top: '20px', left: '20px', bottom: 'auto', right: 'auto' }\n\t\tdefault:\n\t\t\treturn { bottom: '20px', right: '20px', top: 'auto', left: 'auto' }\n\t}\n}\n\nexport function mountWidget(options: WidgetOptions = {}): Widget {\n\t// UI do launcher é decisão do cliente (posição/rotulo/abrir já). Config de LLM/agente/voz\n\t// pode vir do gateway (configUrl) — resolvida lazy em ensureConfig(), antes de criar o agente.\n\tconst position = options.position ?? DEFAULTS.position\n\tconst launcherLabel = options.launcherLabel ?? DEFAULTS.launcherLabel\n\tconst open = options.open ?? DEFAULTS.open\n\n\tlet agent: PageAgent | null = null\n\tlet voice: Voice | null = null\n\tlet micButton: HTMLButtonElement | null = null\n\tlet listening = false\n\tlet configPromise: Promise<void> | null = null\n\n\t// ---- Config pública do gateway (a chave NUNCA vem aqui) ----\n\t// O front manda só a configUrl; modelo/idioma/passos/voz vêm do servidor do projeto. Se não\n\t// houver configUrl, a config é a passada em `options` (modo local, ex.: laboratório).\n\tasync function ensureConfig(): Promise<void> {\n\t\tif (configPromise) return configPromise\n\t\tif (!options.configUrl) return\n\t\tconfigPromise = (async () => {\n\t\t\tconst res = await fetch(options.configUrl as string, { headers: { accept: 'application/json' } })\n\t\t\tif (!res.ok) throw new Error(`mountWidget: configUrl respondeu ${res.status} — o gateway está no ar?`)\n\t\t\tconst server = (await res.json()) as Partial<WidgetOptions>\n\t\t\t// O gateway é a autoridade do LLM/agente/voz. Não deixa o server tocar em\n\t\t\t// baseURL/configUrl/UI (essas são do cliente) nem injetar segredos novos.\n\t\t\tfor (const key of ['model', 'language', 'maxSteps', 'promptForNextTask', 'instructions', 'voice'] as const) {\n\t\t\t\tconst value = (server as Record<string, unknown>)[key]\n\t\t\t\tif (value !== undefined && value !== null) {\n\t\t\t\t\t;(options as Record<string, unknown>)[key] = value\n\t\t\t\t}\n\t\t\t}\n\t\t})()\n\t\treturn configPromise\n\t}\n\n\t// ---- Voz (lazy: só existe após a config resolvida, pois o gateway controla \"voz ativa\") ----\n\tfunction ensureVoice(): Voice {\n\t\tif (!voice) voice = createVoice(options.voice ?? {})\n\t\treturn voice\n\t}\n\n\t// ---- Agente (lazy: config → voz → instância) ----\n\tasync function ensureAgent(): Promise<PageAgent> {\n\t\tif (agent && !agent.disposed) return agent\n\t\tawait ensureConfig()\n\t\tconst v = ensureVoice()\n\t\t// model e baseURL são o mínimo p/ o agente existir. Com configUrl, model vem do gateway;\n\t\t// baseURL o cliente sempre sabe (é onde o gateway escuta). Falhar cedo = mensagem clara.\n\t\tconst model = options.model\n\t\tconst baseURL = options.baseURL\n\t\tif (!model || !baseURL) {\n\t\t\tthrow new Error(\n\t\t\t\toptions.configUrl\n\t\t\t\t\t? 'mountWidget: o gateway não enviou `model` e/ou falta `baseURL` no front. Confira AGENT_MODEL no gateway e a baseURL do widget.'\n\t\t\t\t\t: 'mountWidget: configure `model` e `baseURL` (config central do LLM) antes de abrir o agente.',\n\t\t\t)\n\t\t}\n\t\tagent = new PageAgent({\n\t\t\tmodel,\n\t\t\tbaseURL,\n\t\t\tapiKey: options.apiKey,\n\t\t\ttransformRequestBody: options.transformRequestBody,\n\t\t\tcustomFetch: options.customFetch,\n\t\t\tmaxRetries: options.maxRetries,\n\t\t\tlanguage: options.language ?? DEFAULTS.language,\n\t\t\tmaxSteps: options.maxSteps ?? DEFAULTS.maxSteps,\n\t\t\tenableMask: options.enableMask ?? DEFAULTS.enableMask,\n\t\t\tviewportExpansion: options.viewportExpansion ?? DEFAULTS.viewportExpansion,\n\t\t\tinstructions: options.instructions,\n\t\t\tcustomTools: options.customTools,\n\t\t\tpromptForNextTask: options.promptForNextTask ?? DEFAULTS.promptForNextTask,\n\t\t})\n\t\twireVoiceOutput(agent, v)\n\t\tinjectMicButton(agent, v)\n\t\treturn agent\n\t}\n\n\t// ---- Voz de saída (o gateway já decidiu se fala; a UI só executa) ----\n\tfunction wireVoiceOutput(a: PageAgent, v: Voice) {\n\t\t// lido AQUI (depois do ensureConfig) para refletir a decisão do gateway\n\t\tconst speakOnComplete = options.voice?.speakOnComplete ?? true\n\t\tconst speakSteps = options.voice?.speakSteps ?? false\n\t\tconst onStatus = () => {\n\t\t\tconst status = a.status\n\t\t\tconst result = a.lastResult\n\t\t\tif (status === 'completed' || status === 'error') {\n\t\t\t\tif (speakOnComplete && v.supported.output) {\n\t\t\t\t\tif (status === 'error') {\n\t\t\t\t\t\tv.speak('A tarefa encontrou um problema e foi parada.')\n\t\t\t\t\t} else if (result?.success) {\n\t\t\t\t\t\tv.speak('Tarefa concluída com sucesso.')\n\t\t\t\t\t} else {\n\t\t\t\t\t\tv.speak('A tarefa terminou, mas o resultado não foi confirmado.')\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif (speakSteps && status === 'running' && v.supported.output) {\n\t\t\t\tconst lastStep = [...a.history].reverse().find(h => h.type === 'step')\n\t\t\t\tconst goal = (lastStep as { reflection?: { next_goal?: string } } | undefined)?.reflection?.next_goal\n\t\t\t\tif (goal) v.speak(goal, { interrupt: true })\n\t\t\t}\n\t\t}\n\t\ta.addEventListener('statuschange', onStatus)\n\t\ta.addEventListener('activity', (event: Event) => {\n\t\t\tconst detail = (event as CustomEvent).detail as { type?: string; message?: string } | undefined\n\t\t\tif (detail?.type === 'error' && detail.message && v.supported.output) {\n\t\t\t\tv.speak(detail.message, { interrupt: true })\n\t\t\t}\n\t\t})\n\t}\n\n\t// ---- Botão de microfone (injetado no input de tarefa do painel) ----\n\tfunction injectMicButton(a: PageAgent, v: Voice) {\n\t\tconst wrapper = a.panel.wrapper\n\t\tconst input = wrapper.querySelector('input') as HTMLInputElement | null\n\t\tif (!input || !v.supported.input) return\n\t\tif (wrapper.querySelector('[data-page-agent-voice=\"mic\"]')) return\n\t\tif (micButton) micButton.remove()\n\n\t\tmicButton = document.createElement('button')\n\t\tmicButton.type = 'button'\n\t\tmicButton.className = 'page-agent-voice-mic'\n\t\tmicButton.setAttribute('data-page-agent-voice', 'mic')\n\t\tmicButton.setAttribute('aria-label', 'Ditar tarefa por voz')\n\t\tmicButton.title = 'Ditar tarefa por voz'\n\t\tmicButton.innerHTML = MIC_ICON\n\t\tmicButton.style.display = 'inline-flex'\n\n\t\t// Insere o mic junto ao input (dentro do mesmo contêiner, antes do input).\n\t\tconst host = input.parentElement ?? wrapper\n\t\thost.insertBefore(micButton, input)\n\n\t\tconst unsubscribe = v.onStatus(s => {\n\t\t\tmicButton?.classList.toggle('is-listening', s === 'listening')\n\t\t})\n\n\t\tmicButton.addEventListener('click', async () => {\n\t\t\tif (listening) {\n\t\t\t\tv.stopListening()\n\t\t\t\treturn\n\t\t\t}\n\t\t\tlistening = true\n\t\t\ttry {\n\t\t\t\tconst transcript = await v.listen()\n\t\t\t\tif (transcript) {\n\t\t\t\t\tinput.value = transcript\n\t\t\t\t\tinput.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }))\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\t// Sem rede/permissão de mic: degrada para digitar. O widget não quebra.\n\t\t\t\tinput.setAttribute('placeholder', error instanceof Error ? error.message : 'Não foi possível ouvir; digite a tarefa.')\n\t\t\t\tsetTimeout(() => input.removeAttribute('placeholder'), 6000)\n\t\t\t} finally {\n\t\t\t\tlistening = false\n\t\t\t}\n\t\t})\n\n\t\tvoid unsubscribe\n\t}\n\n\t// ---- Launcher (FAB) ----\n\tconst launcher = document.createElement('button')\n\tlauncher.type = 'button'\n\tlauncher.className = 'page-agent-widget-launcher'\n\tlauncher.setAttribute('aria-label', launcherLabel)\n\tlauncher.title = launcherLabel\n\tlauncher.innerHTML = LAUNCHER_ICON\n\tconst pos = positionCss(position)\n\tObject.assign(launcher.style, pos)\n\n\tlet panelVisible = false\n\t// silent=true (clique no FAB / abrir inicial): loga e deixa o botão disponível para retry.\n\t// silent=false (w.show()/w.ready()/w.run): propaga o erro para quem chamou programaticamente.\n\tasync function openPanel(silent = false) {\n\t\ttry {\n\t\t\tconst a = await ensureAgent()\n\t\t\ta.panel.show()\n\t\t\tpanelVisible = true\n\t\t} catch (error) {\n\t\t\tif (silent) console.error('[page-agent-widget] não abriu o agente:', error)\n\t\t\telse throw error\n\t\t}\n\t}\n\tfunction closePanel() {\n\t\tagent?.panel.hide?.()\n\t\tpanelVisible = false\n\t}\n\tlauncher.addEventListener('click', () => {\n\t\tif (panelVisible) {\n\t\t\tclosePanel()\n\t\t} else {\n\t\t\tvoid openPanel(true)\n\t\t}\n\t})\n\n\tdocument.body.appendChild(launcher)\n\n\tif (open) {\n\t\tvoid openPanel(true)\n\t}\n\n\t// ---- Handle ----\n\tconst widget: Widget = {\n\t\tget agent() {\n\t\t\treturn agent\n\t\t},\n\t\tget voice() {\n\t\t\treturn voice\n\t\t},\n\t\tlauncher,\n\t\tready() {\n\t\t\treturn ensureAgent()\n\t\t},\n\t\tasync run(task: string) {\n\t\t\tconst a = await ensureAgent()\n\t\t\treturn await a.execute(task)\n\t\t},\n\t\tasync stop() {\n\t\t\tif (agent) await agent.stop()\n\t\t},\n\t\tshow() {\n\t\t\treturn openPanel(false)\n\t\t},\n\t\thide() {\n\t\t\tclosePanel()\n\t\t},\n\t\ttoggle() {\n\t\t\tlauncher.click()\n\t\t},\n\t\tsetConfig(patch: Partial<WidgetOptions>) {\n\t\t\t// Config de LLM/agente muda a identidade da instância: recria o agente na próxima abertura.\n\t\t\tObject.assign(options, patch)\n\t\t\tif (agent) {\n\t\t\t\tagent.dispose()\n\t\t\t\tagent = null\n\t\t\t}\n\t\t\tif (panelVisible) {\n\t\t\t\tpanelVisible = false\n\t\t\t\tvoid openPanel(true)\n\t\t\t}\n\t\t},\n\t\tunmount() {\n\t\t\tvoice?.stopSpeaking()\n\t\t\tvoice?.stopListening()\n\t\t\tagent?.dispose()\n\t\t\tagent = null\n\t\t\tvoice = null\n\t\t\tmicButton?.remove()\n\t\t\tmicButton = null\n\t\t\tlauncher.remove()\n\t\t},\n\t}\n\n\treturn widget\n}\n","/**\n * Copyright (C) 2025 Alibaba Group Holding Limited\n * All rights reserved.\n */\nimport { type AgentConfig, PageAgentCore } from '@omnivoice/core'\nimport { PageController, type PageControllerConfig } from '@omnivoice/page-controller'\nimport { Panel, type PanelConfig } from '@omnivoice/ui'\n\nexport * from '@omnivoice/core'\nexport { mountWidget, createVoice, type Widget, type WidgetOptions, type WidgetVoiceOptions, type Voice, type VoiceOptions } from './widget'\n\nexport type PageAgentConfig = AgentConfig & PageControllerConfig & Omit<PanelConfig, 'language'>\n\nexport class PageAgent extends PageAgentCore {\n\tpanel: Panel\n\n\tconstructor(config: PageAgentConfig) {\n\t\tconst pageController = new PageController({\n\t\t\t...config,\n\t\t\tenableMask: config.enableMask ?? true,\n\t\t})\n\n\t\tsuper({ ...config, pageController })\n\n\t\tthis.panel = new Panel(this, {\n\t\t\tlanguage: config.language,\n\t\t\tpromptForNextTask: config.promptForNextTask,\n\t\t})\n\t}\n}\n"],"mappings":";;;;;;AA8BA,SAAS,qBAA8D;CACtE,MAAM,IAAI;CAIV,OAAO,EAAE,qBAAqB,EAAE,2BAA2B;AAC5D;AAqCA,IAAM,mBAAmB;AACzB,IAAM,kBAAkB;AACxB,IAAM,cAAc;AAEpB,SAAgB,YAAY,UAAwB,CAAC,GAAU;CAC9D,MAAM,OAAO,QAAQ,QAAQ;CAC7B,MAAM,OAAO,QAAQ,QAAQ;CAC7B,MAAM,QAAQ,QAAQ,SAAS;CAC/B,MAAM,eAAe,QAAQ,SAAS;CACtC,MAAM,gBAAgB,QAAQ,UAAU;CACxC,MAAM,kBAAkB,QAAQ,mBAAmB;CAEnD,MAAM,cAAc,eAAe,mBAAmB,IAAI;CAC1D,MAAM,QAAQ,OAAO,WAAW,cAAc,OAAO,kBAAkB,KAAA;CAEvE,MAAM,YAAgC;EACrC,OAAO,QAAQ,gBAAgB,WAAW;EAC1C,QAAQ,QAAQ,iBAAiB,KAAK;CACvC;CAEA,IAAI,SAAsB;CAC1B,MAAM,kCAAkB,IAAI,IAA8B;CAC1D,SAAS,UAAU,MAAmB;EACrC,IAAI,WAAW,MAAM;EACrB,SAAS;EACT,gBAAgB,SAAQ,OAAM;GAC7B,IAAI;IACH,GAAG,IAAI;GACR,QAAQ,CAER;EACD,CAAC;CACF;CAEA,IAAI,oBAAiD;CACrD,IAAI,eAA4C;CAIhD,IAAI,OAAO;EACV,MAAM,kBAAkB;GACvB,IAAI,QAAQ,UACX,eAAe,MAAM,UAAU,CAAC,CAAC,MAAK,MAAK,EAAE,aAAa,QAAQ,QAAQ,KAAK;QACzE;IACN,MAAM,SAAS,MAAM,UAAU;IAC/B,MAAM,SAAS,KAAK,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,YAAY;IAC9C,eACC,OAAO,MAAK,MAAK,EAAE,MAAM,YAAY,MAAM,KAAK,YAAY,CAAC,KAC7D,OAAO,MAAK,MAAK,EAAE,MAAM,YAAY,CAAC,CAAC,WAAW,MAAM,CAAC,KACzD;GACF;EACD;EACA,UAAU;EACV,MAAM,kBAAkB;CACzB;CAEA,SAAS,MAAM,MAAc,MAAgC;EAC5D,IAAI,CAAC,SAAS,CAAC,eAAe;EAC9B,MAAM,SAAS,QAAQ,GAAA,CAAI,KAAK;EAChC,IAAI,CAAC,OAAO;EACZ,IAAI,MAAM,cAAc,OACvB,MAAM,OAAO;EAEd,MAAM,YAAY,IAAI,yBAAyB,KAAK;EACpD,UAAU,OAAO;EACjB,UAAU,OAAO;EACjB,UAAU,QAAQ;EAClB,IAAI,cAAc,UAAU,QAAQ;EACpC,UAAU,cAAc,UAAU,WAAW;EAC7C,UAAU,gBAAgB,UAAU,WAAW;EAC/C,UAAU,eAAe;EACzB,MAAM,MAAM,SAAS;CACtB;CAEA,SAAS,SAA0B;EAClC,IAAI,CAAC,aACJ,OAAO,QAAQ,uBAAO,IAAI,MAAM,8CAA8C,CAAC;EAEhF,OAAO,IAAI,SAAiB,SAAS,WAAW;GAC/C,MAAM,cAAc,IAAI,YAAY;GACpC,oBAAoB;GACpB,IAAI,YAAY;GAChB,IAAI,UAAU;GACd,IAAI;GAEJ,MAAM,UAAU,OAAmB;IAClC,IAAI,SAAS;IACb,UAAU;IACV,IAAI,OAAO,aAAa,KAAK;IAC7B,IAAI,sBAAsB,aAAa,oBAAoB;IAC3D,UAAU,WAAW;IACrB,GAAG;GACJ;GAGA,QAAQ,iBAAiB;IACxB,IAAI;KACH,YAAY,KAAK;IAClB,QAAQ,CAER;IACA,aAAa,uBAAO,IAAI,MAAM,0BAA0B,CAAC,CAAC;GAC3D,GAAG,eAAe;GAElB,YAAY,OAAO;GACnB,YAAY,aAAa;GACzB,YAAY,iBAAiB;GAC7B,YAAY,kBAAkB;GAE9B,YAAY,gBAAgB,UAAU,gBAAgB;GACtD,YAAY,YAAW,UAAS;IAC/B,KAAK,IAAI,IAAI,MAAM,aAAa,IAAI,MAAM,QAAQ,QAAQ,KAAK;KAC9D,MAAM,SAAS,MAAM,QAAQ;KAC7B,IAAI,QAAQ,SAAS,YAAY,OAAO,EAAE,EAAE,cAAc;IAC3D;GACD;GACA,YAAY,WAAU,UAAS;IAC9B,MAAM,OAAO,OAAO;IAEpB,IAAI,SAAS,eAAe,SAAS,WAAW;KAC/C,aAAa,QAAQ,UAAU,KAAK,CAAC,CAAC;KACtC;IACD;IACA,aAAa,uBAAO,IAAI,MAAM,kCAAkC,QAAQ,gBAAgB,CAAC,CAAC;GAC3F;GACA,YAAY,cAAc;IACzB,aAAa,QAAQ,UAAU,KAAK,CAAC,CAAC;GACvC;GAEA,IAAI;IACH,YAAY,MAAM;GACnB,SAAS,OAAO;IACf,aAAa,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC,CAAC;GAC/E;EACD,CAAC;CACF;CAEA,OAAO;EACN;EACA;EACA,gBAAgB;GACf,IAAI;IACH,mBAAmB,KAAK;GACzB,QAAQ,CAER;GACA,oBAAoB;GACpB,UAAU,WAAW;EACtB;EACA;EACA,eAAe;GACd,IAAI,CAAC,OAAO;GACZ,MAAM,OAAO;GACb,UAAU,WAAW;EACtB;EACA,SAAS,IAAI;GACZ,gBAAgB,IAAI,EAAE;GACtB,aAAa,gBAAgB,OAAO,EAAE;EACvC;CACD;AACD;;;;;;;;;;;;;;;;;;ACjIA,IAAM,WAAW;CAChB,UAAU;CACV,UAAU;CACV,YAAY;CACZ,mBAAmB;CACnB,mBAAmB;CACnB,UAAU;CACV,eAAe;CACf,MAAM;AACP;AAEA,IAAM,gBACL;AAED,IAAM,WACL;AAID,SAAS,YAAY,UAAuD;CAC3E,QAAQ,UAAR;EACC,KAAK,eACJ,OAAO;GAAE,QAAQ;GAAQ,MAAM;GAAQ,OAAO;GAAQ,KAAK;EAAO;EACnE,KAAK,aACJ,OAAO;GAAE,KAAK;GAAQ,OAAO;GAAQ,QAAQ;GAAQ,MAAM;EAAO;EACnE,KAAK,YACJ,OAAO;GAAE,KAAK;GAAQ,MAAM;GAAQ,QAAQ;GAAQ,OAAO;EAAO;EACnE,SACC,OAAO;GAAE,QAAQ;GAAQ,OAAO;GAAQ,KAAK;GAAQ,MAAM;EAAO;CACpE;AACD;AAEA,SAAgB,YAAY,UAAyB,CAAC,GAAW;CAGhE,MAAM,WAAW,QAAQ,YAAY,SAAS;CAC9C,MAAM,gBAAgB,QAAQ,iBAAiB,SAAS;CACxD,MAAM,OAAO,QAAQ,QAAQ,SAAS;CAEtC,IAAI,QAA0B;CAC9B,IAAI,QAAsB;CAC1B,IAAI,YAAsC;CAC1C,IAAI,YAAY;CAChB,IAAI,gBAAsC;CAK1C,eAAe,eAA8B;EAC5C,IAAI,eAAe,OAAO;EAC1B,IAAI,CAAC,QAAQ,WAAW;EACxB,iBAAiB,YAAY;GAC5B,MAAM,MAAM,MAAM,MAAM,QAAQ,WAAqB,EAAE,SAAS,EAAE,QAAQ,mBAAmB,EAAE,CAAC;GAChG,IAAI,CAAC,IAAI,IAAI,MAAM,IAAI,MAAM,oCAAoC,IAAI,OAAO,yBAAyB;GACrG,MAAM,SAAU,MAAM,IAAI,KAAK;GAG/B,KAAK,MAAM,OAAO;IAAC;IAAS;IAAY;IAAY;IAAqB;IAAgB;GAAO,GAAY;IAC3G,MAAM,QAAS,OAAmC;IAClD,IAAI,UAAU,KAAA,KAAa,UAAU,MACnC,QAAqC,OAAO;GAE/C;EACD,EAAA,CAAG;EACH,OAAO;CACR;CAGA,SAAS,cAAqB;EAC7B,IAAI,CAAC,OAAO,QAAQ,YAAY,QAAQ,SAAS,CAAC,CAAC;EACnD,OAAO;CACR;CAGA,eAAe,cAAkC;EAChD,IAAI,SAAS,CAAC,MAAM,UAAU,OAAO;EACrC,MAAM,aAAa;EACnB,MAAM,IAAI,YAAY;EAGtB,MAAM,QAAQ,QAAQ;EACtB,MAAM,UAAU,QAAQ;EACxB,IAAI,CAAC,SAAS,CAAC,SACd,MAAM,IAAI,MACT,QAAQ,YACL,mIACA,6FACJ;EAED,QAAQ,IAAI,UAAU;GACrB;GACA;GACA,QAAQ,QAAQ;GAChB,sBAAsB,QAAQ;GAC9B,aAAa,QAAQ;GACrB,YAAY,QAAQ;GACpB,UAAU,QAAQ,YAAY,SAAS;GACvC,UAAU,QAAQ,YAAY,SAAS;GACvC,YAAY,QAAQ,cAAc,SAAS;GAC3C,mBAAmB,QAAQ,qBAAqB,SAAS;GACzD,cAAc,QAAQ;GACtB,aAAa,QAAQ;GACrB,mBAAmB,QAAQ,qBAAqB,SAAS;EAC1D,CAAC;EACD,gBAAgB,OAAO,CAAC;EACxB,gBAAgB,OAAO,CAAC;EACxB,OAAO;CACR;CAGA,SAAS,gBAAgB,GAAc,GAAU;EAEhD,MAAM,kBAAkB,QAAQ,OAAO,mBAAmB;EAC1D,MAAM,aAAa,QAAQ,OAAO,cAAc;EAChD,MAAM,iBAAiB;GACtB,MAAM,SAAS,EAAE;GACjB,MAAM,SAAS,EAAE;GACjB,IAAI,WAAW,eAAe,WAAW,SAAS;IACjD,IAAI,mBAAmB,EAAE,UAAU,QAAQ;KAC1C,IAAI,WAAW,SACd,EAAE,MAAM,8CAA8C;UAChD,IAAI,QAAQ,SAClB,EAAE,MAAM,+BAA+B;UAEvC,EAAE,MAAM,wDAAwD;IAElE;IACA;GACD;GACA,IAAI,cAAc,WAAW,aAAa,EAAE,UAAU,QAAQ;IAE7D,MAAM,OADW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAK,MAAK,EAAE,SAAS,MACjD,CAAA,EAAkE,YAAY;IAC5F,IAAI,MAAM,EAAE,MAAM,MAAM,EAAE,WAAW,KAAK,CAAC;GAC5C;EACD;EACA,EAAE,iBAAiB,gBAAgB,QAAQ;EAC3C,EAAE,iBAAiB,aAAa,UAAiB;GAChD,MAAM,SAAU,MAAsB;GACtC,IAAI,QAAQ,SAAS,WAAW,OAAO,WAAW,EAAE,UAAU,QAC7D,EAAE,MAAM,OAAO,SAAS,EAAE,WAAW,KAAK,CAAC;EAE7C,CAAC;CACF;CAGA,SAAS,gBAAgB,GAAc,GAAU;EAChD,MAAM,UAAU,EAAE,MAAM;EACxB,MAAM,QAAQ,QAAQ,cAAc,OAAO;EAC3C,IAAI,CAAC,SAAS,CAAC,EAAE,UAAU,OAAO;EAClC,IAAI,QAAQ,cAAc,iCAA+B,GAAG;EAC5D,IAAI,WAAW,UAAU,OAAO;EAEhC,YAAY,SAAS,cAAc,QAAQ;EAC3C,UAAU,OAAO;EACjB,UAAU,YAAY;EACtB,UAAU,aAAa,yBAAyB,KAAK;EACrD,UAAU,aAAa,cAAc,sBAAsB;EAC3D,UAAU,QAAQ;EAClB,UAAU,YAAY;EACtB,UAAU,MAAM,UAAU;EAI1B,CADa,MAAM,iBAAiB,QAAA,CAC/B,aAAa,WAAW,KAAK;EAEd,EAAE,UAAS,MAAK;GACnC,WAAW,UAAU,OAAO,gBAAgB,MAAM,WAAW;EAC9D,CAAC;EAED,UAAU,iBAAiB,SAAS,YAAY;GAC/C,IAAI,WAAW;IACd,EAAE,cAAc;IAChB;GACD;GACA,YAAY;GACZ,IAAI;IACH,MAAM,aAAa,MAAM,EAAE,OAAO;IAClC,IAAI,YAAY;KACf,MAAM,QAAQ;KACd,MAAM,cAAc,IAAI,cAAc,WAAW;MAAE,KAAK;MAAS,SAAS;KAAK,CAAC,CAAC;IAClF;GACD,SAAS,OAAO;IAEf,MAAM,aAAa,eAAe,iBAAiB,QAAQ,MAAM,UAAU,0CAA0C;IACrH,iBAAiB,MAAM,gBAAgB,aAAa,GAAG,GAAI;GAC5D,UAAU;IACT,YAAY;GACb;EACD,CAAC;CAGF;CAGA,MAAM,WAAW,SAAS,cAAc,QAAQ;CAChD,SAAS,OAAO;CAChB,SAAS,YAAY;CACrB,SAAS,aAAa,cAAc,aAAa;CACjD,SAAS,QAAQ;CACjB,SAAS,YAAY;CACrB,MAAM,MAAM,YAAY,QAAQ;CAChC,OAAO,OAAO,SAAS,OAAO,GAAG;CAEjC,IAAI,eAAe;CAGnB,eAAe,UAAU,SAAS,OAAO;EACxC,IAAI;GAEH,CAAA,MADgB,YAAY,EAAA,CAC1B,MAAM,KAAK;GACb,eAAe;EAChB,SAAS,OAAO;GACf,IAAI,QAAQ,QAAQ,MAAM,2CAA2C,KAAK;QACrE,MAAM;EACZ;CACD;CACA,SAAS,aAAa;EACrB,OAAO,MAAM,OAAO;EACpB,eAAe;CAChB;CACA,SAAS,iBAAiB,eAAe;EACxC,IAAI,cACH,WAAW;OAEX,UAAe,IAAI;CAErB,CAAC;CAED,SAAS,KAAK,YAAY,QAAQ;CAElC,IAAI,MACH,UAAe,IAAI;CAuDpB,OAAO;EAlDN,IAAI,QAAQ;GACX,OAAO;EACR;EACA,IAAI,QAAQ;GACX,OAAO;EACR;EACA;EACA,QAAQ;GACP,OAAO,YAAY;EACpB;EACA,MAAM,IAAI,MAAc;GAEvB,OAAO,OAAM,MADG,YAAY,EAAA,CACb,QAAQ,IAAI;EAC5B;EACA,MAAM,OAAO;GACZ,IAAI,OAAO,MAAM,MAAM,KAAK;EAC7B;EACA,OAAO;GACN,OAAO,UAAU,KAAK;EACvB;EACA,OAAO;GACN,WAAW;EACZ;EACA,SAAS;GACR,SAAS,MAAM;EAChB;EACA,UAAU,OAA+B;GAExC,OAAO,OAAO,SAAS,KAAK;GAC5B,IAAI,OAAO;IACV,MAAM,QAAQ;IACd,QAAQ;GACT;GACA,IAAI,cAAc;IACjB,eAAe;IACf,UAAe,IAAI;GACpB;EACD;EACA,UAAU;GACT,OAAO,aAAa;GACpB,OAAO,cAAc;GACrB,OAAO,QAAQ;GACf,QAAQ;GACR,QAAQ;GACR,WAAW,OAAO;GAClB,YAAY;GACZ,SAAS,OAAO;EACjB;CAGM;AACR;;;;;;;AC1XA,IAAa,YAAb,cAA+B,cAAc;CAC5C;CAEA,YAAY,QAAyB;EACpC,MAAM,iBAAiB,IAAI,eAAe;GACzC,GAAG;GACH,YAAY,OAAO,cAAc;EAClC,CAAC;EAED,MAAM;GAAE,GAAG;GAAQ;EAAe,CAAC;EAEnC,KAAK,QAAQ,IAAI,MAAM,MAAM;GAC5B,UAAU,OAAO;GACjB,mBAAmB,OAAO;EAC3B,CAAC;CACF;AACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){var __vite_style__=document.createElement(`style`);__vite_style__.textContent=`._wrapper_1ooyb_1{z-index:2147483641;cursor:wait;display:none;position:fixed;inset:0;overflow:hidden}._wrapper_1ooyb_1._visible_1ooyb_11{display:block}._cursor_1dgwb_2{width:var(--cursor-size,75px);height:var(--cursor-size,75px);pointer-events:none;z-index:10000;position:absolute}._cursorBorder_1dgwb_10{transform-origin:50%;background:linear-gradient(45deg,#39b6ff,#bd45fb);width:100%;height:100%;margin-top:-18px;margin-left:-10px;position:absolute;transform:rotate(-135deg)scale(1.2);-webkit-mask-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20fill='none'%3e%3cg%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='none'%20stroke='%23000000'%20stroke-width='6'%20stroke-miterlimit='10'%20style='stroke:%20light-dark(rgb(0,%200,%200),%20rgb(255,%20255,%20255));'/%3e%3c/g%3e%3c/svg%3e");mask-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20fill='none'%3e%3cg%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='none'%20stroke='%23000000'%20stroke-width='6'%20stroke-miterlimit='10'%20style='stroke:%20light-dark(rgb(0,%200,%200),%20rgb(255,%20255,%20255));'/%3e%3c/g%3e%3c/svg%3e");-webkit-mask-size:100% 100%;mask-size:100% 100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}._cursorFilling_1dgwb_25{transform-origin:50%;background:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%3e%3cdefs%3e%3c/defs%3e%3cg%20xmlns='http://www.w3.org/2000/svg'%20style='filter:%20drop-shadow(light-dark(rgba(0,%200,%200,%200.4),%20rgba(237,%20237,%20237,%200.4))%203px%204px%204px);'%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='%23ffffff'%20stroke='none'%20style='fill:%20%23ffffff;'/%3e%3c/g%3e%3c/svg%3e") 0 0/100% 100% no-repeat;width:100%;height:100%;margin-top:-18px;margin-left:-10px;position:absolute;transform:rotate(-135deg)scale(1.2)}._cursorRipple_1dgwb_39{pointer-events:none;width:100%;height:100%;margin-top:-50%;margin-left:-50%;position:absolute}._cursorRipple_1dgwb_39:after{content:"";opacity:0;border:4px solid #39b6ff;border-radius:50%;position:absolute;inset:0}._cursor_1dgwb_2._clicking_1dgwb_57 ._cursorRipple_1dgwb_39:after{animation:.3s ease-out forwards _cursor-ripple_1dgwb_1}@keyframes _cursor-ripple_1dgwb_1{0%{opacity:1;transform:scale(0)}to{opacity:0;transform:scale(2)}}._wrapper_1rq3n_1{opacity:0;z-index:2147483642;box-sizing:border-box;position:fixed;bottom:100px;left:50%;overflow:visible;transform:translate(-50%)translateY(20px)}._wrapper_1rq3n_1 *{box-sizing:border-box}._wrapper_1rq3n_1{--width:360px;--height:40px;--border-radius:12px;--side-space:12px;--history-width:calc(var(--width) - var(--side-space) * 2);--color-1:#39b6ff;--color-2:#bd45fb;--color-3:#ff5733;--color-4:#ffd600;width:var(--width);height:var(--height);transition:all .3s ease-in-out}@media (width<=640px){._wrapper_1rq3n_1{--width:calc(100vw - 16px);--side-space:8px;width:var(--width);bottom:calc(12px + env(safe-area-inset-bottom,0px));--history-max:min(60vh, calc(100dvh - 120px - var(--height)))}}@media (prefers-reduced-motion:reduce){._wrapper_1rq3n_1{transition:none}._wrapper_1rq3n_1 *{transition:none!important;animation:none!important}}._wrapper_1rq3n_1 ._background_1rq3n_55{border-radius:calc(var(--border-radius) + 4px);filter:blur(16px);position:absolute;inset:-2px -8px;overflow:hidden}._wrapper_1rq3n_1 ._background_1rq3n_55:before{content:"";z-index:-1;pointer-events:none;background-image:linear-gradient(to bottom left, var(--color-1), var(--color-2), var(--color-1));width:100%;height:100%;animation:2s linear infinite _mask-running_1rq3n_1;position:absolute;top:0;left:0}._wrapper_1rq3n_1 ._background_1rq3n_55:after{content:"";z-index:-1;pointer-events:none;background-image:linear-gradient(to bottom left, var(--color-2), var(--color-1), var(--color-2));width:100%;height:100%;animation:2s linear 1s infinite _mask-running_1rq3n_1;position:absolute;top:0;left:0}@keyframes _mask-running_1rq3n_1{0%{transform:translate(-100%)}to{transform:translate(100%)}}._header_1rq3n_115{-webkit-user-select:none;user-select:none;cursor:pointer;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-radius:var(--border-radius);background:#00000080 padding-box padding-box;flex-shrink:0;justify-content:space-between;align-items:center;padding:8px 12px;display:flex;position:absolute;inset:0;box-shadow:0 0 0 2px #fff6,0 0 5px 1px #ffffff4d}._header_1rq3n_115 ._statusSection_1rq3n_137{flex:1;align-items:center;gap:8px;min-height:24px;display:flex}._header_1rq3n_115 ._statusSection_1rq3n_137 ._indicator_1rq3n_144{background:#ffffff80;border-radius:50%;flex-shrink:0;width:6px;height:6px;animation:none}._header_1rq3n_115 ._statusSection_1rq3n_137 ._indicator_1rq3n_144._thinking_1rq3n_153{background:#39b6ff;animation:.8s ease-in-out infinite _pulse_1rq3n_1}._header_1rq3n_115 ._statusSection_1rq3n_137 ._indicator_1rq3n_144._tool_executing_1rq3n_158{background:#bd45fb;animation:.6s ease-in-out infinite _pulse_1rq3n_1}._header_1rq3n_115 ._statusSection_1rq3n_137 ._indicator_1rq3n_144._retry_1rq3n_163{background:#ffd600;animation:1s ease-in-out infinite _retryPulse_1rq3n_1}._header_1rq3n_115 ._statusSection_1rq3n_137 ._indicator_1rq3n_144._completed_1rq3n_169,._header_1rq3n_115 ._statusSection_1rq3n_137 ._indicator_1rq3n_144._input_1rq3n_170,._header_1rq3n_115 ._statusSection_1rq3n_137 ._indicator_1rq3n_144._output_1rq3n_171{background:#22c55e;animation:none}._header_1rq3n_115 ._statusSection_1rq3n_137 ._indicator_1rq3n_144._error_1rq3n_176{background:#ef4444;animation:none}._header_1rq3n_115 ._statusSection_1rq3n_137 ._statusText_1rq3n_182{color:#fff;align-items:center;min-height:24px;font-size:12px;font-weight:500;line-height:1;transition:all .3s ease-in-out;display:flex;position:relative;overflow:hidden}._header_1rq3n_115 ._statusSection_1rq3n_137 ._statusText_1rq3n_182._fadeOut_1rq3n_194{animation:.3s forwards _statusTextFadeOut_1rq3n_1}._header_1rq3n_115 ._statusSection_1rq3n_137 ._statusText_1rq3n_182._fadeIn_1rq3n_198{animation:.3s forwards _statusTextFadeIn_1rq3n_1}._header_1rq3n_115 ._controls_1rq3n_204{align-items:center;gap:4px;display:flex}._header_1rq3n_115 ._controls_1rq3n_204 ._controlButton_1rq3n_209{color:#fff;cursor:pointer;background:#ffffff1a;border:none;border-radius:4px;justify-content:center;align-items:center;width:24px;height:24px;font-size:12px;line-height:1;display:flex}._header_1rq3n_115 ._controls_1rq3n_204 ._controlButton_1rq3n_209:hover{background:#fff3}._header_1rq3n_115 ._controls_1rq3n_204 ._stopButton_1rq3n_228{color:#ff2929;background:#ef444433;font-weight:600}._header_1rq3n_115 ._controls_1rq3n_204 ._stopButton_1rq3n_228:hover{background:#ef44444d}@keyframes _statusTextFadeIn_1rq3n_1{0%{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translateY(0)}}@keyframes _statusTextFadeOut_1rq3n_1{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-5px)}}._historySectionWrapper_1rq3n_262{width:var(--history-width);bottom:var(--height);left:var(--side-space);z-index:-2;visibility:collapse;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);text-shadow:0 0 1px #0003;border-top-left-radius:calc(var(--border-radius) + 4px);border-top-right-radius:calc(var(--border-radius) + 4px);background:#02001480;border:2px solid #fff6;padding-top:0;transition:all .2s;position:absolute;overflow:hidden;box-shadow:0 4px 16px #0009}._expanded_1rq3n_294 ._historySectionWrapper_1rq3n_262{visibility:visible;padding-top:8px}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262{overscroll-behavior:contain;scrollbar-width:none;max-height:0;padding-inline:8px;transition:max-height .2s;position:relative;overflow-y:auto}._expanded_1rq3n_294 :is(._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262){max-height:var(--history-max,min(500px, calc(100vh - 200px - var(--height))))}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyRow_1rq3n_320{margin-bottom:8px;display:flex}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyRow_1rq3n_320:last-child{margin-bottom:12px}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyRow_1rq3n_320._fromPessoa_1rq3n_328{justify-content:flex-end}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyRow_1rq3n_320._fromAgente_1rq3n_332,._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyRow_1rq3n_320._fromSistema_1rq3n_333{justify-content:flex-start}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338{--bolha:#22222e;--bolha-texto:#ececf2;--bolha-meta:#a9a9bd;--bolha-realce:#7a8cff;background:var(--bolha);min-width:0;max-width:88%;color:var(--bolha-texto);border-radius:12px;padding:7px 10px 8px;font-size:13px;line-height:1.45;box-shadow:0 1px 2px #00000059}._fromPessoa_1rq3n_328 :is(._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338){--bolha:#2f4f74;--bolha-texto:#f2f6fb;--bolha-meta:#bcd0e6;border-bottom-right-radius:4px}._fromAgente_1rq3n_332 :is(._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338),._fromSistema_1rq3n_333 :is(._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338){border-bottom-left-radius:4px}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338._output_1rq3n_171{--bolha-realce:#58d68d}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338._observation_1rq3n_374{--bolha-realce:#c49bff}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338._question_1rq3n_378{--bolha-realce:#ffb067}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338._doneSuccess_1rq3n_382{--bolha:#1d3b2a;--bolha-texto:#e3f8ec;--bolha-meta:#a9d8bd;--bolha-realce:#58d68d;font-weight:500}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338._doneFailure_1rq3n_390,._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338._error_1rq3n_176{--bolha:#412128;--bolha-texto:#fde8ec;--bolha-meta:#e3aeb8;--bolha-realce:#ff8095}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338._retry_1rq3n_163{--bolha-realce:#ffd166}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._historyHeader_1rq3n_402{color:var(--bolha-realce);align-items:center;gap:6px;margin-bottom:3px;display:flex}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._historyAuthor_1rq3n_410{letter-spacing:.01em;font-size:11px;font-weight:600}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._historyMeta_1rq3n_416{color:var(--bolha-meta);white-space:nowrap;margin-left:auto;font-size:11px}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._statusIcon_1rq3n_426{flex-shrink:0;width:14px;height:14px;line-height:1}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._statusIcon_1rq3n_426 svg{width:100%;height:100%;display:block}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._historyContent_1rq3n_439{word-break:normal;overflow-wrap:anywhere}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._historyContent_1rq3n_439>span,._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._historyContent_1rq3n_439 ._reflectionLine_1rq3n_446{white-space:pre-wrap}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._reflectionLines_1rq3n_451{flex-direction:column;gap:7px;display:flex}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._reflectionLine_1rq3n_446{display:block}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._reflectionLabel_1rq3n_462{letter-spacing:.07em;text-transform:uppercase;color:var(--bolha-meta);margin-bottom:1px;font-size:10px;font-weight:700;display:block}@media (prefers-contrast:more){._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338{--bolha:#000;--bolha-texto:#fff;--bolha-meta:#e0e0e0;border:1px solid #fff}}@keyframes _pulse_1rq3n_1{0%,to{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(1.3)}}@keyframes _retryPulse_1rq3n_1{0%,to{opacity:1;transform:scale(1)rotate(0)}25%{opacity:.6;transform:scale(1.2)rotate(90deg)}50%{opacity:.8;transform:scale(1.1)rotate(180deg)}75%{opacity:.6;transform:scale(1.2)rotate(270deg)}}@keyframes _celebrate_1rq3n_1{0%,to{transform:scale(1)}25%{transform:scale(1.2)rotate(-5deg)}75%{transform:scale(1.2)rotate(5deg)}}@keyframes _shimmer_1rq3n_1{0%{left:-100%}to{left:100%}}._inputSectionWrapper_1rq3n_544{width:var(--history-width);top:var(--height);left:var(--side-space);z-index:-1;visibility:visible;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-bottom-left-radius:calc(var(--border-radius) + 4px);border-bottom-right-radius:calc(var(--border-radius) + 4px);background:#bababa33;border:2px solid #ffffff4d;height:48px;transition:all .2s;position:absolute;overflow:hidden;box-shadow:0 1px 16px #0006}._inputSectionWrapper_1rq3n_544._hidden_1rq3n_567{visibility:collapse;height:0}._inputSectionWrapper_1rq3n_544 ._inputSection_1rq3n_544{align-items:center;gap:4px;padding:8px;display:flex}._inputSectionWrapper_1rq3n_544 ._inputSection_1rq3n_544 ._taskInput_1rq3n_578{color:#141414;background:#fff6;border:1px solid #ffffff4d;border-radius:10px;outline:none;flex:1;height:28px;padding-inline:10px;font-size:12px;line-height:1;transition:all .2s}._inputSectionWrapper_1rq3n_544 ._inputSection_1rq3n_544 ._taskInput_1rq3n_578::placeholder{color:#353535}._inputSectionWrapper_1rq3n_544 ._inputSection_1rq3n_544 ._taskInput_1rq3n_578:focus{background:#fffc;border-color:#39b6ff99;box-shadow:0 0 0 2px #39b6ff33}
|
|
1
|
+
(function(){var __vite_style__=document.createElement(`style`);__vite_style__.textContent=`._wrapper_1ooyb_1{z-index:2147483641;cursor:wait;display:none;position:fixed;inset:0;overflow:hidden}._wrapper_1ooyb_1._visible_1ooyb_11{display:block}._cursor_1dgwb_2{width:var(--cursor-size,75px);height:var(--cursor-size,75px);pointer-events:none;z-index:10000;position:absolute}._cursorBorder_1dgwb_10{transform-origin:50%;background:linear-gradient(45deg,#39b6ff,#bd45fb);width:100%;height:100%;margin-top:-18px;margin-left:-10px;position:absolute;transform:rotate(-135deg)scale(1.2);-webkit-mask-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20fill='none'%3e%3cg%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='none'%20stroke='%23000000'%20stroke-width='6'%20stroke-miterlimit='10'%20style='stroke:%20light-dark(rgb(0,%200,%200),%20rgb(255,%20255,%20255));'/%3e%3c/g%3e%3c/svg%3e");mask-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%20fill='none'%3e%3cg%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='none'%20stroke='%23000000'%20stroke-width='6'%20stroke-miterlimit='10'%20style='stroke:%20light-dark(rgb(0,%200,%200),%20rgb(255,%20255,%20255));'/%3e%3c/g%3e%3c/svg%3e");-webkit-mask-size:100% 100%;mask-size:100% 100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}._cursorFilling_1dgwb_25{transform-origin:50%;background:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20100%20100'%3e%3cdefs%3e%3c/defs%3e%3cg%20xmlns='http://www.w3.org/2000/svg'%20style='filter:%20drop-shadow(light-dark(rgba(0,%200,%200,%200.4),%20rgba(237,%20237,%20237,%200.4))%203px%204px%204px);'%3e%3cpath%20d='M%2015%2042%20L%2015%2036.99%20Q%2015%2031.99%2023.7%2031.99%20L%2028.05%2031.99%20Q%2032.41%2031.99%2032.41%2021.99%20L%2032.41%2017%20Q%2032.41%2012%2041.09%2016.95%20L%2076.31%2037.05%20Q%2085%2042%2076.31%2046.95%20L%2041.09%2067.05%20Q%2032.41%2072%2032.41%2062.01%20L%2032.41%2057.01%20Q%2032.41%2052.01%2023.7%2052.01%20L%2019.35%2052.01%20Q%2015%2052.01%2015%2047.01%20Z'%20fill='%23ffffff'%20stroke='none'%20style='fill:%20%23ffffff;'/%3e%3c/g%3e%3c/svg%3e") 0 0/100% 100% no-repeat;width:100%;height:100%;margin-top:-18px;margin-left:-10px;position:absolute;transform:rotate(-135deg)scale(1.2)}._cursorRipple_1dgwb_39{pointer-events:none;width:100%;height:100%;margin-top:-50%;margin-left:-50%;position:absolute}._cursorRipple_1dgwb_39:after{content:"";opacity:0;border:4px solid #39b6ff;border-radius:50%;position:absolute;inset:0}._cursor_1dgwb_2._clicking_1dgwb_57 ._cursorRipple_1dgwb_39:after{animation:.3s ease-out forwards _cursor-ripple_1dgwb_1}@keyframes _cursor-ripple_1dgwb_1{0%{opacity:1;transform:scale(0)}to{opacity:0;transform:scale(2)}}._wrapper_1rq3n_1{opacity:0;z-index:2147483642;box-sizing:border-box;position:fixed;bottom:100px;left:50%;overflow:visible;transform:translate(-50%)translateY(20px)}._wrapper_1rq3n_1 *{box-sizing:border-box}._wrapper_1rq3n_1{--width:360px;--height:40px;--border-radius:12px;--side-space:12px;--history-width:calc(var(--width) - var(--side-space) * 2);--color-1:#39b6ff;--color-2:#bd45fb;--color-3:#ff5733;--color-4:#ffd600;width:var(--width);height:var(--height);transition:all .3s ease-in-out}@media (width<=640px){._wrapper_1rq3n_1{--width:calc(100vw - 16px);--side-space:8px;width:var(--width);bottom:calc(12px + env(safe-area-inset-bottom,0px));--history-max:min(60vh, calc(100dvh - 120px - var(--height)))}}@media (prefers-reduced-motion:reduce){._wrapper_1rq3n_1{transition:none}._wrapper_1rq3n_1 *{transition:none!important;animation:none!important}}._wrapper_1rq3n_1 ._background_1rq3n_55{border-radius:calc(var(--border-radius) + 4px);filter:blur(16px);position:absolute;inset:-2px -8px;overflow:hidden}._wrapper_1rq3n_1 ._background_1rq3n_55:before{content:"";z-index:-1;pointer-events:none;background-image:linear-gradient(to bottom left, var(--color-1), var(--color-2), var(--color-1));width:100%;height:100%;animation:2s linear infinite _mask-running_1rq3n_1;position:absolute;top:0;left:0}._wrapper_1rq3n_1 ._background_1rq3n_55:after{content:"";z-index:-1;pointer-events:none;background-image:linear-gradient(to bottom left, var(--color-2), var(--color-1), var(--color-2));width:100%;height:100%;animation:2s linear 1s infinite _mask-running_1rq3n_1;position:absolute;top:0;left:0}@keyframes _mask-running_1rq3n_1{0%{transform:translate(-100%)}to{transform:translate(100%)}}._header_1rq3n_115{-webkit-user-select:none;user-select:none;cursor:pointer;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-radius:var(--border-radius);background:#00000080 padding-box padding-box;flex-shrink:0;justify-content:space-between;align-items:center;padding:8px 12px;display:flex;position:absolute;inset:0;box-shadow:0 0 0 2px #fff6,0 0 5px 1px #ffffff4d}._header_1rq3n_115 ._statusSection_1rq3n_137{flex:1;align-items:center;gap:8px;min-height:24px;display:flex}._header_1rq3n_115 ._statusSection_1rq3n_137 ._indicator_1rq3n_144{background:#ffffff80;border-radius:50%;flex-shrink:0;width:6px;height:6px;animation:none}._header_1rq3n_115 ._statusSection_1rq3n_137 ._indicator_1rq3n_144._thinking_1rq3n_153{background:#39b6ff;animation:.8s ease-in-out infinite _pulse_1rq3n_1}._header_1rq3n_115 ._statusSection_1rq3n_137 ._indicator_1rq3n_144._tool_executing_1rq3n_158{background:#bd45fb;animation:.6s ease-in-out infinite _pulse_1rq3n_1}._header_1rq3n_115 ._statusSection_1rq3n_137 ._indicator_1rq3n_144._retry_1rq3n_163{background:#ffd600;animation:1s ease-in-out infinite _retryPulse_1rq3n_1}._header_1rq3n_115 ._statusSection_1rq3n_137 ._indicator_1rq3n_144._completed_1rq3n_169,._header_1rq3n_115 ._statusSection_1rq3n_137 ._indicator_1rq3n_144._input_1rq3n_170,._header_1rq3n_115 ._statusSection_1rq3n_137 ._indicator_1rq3n_144._output_1rq3n_171{background:#22c55e;animation:none}._header_1rq3n_115 ._statusSection_1rq3n_137 ._indicator_1rq3n_144._error_1rq3n_176{background:#ef4444;animation:none}._header_1rq3n_115 ._statusSection_1rq3n_137 ._statusText_1rq3n_182{color:#fff;align-items:center;min-height:24px;font-size:12px;font-weight:500;line-height:1;transition:all .3s ease-in-out;display:flex;position:relative;overflow:hidden}._header_1rq3n_115 ._statusSection_1rq3n_137 ._statusText_1rq3n_182._fadeOut_1rq3n_194{animation:.3s forwards _statusTextFadeOut_1rq3n_1}._header_1rq3n_115 ._statusSection_1rq3n_137 ._statusText_1rq3n_182._fadeIn_1rq3n_198{animation:.3s forwards _statusTextFadeIn_1rq3n_1}._header_1rq3n_115 ._controls_1rq3n_204{align-items:center;gap:4px;display:flex}._header_1rq3n_115 ._controls_1rq3n_204 ._controlButton_1rq3n_209{color:#fff;cursor:pointer;background:#ffffff1a;border:none;border-radius:4px;justify-content:center;align-items:center;width:24px;height:24px;font-size:12px;line-height:1;display:flex}._header_1rq3n_115 ._controls_1rq3n_204 ._controlButton_1rq3n_209:hover{background:#fff3}._header_1rq3n_115 ._controls_1rq3n_204 ._stopButton_1rq3n_228{color:#ff2929;background:#ef444433;font-weight:600}._header_1rq3n_115 ._controls_1rq3n_204 ._stopButton_1rq3n_228:hover{background:#ef44444d}@keyframes _statusTextFadeIn_1rq3n_1{0%{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translateY(0)}}@keyframes _statusTextFadeOut_1rq3n_1{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(-5px)}}._historySectionWrapper_1rq3n_262{width:var(--history-width);bottom:var(--height);left:var(--side-space);z-index:-2;visibility:collapse;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);text-shadow:0 0 1px #0003;border-top-left-radius:calc(var(--border-radius) + 4px);border-top-right-radius:calc(var(--border-radius) + 4px);background:#02001480;border:2px solid #fff6;padding-top:0;transition:all .2s;position:absolute;overflow:hidden;box-shadow:0 4px 16px #0009}._expanded_1rq3n_294 ._historySectionWrapper_1rq3n_262{visibility:visible;padding-top:8px}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262{overscroll-behavior:contain;scrollbar-width:none;max-height:0;padding-inline:8px;transition:max-height .2s;position:relative;overflow-y:auto}._expanded_1rq3n_294 :is(._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262){max-height:var(--history-max,min(500px, calc(100vh - 200px - var(--height))))}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyRow_1rq3n_320{margin-bottom:8px;display:flex}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyRow_1rq3n_320:last-child{margin-bottom:12px}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyRow_1rq3n_320._fromPessoa_1rq3n_328{justify-content:flex-end}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyRow_1rq3n_320._fromAgente_1rq3n_332,._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyRow_1rq3n_320._fromSistema_1rq3n_333{justify-content:flex-start}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338{--bolha:#22222e;--bolha-texto:#ececf2;--bolha-meta:#a9a9bd;--bolha-realce:#7a8cff;background:var(--bolha);min-width:0;max-width:88%;color:var(--bolha-texto);border-radius:12px;padding:7px 10px 8px;font-size:13px;line-height:1.45;box-shadow:0 1px 2px #00000059}._fromPessoa_1rq3n_328 :is(._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338){--bolha:#2f4f74;--bolha-texto:#f2f6fb;--bolha-meta:#bcd0e6;border-bottom-right-radius:4px}._fromAgente_1rq3n_332 :is(._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338),._fromSistema_1rq3n_333 :is(._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338){border-bottom-left-radius:4px}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338._output_1rq3n_171{--bolha-realce:#58d68d}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338._observation_1rq3n_374{--bolha-realce:#c49bff}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338._question_1rq3n_378{--bolha-realce:#ffb067}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338._doneSuccess_1rq3n_382{--bolha:#1d3b2a;--bolha-texto:#e3f8ec;--bolha-meta:#a9d8bd;--bolha-realce:#58d68d;font-weight:500}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338._doneFailure_1rq3n_390,._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338._error_1rq3n_176{--bolha:#412128;--bolha-texto:#fde8ec;--bolha-meta:#e3aeb8;--bolha-realce:#ff8095}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338._retry_1rq3n_163{--bolha-realce:#ffd166}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._historyHeader_1rq3n_402{color:var(--bolha-realce);align-items:center;gap:6px;margin-bottom:3px;display:flex}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._historyAuthor_1rq3n_410{letter-spacing:.01em;font-size:11px;font-weight:600}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._historyMeta_1rq3n_416{color:var(--bolha-meta);white-space:nowrap;margin-left:auto;font-size:11px}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._statusIcon_1rq3n_426{flex-shrink:0;width:14px;height:14px;line-height:1}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._statusIcon_1rq3n_426 svg{width:100%;height:100%;display:block}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._historyContent_1rq3n_439{word-break:normal;overflow-wrap:anywhere}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._historyContent_1rq3n_439>span,._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._historyContent_1rq3n_439 ._reflectionLine_1rq3n_446{white-space:pre-wrap}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._reflectionLines_1rq3n_451{flex-direction:column;gap:7px;display:flex}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._reflectionLine_1rq3n_446{display:block}._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338 ._reflectionLabel_1rq3n_462{letter-spacing:.07em;text-transform:uppercase;color:var(--bolha-meta);margin-bottom:1px;font-size:10px;font-weight:700;display:block}@media (prefers-contrast:more){._historySectionWrapper_1rq3n_262 ._historySection_1rq3n_262 ._historyItem_1rq3n_338{--bolha:#000;--bolha-texto:#fff;--bolha-meta:#e0e0e0;border:1px solid #fff}}@keyframes _pulse_1rq3n_1{0%,to{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(1.3)}}@keyframes _retryPulse_1rq3n_1{0%,to{opacity:1;transform:scale(1)rotate(0)}25%{opacity:.6;transform:scale(1.2)rotate(90deg)}50%{opacity:.8;transform:scale(1.1)rotate(180deg)}75%{opacity:.6;transform:scale(1.2)rotate(270deg)}}@keyframes _celebrate_1rq3n_1{0%,to{transform:scale(1)}25%{transform:scale(1.2)rotate(-5deg)}75%{transform:scale(1.2)rotate(5deg)}}@keyframes _shimmer_1rq3n_1{0%{left:-100%}to{left:100%}}._inputSectionWrapper_1rq3n_544{width:var(--history-width);top:var(--height);left:var(--side-space);z-index:-1;visibility:visible;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border-bottom-left-radius:calc(var(--border-radius) + 4px);border-bottom-right-radius:calc(var(--border-radius) + 4px);background:#bababa33;border:2px solid #ffffff4d;height:48px;transition:all .2s;position:absolute;overflow:hidden;box-shadow:0 1px 16px #0006}._inputSectionWrapper_1rq3n_544._hidden_1rq3n_567{visibility:collapse;height:0}._inputSectionWrapper_1rq3n_544 ._inputSection_1rq3n_544{align-items:center;gap:4px;padding:8px;display:flex}._inputSectionWrapper_1rq3n_544 ._inputSection_1rq3n_544 ._taskInput_1rq3n_578{color:#141414;background:#fff6;border:1px solid #ffffff4d;border-radius:10px;outline:none;flex:1;height:28px;padding-inline:10px;font-size:12px;line-height:1;transition:all .2s}._inputSectionWrapper_1rq3n_544 ._inputSection_1rq3n_544 ._taskInput_1rq3n_578::placeholder{color:#353535}._inputSectionWrapper_1rq3n_544 ._inputSection_1rq3n_544 ._taskInput_1rq3n_578:focus{background:#fffc;border-color:#39b6ff99;box-shadow:0 0 0 2px #39b6ff33}.page-agent-widget-launcher{z-index:2147483630;color:#f9fafb;cursor:pointer;-webkit-tap-highlight-color:transparent;width:48px;height:48px;right:calc(20px + env(safe-area-inset-right,0px));bottom:calc(20px + env(safe-area-inset-bottom,0px));background:#111827;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;transition:transform .12s,box-shadow .12s,background .12s;display:inline-flex;position:fixed;box-shadow:0 4px 14px #00000047}.page-agent-widget-launcher:hover{background:#1f2937;transform:translateY(-1px);box-shadow:0 6px 18px #00000057}.page-agent-widget-launcher:active{transform:translateY(0)scale(.97)}.page-agent-widget-launcher:focus-visible{outline-offset:2px;outline:3px solid #60a5fa}.page-agent-widget-launcher svg{display:block}.page-agent-voice-mic{width:34px;height:34px;color:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent;background:#94a3b81f;border:1px solid #94a3b866;border-radius:8px;flex:none;justify-content:center;align-items:center;margin-right:8px;padding:0;transition:background .12s,border-color .12s,transform .12s;display:inline-flex}.page-agent-voice-mic:hover{background:#94a3b838;border-color:#94a3b899}.page-agent-voice-mic:active{transform:scale(.96)}.page-agent-voice-mic:focus-visible{outline-offset:1px;outline:2px solid #60a5fa}.page-agent-voice-mic.is-listening{background:#ef444429;border-color:#ef444499;animation:1.4s ease-in-out infinite page-agent-voice-pulse}@keyframes page-agent-voice-pulse{0%,to{box-shadow:0 0 #ef444459}50%{box-shadow:0 0 0 6px #ef444400}}@media (prefers-reduced-motion:reduce){.page-agent-voice-mic.is-listening{animation:none}}
|
|
2
2
|
/*$vite$:1*/`,document.head.appendChild(__vite_style__);var __defProp=Object.defineProperty,__esmMin=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},__exportAll=(e,t)=>{let n={};for(var r in e)__defProp(n,r,{get:e[r],enumerable:!0});return t||__defProp(n,Symbol.toStringTag,{value:`Module`}),n};function getEnumValues(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function joinValues(e,t=`|`){return e.map(e=>stringifyPrimitive(e)).join(t)}function jsonStringifyReplacer(e,t){return typeof t==`bigint`?t.toString():t}function cached(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function nullish(e){return e==null}function cleanRegex(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function floatSafeRemainder(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function assignProp(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function mergeDefs(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function esc(e){return JSON.stringify(e)}function slugify(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var captureStackTrace=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function isObject(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var allowsEval=cached(()=>{if(globalConfig.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function isPlainObject(e){if(isObject(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return isObject(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function shallowClone(e){return isPlainObject(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var propertyKeyTypes=new Set([`string`,`number`,`symbol`]);function escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function clone(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function normalizeParams(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function stringifyPrimitive(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function optionalKeys(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var NUMBER_FORMAT_RANGES={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function pick(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return clone(e,mergeDefs(e._zod.def,{get shape(){let e={};for(let r of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,r))throw Error(`Unrecognized key: "${String(r)}"`);t[r]&&assignProp(e,r,n.shape[r])}return assignProp(this,`shape`,e),e},checks:[]}))}function omit(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return clone(e,mergeDefs(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,e))throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&delete r[e]}return assignProp(this,`shape`,r),r},checks:[]}))}function extend(e,t){if(!isPlainObject(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return clone(e,mergeDefs(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return assignProp(this,`shape`,n),n}}))}function safeExtend(e,t){if(!isPlainObject(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return clone(e,mergeDefs(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return assignProp(this,`shape`,n),n}}))}function merge(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return clone(e,mergeDefs(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return assignProp(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function partial(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);return clone(t,mergeDefs(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(r,t))throw Error(`Unrecognized key: "${String(t)}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t of Reflect.ownKeys(r))i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return assignProp(this,`shape`,i),i},checks:[]}))}function required(e,t,n){return clone(t,mergeDefs(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(i,t))throw Error(`Unrecognized key: "${String(t)}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t of Reflect.ownKeys(r))i[t]=new e({type:`nonoptional`,innerType:r[t]});return assignProp(this,`shape`,i),i}}))}function aborted(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function explicitlyAborted(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function prefixIssues(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function unwrapMessage(e){return typeof e==`string`?e:e?.message}function attachSchema(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function finalizeIssue(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:unwrapMessage(e.inst?._zod.def?.error?.(e))??unwrapMessage(a?.(e))??unwrapMessage(t?.error?.(e))??unwrapMessage(n.customError?.(e))??unwrapMessage(n.localeError?.(e))??`Invalid input`,{inst:s,schema:c,continue:l,input:u,...d}=e;return d.path??=[],d.message=o,t?.reportInput&&(d.input=u),d}var highSurrogate=/[\uD800-\uDBFF]/;function codePointLength(e){let t=e.length;if(!highSurrogate.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function getLengthableOrigin(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function parsedType(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function issue(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function members(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):defineBound(e,n,r.value)}}function own(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function hide(e,t,n){return own(e,t,n,!1)}function defineBound(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return own(this,t,n.bind(this))},set(e){own(this,t,e)}})}function claim(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var installing,broke=!1,breaker={configurable:!0,get(){broke=!0}};function defineLazyInternal(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&installing!==e._zod){installing=void 0;return}installing=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,breaker);let e=broke;broke=!1;try{let r=n(this);return broke?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),broke||=e,r}catch(n){throw delete this[t],broke||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function installLazyProp(e,t,n,r){let i=claim(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var CONSTANT_CATCH=`~constantCatch`;function constantCatch(e){let t=()=>e;return t[CONSTANT_CATCH]=!0,t}var _a$1,_zodDesc$1={value:void 0,enumerable:!1},_E=`captureStackTrace`in Error?Error:null;function newError(e){let t=_E;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return _E=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function $constructor(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){_zodDesc$1.value=new a(r);try{Object.defineProperty(n,"_zod",_zodDesc$1)}finally{_zodDesc$1.value=void 0}}if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),members(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?newError(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var $ZodAsyncError=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},$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={});var globalConfig=globalThis.__zod_globalConfig;function config(e){return e&&Object.assign(globalConfig,e),globalConfig}function _getMessage(){let e=this._zod;return e.message??=JSON.stringify(e.def,jsonStringifyReplacer,2),e.message}function _setMessage(e){this._zod.message=e}var _messageDesc={get:_getMessage,set:_setMessage,enumerable:!0,configurable:!0},_zodDesc={value:void 0,enumerable:!1},_issuesDesc={value:void 0,enumerable:!1},_installedToString=new WeakSet([Object.prototype,Error.prototype]),initializer$1=(e,t)=>{e.name=`$ZodError`,_zodDesc.value=e._zod,Object.defineProperty(e,"_zod",_zodDesc),_issuesDesc.value=t,Object.defineProperty(e,"issues",_issuesDesc),_zodDesc.value=void 0,_issuesDesc.value=void 0,Object.defineProperty(e,"message",_messageDesc);let n=Object.getPrototypeOf(e);_installedToString.has(n)||(_installedToString.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},$ZodError=$constructor(`$ZodError`,initializer$1),$ZodRealError=$constructor(`$ZodError`,initializer$1,void 0,{Parent:Error});function node(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function flattenError(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?node(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function formatError(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function toDotPath(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function prettifyError(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${toDotPath(e.path)}`);return t.join(`
|
|
3
3
|
`)}function finalizeParams(e,t){return{callee:t?.callee??e,Err:t?.Err}}var _parse=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new $ZodAsyncError;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>finalizeIssue(e,o,config())));throw captureStackTrace(n,a?.callee??t),n}return s.value};return t},_parseAsync=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>finalizeIssue(e,o,config())));throw captureStackTrace(n,a?.callee??t),n}return s.value};return t},_safeParse=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new $ZodAsyncError;return a.issues.length?{success:!1,error:new(e??$ZodError)(a.issues.map(e=>finalizeIssue(e,i,config())))}:{success:!0,data:a.value}},safeParse$1=_safeParse($ZodRealError),_safeParseAsync=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>finalizeIssue(e,i,config())))}:{success:!0,data:a.value}},safeParseAsync$1=_safeParseAsync($ZodRealError),_encode=e=>{let t=_parse(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,finalizeParams(n,a))};return n},_decode=e=>{let t=_parse(e),n=(e,r,i,a)=>t(e,r,i,finalizeParams(n,a));return n},_encodeAsync=e=>{let t=_parseAsync(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,finalizeParams(n,a))};return n},_decodeAsync=e=>{let t=_parseAsync(e),n=async(e,r,i,a)=>await t(e,r,i,finalizeParams(n,a));return n},_safeEncode=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return _safeParse(e)(t,n,i)},_safeDecode=e=>(t,n,r)=>_safeParse(e)(t,n,r),_safeEncodeAsync=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return _safeParseAsync(e)(t,n,i)},_safeDecodeAsync=e=>async(t,n,r)=>_safeParseAsync(e)(t,n,r),cuid=/^[cC][0-9a-z]{6,}$/,cuid2=/^[0-9a-z]+$/,ulid=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,xid=/^[0-9a-vA-V]{20}$/,ksuid=/^[A-Za-z0-9]{27}$/,nanoid=/^[a-zA-Z0-9_-]{21}$/;function nanoidOfLength(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var duration=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,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})$/,uuid=e=>e?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})$`):/^([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)$/,email=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,_emoji$1=`^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function emoji(){return new RegExp(_emoji$1,`u`)}var 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])$/,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}|:))$/,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])$/,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])$/,base64=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,base64url=/^[A-Za-z0-9_-]*$/,httpProtocol=/^https?$/,e164=/^\+[1-9]\d{6,14}$/,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])))`;function anchor(e){return RegExp(`^${e}$`)}var date=anchor(dateSource);function timeSource(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function time(e){return RegExp(`^${timeSource(e)}$`)}function datetime(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${timeSource({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${timeSource({precision:e.precision})}`:n;return RegExp(`^${dateSource}T(?:${r})$`)}var string$1=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},integer=/^-?\d+$/,number$1=/^-?\d+(?:\.\d+)?$/,boolean$1=/^(?:true|false)$/i,lowercase=/^[^A-Z]*$/,uppercase=/^[^a-z]*$/,$ZodCheck=$constructor(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),_whenHasLength=e=>{let t=e.value;return!nullish(t)&&t.length!==void 0},numericOriginMap={number:`number`,bigint:`bigint`,object:`date`},$ZodCheckLessThan=$constructor(`$ZodCheckLessThan`,(e,t)=>{$ZodCheck.init(e,t);let n=numericOriginMap[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:numericOriginMap[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$ZodCheckGreaterThan=$constructor(`$ZodCheckGreaterThan`,(e,t)=>{$ZodCheck.init(e,t);let n=numericOriginMap[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:numericOriginMap[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),$ZodCheckMultipleOf=$constructor(`$ZodCheckMultipleOf`,(e,t)=>{$ZodCheck.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):floatSafeRemainder(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckNumberFormat=$constructor(`$ZodCheckNumberFormat`,(e,t)=>{$ZodCheck.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=NUMBER_FORMAT_RANGES[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=integer)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),$ZodCheckMaxLength=$constructor(`$ZodCheckMaxLength`,(e,t)=>{var n;$ZodCheck.init(e,t),(n=e._zod.def).when??(n.when=_whenHasLength),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?codePointLength(r):i)<=t.maximum)return;let a=getLengthableOrigin(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$ZodCheckMinLength=$constructor(`$ZodCheckMinLength`,(e,t)=>{var n;$ZodCheck.init(e,t),(n=e._zod.def).when??(n.when=_whenHasLength),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?codePointLength(r):i)>=t.minimum)return;let a=getLengthableOrigin(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),$ZodCheckLengthEquals=$constructor(`$ZodCheckLengthEquals`,(e,t)=>{var n;$ZodCheck.init(e,t),(n=e._zod.def).when??(n.when=_whenHasLength),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?codePointLength(r):i;if(a===t.length)return;let o=getLengthableOrigin(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckStringFormat=$constructor(`$ZodCheckStringFormat`,(e,t)=>{var n,r;$ZodCheck.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),$ZodCheckRegex=$constructor(`$ZodCheckRegex`,(e,t)=>{$ZodCheckStringFormat.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),$ZodCheckLowerCase=$constructor(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=lowercase,$ZodCheckStringFormat.init(e,t)}),$ZodCheckUpperCase=$constructor(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=uppercase,$ZodCheckStringFormat.init(e,t)}),$ZodCheckIncludes=$constructor(`$ZodCheckIncludes`,(e,t)=>{$ZodCheck.init(e,t);let n=escapeRegex(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckStartsWith=$constructor(`$ZodCheckStartsWith`,(e,t)=>{$ZodCheck.init(e,t);let n=RegExp(`^${escapeRegex(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckEndsWith=$constructor(`$ZodCheckEndsWith`,(e,t)=>{$ZodCheck.init(e,t);let n=RegExp(`.*${escapeRegex(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),$ZodCheckOverwrite=$constructor(`$ZodCheckOverwrite`,(e,t)=>{$ZodCheck.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Doc=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
4
4
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
|
|
@@ -49,11 +49,11 @@
|
|
|
49
49
|
|
|
50
50
|
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=isObject,c=!globalConfig.jitless,l=c&&allowsEval.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?handleCatchall([],p,i,f,d,e):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function handleUnionResults(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!aborted(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>finalizeIssue(e,r,config())))}),t)}var $ZodUnion=$constructor(`$ZodUnion`,(e,t)=>{$ZodType.init(e,t),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)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>cleanRegex(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>handleUnionResults(t,r,e,i)):handleUnionResults(o,r,e,i)}}),$ZodIntersection=$constructor(`$ZodIntersection`,(e,t)=>{$ZodType.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>handleIntersectionResults(e,t,n)):handleIntersectionResults(e,i,a)}});function mergeValues(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(isPlainObject(e)&&isPlainObject(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=mergeValues(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=mergeValues(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function handleIntersectionResults(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=mergeValues(t.value,n.value);if(!c.valid){if(aborted(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var $ZodEnum=$constructor(`$ZodEnum`,(e,t)=>{$ZodType.init(e,t);let n=getEnumValues(t.entries),r=new Set(n);e._zod.values=r;let i=n.filter(e=>propertyKeyTypes.has(typeof e));e._zod.pattern=RegExp(i.length?`^(${i.map(e=>escapeRegex(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),$ZodTransform=$constructor(`$ZodTransform`,(e,t)=>{$ZodType.init(e,t),e._zod.optin=`optional`,globalConfig.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new $ZodEncodeError(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new $ZodAsyncError;return n.value=i,n}});function handleOptionalResult(e,t){return e.value=t.issues.length?void 0:t.value,e}var $ZodOptional=$constructor(`$ZodOptional`,(e,t)=>{$ZodType.init(e,t),defineLazyInternal(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,defineLazyInternal(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),defineLazyInternal(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${cleanRegex(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>handleOptionalResult(e,t)):handleOptionalResult(e,r)}return t.innerType._zod.run(e,n)}}),$ZodExactOptional=$constructor(`$ZodExactOptional`,(e,t)=>{$ZodOptional.init(e,t),defineLazyInternal(e,`values`,e=>e.def.innerType._zod.values),defineLazyInternal(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),$ZodNullable=$constructor(`$ZodNullable`,(e,t)=>{$ZodType.init(e,t),defineLazyInternal(e,`optin`,e=>e.def.innerType._zod.optin),defineLazyInternal(e,`optout`,e=>e.def.innerType._zod.optout),defineLazyInternal(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${cleanRegex(t.source)}|null)$`):void 0}),defineLazyInternal(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),$ZodDefault=$constructor(`$ZodDefault`,(e,t)=>{$ZodType.init(e,t),e._zod.optin=`defaulted`,defineLazyInternal(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>handleDefaultResult(e,t)):handleDefaultResult(r,t)}});function handleDefaultResult(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var $ZodPrefault=$constructor(`$ZodPrefault`,(e,t)=>{$ZodType.init(e,t),e._zod.optin=`defaulted`,defineLazyInternal(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),$ZodNonOptional=$constructor(`$ZodNonOptional`,(e,t)=>{$ZodType.init(e,t),defineLazyInternal(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>handleNonOptionalResult(t,e)):handleNonOptionalResult(i,e)}});function handleNonOptionalResult(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function handleCatchResult(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>finalizeIssue(e,r,config()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var $ZodCatch=$constructor(`$ZodCatch`,(e,t)=>{$ZodType.init(e,t),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,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>handleCatchResult(e,r,t,n)):handleCatchResult(e,r,t,n)}}),$ZodPipe=$constructor(`$ZodPipe`,(e,t)=>{$ZodType.init(e,t),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,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>handlePipeResult(e,t.in,n)):handlePipeResult(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>handlePipeResult(e,t.out,n)):handlePipeResult(r,t.out,n)}});function handlePipeResult(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var $ZodReadonly=$constructor(`$ZodReadonly`,(e,t)=>{$ZodType.init(e,t),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,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(handleReadonlyResult):handleReadonlyResult(r)}});function handleReadonlyResult(e){return e.memo||(e.value=Object.freeze(e.value)),e}var $ZodCustom=$constructor(`$ZodCustom`,(e,t)=>{$ZodCheck.init(e,t),$ZodType.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>handleRefineResult(t,n,r,e));handleRefineResult(i,n,r,e)}});function handleRefineResult(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(issue(e))}}var $ZodCyclicError=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},STATE=`~memo`,NO_ISSUES=[];function cloneIssues(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var recursive=new WeakMap;function isRecursive(e,t){let n=recursive.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1,i=e=>{!r&&e?._zod&&isRecursive(e,t)&&(r=!0)},a=e._zod.def;if(a.type===`lazy`)i(e._zod.innerType);else{let e=a.shape;if(e)for(let t of Reflect.ownKeys(e))i(e[t]);for(let e in a){let t=a[e];if(t&&typeof t==`object`){if(t._zod)i(t);else if(Array.isArray(t))for(let e of t)i(e)}}}return t.delete(e),recursive.set(e,r),r}function bucketFor(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}var handoff,open=[],memo={alloc(e,t,n){let r=handoff;if(!r)return n;handoff=void 0;let i={value:n,issues:null};return r.set(t.value,i),open.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&isBackEdge(n,e.value))throw new $ZodCyclicError;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,a=(o,s)=>{if(n===void 0&&(n=isRecursive(e,new Set),!n))return e._zod.parse=t,e._zod.run===a&&(e._zod.run=t),t(o,s);let c=o.value;if(typeof c!=`object`||!c)return t(o,s);let l=s[STATE];l||(l={buckets:new Map,backEdges:void 0},s[STATE]=l);let u;r===s?u=i:(u=bucketFor(l,e),r=s,i=u);let d=u.get(c);if(d)return o.value=d.value,d.issues?d.issues.length&&o.issues.push(...cloneIssues(d.issues)):(o.memo=!0,l.backEdges??(l.backEdges=new Set),l.backEdges.add(d.value)),o;handoff=u;let f=open.length,p=t(o,s);handoff=void 0;let m=open.length>f?open.pop():void 0;return p instanceof Promise?p.then(e=>(m&&(m.issues=e.issues.length?cloneIssues(e.issues):NO_ISSUES),e)):(m&&(m.issues=p.issues.length?cloneIssues(p.issues):NO_ISSUES),p)};e._zod.parse=a,e._zod.run===t&&(e._zod.run=a)})}};function memoizer(){return memo}function isBackEdge(e,t){let n=e[STATE]?.backEdges;return n!==void 0&&typeof t==`object`&&!!t&&n.has(t)}var error$1=()=>{let 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 t(t){return e[t]??null}let 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`,credit_card:`credit card number`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(parsedType(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${stringifyPrimitive(e.values[0])}`:`Invalid option: expected one of ${joinValues(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.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`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function en_default(){return{localeError:error$1()}}var _a,$ZodRegistry=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r: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());var globalRegistry=globalThis.__zod_globalRegistry;function _string(e,t){return new e({type:`string`,...normalizeParams(t)})}function _email(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _guid(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _uuid(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _uuidv4(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...normalizeParams(t)})}function _uuidv6(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...normalizeParams(t)})}function _uuidv7(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...normalizeParams(t)})}function _url(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _emoji(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _nanoid(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _cuid(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _cuid2(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _ulid(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _xid(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _ksuid(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _ipv4(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _ipv6(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _cidrv4(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _cidrv6(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _base64(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _base64url(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _e164(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _jwt(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...normalizeParams(t)})}function _isoDateTime(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...normalizeParams(t)})}function _isoDate(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...normalizeParams(t)})}function _isoTime(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...normalizeParams(t)})}function _isoDuration(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...normalizeParams(t)})}function _number(e,t){return new e({type:`number`,checks:[],...normalizeParams(t)})}function _int(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...normalizeParams(t)})}function _boolean(e,t){return new e({type:`boolean`,...normalizeParams(t)})}function _unknown(e){return new e({type:`unknown`})}function _never(e,t){return new e({type:`never`,...normalizeParams(t)})}function _lt(e,t){return new $ZodCheckLessThan({check:`less_than`,...normalizeParams(t),value:e,inclusive:!1})}function _lte(e,t){return new $ZodCheckLessThan({check:`less_than`,...normalizeParams(t),value:e,inclusive:!0})}function _gt(e,t){return new $ZodCheckGreaterThan({check:`greater_than`,...normalizeParams(t),value:e,inclusive:!1})}function _gte(e,t){return new $ZodCheckGreaterThan({check:`greater_than`,...normalizeParams(t),value:e,inclusive:!0})}function _multipleOf(e,t){return new $ZodCheckMultipleOf({check:`multiple_of`,...normalizeParams(t),value:e})}function _maxLength(e,t){return new $ZodCheckMaxLength({check:`max_length`,...normalizeParams(t),maximum:e})}function _minLength(e,t){return new $ZodCheckMinLength({check:`min_length`,...normalizeParams(t),minimum:e})}function _length(e,t){return new $ZodCheckLengthEquals({check:`length_equals`,...normalizeParams(t),length:e})}function _regex(e,t){return new $ZodCheckRegex({check:`string_format`,format:`regex`,...normalizeParams(t),pattern:e})}function _lowercase(e){return new $ZodCheckLowerCase({check:`string_format`,format:`lowercase`,...normalizeParams(e)})}function _uppercase(e){return new $ZodCheckUpperCase({check:`string_format`,format:`uppercase`,...normalizeParams(e)})}function _includes(e,t){return new $ZodCheckIncludes({check:`string_format`,format:`includes`,...normalizeParams(t),includes:e})}function _startsWith(e,t){return new $ZodCheckStartsWith({check:`string_format`,format:`starts_with`,...normalizeParams(t),prefix:e})}function _endsWith(e,t){return new $ZodCheckEndsWith({check:`string_format`,format:`ends_with`,...normalizeParams(t),suffix:e})}function _overwrite(e){return new $ZodCheckOverwrite({check:`overwrite`,tx:e})}function _normalize(e){return _overwrite(t=>t.normalize(e))}function _trim(){return _overwrite(e=>e.trim())}function _toLowerCase(){return _overwrite(e=>e.toLowerCase())}function _toUpperCase(){return _overwrite(e=>e.toUpperCase())}function _slugify(){return _overwrite(e=>slugify(e))}function _array(e,t,n){return new e({type:`array`,element:t,...normalizeParams(n)})}function _refine(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...normalizeParams(n)})}function _superRefine(e,t){let n=_check(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(issue(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(issue(r))}},e(t.value,t)),t);return n}function _check(e,t){let n=new $ZodCheck({check:`custom`,...normalizeParams(t)});return n._zod.check=e,n}function assignProps(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&assignProp(e,t,n[t]);return e}function initializeContext(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??globalRegistry,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],external:e?.external??void 0}}function handleUnrepresentable(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function process(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,process(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&assignProps(o.schema,c),t.io===`input`&&isTransforming(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function encodeJSONPointerSegment(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function extractDefs(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${encodeJSONPointerSegment(a)}`}}let i=`#`,a=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let o=t[1].schema.id??`__schema${e.counter++}`;return{defId:o,ref:a+encodeJSONPointerSegment(o)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
51
51
|
|
|
52
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function compactTypeUnion(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;compactTypeUnion(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var FOLDABLE_KEYS=new Set([`type`,`properties`,`required`,`additionalProperties`]),UNION_KEYS=[`oneOf`,`anyOf`];function undeclaredConstraint(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function foldObjects(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!FOLDABLE_KEYS.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??undeclaredConstraint(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}assignProp(n,r,e.length===1?e[0]:foldObjects(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=undeclaredConstraint(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function foldIntersection(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of FOLDABLE_KEYS)if(t in e)return;let n=t.filter(e=>UNION_KEYS.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=foldObjects(t);else{let e=n[0],i=UNION_KEYS.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>foldObjects([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,assignProps(e,r))}function finalize(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.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)):assignProps(i,s),assignProps(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())compactTypeUnion(t[1].def??t[1].schema);if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])foldIntersection(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}assignProps(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,assignProp(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:createStandardJSONSchemaMethod(t,`input`,e.processors),output:createStandardJSONSchemaMethod(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function isTransforming(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return isTransforming(r.element,n);if(r.type===`set`)return isTransforming(r.valueType,n);if(r.type===`lazy`)return isTransforming(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return isTransforming(r.innerType,n);if(r.type===`intersection`)return isTransforming(r.left,n)||isTransforming(r.right,n);if(r.type===`record`||r.type===`map`)return isTransforming(r.keyType,n)||isTransforming(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:isTransforming(r.in,n)||isTransforming(r.out,n);if(r.type===`object`){for(let e in r.shape)if(isTransforming(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(isTransforming(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(isTransforming(e,n))return!0;return!!(r.rest&&isTransforming(r.rest,n))}return!1}var createToJSONSchemaMethod=(e,t={})=>n=>{let r=initializeContext({...n,processors:t});return process(e,r),extractDefs(r,e),finalize(r,e)},createStandardJSONSchemaMethod=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=initializeContext({...i??{},target:a,io:t,processors:n});return process(e,o),extractDefs(o,e),finalize(o,e)},formatMap={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},stringProcessor=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=formatMap[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},numberProcessor=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(Number.isFinite(c)&&c!==0?i.multipleOf=Math.abs(c):handleUnrepresentable(e,t,i,r,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},booleanProcessor=(e,t,n,r)=>{n.type=`boolean`},bigintProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`BigInt cannot be represented in JSON Schema`)},symbolProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`Symbols cannot be represented in JSON Schema`)},nullProcessor=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},undefinedProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`Undefined cannot be represented in JSON Schema`)},voidProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`Void cannot be represented in JSON Schema`)},neverProcessor=(e,t,n,r)=>{n.not={}},anyProcessor=(e,t,n,r)=>{},unknownProcessor=(e,t,n,r)=>{},dateProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`Date cannot be represented in JSON Schema`)},enumProcessor=(e,t,n,r)=>{let i=e._zod.def,a=getEnumValues(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},literalProcessor=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(handleUnrepresentable(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(handleUnrepresentable(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},nanProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`NaN cannot be represented in JSON Schema`)},templateLiteralProcessor=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},fileProcessor=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},successProcessor=(e,t,n,r)=>{n.type=`boolean`},customProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},functionProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`Function types cannot be represented in JSON Schema`)},transformProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},mapProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`Map cannot be represented in JSON Schema`)},setProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`Set cannot be represented in JSON Schema`)},arrayProcessor=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=process(a.element,t,{...r,path:[...r.path,`items`]})};function inputOptin(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?inputOptin(t.out):t.type===`catch`?inputOptin(t.innerType):e._zod.optin}var objectProcessor=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&handleUnrepresentable(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)assignProp(i.properties,e,process(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e];return t.io===`input`?inputOptin(n)===void 0:n._zod.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=process(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},unionProcessor=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>process(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},intersectionProcessor=(e,t,n,r)=>{let i=e._zod.def,a=process(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=process(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},tupleProcessor=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>process(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?process(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?inputOptin(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=e._zod.bag;typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)},recordProcessor=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=process(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)assignProp(i.patternProperties,t.source,e)}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=process(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=process(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values,l=t.io===`input`&&inputOptin(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},nullableProcessor=(e,t,n,r)=>{let i=e._zod.def,a=process(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},nonoptionalProcessor=(e,t,n,r)=>{let i=e._zod.def;process(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},UNREPRESENTABLE_DEFAULT=Symbol();function serializeDefaultValue(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(handleUnrepresentable(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),UNREPRESENTABLE_DEFAULT):JSON.parse(o)}var defaultProcessor=(e,t,n,r)=>{let i=e._zod.def;process(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=serializeDefaultValue(i.defaultValue,e,t,n,r);o!==UNREPRESENTABLE_DEFAULT&&(n.default=o)},prefaultProcessor=(e,t,n,r)=>{let i=e._zod.def;process(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=serializeDefaultValue(i.defaultValue,e,t,n,r);o!==UNREPRESENTABLE_DEFAULT&&(n._prefault=o)},catchProcessor=(e,t,n,r)=>{let i=e._zod.def;process(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{handleUnrepresentable(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},pipeProcessor=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;process(o,t,r);let s=t.seen.get(e);s.ref=o},readonlyProcessor=(e,t,n,r)=>{let i=e._zod.def;process(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},promiseProcessor=(e,t,n,r)=>{let i=e._zod.def;process(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},optionalProcessor=(e,t,n,r)=>{let i=e._zod.def;process(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},lazyProcessor=(e,t,n,r)=>{let i=e._zod.innerType;process(i,t,r);let a=t.seen.get(e);a.ref=i},allProcessors={string:stringProcessor,number:numberProcessor,boolean:booleanProcessor,bigint:bigintProcessor,symbol:symbolProcessor,null:nullProcessor,undefined:undefinedProcessor,void:voidProcessor,never:neverProcessor,any:anyProcessor,unknown:unknownProcessor,date:dateProcessor,enum:enumProcessor,literal:literalProcessor,nan:nanProcessor,template_literal:templateLiteralProcessor,file:fileProcessor,success:successProcessor,custom:customProcessor,function:functionProcessor,transform:transformProcessor,map:mapProcessor,set:setProcessor,array:arrayProcessor,object:objectProcessor,union:unionProcessor,intersection:intersectionProcessor,tuple:tupleProcessor,record:recordProcessor,nullable:nullableProcessor,nonoptional:nonoptionalProcessor,default:defaultProcessor,prefault:prefaultProcessor,catch:catchProcessor,pipe:pipeProcessor,readonly:readonlyProcessor,promise:promiseProcessor,optional:optionalProcessor,lazy:lazyProcessor};function toJSONSchema(e,t){if(`_idmap`in e){let n=e,r=initializeContext({...t,processors:allProcessors}),i={};for(let e of n._idmap.entries()){let[t,n]=e;process(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;extractDefs(r,n),assignProp(a,t,finalize(r,n))}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=initializeContext({...t,processors:allProcessors});return process(e,n),extractDefs(n,e),finalize(n,e)}var _installedErrorProtos=new WeakSet([Object.prototype,Error.prototype]);function _lazyMethod(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var initializer=(e,t)=>{$ZodError.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);_installedErrorProtos.has(n)||(_installedErrorProtos.add(n),_lazyMethod(n,`format`,e=>t=>formatError(e,t)),_lazyMethod(n,`flatten`,e=>t=>flattenError(e,t)),_lazyMethod(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,jsonStringifyReplacer,2)}),_lazyMethod(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,jsonStringifyReplacer,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},ZodRealError=$constructor(`ZodError`,initializer,void 0,{Parent:Error}),parse=_parse(ZodRealError),parseAsync=_parseAsync(ZodRealError),safeParse=_safeParse(ZodRealError),safeParseAsync=_safeParseAsync(ZodRealError),encode=_encode(ZodRealError),decode=_decode(ZodRealError),encodeAsync=_encodeAsync(ZodRealError),decodeAsync=_decodeAsync(ZodRealError),safeEncode=_safeEncode(ZodRealError),safeDecode=_safeDecode(ZodRealError),safeEncodeAsync=_safeEncodeAsync(ZodRealError),safeDecodeAsync=_safeDecodeAsync(ZodRealError);function _ensureDefaultLocale(){globalConfig.localeError||config(en_default())}function _ensureDefaultMemoizer(){globalConfig.memoizer||config({memoizer:memoizer()})}var ZodType=$constructor(`ZodType`,(e,t)=>(_ensureDefaultLocale(),$ZodType.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(mergeDefs(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return clone(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(refine(e,t))},superRefine(e,t){return this.check(superRefine(e,t))},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){let t=this.clone();return globalRegistry.add(t,{description:e}),t},meta(...e){if(e.length===0)return globalRegistry.get(this);let t=this.clone();return globalRegistry.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},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 e(t,n){return parse(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await parseAsync(this,t,n,{callee:e})},safeParse(e,t){return safeParse(this,e,t)},async safeParseAsync(e,t){return safeParseAsync(this,e,t)},get spa(){return this.safeParseAsync},set spa(e){own(this,`spa`,e)},encode:function e(t,n){return encode(this,t,n,{callee:e})},decode:function e(t,n){return decode(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await encodeAsync(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await decodeAsync(this,t,n,{callee:e})},safeEncode(e,t){return safeEncode(this,e,t)},safeDecode(e,t){return safeDecode(this,e,t)},async safeEncodeAsync(e,t){return safeEncodeAsync(this,e,t)},async safeDecodeAsync(e,t){return safeDecodeAsync(this,e,t)},get toJSONSchema(){return own(this,`toJSONSchema`,createToJSONSchemaMethod(this,{}))},set toJSONSchema(e){own(this,`toJSONSchema`,e)},get description(){return globalRegistry.get(this)?.description},get _def(){return this._zod.def}}),_ZodString=$constructor(`_ZodString`,(e,t)=>{$ZodString.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>stringProcessor(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.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())}}),ZodString=$constructor(`ZodString`,(e,t)=>{$ZodString.init(e,t),_ZodString.init(e,t)},{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)}var ZodStringFormat=$constructor(`ZodStringFormat`,(e,t)=>{$ZodStringFormat.init(e,t),_ZodString.init(e,t)}),ZodISODateTime=$constructor(`ZodISODateTime`,(e,t)=>{$ZodISODateTime.init(e,t),ZodStringFormat.init(e,t)}),ZodISODate=$constructor(`ZodISODate`,(e,t)=>{$ZodISODate.init(e,t),ZodStringFormat.init(e,t)}),ZodISOTime=$constructor(`ZodISOTime`,(e,t)=>{$ZodISOTime.init(e,t),ZodStringFormat.init(e,t)}),ZodISODuration=$constructor(`ZodISODuration`,(e,t)=>{$ZodISODuration.init(e,t),ZodStringFormat.init(e,t)}),ZodEmail=$constructor(`ZodEmail`,(e,t)=>{$ZodEmail.init(e,t),ZodStringFormat.init(e,t)}),ZodGUID=$constructor(`ZodGUID`,(e,t)=>{$ZodGUID.init(e,t),ZodStringFormat.init(e,t)}),ZodUUID=$constructor(`ZodUUID`,(e,t)=>{$ZodUUID.init(e,t),ZodStringFormat.init(e,t)}),ZodURL=$constructor(`ZodURL`,(e,t)=>{$ZodURL.init(e,t),ZodStringFormat.init(e,t)}),ZodEmoji=$constructor(`ZodEmoji`,(e,t)=>{$ZodEmoji.init(e,t),ZodStringFormat.init(e,t)}),ZodNanoID=$constructor(`ZodNanoID`,(e,t)=>{$ZodNanoID.init(e,t),ZodStringFormat.init(e,t)}),ZodCUID=$constructor(`ZodCUID`,(e,t)=>{$ZodCUID.init(e,t),ZodStringFormat.init(e,t)}),ZodCUID2=$constructor(`ZodCUID2`,(e,t)=>{$ZodCUID2.init(e,t),ZodStringFormat.init(e,t)}),ZodULID=$constructor(`ZodULID`,(e,t)=>{$ZodULID.init(e,t),ZodStringFormat.init(e,t)}),ZodXID=$constructor(`ZodXID`,(e,t)=>{$ZodXID.init(e,t),ZodStringFormat.init(e,t)}),ZodKSUID=$constructor(`ZodKSUID`,(e,t)=>{$ZodKSUID.init(e,t),ZodStringFormat.init(e,t)}),ZodIPv4=$constructor(`ZodIPv4`,(e,t)=>{$ZodIPv4.init(e,t),ZodStringFormat.init(e,t)}),ZodIPv6=$constructor(`ZodIPv6`,(e,t)=>{$ZodIPv6.init(e,t),ZodStringFormat.init(e,t)}),ZodCIDRv4=$constructor(`ZodCIDRv4`,(e,t)=>{$ZodCIDRv4.init(e,t),ZodStringFormat.init(e,t)}),ZodCIDRv6=$constructor(`ZodCIDRv6`,(e,t)=>{$ZodCIDRv6.init(e,t),ZodStringFormat.init(e,t)}),ZodBase64=$constructor(`ZodBase64`,(e,t)=>{$ZodBase64.init(e,t),ZodStringFormat.init(e,t)}),ZodBase64URL=$constructor(`ZodBase64URL`,(e,t)=>{$ZodBase64URL.init(e,t),ZodStringFormat.init(e,t)}),ZodE164=$constructor(`ZodE164`,(e,t)=>{$ZodE164.init(e,t),ZodStringFormat.init(e,t)}),ZodJWT=$constructor(`ZodJWT`,(e,t)=>{$ZodJWT.init(e,t),ZodStringFormat.init(e,t)}),ZodNumber=$constructor(`ZodNumber`,(e,t)=>{$ZodNumber.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>numberProcessor(e,t,n,r);let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null},{gt(e,t){return this.check(_gt(e,t))},gte(e,t){return this.check(_gte(e,t))},min(e,t){return this.check(_gte(e,t))},lt(e,t){return this.check(_lt(e,t))},lte(e,t){return this.check(_lte(e,t))},max(e,t){return this.check(_lte(e,t))},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,t){return this.check(_multipleOf(e,t))},step(e,t){return this.check(_multipleOf(e,t))},finite(){return this}});function number(e){return _number(ZodNumber,e)}var ZodNumberFormat=$constructor(`ZodNumberFormat`,(e,t)=>{$ZodNumberFormat.init(e,t),ZodNumber.init(e,t)});function int(e){return _int(ZodNumberFormat,e)}var ZodBoolean=$constructor(`ZodBoolean`,(e,t)=>{$ZodBoolean.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>booleanProcessor(e,t,n,r)});function boolean(e){return _boolean(ZodBoolean,e)}var ZodUnknown=$constructor(`ZodUnknown`,(e,t)=>{$ZodUnknown.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>unknownProcessor(e,t,n,r)});function unknown(){return _unknown(ZodUnknown)}var ZodNever=$constructor(`ZodNever`,(e,t)=>{$ZodNever.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>neverProcessor(e,t,n,r)});function never(e){return _never(ZodNever,e)}var ZodArray=$constructor(`ZodArray`,(e,t)=>{_ensureDefaultMemoizer(),$ZodArray.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>arrayProcessor(e,t,n,r),e.element=t.element},{min(e,t){return this.check(_minLength(e,t))},nonempty(e){return this.check(_minLength(1,e))},max(e,t){return this.check(_maxLength(e,t))},length(e,t){return this.check(_length(e,t))},unwrap(){return this.element}});function array(e,t){return _array(ZodArray,e,t)}var ZodObject=$constructor(`ZodObject`,(e,t)=>{_ensureDefaultMemoizer(),$ZodObjectJIT.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>objectProcessor(e,t,n,r),installLazyProp(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return _enum(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:unknown()})},loose(){return this.clone({...this._zod.def,catchall:unknown()})},strict(){return this.clone({...this._zod.def,catchall:never()})},strip(){return this.clone({...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,t){return new ZodObject({type:`object`,shape:e??{},...normalizeParams(t)})}var ZodUnion=$constructor(`ZodUnion`,(e,t)=>{$ZodUnion.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>unionProcessor(e,t,n,r),e.options=t.options});function union(e,t){return new ZodUnion({type:`union`,options:e,...normalizeParams(t)})}var ZodIntersection=$constructor(`ZodIntersection`,(e,t)=>{$ZodIntersection.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>intersectionProcessor(e,t,n,r)});function intersection(e,t){return new ZodIntersection({type:`intersection`,left:e,right:t})}var ZodEnum=$constructor(`ZodEnum`,(e,t)=>{$ZodEnum.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>enumProcessor(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new ZodEnum({...t,checks:[],...normalizeParams(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new ZodEnum({...t,checks:[],...normalizeParams(r),entries:i})}});function _enum(e,t){return new ZodEnum({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...normalizeParams(t)})}var ZodTransform=$constructor(`ZodTransform`,(e,t)=>{_ensureDefaultMemoizer(),$ZodTransform.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>transformProcessor(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new $ZodEncodeError(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(issue(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(issue(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function transform(e){return new ZodTransform({type:`transform`,transform:e})}var ZodOptional=$constructor(`ZodOptional`,(e,t)=>{$ZodOptional.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>optionalProcessor(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function optional(e){return new ZodOptional({type:`optional`,innerType:e})}var ZodExactOptional=$constructor(`ZodExactOptional`,(e,t)=>{$ZodExactOptional.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>optionalProcessor(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function exactOptional(e){return new ZodExactOptional({type:`optional`,innerType:e})}var ZodNullable=$constructor(`ZodNullable`,(e,t)=>{$ZodNullable.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nullableProcessor(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nullable(e){return new ZodNullable({type:`nullable`,innerType:e})}var ZodDefault=$constructor(`ZodDefault`,(e,t)=>{$ZodDefault.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>defaultProcessor(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function _default(e,t){return new ZodDefault({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():shallowClone(t)}})}var ZodPrefault=$constructor(`ZodPrefault`,(e,t)=>{$ZodPrefault.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>prefaultProcessor(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function prefault(e,t){return new ZodPrefault({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():shallowClone(t)}})}var ZodNonOptional=$constructor(`ZodNonOptional`,(e,t)=>{$ZodNonOptional.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nonoptionalProcessor(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nonoptional(e,t){return new ZodNonOptional({type:`nonoptional`,innerType:e,...normalizeParams(t)})}var ZodCatch=$constructor(`ZodCatch`,(e,t)=>{$ZodCatch.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>catchProcessor(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function _catch(e,t){return new ZodCatch({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:constantCatch(t)})}var ZodPipe=$constructor(`ZodPipe`,(e,t)=>{$ZodPipe.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pipeProcessor(e,t,n,r),e.in=t.in,e.out=t.out});function pipe(e,t){return new ZodPipe({type:`pipe`,in:e,out:t})}var ZodReadonly=$constructor(`ZodReadonly`,(e,t)=>{$ZodReadonly.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>readonlyProcessor(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function readonly(e){return new ZodReadonly({type:`readonly`,innerType:e})}var ZodCustom=$constructor(`ZodCustom`,(e,t)=>{$ZodCustom.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>customProcessor(e,t,n,r)});function refine(e,t={}){return _refine(ZodCustom,e,t)}function superRefine(e,t){return _superRefine(e,t)}function stringReplaceAll(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function stringEncaseCRLFWithFirstIndex(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
|
|
52
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function compactTypeUnion(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;compactTypeUnion(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var FOLDABLE_KEYS=new Set([`type`,`properties`,`required`,`additionalProperties`]),UNION_KEYS=[`oneOf`,`anyOf`];function undeclaredConstraint(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function foldObjects(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!FOLDABLE_KEYS.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??undeclaredConstraint(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}assignProp(n,r,e.length===1?e[0]:foldObjects(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=undeclaredConstraint(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function foldIntersection(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of FOLDABLE_KEYS)if(t in e)return;let n=t.filter(e=>UNION_KEYS.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=foldObjects(t);else{let e=n[0],i=UNION_KEYS.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>foldObjects([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,assignProps(e,r))}function finalize(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.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)):assignProps(i,s),assignProps(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())compactTypeUnion(t[1].def??t[1].schema);if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])foldIntersection(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}assignProps(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,assignProp(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:createStandardJSONSchemaMethod(t,`input`,e.processors),output:createStandardJSONSchemaMethod(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function isTransforming(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return isTransforming(r.element,n);if(r.type===`set`)return isTransforming(r.valueType,n);if(r.type===`lazy`)return isTransforming(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return isTransforming(r.innerType,n);if(r.type===`intersection`)return isTransforming(r.left,n)||isTransforming(r.right,n);if(r.type===`record`||r.type===`map`)return isTransforming(r.keyType,n)||isTransforming(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:isTransforming(r.in,n)||isTransforming(r.out,n);if(r.type===`object`){for(let e in r.shape)if(isTransforming(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(isTransforming(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(isTransforming(e,n))return!0;return!!(r.rest&&isTransforming(r.rest,n))}return!1}var createToJSONSchemaMethod=(e,t={})=>n=>{let r=initializeContext({...n,processors:t});return process(e,r),extractDefs(r,e),finalize(r,e)},createStandardJSONSchemaMethod=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=initializeContext({...i??{},target:a,io:t,processors:n});return process(e,o),extractDefs(o,e),finalize(o,e)},formatMap={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},stringProcessor=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=formatMap[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},numberProcessor=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(Number.isFinite(c)&&c!==0?i.multipleOf=Math.abs(c):handleUnrepresentable(e,t,i,r,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},booleanProcessor=(e,t,n,r)=>{n.type=`boolean`},bigintProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`BigInt cannot be represented in JSON Schema`)},symbolProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`Symbols cannot be represented in JSON Schema`)},nullProcessor=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},undefinedProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`Undefined cannot be represented in JSON Schema`)},voidProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`Void cannot be represented in JSON Schema`)},neverProcessor=(e,t,n,r)=>{n.not={}},anyProcessor=(e,t,n,r)=>{},unknownProcessor=(e,t,n,r)=>{},dateProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`Date cannot be represented in JSON Schema`)},enumProcessor=(e,t,n,r)=>{let i=e._zod.def,a=getEnumValues(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},literalProcessor=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(handleUnrepresentable(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(handleUnrepresentable(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},nanProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`NaN cannot be represented in JSON Schema`)},templateLiteralProcessor=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},fileProcessor=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},successProcessor=(e,t,n,r)=>{n.type=`boolean`},customProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},functionProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`Function types cannot be represented in JSON Schema`)},transformProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},mapProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`Map cannot be represented in JSON Schema`)},setProcessor=(e,t,n,r)=>{handleUnrepresentable(e,t,n,r,`Set cannot be represented in JSON Schema`)},arrayProcessor=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=process(a.element,t,{...r,path:[...r.path,`items`]})};function inputOptin(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?inputOptin(t.out):t.type===`catch`?inputOptin(t.innerType):e._zod.optin}var objectProcessor=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&handleUnrepresentable(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)assignProp(i.properties,e,process(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e];return t.io===`input`?inputOptin(n)===void 0:n._zod.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=process(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},unionProcessor=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>process(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},intersectionProcessor=(e,t,n,r)=>{let i=e._zod.def,a=process(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=process(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},tupleProcessor=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>process(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?process(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?inputOptin(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=e._zod.bag;typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)},recordProcessor=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=process(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)assignProp(i.patternProperties,t.source,e)}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=process(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=process(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values,l=t.io===`input`&&inputOptin(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},nullableProcessor=(e,t,n,r)=>{let i=e._zod.def,a=process(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},nonoptionalProcessor=(e,t,n,r)=>{let i=e._zod.def;process(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},UNREPRESENTABLE_DEFAULT=Symbol();function serializeDefaultValue(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(handleUnrepresentable(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),UNREPRESENTABLE_DEFAULT):JSON.parse(o)}var defaultProcessor=(e,t,n,r)=>{let i=e._zod.def;process(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=serializeDefaultValue(i.defaultValue,e,t,n,r);o!==UNREPRESENTABLE_DEFAULT&&(n.default=o)},prefaultProcessor=(e,t,n,r)=>{let i=e._zod.def;process(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=serializeDefaultValue(i.defaultValue,e,t,n,r);o!==UNREPRESENTABLE_DEFAULT&&(n._prefault=o)},catchProcessor=(e,t,n,r)=>{let i=e._zod.def;process(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{handleUnrepresentable(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},pipeProcessor=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;process(o,t,r);let s=t.seen.get(e);s.ref=o},readonlyProcessor=(e,t,n,r)=>{let i=e._zod.def;process(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},promiseProcessor=(e,t,n,r)=>{let i=e._zod.def;process(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},optionalProcessor=(e,t,n,r)=>{let i=e._zod.def;process(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},lazyProcessor=(e,t,n,r)=>{let i=e._zod.innerType;process(i,t,r);let a=t.seen.get(e);a.ref=i},allProcessors={string:stringProcessor,number:numberProcessor,boolean:booleanProcessor,bigint:bigintProcessor,symbol:symbolProcessor,null:nullProcessor,undefined:undefinedProcessor,void:voidProcessor,never:neverProcessor,any:anyProcessor,unknown:unknownProcessor,date:dateProcessor,enum:enumProcessor,literal:literalProcessor,nan:nanProcessor,template_literal:templateLiteralProcessor,file:fileProcessor,success:successProcessor,custom:customProcessor,function:functionProcessor,transform:transformProcessor,map:mapProcessor,set:setProcessor,array:arrayProcessor,object:objectProcessor,union:unionProcessor,intersection:intersectionProcessor,tuple:tupleProcessor,record:recordProcessor,nullable:nullableProcessor,nonoptional:nonoptionalProcessor,default:defaultProcessor,prefault:prefaultProcessor,catch:catchProcessor,pipe:pipeProcessor,readonly:readonlyProcessor,promise:promiseProcessor,optional:optionalProcessor,lazy:lazyProcessor};function toJSONSchema(e,t){if(`_idmap`in e){let n=e,r=initializeContext({...t,processors:allProcessors}),i={};for(let e of n._idmap.entries()){let[t,n]=e;process(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;extractDefs(r,n),assignProp(a,t,finalize(r,n))}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=initializeContext({...t,processors:allProcessors});return process(e,n),extractDefs(n,e),finalize(n,e)}var _installedErrorProtos=new WeakSet([Object.prototype,Error.prototype]);function _lazyMethod(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var initializer=(e,t)=>{$ZodError.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);_installedErrorProtos.has(n)||(_installedErrorProtos.add(n),_lazyMethod(n,`format`,e=>t=>formatError(e,t)),_lazyMethod(n,`flatten`,e=>t=>flattenError(e,t)),_lazyMethod(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,jsonStringifyReplacer,2)}),_lazyMethod(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,jsonStringifyReplacer,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},ZodRealError=$constructor(`ZodError`,initializer,void 0,{Parent:Error}),parse=_parse(ZodRealError),parseAsync=_parseAsync(ZodRealError),safeParse=_safeParse(ZodRealError),safeParseAsync=_safeParseAsync(ZodRealError),encode=_encode(ZodRealError),decode=_decode(ZodRealError),encodeAsync=_encodeAsync(ZodRealError),decodeAsync=_decodeAsync(ZodRealError),safeEncode=_safeEncode(ZodRealError),safeDecode=_safeDecode(ZodRealError),safeEncodeAsync=_safeEncodeAsync(ZodRealError),safeDecodeAsync=_safeDecodeAsync(ZodRealError);function _ensureDefaultLocale(){globalConfig.localeError||config(en_default())}function _ensureDefaultMemoizer(){globalConfig.memoizer||config({memoizer:memoizer()})}var ZodType=$constructor(`ZodType`,(e,t)=>(_ensureDefaultLocale(),$ZodType.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(mergeDefs(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return clone(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(refine(e,t))},superRefine(e,t){return this.check(superRefine(e,t))},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){let t=this.clone();return globalRegistry.add(t,{description:e}),t},meta(...e){if(e.length===0)return globalRegistry.get(this);let t=this.clone();return globalRegistry.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},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 e(t,n){return parse(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await parseAsync(this,t,n,{callee:e})},safeParse(e,t){return safeParse(this,e,t)},async safeParseAsync(e,t){return safeParseAsync(this,e,t)},get spa(){return this.safeParseAsync},set spa(e){own(this,`spa`,e)},encode:function e(t,n){return encode(this,t,n,{callee:e})},decode:function e(t,n){return decode(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await encodeAsync(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await decodeAsync(this,t,n,{callee:e})},safeEncode(e,t){return safeEncode(this,e,t)},safeDecode(e,t){return safeDecode(this,e,t)},async safeEncodeAsync(e,t){return safeEncodeAsync(this,e,t)},async safeDecodeAsync(e,t){return safeDecodeAsync(this,e,t)},get toJSONSchema(){return own(this,`toJSONSchema`,createToJSONSchemaMethod(this,{}))},set toJSONSchema(e){own(this,`toJSONSchema`,e)},get description(){return globalRegistry.get(this)?.description},get _def(){return this._zod.def}}),_ZodString=$constructor(`_ZodString`,(e,t)=>{$ZodString.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>stringProcessor(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.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())}}),ZodString=$constructor(`ZodString`,(e,t)=>{$ZodString.init(e,t),_ZodString.init(e,t)},{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)}var ZodStringFormat=$constructor(`ZodStringFormat`,(e,t)=>{$ZodStringFormat.init(e,t),_ZodString.init(e,t)}),ZodISODateTime=$constructor(`ZodISODateTime`,(e,t)=>{$ZodISODateTime.init(e,t),ZodStringFormat.init(e,t)}),ZodISODate=$constructor(`ZodISODate`,(e,t)=>{$ZodISODate.init(e,t),ZodStringFormat.init(e,t)}),ZodISOTime=$constructor(`ZodISOTime`,(e,t)=>{$ZodISOTime.init(e,t),ZodStringFormat.init(e,t)}),ZodISODuration=$constructor(`ZodISODuration`,(e,t)=>{$ZodISODuration.init(e,t),ZodStringFormat.init(e,t)}),ZodEmail=$constructor(`ZodEmail`,(e,t)=>{$ZodEmail.init(e,t),ZodStringFormat.init(e,t)}),ZodGUID=$constructor(`ZodGUID`,(e,t)=>{$ZodGUID.init(e,t),ZodStringFormat.init(e,t)}),ZodUUID=$constructor(`ZodUUID`,(e,t)=>{$ZodUUID.init(e,t),ZodStringFormat.init(e,t)}),ZodURL=$constructor(`ZodURL`,(e,t)=>{$ZodURL.init(e,t),ZodStringFormat.init(e,t)}),ZodEmoji=$constructor(`ZodEmoji`,(e,t)=>{$ZodEmoji.init(e,t),ZodStringFormat.init(e,t)}),ZodNanoID=$constructor(`ZodNanoID`,(e,t)=>{$ZodNanoID.init(e,t),ZodStringFormat.init(e,t)}),ZodCUID=$constructor(`ZodCUID`,(e,t)=>{$ZodCUID.init(e,t),ZodStringFormat.init(e,t)}),ZodCUID2=$constructor(`ZodCUID2`,(e,t)=>{$ZodCUID2.init(e,t),ZodStringFormat.init(e,t)}),ZodULID=$constructor(`ZodULID`,(e,t)=>{$ZodULID.init(e,t),ZodStringFormat.init(e,t)}),ZodXID=$constructor(`ZodXID`,(e,t)=>{$ZodXID.init(e,t),ZodStringFormat.init(e,t)}),ZodKSUID=$constructor(`ZodKSUID`,(e,t)=>{$ZodKSUID.init(e,t),ZodStringFormat.init(e,t)}),ZodIPv4=$constructor(`ZodIPv4`,(e,t)=>{$ZodIPv4.init(e,t),ZodStringFormat.init(e,t)}),ZodIPv6=$constructor(`ZodIPv6`,(e,t)=>{$ZodIPv6.init(e,t),ZodStringFormat.init(e,t)}),ZodCIDRv4=$constructor(`ZodCIDRv4`,(e,t)=>{$ZodCIDRv4.init(e,t),ZodStringFormat.init(e,t)}),ZodCIDRv6=$constructor(`ZodCIDRv6`,(e,t)=>{$ZodCIDRv6.init(e,t),ZodStringFormat.init(e,t)}),ZodBase64=$constructor(`ZodBase64`,(e,t)=>{$ZodBase64.init(e,t),ZodStringFormat.init(e,t)}),ZodBase64URL=$constructor(`ZodBase64URL`,(e,t)=>{$ZodBase64URL.init(e,t),ZodStringFormat.init(e,t)}),ZodE164=$constructor(`ZodE164`,(e,t)=>{$ZodE164.init(e,t),ZodStringFormat.init(e,t)}),ZodJWT=$constructor(`ZodJWT`,(e,t)=>{$ZodJWT.init(e,t),ZodStringFormat.init(e,t)}),ZodNumber=$constructor(`ZodNumber`,(e,t)=>{$ZodNumber.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>numberProcessor(e,t,n,r);let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null},{gt(e,t){return this.check(_gt(e,t))},gte(e,t){return this.check(_gte(e,t))},min(e,t){return this.check(_gte(e,t))},lt(e,t){return this.check(_lt(e,t))},lte(e,t){return this.check(_lte(e,t))},max(e,t){return this.check(_lte(e,t))},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,t){return this.check(_multipleOf(e,t))},step(e,t){return this.check(_multipleOf(e,t))},finite(){return this}});function number(e){return _number(ZodNumber,e)}var ZodNumberFormat=$constructor(`ZodNumberFormat`,(e,t)=>{$ZodNumberFormat.init(e,t),ZodNumber.init(e,t)});function int(e){return _int(ZodNumberFormat,e)}var ZodBoolean=$constructor(`ZodBoolean`,(e,t)=>{$ZodBoolean.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>booleanProcessor(e,t,n,r)});function boolean(e){return _boolean(ZodBoolean,e)}var ZodUnknown=$constructor(`ZodUnknown`,(e,t)=>{$ZodUnknown.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>unknownProcessor(e,t,n,r)});function unknown(){return _unknown(ZodUnknown)}var ZodNever=$constructor(`ZodNever`,(e,t)=>{$ZodNever.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>neverProcessor(e,t,n,r)});function never(e){return _never(ZodNever,e)}var ZodArray=$constructor(`ZodArray`,(e,t)=>{_ensureDefaultMemoizer(),$ZodArray.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>arrayProcessor(e,t,n,r),e.element=t.element},{min(e,t){return this.check(_minLength(e,t))},nonempty(e){return this.check(_minLength(1,e))},max(e,t){return this.check(_maxLength(e,t))},length(e,t){return this.check(_length(e,t))},unwrap(){return this.element}});function array(e,t){return _array(ZodArray,e,t)}var ZodObject=$constructor(`ZodObject`,(e,t)=>{_ensureDefaultMemoizer(),$ZodObjectJIT.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>objectProcessor(e,t,n,r),installLazyProp(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return _enum(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:unknown()})},loose(){return this.clone({...this._zod.def,catchall:unknown()})},strict(){return this.clone({...this._zod.def,catchall:never()})},strip(){return this.clone({...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,t){return new ZodObject({type:`object`,shape:e??{},...normalizeParams(t)})}var ZodUnion=$constructor(`ZodUnion`,(e,t)=>{$ZodUnion.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>unionProcessor(e,t,n,r),e.options=t.options});function union(e,t){return new ZodUnion({type:`union`,options:e,...normalizeParams(t)})}var ZodIntersection=$constructor(`ZodIntersection`,(e,t)=>{$ZodIntersection.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>intersectionProcessor(e,t,n,r)});function intersection(e,t){return new ZodIntersection({type:`intersection`,left:e,right:t})}var ZodEnum=$constructor(`ZodEnum`,(e,t)=>{$ZodEnum.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>enumProcessor(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new ZodEnum({...t,checks:[],...normalizeParams(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new ZodEnum({...t,checks:[],...normalizeParams(r),entries:i})}});function _enum(e,t){return new ZodEnum({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...normalizeParams(t)})}var ZodTransform=$constructor(`ZodTransform`,(e,t)=>{_ensureDefaultMemoizer(),$ZodTransform.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>transformProcessor(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new $ZodEncodeError(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(issue(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(issue(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function transform(e){return new ZodTransform({type:`transform`,transform:e})}var ZodOptional=$constructor(`ZodOptional`,(e,t)=>{$ZodOptional.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>optionalProcessor(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function optional(e){return new ZodOptional({type:`optional`,innerType:e})}var ZodExactOptional=$constructor(`ZodExactOptional`,(e,t)=>{$ZodExactOptional.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>optionalProcessor(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function exactOptional(e){return new ZodExactOptional({type:`optional`,innerType:e})}var ZodNullable=$constructor(`ZodNullable`,(e,t)=>{$ZodNullable.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nullableProcessor(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nullable(e){return new ZodNullable({type:`nullable`,innerType:e})}var ZodDefault=$constructor(`ZodDefault`,(e,t)=>{$ZodDefault.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>defaultProcessor(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function _default(e,t){return new ZodDefault({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():shallowClone(t)}})}var ZodPrefault=$constructor(`ZodPrefault`,(e,t)=>{$ZodPrefault.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>prefaultProcessor(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function prefault(e,t){return new ZodPrefault({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():shallowClone(t)}})}var ZodNonOptional=$constructor(`ZodNonOptional`,(e,t)=>{$ZodNonOptional.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nonoptionalProcessor(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function nonoptional(e,t){return new ZodNonOptional({type:`nonoptional`,innerType:e,...normalizeParams(t)})}var ZodCatch=$constructor(`ZodCatch`,(e,t)=>{$ZodCatch.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>catchProcessor(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function _catch(e,t){return new ZodCatch({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:constantCatch(t)})}var ZodPipe=$constructor(`ZodPipe`,(e,t)=>{$ZodPipe.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pipeProcessor(e,t,n,r),e.in=t.in,e.out=t.out});function pipe(e,t){return new ZodPipe({type:`pipe`,in:e,out:t})}var ZodReadonly=$constructor(`ZodReadonly`,(e,t)=>{$ZodReadonly.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>readonlyProcessor(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function readonly(e){return new ZodReadonly({type:`readonly`,innerType:e})}var ZodCustom=$constructor(`ZodCustom`,(e,t)=>{$ZodCustom.init(e,t),ZodType.init(e,t),e._zod.processJSONSchema=(t,n,r)=>customProcessor(e,t,n,r)});function refine(e,t={}){return _refine(ZodCustom,e,t)}function superRefine(e,t){return _superRefine(e,t)}var InvokeErrorTypes={NETWORK_ERROR:`network_error`,RATE_LIMIT:`rate_limit`,SERVER_ERROR:`server_error`,NO_TOOL_CALL:`no_tool_call`,INVALID_TOOL_ARGS:`invalid_tool_args`,TOOL_EXECUTION_ERROR:`tool_execution_error`,INVALID_RESPONSE:`invalid_response`,INVALID_SCHEMA:`invalid_schema`,UNKNOWN:`unknown`,CONFIG_ERROR:`config_error`,AUTH_ERROR:`auth_error`,CONTEXT_LENGTH:`context_length`,CONTENT_FILTER:`content_filter`},RETRYABLE_TYPES=[InvokeErrorTypes.NETWORK_ERROR,InvokeErrorTypes.RATE_LIMIT,InvokeErrorTypes.SERVER_ERROR,InvokeErrorTypes.NO_TOOL_CALL,InvokeErrorTypes.INVALID_TOOL_ARGS,InvokeErrorTypes.TOOL_EXECUTION_ERROR,InvokeErrorTypes.INVALID_RESPONSE,InvokeErrorTypes.INVALID_SCHEMA,InvokeErrorTypes.UNKNOWN],InvokeError=class extends Error{type;retryable;statusCode;rawError;rawResponse;constructor(e,t,n,r){super(t),this.name=`InvokeError`,this.type=e,this.retryable=RETRYABLE_TYPES.includes(e),this.rawError=n,this.rawResponse=r}};function stringReplaceAll(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function stringEncaseCRLFWithFirstIndex(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
|
|
53
53
|
`:`
|
|
54
54
|
`)+n,i=r+1,r=e.indexOf(`
|
|
55
55
|
`,i)}while(r!==-1);return a+=e.slice(i),a}var ANSI_BACKGROUND_OFFSET=10,ANSI_UNDERLINE_OFFSET=20,wrapAnsi16=(e=0)=>t=>`\u{1B}[${t+e}m`,wrapAnsi256=(e=0)=>t=>`\u{1B}[${38+e};5;${t}m`,wrapAnsi16m=(e=0)=>(t,n,r)=>`\u{1B}[${38+e};2;${t};${n};${r}m`,wrapUnderlineAnsi=e=>`\u{1B}[58;5;${e<90?e-30:e-90+8}m`,styles$1={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],underlineDouble:[`4:2`,24],underlineCurly:[`4:3`,24],underlineDotted:[`4:4`,24],underlineDashed:[`4:5`,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]},underlineColor:{underlineBlack:[`58;5;0`,59],underlineRed:[`58;5;1`,59],underlineGreen:[`58;5;2`,59],underlineYellow:[`58;5;3`,59],underlineBlue:[`58;5;4`,59],underlineMagenta:[`58;5;5`,59],underlineCyan:[`58;5;6`,59],underlineWhite:[`58;5;7`,59],underlineBlackBright:[`58;5;8`,59],underlineGray:[`58;5;8`,59],underlineGrey:[`58;5;8`,59],underlineRedBright:[`58;5;9`,59],underlineGreenBright:[`58;5;10`,59],underlineYellowBright:[`58;5;11`,59],underlineBlueBright:[`58;5;12`,59],underlineMagentaBright:[`58;5;13`,59],underlineCyanBright:[`58;5;14`,59],underlineWhiteBright:[`58;5;15`,59]}},modifierNames=Object.keys(styles$1.modifier),foregroundColorNames=Object.keys(styles$1.color),backgroundColorNames=Object.keys(styles$1.bgColor),underlineColorNames=Object.keys(styles$1.underlineColor),colorNames=[...foregroundColorNames,...backgroundColorNames];function assembleStyles(){let e=new Map;for(let[t,n]of Object.entries(styles$1)){for(let[t,r]of Object.entries(n))styles$1[t]={open:`\u{1B}[${r[0]}m`,close:`\u{1B}[${r[1]}m`},n[t]=styles$1[t],e.set(Number.parseInt(r[0],10),r[1]);Object.defineProperty(styles$1,t,{value:n,enumerable:!1})}return Object.defineProperty(styles$1,"codes",{value:e,enumerable:!1}),styles$1.color.close=`\x1B[39m`,styles$1.bgColor.close=`\x1B[49m`,styles$1.underlineColor.close=`\x1B[59m`,styles$1.color.ansi=wrapAnsi16(),styles$1.color.ansi256=wrapAnsi256(),styles$1.color.ansi16m=wrapAnsi16m(),styles$1.bgColor.ansi=wrapAnsi16(ANSI_BACKGROUND_OFFSET),styles$1.bgColor.ansi256=wrapAnsi256(ANSI_BACKGROUND_OFFSET),styles$1.bgColor.ansi16m=wrapAnsi16m(ANSI_BACKGROUND_OFFSET),styles$1.underlineColor.ansi=wrapUnderlineAnsi,styles$1.underlineColor.ansi256=wrapAnsi256(ANSI_UNDERLINE_OFFSET),styles$1.underlineColor.ansi16m=wrapAnsi16m(ANSI_UNDERLINE_OFFSET),Object.defineProperties(styles$1,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[\da-f]{6}|[\da-f]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>styles$1.rgbToAnsi256(...styles$1.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>styles$1.ansi256ToAnsi(styles$1.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>styles$1.ansi256ToAnsi(styles$1.hexToAnsi256(e)),enumerable:!1}}),styles$1}var ansiStyles=assembleStyles(),level=`navigator`in globalThis?globalThis.navigator.userAgentData&&globalThis.navigator.userAgentData.brands.find(({brand:e})=>e===`Chromium`)?.version>93?3:+!!/\b(?:Chrome|Chromium)\//.test(globalThis.navigator.userAgent):0,colorSupport=level!==0&&{level,hasBasic:!0,has256:level>=2,has16m:level>=3},supportsColor={stdout:colorSupport,stderr:colorSupport},{stdout:stdoutColor,stderr:stderrColor}=supportsColor,GENERATOR=Symbol(`GENERATOR`),STYLER=Symbol(`STYLER`),IS_EMPTY=Symbol(`IS_EMPTY`),LEVEL=Symbol(`LEVEL`),styles=Object.create(null),assertValidLevel=e=>{if(!Number.isSafeInteger(e)||e<0||e>3)throw Error("The `level` should be an integer from 0 to 3")},levelDescriptor={enumerable:!0,get(){return this[LEVEL]},set(e){assertValidLevel(e),this[LEVEL]=e}},applyOptions=(e,t={})=>{t.level!==void 0&&assertValidLevel(t.level);let n=stdoutColor?stdoutColor.level:0;e[LEVEL]=t.level===void 0?n:t.level},chalkFactory=e=>{let t=(...e)=>e.join(` `);return applyOptions(t,e),Object.setPrototypeOf(t,createChalk.prototype),t};function createChalk(e){return chalkFactory(e)}Object.setPrototypeOf(createChalk.prototype,Function.prototype);for(let[e,t]of Object.entries(ansiStyles))styles[e]={get(){let n=createBuilder(this,createStyler(t.open,t.close,this[STYLER]),this[IS_EMPTY]);return Object.defineProperty(this,e,{value:n}),n}};styles.visible={get(){let e=createBuilder(this,this[STYLER],!0);return Object.defineProperty(this,"visible",{value:e}),e}};var createModelConverters=(e,t)=>{let n=ansiStyles[t];if(e===`rgb`){let e=(e,t,r)=>n.ansi(ansiStyles.rgbToAnsi(e,t,r));return[e,e,(e,t,r)=>n.ansi256(ansiStyles.rgbToAnsi256(e,t,r)),n.ansi16m]}if(e===`hex`){let e=e=>n.ansi(ansiStyles.hexToAnsi(e));return[e,e,e=>n.ansi256(ansiStyles.hexToAnsi256(e)),e=>n.ansi16m(...ansiStyles.hexToRgb(e))]}let r=e=>n.ansi(ansiStyles.ansi256ToAnsi(e));return[r,r,n.ansi256,n.ansi256]};for(let e of[`rgb`,`hex`,`ansi256`]){let t=e[0].toUpperCase()+e.slice(1);for(let[n,r]of[[e,`color`],[`bg`+t,`bgColor`],[`underline`+t,`underlineColor`]]){let{close:t}=ansiStyles[r],i=createModelConverters(e,r);styles[n]={get(){let e=function(e,n,r){let a=i[this.level](e,n,r);return createBuilder(this,createStyler(a,t,this[STYLER]),this[IS_EMPTY])};return Object.defineProperty(this,n,{value:e}),e}}}}var proto=Object.defineProperties(()=>{},{...styles,level:{enumerable:!0,get(){return this[GENERATOR].level},set(e){this[GENERATOR].level=e}}}),createStyler=(e,t,n)=>{let r,i;return n===void 0?(r=e,i=t):(r=n.openAll+e,i=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:i,parent:n}},createBuilder=(e,t,n)=>{let r=(...e)=>e.length===1?applyStyle(r,``+e[0]):e.length===2?applyStyle(r,e[0]+` `+e[1]):applyStyle(r,e.join(` `));return Object.setPrototypeOf(r,proto),r[GENERATOR]=e[GENERATOR]??e,r[STYLER]=t,r[IS_EMPTY]=n,r},applyStyle=(e,t)=>{if(e[GENERATOR][LEVEL]<=0||!t)return e[IS_EMPTY]?``:t;let n=e[STYLER];if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=stringReplaceAll(t,n.close,n.open),n=n.parent;let a=t.indexOf(`
|
|
56
|
-
`);return a!==-1&&(t=stringEncaseCRLFWithFirstIndex(t,i,r,a)),r+t+i};Object.defineProperties(createChalk.prototype,{...styles,level:levelDescriptor});var chalk=createChalk(),chalkStderr=createChalk({level:stderrColor?stderrColor.level:0}),InvokeErrorTypes={NETWORK_ERROR:`network_error`,RATE_LIMIT:`rate_limit`,SERVER_ERROR:`server_error`,NO_TOOL_CALL:`no_tool_call`,INVALID_TOOL_ARGS:`invalid_tool_args`,TOOL_EXECUTION_ERROR:`tool_execution_error`,INVALID_RESPONSE:`invalid_response`,INVALID_SCHEMA:`invalid_schema`,UNKNOWN:`unknown`,CONFIG_ERROR:`config_error`,AUTH_ERROR:`auth_error`,CONTEXT_LENGTH:`context_length`,CONTENT_FILTER:`content_filter`},RETRYABLE_TYPES=[InvokeErrorTypes.NETWORK_ERROR,InvokeErrorTypes.RATE_LIMIT,InvokeErrorTypes.SERVER_ERROR,InvokeErrorTypes.NO_TOOL_CALL,InvokeErrorTypes.INVALID_TOOL_ARGS,InvokeErrorTypes.TOOL_EXECUTION_ERROR,InvokeErrorTypes.INVALID_RESPONSE,InvokeErrorTypes.INVALID_SCHEMA,InvokeErrorTypes.UNKNOWN],InvokeError=class extends Error{type;retryable;statusCode;rawError;rawResponse;constructor(e,t,n,r){super(t),this.name=`InvokeError`,this.type=e,this.retryable=RETRYABLE_TYPES.includes(e),this.rawError=n,this.rawResponse=r}};function debug(...e){console.debug(chalk.gray(`[LLM]`),...e)}function zodToOpenAITool(e,t){return{type:`function`,function:{name:e,description:t.description,parameters:toJSONSchema(t.inputSchema,{target:`openapi-3.0`})}}}function modelPatch(e,t){let n=e.model||``;if(!n)return e;let r=getProvider(t),i=normalizeModelName(n);if(i.startsWith(`qwen`)&&(r===`openrouter`&&i.startsWith(`qwen38-max`)?(debug(`Patch Qwen3.8-max on OpenRouter: reasoning_effort=low, remove tool_choice`),e.reasoning_effort=`low`,delete e.tool_choice):(debug(`Patch Qwen: disable thinking`),e.enable_thinking=!1),e.temperature===void 0&&!/max|plus/.test(i)&&(debug(`Patch Qwen: raise temperature to 1.0`),e.temperature=1)),i.startsWith(`deepseek`)&&(debug(`Patch DeepSeek: disable thinking, remove tool_choice`),e.thinking={type:`disabled`},delete e.tool_choice),i.startsWith(`gpt`)&&(i.startsWith(`gpt-5`)&&(e.verbosity=`low`),i.includes(`chat-latest`)?(debug(`Patch chat-latest: omit reasoning_effort and temperature`),delete e.reasoning_effort,delete e.temperature):/^gpt-5[12](-|$)/.test(i)?(debug(`Patch GPT-5.1/5.2: reasoning_effort=none`),e.reasoning_effort=`none`):/^gpt-5(-|$)/.test(i)?(debug(`Patch GPT-5: reasoning_effort=minimal`),e.reasoning_effort=`minimal`):(debug(`Patch GPT: omit reasoning_effort`),delete e.reasoning_effort)),i.startsWith(`claude`)&&(/opus|sonnet|haiku/.test(i)?(debug(`Patch Claude: disable thinking`),e.thinking={type:`disabled`},r!==`openrouter`&&(e.tool_choice===`required`?(debug(`Applying Claude patch: convert tool_choice "required" to { type: "any" }`),e.tool_choice={type:`any`}):e.tool_choice?.function?.name&&(debug(`Applying Claude patch: convert tool_choice format`),e.tool_choice={type:`tool`,name:e.tool_choice.function.name}))):(debug(`Patch Claude: reasoning_effort=low`),e.reasoning_effort=`low`,delete e.tool_choice)),i.startsWith(`gemini`)&&(debug(`Patch Gemini: reasoning_effort=low`),e.reasoning_effort=`low`,/^gemini-25(?!.*pro)/.test(i)?(debug(`Patch Gemini 2.5 non-Pro: reasoning_effort=none`),e.reasoning_effort=`none`):(i.startsWith(`gemini-35-flash`)||i.startsWith(`gemini-31-flash-lite`)||i.startsWith(`gemini-3-flash`))&&(debug(`Patch Gemini 3.x Flash/Lite: reasoning_effort=minimal`),e.reasoning_effort=`minimal`)),i.startsWith(`glm`)&&(/^glm-5[3-9]/.test(i)?(debug(`Patch GLM 5.3+: reasoning_effort=low`),e.reasoning_effort=`low`):(debug(`Patch GLM: disable thinking`),e.thinking={type:`disabled`})),i.startsWith(`hy`)&&(debug(`Patch Hunyuan: disable thinking, reasoning_effort=low`),e.thinking={type:`disabled`},e.reasoning_effort=`low`),i.startsWith(`grok`)&&(/^grok-4-?3/.test(i)?(debug(`Patch Grok 4.3: reasoning_effort=none`),e.reasoning_effort=`none`):(i.startsWith(`grok-3-mini`)||i.startsWith(`grok-code-fast`))&&(debug(`Patch Grok mini/code: reasoning_effort=low`),e.reasoning_effort=`low`)),i.startsWith(`kimi`)&&(i.startsWith(`kimi-k3`)?(debug(`Patch Kimi K3: use required tool choice, remove parallel tool calls`),delete e.parallel_tool_calls,e.tool_choice?.function?.name&&(e.tool_choice=`required`)):i.includes(`code`)||(debug(`Patch Kimi: disable thinking`),e.thinking={type:`disabled`})),i.startsWith(`minimax`)&&(debug(`Patch MiniMax: remove parallel_tool_calls`),delete e.parallel_tool_calls,i.includes(`m3`)&&(debug(`Patch MiniMax: disable thinking`),e.thinking={type:`disabled`})),r===`openrouter`){let t=e.reasoning_effort;e.thinking?.type===`disabled`||e.enable_thinking===!1||t===`none`?e.reasoning={enabled:!1}:t&&(e.reasoning={enabled:!0,effort:t})}return e}function normalizeModelName(e){let t=e.toLowerCase();return t.includes(`/`)&&(t=t.split(`/`)[1]),t=t.replace(/_/g,``),t=t.replace(/\./g,``),t}function getProvider(e){if(e)try{return new URL(e).hostname===`openrouter.ai`?`openrouter`:void 0}catch{return}}var OpenAIClient=class{config;fetch;constructor(e){this.config=e,this.fetch=e.customFetch}async invoke(e,t,n,r){n?.throwIfAborted();let i=Object.entries(t).map(([e,t])=>zodToOpenAITool(e,t)),a=`required`;r?.toolChoiceName&&!this.config.disableNamedToolChoice&&(a={type:`function`,function:{name:r.toolChoiceName}});let o={model:this.config.model,messages:e,tools:i,parallel_tool_calls:!1,tool_choice:a};this.config.temperature!==void 0&&(o.temperature=this.config.temperature),modelPatch(o,this.config.baseURL);let s;try{s=this.config.transformRequestBody(o)}catch(e){throw new InvokeError(InvokeErrorTypes.CONFIG_ERROR,`transformRequestBody failed: ${e.message}`,e)}let c=s??o,l;try{l=await this.fetch(`${this.config.baseURL}/chat/completions`,{method:`POST`,headers:{"Content-Type":`application/json`,...this.config.apiKey&&{Authorization:`Bearer ${this.config.apiKey}`}},body:JSON.stringify(c),signal:n})}catch(e){throw e?.name===`AbortError`?e:(console.error(e),new InvokeError(InvokeErrorTypes.NETWORK_ERROR,`Network request failed`,e))}if(!l.ok){let e;try{e=await l.json()}catch(e){if(e?.name===`AbortError`)throw e}let t=e?.error?.message||l.statusText;throw l.status===401||l.status===403?new InvokeError(InvokeErrorTypes.AUTH_ERROR,`Authentication failed: ${t}`,e):l.status===429?new InvokeError(InvokeErrorTypes.RATE_LIMIT,`Rate limit exceeded: ${t}`,e):l.status>=500?new InvokeError(InvokeErrorTypes.SERVER_ERROR,`Server error: ${t}`,e):new InvokeError(InvokeErrorTypes.UNKNOWN,`HTTP ${l.status}: ${t}`,e)}let u;try{u=await l.json()}catch(e){throw e?.name===`AbortError`?e:new InvokeError(InvokeErrorTypes.INVALID_RESPONSE,`Response body is not valid JSON`,e)}let d=u.choices?.[0];if(!d)throw new InvokeError(InvokeErrorTypes.INVALID_SCHEMA,`No choices in response`,u);switch(d.finish_reason){case`tool_calls`:case`function_call`:case`stop`:break;case`length`:throw new InvokeError(InvokeErrorTypes.CONTEXT_LENGTH,`Response truncated: max tokens reached`,void 0,u);case`content_filter`:throw new InvokeError(InvokeErrorTypes.CONTENT_FILTER,`Content filtered by safety system`,void 0,u);default:throw new InvokeError(InvokeErrorTypes.INVALID_SCHEMA,`Unexpected finish_reason: ${d.finish_reason}`,void 0,u)}let f=(r?.normalizeResponse?r.normalizeResponse(u):u).choices?.[0],p=f?.message?.tool_calls?.[0]?.function?.name;if(!p)throw new InvokeError(InvokeErrorTypes.NO_TOOL_CALL,`No tool call found in response`,void 0,u);let m=t[p];if(!m)throw new InvokeError(InvokeErrorTypes.UNKNOWN,`Tool "${p}" not found in tools`,void 0,u);let h=f.message?.tool_calls?.[0]?.function?.arguments;if(!h)throw new InvokeError(InvokeErrorTypes.INVALID_TOOL_ARGS,`No tool call arguments found`,void 0,u);let g;try{g=JSON.parse(h)}catch(e){throw new InvokeError(InvokeErrorTypes.INVALID_TOOL_ARGS,`Failed to parse tool arguments as JSON`,e,u)}let _=m.inputSchema.safeParse(g);if(!_.success)throw console.error(prettifyError(_.error)),new InvokeError(InvokeErrorTypes.INVALID_TOOL_ARGS,`Tool arguments validation failed`,_.error,u);let v=_.data,y;try{y=await m.execute(v)}catch(e){throw e?.name===`AbortError`?e:new InvokeError(InvokeErrorTypes.TOOL_EXECUTION_ERROR,`Tool execution failed: ${e?.message}`,e,u)}return{toolCall:{name:p,args:v},toolResult:y,usage:{promptTokens:u.usage?.prompt_tokens??0,completionTokens:u.usage?.completion_tokens??0,totalTokens:u.usage?.total_tokens??0,cachedTokens:u.usage?.prompt_tokens_details?.cached_tokens,reasoningTokens:u.usage?.completion_tokens_details?.reasoning_tokens},rawResponse:u,rawRequest:c}}},LLM=class extends EventTarget{config;client;constructor(e){super(),this.config=parseLLMConfig(e),this.client=new OpenAIClient(this.config)}async invoke(e,t,n,r){return await withRetry(async()=>this.client.invoke(e,t,n,r),{maxRetries:this.config.maxRetries,onRetry:(e,t)=>{this.dispatchEvent(new CustomEvent(`retry`,{detail:{attempt:e,maxAttempts:this.config.maxRetries,lastError:t}}))}})}};async function withRetry(e,t){let n=0;for(;;)try{return await e()}catch(e){if(e?.name===`AbortError`||e instanceof InvokeError&&!e.retryable||(n++,n>t.maxRetries))throw e;console.debug(`[LLM] retryable failure, will retry:`,e),t.onRetry(n,e),await new Promise(e=>setTimeout(e,100))}}function parseLLMConfig(e){if(!e.baseURL||!e.model)throw Error(`[PageAgent] LLM configuration required. Please provide: baseURL, model. See: https://alibaba.github.io/page-agent/docs/features/models`);return e.temperature!==void 0&&console.warn(`[PageAgent] LLMConfig.temperature is deprecated and will be removed in a future version. Use transformRequestBody to set it only for models you have verified accept it.`),{baseURL:e.baseURL,model:e.model,apiKey:e.apiKey||``,temperature:e.temperature,maxRetries:e.maxRetries??2,transformRequestBody:e.transformRequestBody??(e=>e),disableNamedToolChoice:e.disableNamedToolChoice??!1,customFetch:(e.customFetch??fetch).bind(globalThis)}}var system_prompt_default=`You are an AI agent designed to operate in an iterative loop to automate browser tasks. Your ultimate goal is accomplishing the task provided in <user_request>.
|
|
56
|
+
`);return a!==-1&&(t=stringEncaseCRLFWithFirstIndex(t,i,r,a)),r+t+i};Object.defineProperties(createChalk.prototype,{...styles,level:levelDescriptor});var chalk=createChalk(),chalkStderr=createChalk({level:stderrColor?stderrColor.level:0});function debug(...e){console.debug(chalk.gray(`[LLM]`),...e)}function zodToOpenAITool(e,t){return{type:`function`,function:{name:e,description:t.description,parameters:toJSONSchema(t.inputSchema,{target:`openapi-3.0`})}}}function modelPatch(e,t){let n=e.model||``;if(!n)return e;let r=getProvider(t),i=normalizeModelName(n);if(i.startsWith(`qwen`)&&(r===`openrouter`&&i.startsWith(`qwen38-max`)?(debug(`Patch Qwen3.8-max on OpenRouter: reasoning_effort=low, remove tool_choice`),e.reasoning_effort=`low`,delete e.tool_choice):(debug(`Patch Qwen: disable thinking`),e.enable_thinking=!1),e.temperature===void 0&&!/max|plus/.test(i)&&(debug(`Patch Qwen: raise temperature to 1.0`),e.temperature=1)),i.startsWith(`deepseek`)&&(debug(`Patch DeepSeek: disable thinking, remove tool_choice`),e.thinking={type:`disabled`},delete e.tool_choice),i.startsWith(`gpt`)&&(i.startsWith(`gpt-5`)&&(e.verbosity=`low`),i.includes(`chat-latest`)?(debug(`Patch chat-latest: omit reasoning_effort and temperature`),delete e.reasoning_effort,delete e.temperature):/^gpt-5[12](-|$)/.test(i)?(debug(`Patch GPT-5.1/5.2: reasoning_effort=none`),e.reasoning_effort=`none`):/^gpt-5(-|$)/.test(i)?(debug(`Patch GPT-5: reasoning_effort=minimal`),e.reasoning_effort=`minimal`):(debug(`Patch GPT: omit reasoning_effort`),delete e.reasoning_effort)),i.startsWith(`claude`)&&(/opus|sonnet|haiku/.test(i)?(debug(`Patch Claude: disable thinking`),e.thinking={type:`disabled`},r!==`openrouter`&&(e.tool_choice===`required`?(debug(`Applying Claude patch: convert tool_choice "required" to { type: "any" }`),e.tool_choice={type:`any`}):e.tool_choice?.function?.name&&(debug(`Applying Claude patch: convert tool_choice format`),e.tool_choice={type:`tool`,name:e.tool_choice.function.name}))):(debug(`Patch Claude: reasoning_effort=low`),e.reasoning_effort=`low`,delete e.tool_choice)),i.startsWith(`gemini`)&&(debug(`Patch Gemini: reasoning_effort=low`),e.reasoning_effort=`low`,/^gemini-25(?!.*pro)/.test(i)?(debug(`Patch Gemini 2.5 non-Pro: reasoning_effort=none`),e.reasoning_effort=`none`):(i.startsWith(`gemini-35-flash`)||i.startsWith(`gemini-31-flash-lite`)||i.startsWith(`gemini-3-flash`))&&(debug(`Patch Gemini 3.x Flash/Lite: reasoning_effort=minimal`),e.reasoning_effort=`minimal`)),i.startsWith(`glm`)&&(/^glm-5[3-9]/.test(i)?(debug(`Patch GLM 5.3+: reasoning_effort=low`),e.reasoning_effort=`low`):(debug(`Patch GLM: disable thinking`),e.thinking={type:`disabled`})),i.startsWith(`hy`)&&(debug(`Patch Hunyuan: disable thinking, reasoning_effort=low`),e.thinking={type:`disabled`},e.reasoning_effort=`low`),i.startsWith(`grok`)&&(/^grok-4-?3/.test(i)?(debug(`Patch Grok 4.3: reasoning_effort=none`),e.reasoning_effort=`none`):(i.startsWith(`grok-3-mini`)||i.startsWith(`grok-code-fast`))&&(debug(`Patch Grok mini/code: reasoning_effort=low`),e.reasoning_effort=`low`)),i.startsWith(`kimi`)&&(i.startsWith(`kimi-k3`)?(debug(`Patch Kimi K3: use required tool choice, remove parallel tool calls`),delete e.parallel_tool_calls,e.tool_choice?.function?.name&&(e.tool_choice=`required`)):i.includes(`code`)||(debug(`Patch Kimi: disable thinking`),e.thinking={type:`disabled`})),i.startsWith(`minimax`)&&(debug(`Patch MiniMax: remove parallel_tool_calls`),delete e.parallel_tool_calls,i.includes(`m3`)&&(debug(`Patch MiniMax: disable thinking`),e.thinking={type:`disabled`})),r===`openrouter`){let t=e.reasoning_effort;e.thinking?.type===`disabled`||e.enable_thinking===!1||t===`none`?e.reasoning={enabled:!1}:t&&(e.reasoning={enabled:!0,effort:t})}return e}function normalizeModelName(e){let t=e.toLowerCase();return t.includes(`/`)&&(t=t.split(`/`)[1]),t=t.replace(/_/g,``),t=t.replace(/\./g,``),t}function getProvider(e){if(e)try{return new URL(e).hostname===`openrouter.ai`?`openrouter`:void 0}catch{return}}var OpenAIClient=class{config;fetch;constructor(e){this.config=e,this.fetch=e.customFetch}async invoke(e,t,n,r){n?.throwIfAborted();let i=Object.entries(t).map(([e,t])=>zodToOpenAITool(e,t)),a=`required`;r?.toolChoiceName&&!this.config.disableNamedToolChoice&&(a={type:`function`,function:{name:r.toolChoiceName}});let o={model:this.config.model,messages:e,tools:i,parallel_tool_calls:!1,tool_choice:a};this.config.temperature!==void 0&&(o.temperature=this.config.temperature),modelPatch(o,this.config.baseURL);let s;try{s=this.config.transformRequestBody(o)}catch(e){throw new InvokeError(InvokeErrorTypes.CONFIG_ERROR,`transformRequestBody failed: ${e.message}`,e)}let c=s??o,l;try{l=await this.fetch(`${this.config.baseURL}/chat/completions`,{method:`POST`,headers:{"Content-Type":`application/json`,...this.config.apiKey&&{Authorization:`Bearer ${this.config.apiKey}`}},body:JSON.stringify(c),signal:n})}catch(e){throw e?.name===`AbortError`?e:(console.error(e),new InvokeError(InvokeErrorTypes.NETWORK_ERROR,`Network request failed`,e))}if(!l.ok){let e;try{e=await l.json()}catch(e){if(e?.name===`AbortError`)throw e}let t=e?.error?.message||l.statusText;throw l.status===401||l.status===403?new InvokeError(InvokeErrorTypes.AUTH_ERROR,`Authentication failed: ${t}`,e):l.status===429?new InvokeError(InvokeErrorTypes.RATE_LIMIT,`Rate limit exceeded: ${t}`,e):l.status>=500?new InvokeError(InvokeErrorTypes.SERVER_ERROR,`Server error: ${t}`,e):new InvokeError(InvokeErrorTypes.UNKNOWN,`HTTP ${l.status}: ${t}`,e)}let u;try{u=await l.json()}catch(e){throw e?.name===`AbortError`?e:new InvokeError(InvokeErrorTypes.INVALID_RESPONSE,`Response body is not valid JSON`,e)}let d=u.choices?.[0];if(!d)throw new InvokeError(InvokeErrorTypes.INVALID_SCHEMA,`No choices in response`,u);switch(d.finish_reason){case`tool_calls`:case`function_call`:case`stop`:break;case`length`:throw new InvokeError(InvokeErrorTypes.CONTEXT_LENGTH,`Response truncated: max tokens reached`,void 0,u);case`content_filter`:throw new InvokeError(InvokeErrorTypes.CONTENT_FILTER,`Content filtered by safety system`,void 0,u);default:throw new InvokeError(InvokeErrorTypes.INVALID_SCHEMA,`Unexpected finish_reason: ${d.finish_reason}`,void 0,u)}let f=(r?.normalizeResponse?r.normalizeResponse(u):u).choices?.[0],p=f?.message?.tool_calls?.[0]?.function?.name;if(!p)throw new InvokeError(InvokeErrorTypes.NO_TOOL_CALL,`No tool call found in response`,void 0,u);let m=t[p];if(!m)throw new InvokeError(InvokeErrorTypes.UNKNOWN,`Tool "${p}" not found in tools`,void 0,u);let h=f.message?.tool_calls?.[0]?.function?.arguments;if(!h)throw new InvokeError(InvokeErrorTypes.INVALID_TOOL_ARGS,`No tool call arguments found`,void 0,u);let g;try{g=JSON.parse(h)}catch(e){throw new InvokeError(InvokeErrorTypes.INVALID_TOOL_ARGS,`Failed to parse tool arguments as JSON`,e,u)}let _=m.inputSchema.safeParse(g);if(!_.success)throw console.error(prettifyError(_.error)),new InvokeError(InvokeErrorTypes.INVALID_TOOL_ARGS,`Tool arguments validation failed`,_.error,u);let v=_.data,y;try{y=await m.execute(v)}catch(e){throw e?.name===`AbortError`?e:new InvokeError(InvokeErrorTypes.TOOL_EXECUTION_ERROR,`Tool execution failed: ${e?.message}`,e,u)}return{toolCall:{name:p,args:v},toolResult:y,usage:{promptTokens:u.usage?.prompt_tokens??0,completionTokens:u.usage?.completion_tokens??0,totalTokens:u.usage?.total_tokens??0,cachedTokens:u.usage?.prompt_tokens_details?.cached_tokens,reasoningTokens:u.usage?.completion_tokens_details?.reasoning_tokens},rawResponse:u,rawRequest:c}}},LLM=class extends EventTarget{config;client;constructor(e){super(),this.config=parseLLMConfig(e),this.client=new OpenAIClient(this.config)}async invoke(e,t,n,r){return await withRetry(async()=>this.client.invoke(e,t,n,r),{maxRetries:this.config.maxRetries,onRetry:(e,t)=>{this.dispatchEvent(new CustomEvent(`retry`,{detail:{attempt:e,maxAttempts:this.config.maxRetries,lastError:t}}))}})}};async function withRetry(e,t){let n=0;for(;;)try{return await e()}catch(e){if(e?.name===`AbortError`||e instanceof InvokeError&&!e.retryable||(n++,n>t.maxRetries))throw e;console.debug(`[LLM] retryable failure, will retry:`,e),t.onRetry(n,e),await new Promise(e=>setTimeout(e,100))}}function parseLLMConfig(e){if(!e.baseURL||!e.model)throw Error(`[PageAgent] LLM configuration required. Please provide: baseURL, model. See: https://alibaba.github.io/page-agent/docs/features/models`);return e.temperature!==void 0&&console.warn(`[PageAgent] LLMConfig.temperature is deprecated and will be removed in a future version. Use transformRequestBody to set it only for models you have verified accept it.`),{baseURL:e.baseURL,model:e.model,apiKey:e.apiKey||``,temperature:e.temperature,maxRetries:e.maxRetries??2,transformRequestBody:e.transformRequestBody??(e=>e),disableNamedToolChoice:e.disableNamedToolChoice??!1,customFetch:(e.customFetch??fetch).bind(globalThis)}}var system_prompt_default=`You are an AI agent designed to operate in an iterative loop to automate browser tasks. Your ultimate goal is accomplishing the task provided in <user_request>.
|
|
57
57
|
|
|
58
58
|
<intro>
|
|
59
59
|
You excel at following tasks:
|
|
@@ -399,4 +399,4 @@ gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
|
399
399
|
/>
|
|
400
400
|
</div>
|
|
401
401
|
</div>
|
|
402
|
-
`,document.body.appendChild(t),t}#P(){this.wrapper.querySelector(`.${Panel_module_default.header}`).addEventListener(`click`,e=>{e.target.closest(`.${Panel_module_default.controlButton}`)||this.#F()}),this.#i.addEventListener(`click`,e=>{e.stopPropagation(),this.#F()}),this.#a.addEventListener(`click`,e=>{e.stopPropagation(),this.#D()}),this.#s.addEventListener(`keydown`,e=>{e.isComposing||e.key===`Enter`&&(e.preventDefault(),this.#O())}),this.#o.addEventListener(`click`,e=>{e.stopPropagation()})}#F(){this.#u?this.#L():this.#I()}#I(){this.#u=!0,this.wrapper.classList.add(Panel_module_default.expanded),this.#i.textContent=`▲`}#L(){this.#u=!1,this.wrapper.classList.remove(Panel_module_default.expanded),this.#i.textContent=`▼`}#R(){this.#m=setInterval(()=>{this.#B()},450)}#z(){this.#m&&=(clearInterval(this.#m),null)}#B(){if(!this.#h||this.#g)return;if(this.#n.textContent===this.#h){this.#h=null;return}let e=this.#h;this.#h=null,this.#V(e)}#V(e){this.#g=!0,this.#n.classList.add(Panel_module_default.fadeOut),setTimeout(()=>{this.#n.textContent=e,this.#n.classList.remove(Panel_module_default.fadeOut),this.#n.classList.add(Panel_module_default.fadeIn),setTimeout(()=>{this.#n.classList.remove(Panel_module_default.fadeIn),this.#g=!1},300)},150)}#H(e){let t=e===`running`?`thinking`:e;this.#t.className=Panel_module_default.indicator,t!==`idle`&&t!==`stopped`&&this.#t.classList.add(Panel_module_default[t])}#U(){setTimeout(()=>{this.#r.scrollTop=this.#r.scrollHeight},0)}#W(){let e=[],t=this.#c.task;t&&e.push(this.#G(t));let n=this.#c.history;for(let t of n)e.push(...this.#K(t));this.#r.innerHTML=e.join(``),this.#U()}#G(e){return createCard({icon:iconTask,content:e,type:`input`,from:`pessoa`,author:this.#d.t(`ui.panel.authorPerson`)})}#K(e){let t=[],n=e.type===`step`&&e.stepIndex!==void 0?this.#d.t(`ui.panel.step`,{number:(e.stepIndex+1).toString()}):void 0;if(e.type===`step`){if(e.reflection){let r=createReflectionLines(e.reflection,{evaluation:this.#d.t(`ui.panel.reflectionEvaluation`),memory:this.#d.t(`ui.panel.reflectionMemory`),nextGoal:this.#d.t(`ui.panel.reflectionNextGoal`)});r.length>0&&t.push(createCard({icon:iconThinking,content:r,meta:n,author:this.#d.t(`ui.panel.authorReasoning`)}))}let r=e.action;r&&t.push(...this.#q(r,n))}else if(e.type===`observation`)t.push(createCard({icon:iconObservation,content:e.content||``,meta:n,type:`observation`,author:this.#d.t(`ui.panel.authorPage`)}));else if(e.type===`user_takeover`)t.push(createCard({icon:iconUser,content:this.#d.t(`ui.panel.userTakeover`),meta:n,type:`input`,from:`pessoa`,author:this.#d.t(`ui.panel.authorPerson`)}));else if(e.type===`retry`){let r=`${e.message||this.#d.t(`ui.panel.retrying`)} (${e.attempt}/${e.maxAttempts})`;t.push(createCard({icon:iconRetry,content:r,meta:n,type:`observation`,from:`sistema`,author:this.#d.t(`ui.panel.authorSystem`)}))}else e.type===`error`&&t.push(createCard({icon:iconError,content:e.message||this.#d.t(`ui.panel.errorLabel`),meta:n,type:`observation`,from:`sistema`,author:this.#d.t(`ui.panel.authorSystem`)}));return t}#q(e,t){let n=[];if(e.name===`done`){let r=e.input.text||e.output||``;r&&n.push(createCard({icon:iconDone,content:r,meta:t,type:`output`,author:this.#d.t(`ui.panel.authorAgent`)}))}else if(e.name===`ask_user`){let r=e.input,i=e.output.replace(/^User answered:\s*/i,``);n.push(createCard({icon:iconQuestion,content:this.#d.t(`ui.panel.question`,{question:r.question||``}),meta:t,type:`question`,author:this.#d.t(`ui.panel.authorAgent`)})),n.push(createCard({icon:iconAnswer,content:this.#d.t(`ui.panel.userAnswer`,{input:i}),meta:t,type:`input`,from:`pessoa`,author:this.#d.t(`ui.panel.authorPerson`)}))}else{let r=this.#E(e.name,e.input);n.push(createCard({icon:iconTool,content:r,meta:t,author:this.#d.t(`ui.panel.authorAction`)})),e.output?.length>0&&n.push(createCard({icon:iconTool,content:e.output,meta:t,type:`output`,author:this.#d.t(`ui.panel.authorResult`)}))}return n}},PageAgent=class extends PageAgentCore{panel;constructor(e){let t=new PageController({...e,enableMask:e.enableMask??!0});super({...e,pageController:t}),this.panel=new Panel(this,{language:e.language,promptForNextTask:e.promptForNextTask})}},currentScript=document.currentScript,currentScriptURL=currentScript?.src?new URL(currentScript.src):null,autoInit=currentScriptURL?.searchParams.get(`autoInit`)!==`false`;autoInit&&window.pageAgent&&window.pageAgent.dispose(),window.PageAgent=PageAgent,console.log(`🚀 page-agent.js loaded!`);var DEMO_MODEL=`qwen3.5-plus`,DEMO_BASE_URL=`https://page-ag-testing-ohftxirgbn.cn-shanghai.fcapp.run`,DEMO_API_KEY=`NA`;autoInit&&setTimeout(()=>{let e,t=!0;if(currentScriptURL){let n=currentScriptURL,r=n.searchParams.get(`model`)||DEMO_MODEL,i=n.searchParams.get(`baseURL`)||DEMO_BASE_URL,a=n.searchParams.get(`apiKey`)||DEMO_API_KEY,o=n.searchParams.get(`lang`)||`zh-CN`;t=(n.searchParams.get(`showPanel`)||`true`)===`true`,e={model:r,baseURL:i,apiKey:a,language:o}}else console.log(`🚀 page-agent.js no current script detected, using default demo config`),e={model:DEMO_MODEL,baseURL:DEMO_BASE_URL,apiKey:DEMO_API_KEY};window.pageAgent=new PageAgent(e),t&&window.pageAgent.panel.show(),console.log(`🚀 page-agent.js initialized with config:`,window.pageAgent.config)})})();
|
|
402
|
+
`,document.body.appendChild(t),t}#P(){this.wrapper.querySelector(`.${Panel_module_default.header}`).addEventListener(`click`,e=>{e.target.closest(`.${Panel_module_default.controlButton}`)||this.#F()}),this.#i.addEventListener(`click`,e=>{e.stopPropagation(),this.#F()}),this.#a.addEventListener(`click`,e=>{e.stopPropagation(),this.#D()}),this.#s.addEventListener(`keydown`,e=>{e.isComposing||e.key===`Enter`&&(e.preventDefault(),this.#O())}),this.#o.addEventListener(`click`,e=>{e.stopPropagation()})}#F(){this.#u?this.#L():this.#I()}#I(){this.#u=!0,this.wrapper.classList.add(Panel_module_default.expanded),this.#i.textContent=`▲`}#L(){this.#u=!1,this.wrapper.classList.remove(Panel_module_default.expanded),this.#i.textContent=`▼`}#R(){this.#m=setInterval(()=>{this.#B()},450)}#z(){this.#m&&=(clearInterval(this.#m),null)}#B(){if(!this.#h||this.#g)return;if(this.#n.textContent===this.#h){this.#h=null;return}let e=this.#h;this.#h=null,this.#V(e)}#V(e){this.#g=!0,this.#n.classList.add(Panel_module_default.fadeOut),setTimeout(()=>{this.#n.textContent=e,this.#n.classList.remove(Panel_module_default.fadeOut),this.#n.classList.add(Panel_module_default.fadeIn),setTimeout(()=>{this.#n.classList.remove(Panel_module_default.fadeIn),this.#g=!1},300)},150)}#H(e){let t=e===`running`?`thinking`:e;this.#t.className=Panel_module_default.indicator,t!==`idle`&&t!==`stopped`&&this.#t.classList.add(Panel_module_default[t])}#U(){setTimeout(()=>{this.#r.scrollTop=this.#r.scrollHeight},0)}#W(){let e=[],t=this.#c.task;t&&e.push(this.#G(t));let n=this.#c.history;for(let t of n)e.push(...this.#K(t));this.#r.innerHTML=e.join(``),this.#U()}#G(e){return createCard({icon:iconTask,content:e,type:`input`,from:`pessoa`,author:this.#d.t(`ui.panel.authorPerson`)})}#K(e){let t=[],n=e.type===`step`&&e.stepIndex!==void 0?this.#d.t(`ui.panel.step`,{number:(e.stepIndex+1).toString()}):void 0;if(e.type===`step`){if(e.reflection){let r=createReflectionLines(e.reflection,{evaluation:this.#d.t(`ui.panel.reflectionEvaluation`),memory:this.#d.t(`ui.panel.reflectionMemory`),nextGoal:this.#d.t(`ui.panel.reflectionNextGoal`)});r.length>0&&t.push(createCard({icon:iconThinking,content:r,meta:n,author:this.#d.t(`ui.panel.authorReasoning`)}))}let r=e.action;r&&t.push(...this.#q(r,n))}else if(e.type===`observation`)t.push(createCard({icon:iconObservation,content:e.content||``,meta:n,type:`observation`,author:this.#d.t(`ui.panel.authorPage`)}));else if(e.type===`user_takeover`)t.push(createCard({icon:iconUser,content:this.#d.t(`ui.panel.userTakeover`),meta:n,type:`input`,from:`pessoa`,author:this.#d.t(`ui.panel.authorPerson`)}));else if(e.type===`retry`){let r=`${e.message||this.#d.t(`ui.panel.retrying`)} (${e.attempt}/${e.maxAttempts})`;t.push(createCard({icon:iconRetry,content:r,meta:n,type:`observation`,from:`sistema`,author:this.#d.t(`ui.panel.authorSystem`)}))}else e.type===`error`&&t.push(createCard({icon:iconError,content:e.message||this.#d.t(`ui.panel.errorLabel`),meta:n,type:`observation`,from:`sistema`,author:this.#d.t(`ui.panel.authorSystem`)}));return t}#q(e,t){let n=[];if(e.name===`done`){let r=e.input.text||e.output||``;r&&n.push(createCard({icon:iconDone,content:r,meta:t,type:`output`,author:this.#d.t(`ui.panel.authorAgent`)}))}else if(e.name===`ask_user`){let r=e.input,i=e.output.replace(/^User answered:\s*/i,``);n.push(createCard({icon:iconQuestion,content:this.#d.t(`ui.panel.question`,{question:r.question||``}),meta:t,type:`question`,author:this.#d.t(`ui.panel.authorAgent`)})),n.push(createCard({icon:iconAnswer,content:this.#d.t(`ui.panel.userAnswer`,{input:i}),meta:t,type:`input`,from:`pessoa`,author:this.#d.t(`ui.panel.authorPerson`)}))}else{let r=this.#E(e.name,e.input);n.push(createCard({icon:iconTool,content:r,meta:t,author:this.#d.t(`ui.panel.authorAction`)})),e.output?.length>0&&n.push(createCard({icon:iconTool,content:e.output,meta:t,type:`output`,author:this.#d.t(`ui.panel.authorResult`)}))}return n}};function getRecognitionCtor(){let e=globalThis;return e.SpeechRecognition??e.webkitSpeechRecognition??null}var STATUS_LISTENING=`listening`,STATUS_SPEAKING=`speaking`,STATUS_IDLE=`idle`;function createVoice(e={}){let t=e.lang??`pt-BR`,n=e.rate??1,r=e.pitch??1,i=e.input??!0,a=e.output??!1,o=e.listenTimeoutMs??3e4,s=i?getRecognitionCtor():null,c=typeof window<`u`?window.speechSynthesis:void 0,l={input:!!(i&&s),output:!!(a&&c)},u=STATUS_IDLE,d=new Set;function f(e){u!==e&&(u=e,d.forEach(t=>{try{t(e)}catch{}}))}let p=null,m=null;if(c){let n=()=>{if(e.voiceURI)m=c.getVoices().find(t=>t.voiceURI===e.voiceURI)??null;else{let e=c.getVoices(),n=t.split(`-`)[0].toLowerCase();m=e.find(e=>e.lang?.toLowerCase()===t.toLowerCase())??e.find(e=>e.lang?.toLowerCase().startsWith(n))??null}};n(),c.onvoiceschanged=n}function h(e,i){if(!c||!a)return;let o=(e??``).trim();if(!o)return;i?.interrupt!==!1&&c.cancel();let s=new SpeechSynthesisUtterance(o);s.lang=t,s.rate=n,s.pitch=r,m&&(s.voice=m),s.onend=()=>f(STATUS_IDLE),s.onerror=()=>f(STATUS_IDLE),f(STATUS_SPEAKING),c.speak(s)}function g(){return s?new Promise((e,n)=>{let r=new s;p=r;let i=``,a=!1,c,l=e=>{a||(a=!0,c&&clearTimeout(c),p===r&&(p=null),f(STATUS_IDLE),e())};c=setTimeout(()=>{try{r.stop()}catch{}l(()=>n(Error(`Tempo de escuta esgotado`)))},o),r.lang=t,r.continuous=!1,r.interimResults=!0,r.maxAlternatives=1,r.onstart=()=>f(STATUS_LISTENING),r.onresult=e=>{for(let t=e.resultIndex;t<e.results.length;t++){let n=e.results[t];n?.isFinal&&(i=n[0]?.transcript??i)}},r.onerror=t=>{let r=t?.error;if(r===`no-speech`||r===`aborted`){l(()=>e(i.trim()));return}l(()=>n(Error(`Erro de reconhecimento de voz: ${r??`desconhecido`}`)))},r.onend=()=>{l(()=>e(i.trim()))};try{r.start()}catch(e){l(()=>n(e instanceof Error?e:Error(String(e))))}}):Promise.reject(Error(`Voz de entrada não suportada neste navegador`))}return{supported:l,listen:g,stopListening(){try{p?.stop()}catch{}p=null,f(STATUS_IDLE)},speak:h,stopSpeaking(){c&&(c.cancel(),f(STATUS_IDLE))},onStatus(e){return d.add(e),()=>d.delete(e)}}}var DEFAULTS={language:`pt-BR`,maxSteps:30,enableMask:!0,viewportExpansion:0,promptForNextTask:!0,position:`bottom-right`,launcherLabel:`Abrir assistente da página`,open:!1},LAUNCHER_ICON=`<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3l1.9 4.6L18.5 9l-4.6 1.9L12 15.5l-1.9-4.6L5.5 9l4.6-1.4L12 3z"/><path d="M19 14l.8 2 2 .8-2 .8-.8 2-.8-2-2-.8 2-.8.8-2z"/></svg>`,MIC_ICON=`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="9" y="3" width="6" height="11" rx="3"/><path d="M5 11a7 7 0 0 0 14 0M12 18v3"/></svg>`;function positionCss(e){switch(e){case`bottom-left`:return{bottom:`20px`,left:`20px`,right:`auto`,top:`auto`};case`top-right`:return{top:`20px`,right:`20px`,bottom:`auto`,left:`auto`};case`top-left`:return{top:`20px`,left:`20px`,bottom:`auto`,right:`auto`};default:return{bottom:`20px`,right:`20px`,top:`auto`,left:`auto`}}}function mountWidget(e={}){let t=e.position??DEFAULTS.position,n=e.launcherLabel??DEFAULTS.launcherLabel,r=e.open??DEFAULTS.open,i=null,a=null,o=null,s=!1,c=null;async function l(){if(c)return c;if(e.configUrl)return c=(async()=>{let t=await fetch(e.configUrl,{headers:{accept:`application/json`}});if(!t.ok)throw Error(`mountWidget: configUrl respondeu ${t.status} — o gateway está no ar?`);let n=await t.json();for(let t of[`model`,`language`,`maxSteps`,`promptForNextTask`,`instructions`,`voice`]){let r=n[t];r!=null&&(e[t]=r)}})(),c}function u(){return a||=createVoice(e.voice??{}),a}async function d(){if(i&&!i.disposed)return i;await l();let t=u(),n=e.model,r=e.baseURL;if(!n||!r)throw Error(e.configUrl?"mountWidget: o gateway não enviou `model` e/ou falta `baseURL` no front. Confira AGENT_MODEL no gateway e a baseURL do widget.":"mountWidget: configure `model` e `baseURL` (config central do LLM) antes de abrir o agente.");return i=new PageAgent({model:n,baseURL:r,apiKey:e.apiKey,transformRequestBody:e.transformRequestBody,customFetch:e.customFetch,maxRetries:e.maxRetries,language:e.language??DEFAULTS.language,maxSteps:e.maxSteps??DEFAULTS.maxSteps,enableMask:e.enableMask??DEFAULTS.enableMask,viewportExpansion:e.viewportExpansion??DEFAULTS.viewportExpansion,instructions:e.instructions,customTools:e.customTools,promptForNextTask:e.promptForNextTask??DEFAULTS.promptForNextTask}),f(i,t),p(i,t),i}function f(t,n){let r=e.voice?.speakOnComplete??!0,i=e.voice?.speakSteps??!1;t.addEventListener(`statuschange`,()=>{let e=t.status,a=t.lastResult;if(e===`completed`||e===`error`){r&&n.supported.output&&(e===`error`?n.speak(`A tarefa encontrou um problema e foi parada.`):a?.success?n.speak(`Tarefa concluída com sucesso.`):n.speak(`A tarefa terminou, mas o resultado não foi confirmado.`));return}if(i&&e===`running`&&n.supported.output){let e=[...t.history].reverse().find(e=>e.type===`step`)?.reflection?.next_goal;e&&n.speak(e,{interrupt:!0})}}),t.addEventListener(`activity`,e=>{let t=e.detail;t?.type===`error`&&t.message&&n.supported.output&&n.speak(t.message,{interrupt:!0})})}function p(e,t){let n=e.panel.wrapper,r=n.querySelector(`input`);r&&t.supported.input&&(n.querySelector(`[data-page-agent-voice="mic"]`)||(o&&o.remove(),o=document.createElement(`button`),o.type=`button`,o.className=`page-agent-voice-mic`,o.setAttribute(`data-page-agent-voice`,`mic`),o.setAttribute(`aria-label`,`Ditar tarefa por voz`),o.title=`Ditar tarefa por voz`,o.innerHTML=MIC_ICON,o.style.display=`inline-flex`,(r.parentElement??n).insertBefore(o,r),t.onStatus(e=>{o?.classList.toggle(`is-listening`,e===`listening`)}),o.addEventListener(`click`,async()=>{if(s){t.stopListening();return}s=!0;try{let e=await t.listen();e&&(r.value=e,r.dispatchEvent(new KeyboardEvent(`keydown`,{key:`Enter`,bubbles:!0})))}catch(e){r.setAttribute(`placeholder`,e instanceof Error?e.message:`Não foi possível ouvir; digite a tarefa.`),setTimeout(()=>r.removeAttribute(`placeholder`),6e3)}finally{s=!1}})))}let m=document.createElement(`button`);m.type=`button`,m.className=`page-agent-widget-launcher`,m.setAttribute(`aria-label`,n),m.title=n,m.innerHTML=LAUNCHER_ICON;let h=positionCss(t);Object.assign(m.style,h);let g=!1;async function _(e=!1){try{(await d()).panel.show(),g=!0}catch(t){if(e)console.error(`[page-agent-widget] não abriu o agente:`,t);else throw t}}function v(){i?.panel.hide?.(),g=!1}return m.addEventListener(`click`,()=>{g?v():_(!0)}),document.body.appendChild(m),r&&_(!0),{get agent(){return i},get voice(){return a},launcher:m,ready(){return d()},async run(e){return await(await d()).execute(e)},async stop(){i&&await i.stop()},show(){return _(!1)},hide(){v()},toggle(){m.click()},setConfig(t){Object.assign(e,t),i&&=(i.dispose(),null),g&&(g=!1,_(!0))},unmount(){a?.stopSpeaking(),a?.stopListening(),i?.dispose(),i=null,a=null,o?.remove(),o=null,m.remove()}}}var PageAgent=class extends PageAgentCore{panel;constructor(e){let t=new PageController({...e,enableMask:e.enableMask??!0});super({...e,pageController:t}),this.panel=new Panel(this,{language:e.language,promptForNextTask:e.promptForNextTask})}},currentScript=document.currentScript,currentScriptURL=currentScript?.src?new URL(currentScript.src):null,autoInit=currentScript?.getAttribute(`data-auto-init`)!==`false`&¤tScriptURL?.searchParams.get(`autoInit`)!==`false`;autoInit&&window.pageAgent&&window.pageAgent.dispose(),window.PageAgent=PageAgent,PageAgent.mountWidget=mountWidget,PageAgent.createVoice=createVoice,console.log(`🚀 page-agent.js loaded!`);var DEMO_MODEL=`qwen3.5-plus`,DEMO_BASE_URL=`https://page-ag-testing-ohftxirgbn.cn-shanghai.fcapp.run`,DEMO_API_KEY=`NA`;autoInit&&setTimeout(()=>{let e,t=!0;if(currentScriptURL){let n=currentScriptURL,r=n.searchParams.get(`model`)||DEMO_MODEL,i=n.searchParams.get(`baseURL`)||DEMO_BASE_URL,a=n.searchParams.get(`apiKey`)||DEMO_API_KEY,o=n.searchParams.get(`lang`)||`zh-CN`;t=(n.searchParams.get(`showPanel`)||`true`)===`true`,e={model:r,baseURL:i,apiKey:a,language:o}}else console.log(`🚀 page-agent.js no current script detected, using default demo config`),e={model:DEMO_MODEL,baseURL:DEMO_BASE_URL,apiKey:DEMO_API_KEY};window.pageAgent=new PageAgent(e),t&&window.pageAgent.panel.show(),console.log(`🚀 page-agent.js initialized with config:`,window.pageAgent.config)})})();
|