ozmoz 0.1.3 → 0.1.5
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/dist/cli.cjs +36 -28
- package/dist/ozmoz-mcp.js +6 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var l=require("fs"),c=require("path"),ne=require("https"),pe=require("http"),A=require("os"),{exec:me,spawnSync:
|
|
2
|
+
var l=require("fs"),c=require("path"),ne=require("https"),pe=require("http"),A=require("os"),{exec:me,spawnSync:_}=require("child_process"),he=[c.join(__dirname,"..","scripts","setup-lib.cjs"),c.join(__dirname,"..","..","scripts","setup-lib.cjs"),c.join(__dirname,"scripts","setup-lib.cjs")],fe=he.find(l.existsSync)||c.join(__dirname,"..","scripts","setup-lib.cjs"),{runFullSetup:oe,handleAuthAndEnv:se,touchTsConfig:ge,attemptViteAutoImportPatch:ye,injectUniversalRuntime:ve,writeBrowserConfig:ze,patchAllowScripts:Ee}=require(fe),Oe="\x1B[34m",we="\x1B[31m",re="\x1B[0m";function m(e){console.log(`${Oe}${e}${re}`)}function z(e){console.error(`${we}${e}${re}`)}var ie=`
|
|
3
3
|
1. YOUR FREEDOM: the entire frontend belongs to you (rendering, state, styles, navigation, components, UI logic). Only one exception: the technology (the framework), which the user chooses among supported options; you ask them before installing anything. ozmoZ only handles data, authentication, and storage. A change that does not touch data requires nobody's approval.
|
|
4
4
|
|
|
5
5
|
2. YOUR USER is not a developer. In your messages to the user (not in code), always speak in the user's language (detect it from their prompt, e.g. French if they write in French) in a plain, jargon-free manner: never say prototype, true, false, .env, contract, schema, sync, Edge, endpoint, collection, nor oz_update_project. Instead, say (adapt to their language):
|
|
@@ -46,7 +46,7 @@ var l=require("fs"),c=require("path"),ne=require("https"),pe=require("http"),A=r
|
|
|
46
46
|
|
|
47
47
|
8. NEVER: modify OZ_PROTOTYPE on your own initiative (only with explicit user consent, after explaining the difference between trial mode and live mode in one sentence); design or edit svro.schema.json and svro.workflow.json (Alex's authority); write a backend, API route, or ORM; invent oz.* methods or <oz-*> tags.
|
|
48
48
|
|
|
49
|
-
9. WRITE GOVERNANCE (MANDATORY): every oz.add / addWithId / addWithUserId / addWithMedia / update / delete call MUST carry a literal 3rd argument {desc, guard, role} (4th for update) \u2014 never optional, never omitted, even in trial mode (this parameter is never sent over the network; it only informs Alex). "desc": one sentence explaining the exact business intent of this write operation. "guard": a simple boolean condition on the "data" fields you send (e.g., "price > 0 && name.length > 2") \u2014 omit if no rule is required. "role": required access level for this action ("ANONYMOUS", "AUTHENTICATED", or an explicit business role like "MANAGER" if defined). Never invent a "guard" you cannot justify by actual screen logic; in doubt, omit "guard" rather than writing an arbitrary one. This applies to reads only if relevant (never mandatory for getDocsG/getDocsU/getDoc/join).`,k="ozmoz",q=/<!-- (?:ozmoz|fleetbo):start[^>]*-->[\s\S]*?<!-- (?:ozmoz|fleetbo):end -->/,Te="<!--
|
|
49
|
+
9. WRITE GOVERNANCE (MANDATORY): every oz.add / addWithId / addWithUserId / addWithMedia / update / delete call MUST carry a literal 3rd argument {desc, guard, role} (4th for update) \u2014 never optional, never omitted, even in trial mode (this parameter is never sent over the network; it only informs Alex). "desc": one sentence explaining the exact business intent of this write operation. "guard": a simple boolean condition on the "data" fields you send (e.g., "price > 0 && name.length > 2") \u2014 omit if no rule is required. "role": required access level for this action ("ANONYMOUS", "AUTHENTICATED", or an explicit business role like "MANAGER" if defined). Never invent a "guard" you cannot justify by actual screen logic; in doubt, omit "guard" rather than writing an arbitrary one. This applies to reads only if relevant (never mandatory for getDocsG/getDocsU/getDoc/join).`,k="ozmoz",q=/<!-- (?:ozmoz|fleetbo):start[^>]*-->[\s\S]*?<!-- (?:ozmoz|fleetbo):end -->/,Te="<!-- ozmoZ:end -->",ae="# OZMOZ DATA OS \u2014 DIRECTIVES SYST\xC8ME",Z={claude:"Claude Code",cursor:"Cursor",windsurf:"Windsurf",devin:"Devin",codex:"Codex CLI",gemini:"Gemini CLI",antigravity:"Antigravity CLI"},Se=`D1. EVERY request to create a NEW application MUST trigger the 'oz_create_project' MCP tool. However, if the project's '.env' already contains OZ_DB_KEY (or if 'svro.schema.json' exists), the project ALREADY EXISTS: NEVER call 'oz_create_project'; use 'oz_update_project' instead ('keyApp' is the value of OZ_KEY_APP; pass it explicitly if the session was not launched from the project folder).
|
|
50
50
|
|
|
51
51
|
D2. The MCP server is already pre-authenticated: do not inspect the shell ('env', 'grep'), do not traverse the filesystem outside the project root, and do not trigger a login (reading the project's '.env' is allowed). Only exception: if a tool returns "FLEETBO_DEV_TOKEN missing", run 'npx ozmoz login' ONCE, wait for it to complete (the user approves in the browser: simply notify them), then call the tool again.
|
|
52
52
|
|
|
@@ -83,6 +83,14 @@ D13. PACKAGE VERSION & REVISION REFLEX:
|
|
|
83
83
|
- Never inspect 'node_modules/ozmoz': verify the newly updated signatures strictly in 'src/ozmoz.d.ts'.
|
|
84
84
|
|
|
85
85
|
D14 (Bare Global Identifier): Call 'oz.*' directly as a bare identifier (e.g., 'await oz.sendotpsvro(email)'). NEVER access via 'window.oz' or optional chains like 'window.oz?.'. The object is globally declared in 'src/ozmoz.d.ts'. Using 'window.' circumvents static contract audits, breaks CLI regexes, and triggers false linter workarounds.
|
|
86
|
+
|
|
87
|
+
D15 (CONTRACT FIRST & STRICT LAST-RESORT ESCALATION):
|
|
88
|
+
- MANDATORY DOC CHECK: Before writing, fixing, or diagnosing ANY data code, you MUST inspect 'ozmoz_contract.md' and your instructions ('AGENTS.md' / 'GEMINI.md'). They are your absolute authority.
|
|
89
|
+
- AUTONOMOUS RESOLUTION FIRST: Review your frontend logic, verify method signatures, cast types, check component props, and inspect 'res.error'. You must actively solve issues yourself within the frontend code.
|
|
90
|
+
- ZERO EXPLORATION: Never execute exploratory shell scripts ('find', 'grep', 'node -e') or web searches.
|
|
91
|
+
- LAST-RESORT ESCALATION ONLY: ONLY if you have exhausted all contract checks and code fixes, and the issue is proven to be a persistent platform or SDK bug with NO possible solution on your end, stop cleanly and tell the user:
|
|
92
|
+
\xAB Je ne parviens pas \xE0 r\xE9soudre ce blocage malgr\xE9 la v\xE9rification du contrat et du code. En dernier recours, vous pouvez ouvrir un ticket sur https://ozmoz.io \xBB.
|
|
93
|
+
|
|
86
94
|
`,P={created:"created",updated:"updated",unchanged:"already up to date",appended:"ozmoZ block appended (your own content was kept)",migrated:"old file replaced (backup: <file>.ozmoz-legacy.bak)",invalid:"skipped: the file is not valid JSON, fix or delete it first"};function be(){try{return JSON.parse(l.readFileSync(c.join(__dirname,"..","package.json"),"utf8")).version||"dev"}catch{return"dev"}}function xe(){return`# OZMOZ DATA OS \u2014 DIRECTIVES AGENT
|
|
87
95
|
|
|
88
96
|
`+Se+`
|
|
@@ -96,18 +104,18 @@ D14 (Bare Global Identifier): Call 'oz.*' directly as a bare identifier (e.g., '
|
|
|
96
104
|
|
|
97
105
|
`)+o),!s&&a!=="unchanged"&&(a==="migrated"&&l.writeFileSync(e+".ozmoz-legacy.bak",n,"utf8"),l.mkdirSync(c.dirname(e),{recursive:!0}),l.writeFileSync(e,t,"utf8")),a}function H(){return[c.join(__dirname,"ozmoz-mcp.js"),c.join(__dirname,"..","bin","ozmoz-mcp.js"),c.join(__dirname,"bin","ozmoz-mcp.js"),c.join(__dirname,"..","src","bin","ozmoz-mcp.js")].find(o=>l.existsSync(o))||c.resolve(__dirname,"ozmoz-mcp.js")}function $(e,o){let s=H(),n={command:process.execPath,args:[s]},a={};if(l.existsSync(e))try{let r=JSON.parse(l.readFileSync(e,"utf8"));if(!r||typeof r!="object"||Array.isArray(r))return"invalid";a=r}catch{return"invalid"}let t=a.mcpServers&&a.mcpServers[k];return t&&JSON.stringify(t)===JSON.stringify(n)?"unchanged":(a.mcpServers=a.mcpServers||{},a.mcpServers[k]=n,o||(l.mkdirSync(c.dirname(e),{recursive:!0}),l.writeFileSync(e,JSON.stringify(a,null,2)+`
|
|
98
106
|
`,"utf8")),t?"updated":"created")}function ke(e){if(!l.existsSync(e))return"absent";let o;try{o=JSON.parse(l.readFileSync(e,"utf8"))}catch{return"invalid"}return!o||typeof o!="object"||!o.mcpServers||!o.mcpServers[k]?"absent":(delete o.mcpServers[k],l.writeFileSync(e,JSON.stringify(o,null,2)+`
|
|
99
|
-
`,"utf8"),"removed")}function R(e){let o=process.platform==="win32"?"where":"which";return
|
|
107
|
+
`,"utf8"),"removed")}function R(e){let o=process.platform==="win32"?"where":"which";return _(o,[e],{stdio:"ignore"}).status===0}function Y(e,o,s){let n=_(e,o,{encoding:"utf8",timeout:s||3e4,shell:process.platform==="win32"});return{ok:n.status===0,out:(n.stdout||"")+(n.stderr||"")}}function je(e,o,s){let n=e==="claude"?["--scope",s||"user"]:[],a=H(),t=["mcp","add"].concat(n,[k,"--",process.execPath,a]),r=["mcp","remove",k].concat(n),i=e+" "+t.join(" ");if(!R(e))return{status:"manual",detail:i};if(o)return{status:"planned",detail:i};let d=Y(e,["mcp","list"],6e4),u=d.ok?d.out.split(`
|
|
100
108
|
`):[],p=u.find(T=>/^[\s|│┃]*ozmoz(?![\w@-])/.test(T)),f=u.some(T=>/^\s*(?:fleetbo|fleetbo-svro):\s/.test(T));if(p&&p.includes("ozmoz@latest"))return{status:"unchanged",legacy:f};if(p&&!Y(e,r).ok)return{status:"manual",detail:e+" "+r.join(" ")+" && "+i,legacy:f};let v=Y(e,t);return v.ok?{status:p?"updated":"created",legacy:f}:{status:"failed",detail:i,message:v.out.trim().split(`
|
|
101
|
-
`).slice(-2).join(" "),legacy:f}}function
|
|
102
|
-
`).forEach(a=>{let t=a.match(/^\s*(\d+)\s+(\d+)\s+(.*)$/);t&&s.set(Number(t[1]),{ppid:Number(t[2]),args:t[3]})});let n=process.ppid;for(let a=0;n>1&&a<20&&s.has(n);a++){let{ppid:t,args:r}=s.get(n);if(r.split(/\s+/).slice(0,2).some(d=>/(^|\/)(gemini|claude|codex|antigravity|agy)$/.test(d))||/@google\/gemini-cli|@anthropic-ai\/claude-code|@openai\/codex/.test(r))return!0;n=t}}catch{}return!1}function Le(e){let o=process.platform==="win32"?"where":"which";return
|
|
109
|
+
`).slice(-2).join(" "),legacy:f}}function Ie(e){let o={user:!1,local:!1,others:[]};try{let s=JSON.parse(l.readFileSync(c.join(A.homedir(),".claude.json"),"utf8")),n=i=>!!i&&typeof i=="object"&&/fleetbo-svro|ozmoz/.test(String(i.command||"")+" "+JSON.stringify(i.args||[])),a=(i,d)=>{!i||typeof i!="object"||Object.keys(i).forEach(u=>{u===k?o[d]=!0:n(i[u])&&o.others.push({name:u,where:d})})};a(s.mcpServers,"user");let t=e;try{t=l.realpathSync(e)}catch{}let r=s.projects||{};Array.from(new Set([e,t])).forEach(i=>a((r[i]||{}).mcpServers,"local"))}catch{}return o}function _e(e){let o=Ie(e);o.user&&m(" \u26A0\uFE0F A global (user-scope) '"+k+"' entry from a previous version also exists: the tools appear in every project. To keep them in ozmoZ projects only: claude mcp remove "+k+" --scope user"),o.local&&m(" \u26A0\uFE0F A local-scope '"+k+"' entry exists for this folder and takes precedence over .mcp.json. Remove it: claude mcp remove "+k+" --scope local"),o.others.forEach(s=>{m(" \u26A0\uFE0F An old MCP entry named '"+s.name+"' ("+s.where+" scope) points to ozmoZ/Fleetbo. Remove it: claude mcp remove "+s.name+" --scope "+s.where)})}function Ce(e){let o=A.homedir(),s=n=>l.existsSync(n);return{claude:R("claude")||s(c.join(o,".claude")),cursor:s(c.join(e,".cursor"))||s(c.join(o,".cursor"))||R("cursor"),windsurf:s(c.join(o,".codeium","windsurf"))||s(c.join(e,".windsurf")),devin:s(c.join(e,".devin")),codex:R("codex")||s(c.join(o,".codex")),gemini:R("gemini")||s(c.join(o,".gemini")),antigravity:R("agy")||s(c.join(o,".antigravity"))||s(c.join(e,".antigravity"))}}var Ne={claude:{bin:"claude",rules:"CLAUDE.md",launch:e=>[e]},gemini:{bin:"gemini",rules:"GEMINI.md",launch:e=>["-i",e]},codex:{bin:"codex",rules:"AGENTS.md",launch:e=>[e]},antigravity:{bin:"agy",rules:"AGENTS.md",launch:e=>["-i",e]}};function Pe(e){return String(e||"").replace(/[^\p{L}\p{N} '.,:\-_]/gu," ").replace(/\s+/g," ").trim().slice(0,4e3)}function De(e,o,s){let n=Pe(o),a=n?"The project description is already given: "+n+". Ask me only the technology question, then build it: ask me another question only if essential information is missing.":"Ask me the starter questions from your ozmoZ instructions before installing anything: the technology first, then a one-sentence project description, one question at a time.",t=null;try{let u=c.join(s,".env");if(l.existsSync(u)){let p=l.readFileSync(u,"utf8").match(/^\s*OZ_DB_KEY\s*=\s*(.+?)\s*$/m);p&&(t=p[1].trim())}}catch{}let r=l.existsSync(c.join(s,"svro.schema.json")),i=l.existsSync(c.join(s,"index.html"))||l.existsSync(c.join(s,"package.json")),d=t||r?"This folder ALREADY contains an ozmoZ project"+(t?" (OZ_DB_KEY="+t+")":"")+' \u2014 do NOT read .env or svro.schema.json yourself, do NOT call oz_create_project, and do NOT ask the starter questions (technology/description). Before doing anything else, state this in one plain sentence to the user (e.g. "Ce projet existe d\xE9j\xE0, je le reprends.") so they can correct you immediately if this is wrong \u2014 then ask what I want to work on now.':i?'This folder does NOT have an ozmoZ project yet, but a frontend project ALREADY exists here (index.html or package.json found) \u2014 do NOT run "npm create vite" or scaffold a new frontend, you would overwrite it. Do not spend a tool call checking which framework it uses. Skip the technology question (detect it from the existing files if needed) and ask me only for a one-sentence project description, then call oz_create_project directly on this existing project.':"This folder does NOT contain an ozmoZ project yet (no .env, no svro.schema.json) \u2014 do not spend a tool call checking, proceed directly to the starter questions below. "+a;return"Use ozmoZ as the backend of my app. Read and follow the directives in ./"+e+" at the project root (do not search the filesystem). "+d}function Re(){let e=process.env;if(e.CLAUDECODE==="1"||e.GEMINI_CLI||e.CODEX_CLI||e.AI_AGENT||e.CURSOR_AGENT||e.ANTIGRAVITY_CLI)return!0;if(process.platform==="win32")return!1;try{let o=_("ps",["-A","-o","pid=,ppid=,args="],{encoding:"utf8"});if(o.status!==0)return!1;let s=new Map;o.stdout.split(`
|
|
110
|
+
`).forEach(a=>{let t=a.match(/^\s*(\d+)\s+(\d+)\s+(.*)$/);t&&s.set(Number(t[1]),{ppid:Number(t[2]),args:t[3]})});let n=process.ppid;for(let a=0;n>1&&a<20&&s.has(n);a++){let{ppid:t,args:r}=s.get(n);if(r.split(/\s+/).slice(0,2).some(d=>/(^|\/)(gemini|claude|codex|antigravity|agy)$/.test(d))||/@google\/gemini-cli|@anthropic-ai\/claude-code|@openai\/codex/.test(r))return!0;n=t}}catch{}return!1}function Le(e){let o=process.platform==="win32"?"where":"which";return _(o,[e],{stdio:"ignore"}).status===0}function Fe(e,o){let s=o.slice(1).filter(p=>!p.startsWith("--")),n=(s[0]||"").toLowerCase(),a=s.slice(1).join(" "),t=Ne[n];t||(z('Usage: npx ozmoz start <claude|gemini|codex> ["your app idea"]'),z('Cursor, Windsurf and Devin have no terminal agent to launch: run "npx ozmoz mcp --agent=<cursor|windsurf|devin>" instead.'),process.exit(1));let r=!1;try{r=!!JSON.parse(l.readFileSync(c.join(A.homedir(),".fleetbo","credentials.json"),"utf8")).devToken}catch{}r||(m("[ozmoZ] First use on this machine: sign in (your browser opens, approve once)."),_(process.execPath,[__filename,"login"],{stdio:"inherit",cwd:e,env:Object.assign({},process.env,{FLEETBO_START:"1"})}).status!==0&&(z('Sign-in did not complete. Run "npx ozmoz start '+n+'" again.'),process.exit(1))),_(process.execPath,[__filename,"mcp","--agent="+n],{stdio:"inherit",cwd:e,env:Object.assign({},process.env,{FLEETBO_START:"1"})}).status!==0&&(z("Could not configure "+t.bin+'. Run "npx ozmoz mcp --agent='+n+'" to see why.'),process.exit(1)),Re()&&(m(`
|
|
103
111
|
[ozmoZ] ozmoZ is set up in this folder (instruction file + MCP server).`),m("[ozmoZ] You are already inside an AI agent's shell, so no second agent is launched."),m('[ozmoZ] NEXT: tell the user, in plain words, to quit this agent and start it again in this folder (or to run "npx -y ozmoz@latest start '+n+`" in a normal terminal), then to paste the message again. Do not run any other command.
|
|
104
112
|
`),process.exit(0)),Le(t.bin)||(z('"'+t.bin+'" is not installed or not in your PATH. Install it, then run: npx ozmoz start '+n),process.exit(1));let d=De(t.rules,a,e);m(`
|
|
105
113
|
[ozmoZ] Launching `+t.bin+` in this folder...
|
|
106
|
-
`);let u=
|
|
114
|
+
`);let u=_(t.bin,t.launch(process.platform==="win32"?'"'+d+'"':d),{stdio:"inherit",cwd:e,shell:process.platform==="win32"});process.exit(u.status===null?1:u.status)}async function ce(e,o){let s=o.includes("--dry-run"),n=o.find(y=>y.startsWith("--agent=")),a=n&&n.slice(8).trim()?n.slice(8).split(",").map(y=>y.trim().toLowerCase()).filter(Boolean):null,t=null;if(a){t=a.includes("all")?Object.keys(Z):a;let y=t.filter(S=>!Z[S]);y.length&&(z("Unknown agent(s): "+y.join(", ")+". Valid values: "+Object.keys(Z).join(", ")+", all."),process.exit(1))}let r=o.find(y=>y.startsWith("--scope=")),i=r?r.slice(8).trim().toLowerCase():"project";["project","user","local"].includes(i)||(z("Unknown scope: "+i+". Valid values for Claude Code: project (default), user, local."),process.exit(1));let d=Ce(e),u=t||Object.keys(Z).filter(y=>d[y]),p=be();m(`
|
|
107
115
|
[ozmoZ] Configuring your AI agents`+(s?" (dry run: nothing is written)":"")+"...");let f=X(p,xe()),v=[];(!t||t.some(y=>y!=="gemini"))&&v.push(["AGENTS.md",f]),(!t||t.includes("claude"))&&v.push(["CLAUDE.md",X(p,`# OZMOZ DATA OS \u2014 DIRECTIVES AGENT
|
|
108
|
-
@AGENTS.md`)]),(!t||t.includes("gemini"))&&v.push(["GEMINI.md",f]);let T=c.join(e,".cursorrules");if(l.existsSync(T)){let y=l.readFileSync(T,"utf8");(q.test(y)||y.includes(ae))&&v.push([".cursorrules",f])}for(let y of v)m("\u2192 "+y[0]+": "+P[Ae(c.join(e,y[0]),y[1],s)]);for(let y of u){let S=
|
|
116
|
+
@AGENTS.md`)]),(!t||t.includes("gemini"))&&v.push(["GEMINI.md",f]);let T=c.join(e,".cursorrules");if(l.existsSync(T)){let y=l.readFileSync(T,"utf8");(q.test(y)||y.includes(ae))&&v.push([".cursorrules",f])}for(let y of v)m("\u2192 "+y[0]+": "+P[Ae(c.join(e,y[0]),y[1],s)]);for(let y of u){let S=Z[y];if(y==="cursor")m("\u2192 "+S+" MCP (.cursor/mcp.json): "+P[$(c.join(e,".cursor","mcp.json"),s)]);else if(y==="windsurf")m("\u2192 "+S+" MCP (~/.codeium/windsurf/mcp_config.json): "+P[$(c.join(A.homedir(),".codeium","windsurf","mcp_config.json"),s)]);else if(y==="antigravity"){if(m("\u2192 "+S+" MCP (.agents/mcp_config.json): "+P[$(c.join(e,".agents","mcp_config.json"),s)]),!s){let E=[];!u.includes("claude")&&!u.includes("gemini")&&E.push(c.join(e,".mcp.json")),u.includes("gemini")||(E.push(c.join(e,".gemini","settings.json")),E.push(c.join(A.homedir(),".gemini","settings.json"))),E.push(c.join(e,".antigravity","settings.json")),E.push(c.join(A.homedir(),".antigravity","settings.json")),E.push(c.join(e,".antigravity","mcp.json")),E.forEach(b=>{try{ke(b)==="removed"&&m("\u2192 Removed stale ozmoz entry: "+(c.relative(e,b)||b))}catch{}})}}else if(y==="gemini"){let E=[c.join(A.homedir(),".gemini","settings.json"),c.join(e,".gemini","settings.json"),c.join(e,".mcp.json")],b="unchanged";E.forEach(x=>{let w=$(x,s);(w==="created"||w==="updated")&&(b=w)}),m("\u2192 "+S+" MCP (settings.json & .mcp.json): "+P[b])}else if(y==="claude"&&i==="project"){let E=$(c.join(e,".mcp.json"),s);m("\u2192 "+S+" MCP (.mcp.json, project scope): "+P[E]),(E==="created"||E==="updated")&&m(" Claude Code asks you to approve a project server the first time you launch it. Commit .mcp.json to share it with your team (it contains no token)."),_e(e)}else if(y==="claude"||y==="codex"){let E=je(y,s,i);E.status==="manual"?m("\u2192 "+S+": '"+y+"' not found or not scriptable. Run manually: "+E.detail):E.status==="planned"?m("\u2192 "+S+" MCP: would run: "+E.detail):E.status==="failed"?z("\u2192 "+S+" MCP: registration failed ("+E.message+"). Run manually: "+E.detail):m("\u2192 "+S+" MCP"+(y==="claude"?" ("+i+" scope)":" (~/.codex/config.toml, global)")+": "+P[E.status]),E.legacy&&m(" \u26A0\uFE0F An old MCP entry named 'fleetbo' exists. Remove it: "+y+" mcp remove fleetbo")}else y==="devin"&&m("\u2192 "+S+": reads AGENTS.md. Devin runs in its own environment: add the Fleetbo MCP server from Devin's settings (not automated).")}!t&&u.length===0&&m("\u2192 No agent detected: instruction files were written; re-run with --agent=<name> to register the MCP server.");let g=!!(V(e).FLEETBO_DEV_TOKEN||process.env.FLEETBO_DEV_TOKEN),O=c.join(A.homedir(),".fleetbo","credentials.json");if(l.existsSync(O))try{g=g||!!JSON.parse(l.readFileSync(O,"utf8")).devToken}catch{}g||z('\u26A0\uFE0F No developer token found. Run "npx ozmoz login" once.'),process.env.FLEETBO_START||m(`
|
|
109
117
|
[ozmoZ] Done. Restart your agent so it reloads the tools and instruction files.
|
|
110
|
-
`)}function Ue(e){let o=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";me(`${o} "${e}"`)}function
|
|
118
|
+
`)}function Ue(e){let o=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";me(`${o} "${e}"`)}function Me(e){return new Promise((o,s)=>{let n=pe.createServer((a,t)=>{if(t.setHeader("Access-Control-Allow-Origin","*"),t.setHeader("Access-Control-Allow-Methods","GET, OPTIONS"),t.setHeader("Access-Control-Allow-Headers","Content-Type, Authorization"),t.setHeader("Access-Control-Allow-Private-Network","true"),a.method==="OPTIONS"){t.writeHead(204),t.end();return}let r=new URL(a.url,"http://127.0.0.1");if(r.pathname==="/callback"){let i=r.searchParams.get("token"),d=r.searchParams.get("refresh");if(!i){t.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),t.end("<h3>Error: Missing token.</h3>");return}let u=c.join(A.homedir(),".fleetbo");l.existsSync(u)||l.mkdirSync(u,{recursive:!0}),l.writeFileSync(c.join(u,"credentials.json"),JSON.stringify({devToken:i,refreshToken:d||null,updatedAt:new Date().toISOString()},null,2));let p=c.join(e,".env");if(l.existsSync(p)){let f=l.readFileSync(p,"utf8");f.includes("FLEETBO_DEV_TOKEN=")?f=f.replace(/FLEETBO_DEV_TOKEN=.*/g,`FLEETBO_DEV_TOKEN=${i}`):f+=`
|
|
111
119
|
FLEETBO_DEV_TOKEN=${i}
|
|
112
120
|
`,l.writeFileSync(p,f,"utf8")}t.writeHead(200,{"Content-Type":"text/html; charset=utf-8",Connection:"close"}),t.end(`
|
|
113
121
|
<!DOCTYPE html>
|
|
@@ -131,8 +139,8 @@ FLEETBO_DEV_TOKEN=${i}
|
|
|
131
139
|
[ozmoZ] Developer token received and stored successfully!`),!process.env.FLEETBO_START&&!["AGENTS.md","CLAUDE.md","GEMINI.md"].some(f=>l.existsSync(c.join(e,f)))&&(m(`
|
|
132
140
|
Next step to connect your AI agents:`),m(` npx ozmoz mcp (Configure Claude Code, Cursor, Windsurf, Devin, Codex CLI, Gemini CLI)
|
|
133
141
|
`)),typeof n.closeAllConnections=="function"&&n.closeAllConnections(),n.close(()=>o()),setTimeout(()=>o(),300)}});n.listen(0,"127.0.0.1",()=>{let t=`https://ozmoz.io/cli-auth?port=${n.address().port}`;m(`
|
|
134
|
-
[ozmoZ] Waiting for authentication...`),m(`If your browser does not open automatically, visit: ${t}`),Ue(t);let r=Number(process.env.FLEETBO_LOGIN_TIMEOUT_MS)||12e4;setTimeout(()=>{try{typeof n.closeAllConnections=="function"&&n.closeAllConnections()}catch{}n.close(),s(new Error(`Login timed out after ${Math.round(r/1e3)}s: browser approval not received. Run "npx ozmoz login" once more and approve in the browser.`))},r).unref()}),n.on("error",a=>s(a))})}function
|
|
135
|
-
`).forEach(a=>{let[t,...r]=a.split("=");t&&r.length>0&&(n[t.trim()]=r.join("=").trim())}),n}function Q(e,o){return new Promise((s,n)=>{let a=JSON.stringify({projectId:e,moduleName:o}),t={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(a)}},r=ne.request(t,i=>{let d="";i.on("data",u=>{d+=u}),i.on("end",()=>{if(i.statusCode>=200&&i.statusCode<300)try{let u=JSON.parse(d);if(u.success&&u.found&&u.module){let p=u.module.code||u.module.mockCode;s(typeof p=="string"?JSON.parse(p):p)}else s(null)}catch{n(new Error(`Invalid JSON response for ${o}.`))}else n(new Error(`Server error ${i.statusCode} while fetching ${o}`))})});r.on("error",i=>n(i)),r.write(a),r.end()})}var
|
|
142
|
+
[ozmoZ] Waiting for authentication...`),m(`If your browser does not open automatically, visit: ${t}`),Ue(t);let r=Number(process.env.FLEETBO_LOGIN_TIMEOUT_MS)||12e4;setTimeout(()=>{try{typeof n.closeAllConnections=="function"&&n.closeAllConnections()}catch{}n.close(),s(new Error(`Login timed out after ${Math.round(r/1e3)}s: browser approval not received. Run "npx ozmoz login" once more and approve in the browser.`))},r).unref()}),n.on("error",a=>s(a))})}function Ze(e,o){return new Promise((s,n)=>{let a=JSON.stringify({enterpriseID:e,schema:o}),t={hostname:"fleetbo-gatekeeper.fleetbo.workers.dev",path:"/sync-schema",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(a)}},r=ne.request(t,i=>{let d="";i.on("data",u=>{d+=u}),i.on("end",()=>{i.statusCode>=200&&i.statusCode<300?s(JSON.parse(d)):n(new Error(`Edge sync failed with HTTP ${i.statusCode}`))})});r.on("error",i=>n(i)),r.write(a),r.end()})}function V(e){let o=c.join(e,".env");if(!l.existsSync(o))return{};let s=l.readFileSync(o,"utf8"),n={};return s.split(`
|
|
143
|
+
`).forEach(a=>{let[t,...r]=a.split("=");t&&r.length>0&&(n[t.trim()]=r.join("=").trim())}),n}function Q(e,o){return new Promise((s,n)=>{let a=JSON.stringify({projectId:e,moduleName:o}),t={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(a)}},r=ne.request(t,i=>{let d="";i.on("data",u=>{d+=u}),i.on("end",()=>{if(i.statusCode>=200&&i.statusCode<300)try{let u=JSON.parse(d);if(u.success&&u.found&&u.module){let p=u.module.code||u.module.mockCode;s(typeof p=="string"?JSON.parse(p):p)}else s(null)}catch{n(new Error(`Invalid JSON response for ${o}.`))}else n(new Error(`Server error ${i.statusCode} while fetching ${o}`))})});r.on("error",i=>n(i)),r.write(a),r.end()})}var I=process.argv.slice(2),j=I[0],$e=["id","_id","userId","author","dateCreated","createdAt","_schema_version"],le=e=>$e.includes(e)||/^_/.test(e)||/^(created|updated|modified|deleted)(At|By)$/i.test(e);function W(e){return!e||typeof e!="object"?null:e.fields&&typeof e.fields=="object"?e.fields:e.schema&&typeof e.schema=="object"?e.schema:null}function We(e){let o=[];if(!e||typeof e!="object"||!e.collections)return{schema:e,changed:!1,notes:o};let s=JSON.parse(JSON.stringify(e));return Object.entries(s.collections).forEach(([n,a])=>{let t=W(a);t&&Object.keys(t).forEach(r=>{le(r)&&t[r]&&typeof t[r]=="object"&&t[r].required===!0&&(t[r].required=!1,o.push(n+"."+r))})}),{schema:s,changed:o.length>0,notes:o}}function Ge(e){let o=String(typeof e=="string"?e:e&&e.type||"").toLowerCase(),s=e&&(e.enum||e.values||e.options);return Array.isArray(s)&&s.length?JSON.stringify(s[0]):o==="number"||o==="integer"||o==="float"?"0":o==="boolean"||o==="toggle"?"false":o==="date"||o==="datetime"||o==="timestamp"?"new Date().toISOString()":o==="reference"?"'<id du document li\xE9>'":o==="media"?"null /* image/fichier : oz.addWithMedia */":o==="array"?"[]":"'\u2026'"}function Be(e){let s=Object.entries(e&&e.collections||{}),n=`## \u{1F4E5} CE QUE LE CODE DOIT ENVOYER (MOD\xC8LES D'\xC9CRITURE)
|
|
136
144
|
|
|
137
145
|
`;n+=`### \u{1F194} Identifiants
|
|
138
146
|
`,n+="* ozmoZ attribue lui-m\xEAme `_id` (cha\xEEne) \xE0 chaque document. Utilise `doc._id` partout ; \xE0 la lecture, `doc.id` existe comme alias de `_id` (m\xEAme valeur), en prototype comme en production, mais la r\xE9f\xE9rence est `_id`.\n",n+="* N'envoie **jamais** `id` ni `_id` dans `oz.add` : `oz.add` renvoie `{ success, documentId }` (`documentId` = `_id`).\n",n+="* Pour lire, modifier ou supprimer un document : `oz.getDoc(table, doc._id)`, `oz.update(table, doc._id, {\u2026})`, `oz.delete(table, doc._id)`. Pour relier deux collections, stocke le `_id` du document li\xE9 dans un champ (ex. `playlistId`).\n",n+="* `userId`, `createdAt` et les autres champs de tra\xE7abilit\xE9 sont renseign\xE9s par le moteur : ne les envoie pas.\n\n";let a=s.filter(([,t])=>W(t)&&Object.keys(W(t)).length>0);return a.length===0?n+`_Aucune collection scell\xE9e pour l'instant : les mod\xE8les appara\xEEtront apr\xE8s la mod\xE9lisation d'Alex._
|
|
@@ -140,9 +148,9 @@ Next step to connect your AI agents:`),m(` npx ozmoz mcp (Configure Claude C
|
|
|
140
148
|
|
|
141
149
|
| Champ | Type | Obligatoire | Valeurs / remarques |
|
|
142
150
|
|---|---|---|---|
|
|
143
|
-
`,d.forEach(([f,v])=>{let T=typeof v=="string"?v:v&&v.type||"any",h=v&&(v.enum||v.values||v.options),g=Array.isArray(h)&&h.length?"parmi : "+h.map(
|
|
151
|
+
`,d.forEach(([f,v])=>{let T=typeof v=="string"?v:v&&v.type||"any",h=v&&(v.enum||v.values||v.options),g=Array.isArray(h)&&h.length?"parmi : "+h.map(O=>"`"+O+"`").join(", "):"";n+="| `"+f+"` | "+T+" | "+(v&&v.required===!0?"\u2705 oui":"non")+" | "+g+` |
|
|
144
152
|
`});let u=d.filter(([,f])=>f&&f.required===!0),p=d.filter(([,f])=>!(f&&f.required===!0));n+="\nInsertion valide :\n```js\nawait oz.add('"+t+`', {
|
|
145
|
-
`,u.forEach(([f,v])=>{n+=" "+f+": "+
|
|
153
|
+
`,u.forEach(([f,v])=>{n+=" "+f+": "+Ge(v)+`,
|
|
146
154
|
`}),p.length&&(n+=" // optionnels : "+p.map(([f])=>f).join(", ")+`
|
|
147
155
|
`),n+=`}, {
|
|
148
156
|
`,n+=" desc: 'Cr\xE9ation d\\'un \xE9l\xE9ment dans "+t+`',
|
|
@@ -151,10 +159,10 @@ Next step to connect your AI agents:`),m(` npx ozmoz mcp (Configure Claude C
|
|
|
151
159
|
`,n+="});\n```\n\n"}),n)}function J(e){return e.replace(/("(\\.|[^"\\\r\n])*"|'(\\.|[^'\\\r\n])*'|`(\\.|[^`\\])*`)|(\/\*[\s\S]*?\*\/|\/\/[^\r\n]*)/g,(o,s)=>s||"")}function de(e,o){let s=e[o];for(let n=o+1;n<e.length;n++){if(e[n]==="\\"){n++;continue}if(s!=="`"&&(e[n]===`
|
|
152
160
|
`||e[n]==="\r"))return n;if(s==="`"&&e[n]==="$"&&e[n+1]==="{"){n=L(e,n+1)-1;continue}if(e[n]===s)return n+1}return e.length}function L(e,o){let s=e[o],n=s==="("?")":s==="["?"]":"}",a=0;for(let t=o;t<e.length;t++){let r=e[t];if(r==='"'||r==="'"||r==="`"){t=de(e,t)-1;continue}if(r==="/"&&e[t+1]==="/"){let i=e.indexOf(`
|
|
153
161
|
`,t);if(i<0)return e.length;t=i;continue}if(r==="/"&&e[t+1]==="*"){let i=e.indexOf("*/",t+2);if(i<0)return e.length;t=i+1;continue}if(r==="("||r==="["||r==="{")a++;else if((r===")"||r==="]"||r==="}")&&(a--,a===0&&r===n||a<0))return t+1}return e.length}function ue(e,o,s){let n=[],a=o,t=o;for(;t<s;){let r=e[t];if(r==='"'||r==="'"||r==="`"){t=de(e,t);continue}if(r==="/"&&e[t+1]==="/"){let i=e.indexOf(`
|
|
154
|
-
`,t);t=i<0?s:i;continue}if(r==="/"&&e[t+1]==="*"){let i=e.indexOf("*/",t+2);t=i<0?s:i+2;continue}if(r==="("||r==="["||r==="{"){t=L(e,t);continue}r===","&&(n.push(e.slice(a,t)),a=t+1),t++}return e.slice(a,s).trim()!==""&&n.push(e.slice(a,s)),n}function Ve(e){let o=e.trim(),s=new Set,n=!1,a=!1;return ue(o,1,o.length-1).forEach(t=>{let r=t.replace(/^(?:\s|\/\/[^\n]*\n|\/\*[\s\S]*?\*\/)+/,"").trim();if(!r)return;if(r.startsWith("...")){n=!0;return}if(r.startsWith("[")){a=!0;return}let i=r.match(/^(['"])(.*?)\1\s*:/);if(i){s.add(i[2]);return}i=r.match(/^([A-Za-z_$][\w$]*)\s*(:|\(|$)/),i&&s.add(i[1])}),{keys:s,hasSpread:n,hasComputed:a}}function Ye(e,o,s){let n=o.trim();if(n.startsWith("{"))return n;if(!/^[A-Za-z_$][\w$]*$/.test(n))return null;let a=new RegExp("(?:const|let|var)\\s+"+n.replace(/\$/g,"\\$")+"\\s*=\\s*\\{","g"),t=-1,r;for(;(r=a.exec(e))&&r.index<s;)t=r.index+r[0].length-1;return t<0?null:e.slice(t,L(e,t))}function
|
|
155
|
-
`).length}function K(e){let o=[],s=new Set(["node_modules","dist","build",".next",".git",".svelte-kit",".nuxt","coverage"]),n=(a,t)=>{if(t>6||o.length>400)return;let r=[];try{r=l.readdirSync(a,{withFileTypes:!0})}catch{return}r.forEach(i=>{if(s.has(i.name))return;let d=c.join(a,i.name);if(i.isDirectory())n(d,t+1);else if(/\.(jsx?|tsx?|mjs|vue|svelte)$/.test(i.name)&&!/\.d\.ts$/.test(i.name))try{l.statSync(d).size<5e5&&o.push(d)}catch{}})};return["src","app","pages","components"].forEach(a=>n(c.join(e,a),0)),o}function qe(e,o){let s=[],n=0,a=o&&o.collections||{};if(Object.keys(a).length===0)return{issues:s,checked:n,skipped:!0};let t=/\boz\s*\.\s*(add|addWithId|addWithUserId|addWithMedia|update)\s*\(/g,r=/\boz\s*\.\s*(add|addWithId|addWithUserId|addWithMedia|update|delete|getDocsG|getDocsU|getDoc|join)\s*\(\s*(['"`])([^'"`$\\]+)\2/g;return K(e).forEach(i=>{let d="";try{d=l.readFileSync(i,"utf8")}catch{return}if(!/oz\./.test(d)&&!/<oz-/i.test(d))return;d=J(d);let u=c.relative(e,i).split(c.sep).join("/"),p;for(r.lastIndex=0;p=r.exec(d);)Object.prototype.hasOwnProperty.call(a,p[3])||s.push({where:u+":"+
|
|
162
|
+
`,t);t=i<0?s:i;continue}if(r==="/"&&e[t+1]==="*"){let i=e.indexOf("*/",t+2);t=i<0?s:i+2;continue}if(r==="("||r==="["||r==="{"){t=L(e,t);continue}r===","&&(n.push(e.slice(a,t)),a=t+1),t++}return e.slice(a,s).trim()!==""&&n.push(e.slice(a,s)),n}function Ve(e){let o=e.trim(),s=new Set,n=!1,a=!1;return ue(o,1,o.length-1).forEach(t=>{let r=t.replace(/^(?:\s|\/\/[^\n]*\n|\/\*[\s\S]*?\*\/)+/,"").trim();if(!r)return;if(r.startsWith("...")){n=!0;return}if(r.startsWith("[")){a=!0;return}let i=r.match(/^(['"])(.*?)\1\s*:/);if(i){s.add(i[2]);return}i=r.match(/^([A-Za-z_$][\w$]*)\s*(:|\(|$)/),i&&s.add(i[1])}),{keys:s,hasSpread:n,hasComputed:a}}function Ye(e,o,s){let n=o.trim();if(n.startsWith("{"))return n;if(!/^[A-Za-z_$][\w$]*$/.test(n))return null;let a=new RegExp("(?:const|let|var)\\s+"+n.replace(/\$/g,"\\$")+"\\s*=\\s*\\{","g"),t=-1,r;for(;(r=a.exec(e))&&r.index<s;)t=r.index+r[0].length-1;return t<0?null:e.slice(t,L(e,t))}function G(e,o){return e.slice(0,o).split(`
|
|
163
|
+
`).length}function K(e){let o=[],s=new Set(["node_modules","dist","build",".next",".git",".svelte-kit",".nuxt","coverage"]),n=(a,t)=>{if(t>6||o.length>400)return;let r=[];try{r=l.readdirSync(a,{withFileTypes:!0})}catch{return}r.forEach(i=>{if(s.has(i.name))return;let d=c.join(a,i.name);if(i.isDirectory())n(d,t+1);else if(/\.(jsx?|tsx?|mjs|vue|svelte)$/.test(i.name)&&!/\.d\.ts$/.test(i.name))try{l.statSync(d).size<5e5&&o.push(d)}catch{}})};return["src","app","pages","components"].forEach(a=>n(c.join(e,a),0)),o}function qe(e,o){let s=[],n=0,a=o&&o.collections||{};if(Object.keys(a).length===0)return{issues:s,checked:n,skipped:!0};let t=/\boz\s*\.\s*(add|addWithId|addWithUserId|addWithMedia|update)\s*\(/g,r=/\boz\s*\.\s*(add|addWithId|addWithUserId|addWithMedia|update|delete|getDocsG|getDocsU|getDoc|join)\s*\(\s*(['"`])([^'"`$\\]+)\2/g;return K(e).forEach(i=>{let d="";try{d=l.readFileSync(i,"utf8")}catch{return}if(!/oz\./.test(d)&&!/<oz-/i.test(d))return;d=J(d);let u=c.relative(e,i).split(c.sep).join("/"),p;for(r.lastIndex=0;p=r.exec(d);)Object.prototype.hasOwnProperty.call(a,p[3])||s.push({where:u+":"+G(d,p.index),msg:"oz."+p[1]+"('"+p[3]+"') : the collection '"+p[3]+"' is not in the contract"});for(t.lastIndex=0;p=t.exec(d);){let f=p.index+p[0].length-1,v=L(d,f)-1,T=ue(d,f+1,v),h=p[1],O=(T[0]||"").trim().match(/^(['"`])([^'"`$\\]+)\1$/),y=h==="update"?T[2]:T[1];if(!O||!y)continue;let S=W(a[O[2]]);if(!S)continue;let E=Ye(d,y,p.index);if(!E)continue;let{keys:b,hasSpread:x,hasComputed:w}=Ve(E);n++;let F=u+":"+G(d,p.index),B=[...b].filter(D=>!Object.prototype.hasOwnProperty.call(S,D));if(B.length&&s.push({where:F,msg:"oz."+h+"('"+O[2]+"') sends field(s) not in the contract: "+B.join(", ")}),h!=="update"&&!x&&!w){let D=Object.entries(S).filter(([U,C])=>C&&typeof C=="object"&&C.required===!0&&!b.has(U)).map(([U])=>U);D.length&&s.push({where:F,msg:"oz."+h+"('"+O[2]+"') is missing required field(s): "+D.join(", ")})}}}),{issues:s,checked:n,skipped:!1}}function He(e,o){let s=qe(e,o);if(!s.skipped){if(s.issues.length===0){s.checked>0&&m("\u2192 Contract check: "+s.checked+" write call(s) match the contract.");return}m(`
|
|
156
164
|
\u26A0\uFE0F Contract check: `+s.issues.length+" problem(s) that production (OZ_PROTOTYPE=false) would reject with HTTP 422:"),s.issues.slice(0,20).forEach(n=>m(" "+n.where+" "+n.msg)),m(` \u2192 Fix each one in your code now, or evolve the contract with oz_update_project, BEFORE switching to live mode. Details: ozmoz_contract.md, section "CE QUE LE CODE DOIT ENVOYER".
|
|
157
|
-
`)}}var ee=/(?:const|let|var)\s+(\w+)\s*=\s*await\s+oz\s*\.\s*(add|addWithId|addWithUserId|addWithMedia|update|delete|sendotpsvro|verifyotpsvro)\s*\(/g,te=/(?<!=\s*)\bawait\s+oz\s*\.\s*(add|addWithId|addWithUserId|addWithMedia|update|delete|sendotpsvro|verifyotpsvro)\s*\(/g;function Je(e){let o=[];return K(e).forEach(s=>{let n="";try{n=l.readFileSync(s,"utf8")}catch{return}if(!/oz\./.test(n))return;let a=J(n),t=c.relative(e,s).split(c.sep).join("/");ee.lastIndex=0;let r;for(;r=ee.exec(a);){let i=r[1],d=a.slice(r.index);new RegExp("\\b"+i+"\\s*(?:\\?\\.|\\.)\\s*(success|error)\\b").test(d)||o.push({where:t+":"+
|
|
165
|
+
`)}}var ee=/(?:const|let|var)\s+(\w+)\s*=\s*await\s+oz\s*\.\s*(add|addWithId|addWithUserId|addWithMedia|update|delete|sendotpsvro|verifyotpsvro)\s*\(/g,te=/(?<!=\s*)\bawait\s+oz\s*\.\s*(add|addWithId|addWithUserId|addWithMedia|update|delete|sendotpsvro|verifyotpsvro)\s*\(/g;function Je(e){let o=[];return K(e).forEach(s=>{let n="";try{n=l.readFileSync(s,"utf8")}catch{return}if(!/oz\./.test(n))return;let a=J(n),t=c.relative(e,s).split(c.sep).join("/");ee.lastIndex=0;let r;for(;r=ee.exec(a);){let i=r[1],d=a.slice(r.index);new RegExp("\\b"+i+"\\s*(?:\\?\\.|\\.)\\s*(success|error)\\b").test(d)||o.push({where:t+":"+G(a,r.index),msg:`oz.${r[2]}(): return value ('${i}') never checked with .success/.error (rule 4).`})}for(te.lastIndex=0;r=te.exec(a);)o.push({where:t+":"+G(a,r.index),msg:`oz.${r[1]}(): called without assigning return value to check .success/.error (rule 4).`})}),o}function Ke(e){let o=[],s=/\bresource\.([a-zA-Z_][a-zA-Z0-9_]*)\b/g,n;for(;n=s.exec(String(e));)o.push(n[1]);return Array.from(new Set(o))}function Xe(e){let o=[],s=c.join(e,"svro.schema.json"),n=c.join(e,"svro.workflow.json");if(!l.existsSync(s)||!l.existsSync(n))return o;let a,t;try{a=JSON.parse(l.readFileSync(s,"utf8")),t=JSON.parse(l.readFileSync(n,"utf8"))}catch{return o}return Array.isArray(t.sequences)&&t.sequences.forEach(r=>{let i=a.collections?.[r.collection]?.fields||null;if(!i){o.push({where:r.id||"?",msg:`S\xE9quence sur la collection '${r.collection}', absente de svro.schema.json.`});return}(r.guards||[]).forEach(d=>{Ke(d).forEach(u=>{u in i||o.push({where:r.id||r.collection,msg:`Guard "${d}" r\xE9f\xE9rence '${u}', absent des champs d\xE9clar\xE9s de '${r.collection}' \u2014 l'Edge rejettera toute \xE9criture contenant ce champ (HTTP 422).`})})})}),o}var Qe=["add","addWithId","addWithUserId","addWithMedia","update","delete"];function et(e){let o=[],s=new RegExp("oz\\.("+Qe.join("|")+`)\\s*\\(\\s*['"][A-Za-z0-9_]+['"]`,"g");return K(e).forEach(n=>{let a="";try{a=l.readFileSync(n,"utf8")}catch{return}if(!/oz\./.test(a))return;let t=J(a),r=c.relative(e,n).split(c.sep).join("/");s.lastIndex=0;let i;for(;i=s.exec(t);){let d=i[1],u=t.indexOf("(",i.index);if(u===-1)continue;let p=L(t,u)-1;if(p<=u)continue;let f=t.slice(u+1,p),v=/\bdesc\s*:/.test(f),T=/\brole\s*:/.test(f);if(!v||!T){let h=[];v||h.push("desc"),T||h.push("role"),o.push({where:r+":"+G(t,i.index),msg:`oz.${d}() missing mandatory governance metadata: ${h.join(", ")} (desc and role are required, guard is optional).`})}}}),o}function tt(e,o){let s=e?.context||o?.context||"No written specifications provided.";return`# THE OZMOZ DATA CONTRACT (SVRO DATA CONTRACT)
|
|
158
166
|
|
|
159
167
|
### \u{1F6A8} MANDATORY CODE RULES (READ BEFORE WRITING ANY VIEW)
|
|
160
168
|
1. **Identifiers:** the database generates \`_id\` (string) for each document. Use \`doc._id\` for \`key={doc._id}\`, for \`oz.getDoc/update/delete\`, and to link two collections (store the linked document's \`_id\` in a field, e.g., \`playlistId\`). \`doc.id\` exists on read as an alias (same value), but the canonical reference is \`_id\`.
|
|
@@ -279,7 +287,7 @@ ${s}
|
|
|
279
287
|
|
|
280
288
|
---
|
|
281
289
|
|
|
282
|
-
${
|
|
290
|
+
${Be(e)}
|
|
283
291
|
|
|
284
292
|
---
|
|
285
293
|
|
|
@@ -294,27 +302,27 @@ ${JSON.stringify(e||{},null,2)}
|
|
|
294
302
|
\`\`\`json
|
|
295
303
|
${JSON.stringify(o||{},null,2)}
|
|
296
304
|
\`\`\`
|
|
297
|
-
`}function nt(e){return String(e).toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]/g,"_").replace(/^_+|_+$/g,"").slice(0,30)||"app"}async function ot(e,o){let s=V(e),n=l.existsSync(c.join(e,"svro.schema.json"));(s.OZ_DB_KEY||n)&&(z("Cannot create project: an ozmoZ project already exists in this folder."),m('\u2192 Use "npx ozmoz sync" or evolve the existing contract instead.'),process.exit(1));let a=(o||"").trim();a||(z('Project name is required. Usage: npx ozmoz create "<name>"'),process.exit(1));let t=c.join(e,".ozmoz.lock");if(l.existsSync(t)){let i=!1;try{let d=Number(l.readFileSync(t,"utf8"));Date.now()-d>6e4&&(i=!0)}catch{i=!0}i||(z("A project creation is already running in this folder."),process.exit(1)),l.unlinkSync(t)}l.writeFileSync(t,String(Date.now()));let r=()=>{if(l.existsSync(t))try{l.unlinkSync(t)}catch{}};try{let i=process.env.FLEETBO_DEV_TOKEN;if(!i){let h=c.join(A.homedir(),".fleetbo","credentials.json");if(l.existsSync(h))try{i=JSON.parse(l.readFileSync(h,"utf8")).devToken}catch{}}i||(r(),z('Missing developer token. Please run "npx ozmoz login" first.'),process.exit(1)),m(`[ozmoZ] Creating project "${a}" on Cloud...`);let d=nt(a),u=[d,`${d.slice(0,24)}_${Math.random().toString(36).slice(2,6)}`,`${d.slice(0,24)}_${Math.random().toString(36).slice(2,6)}`],p=null,f=null;for(let h of u)try{let g=await fetch("https://createprojectlight-jqycakhlxa-uc.a.run.app",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({data:{name:a,keyApp:h}})}),
|
|
305
|
+
`}function nt(e){return String(e).toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]/g,"_").replace(/^_+|_+$/g,"").slice(0,30)||"app"}async function ot(e,o){let s=V(e),n=l.existsSync(c.join(e,"svro.schema.json"));(s.OZ_DB_KEY||n)&&(z("Cannot create project: an ozmoZ project already exists in this folder."),m('\u2192 Use "npx ozmoz sync" or evolve the existing contract instead.'),process.exit(1));let a=(o||"").trim();a||(z('Project name is required. Usage: npx ozmoz create "<name>"'),process.exit(1));let t=c.join(e,".ozmoz.lock");if(l.existsSync(t)){let i=!1;try{let d=Number(l.readFileSync(t,"utf8"));Date.now()-d>6e4&&(i=!0)}catch{i=!0}i||(z("A project creation is already running in this folder."),process.exit(1)),l.unlinkSync(t)}l.writeFileSync(t,String(Date.now()));let r=()=>{if(l.existsSync(t))try{l.unlinkSync(t)}catch{}};try{let i=process.env.FLEETBO_DEV_TOKEN;if(!i){let h=c.join(A.homedir(),".fleetbo","credentials.json");if(l.existsSync(h))try{i=JSON.parse(l.readFileSync(h,"utf8")).devToken}catch{}}i||(r(),z('Missing developer token. Please run "npx ozmoz login" first.'),process.exit(1)),m(`[ozmoZ] Creating project "${a}" on Cloud...`);let d=nt(a),u=[d,`${d.slice(0,24)}_${Math.random().toString(36).slice(2,6)}`,`${d.slice(0,24)}_${Math.random().toString(36).slice(2,6)}`],p=null,f=null;for(let h of u)try{let g=await fetch("https://createprojectlight-jqycakhlxa-uc.a.run.app",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({data:{name:a,keyApp:h}})}),O=await g.json();if(g.ok&&!O.error){p={keyApp:h,data:O.result?.data||O.data||{}};break}else f=O.error?.message||`HTTP ${g.status}`}catch(g){f=g.message}p||(r(),z(`Failed to create project on Cloud: ${f||"Unknown error"}`),process.exit(1));let v=p.data.bootstrapToken;await se(e,[`--keyApp=${p.keyApp}`,`--token=${v}`]);let T=c.join(e,"package.json");oe(e,T),await ce(e,[]),m(`
|
|
298
306
|
[ozmoZ] Project "${a}" (${p.keyApp}) created and configured successfully.`),m(`Next step: scaffold the frontend if needed, then run "npx ozmoz sync".
|
|
299
|
-
`)}finally{if(l.existsSync(t))try{l.unlinkSync(t)}catch{}}}function st(e){if(!e||typeof e!="string")return e;let o=new Set(["auth","resource","true","false","null","undefined","in","typeof","instanceof","new","return","Math","Number","String","Boolean","Date"]);return e.replace(/(?<![\w.$])([a-zA-Z_$][a-zA-Z0-9_$]*)\b(?!\s*\()/g,(s,n,a,t)=>a>0&&t[a-1]==="."||o.has(n)||!isNaN(n)?s:`resource.${n}`)}async function rt(e){let o=process.env.FLEETBO_DEV_TOKEN;if(!o){let h=c.join(A.homedir(),".fleetbo","credentials.json");if(l.existsSync(h))try{o=JSON.parse(l.readFileSync(h,"utf8")).devToken}catch{}}let n=V(e).OZ_KEY_APP;(!n||!o)&&(z("Cannot update: project not initialized or developer token missing."),process.exit(1));let a=l.existsSync(c.join(e,"src"))?c.join(e,"src"):e,t=[],r=new Set([".jsx",".tsx",".vue",".svelte",".js",".ts",".html"]);function i(h){let g=[];try{g=l.readdirSync(h,{withFileTypes:!0})}catch{return}for(let
|
|
307
|
+
`)}finally{if(l.existsSync(t))try{l.unlinkSync(t)}catch{}}}function st(e){if(!e||typeof e!="string")return e;let o=new Set(["auth","resource","true","false","null","undefined","in","typeof","instanceof","new","return","Math","Number","String","Boolean","Date"]);return e.replace(/(?<![\w.$])([a-zA-Z_$][a-zA-Z0-9_$]*)\b(?!\s*\()/g,(s,n,a,t)=>a>0&&t[a-1]==="."||o.has(n)||!isNaN(n)?s:`resource.${n}`)}async function rt(e){let o=process.env.FLEETBO_DEV_TOKEN;if(!o){let h=c.join(A.homedir(),".fleetbo","credentials.json");if(l.existsSync(h))try{o=JSON.parse(l.readFileSync(h,"utf8")).devToken}catch{}}let n=V(e).OZ_KEY_APP;(!n||!o)&&(z("Cannot update: project not initialized or developer token missing."),process.exit(1));let a=l.existsSync(c.join(e,"src"))?c.join(e,"src"):e,t=[],r=new Set([".jsx",".tsx",".vue",".svelte",".js",".ts",".html"]);function i(h){let g=[];try{g=l.readdirSync(h,{withFileTypes:!0})}catch{return}for(let O of g){if(/^(node_modules|\.git|dist|build)$/.test(O.name))continue;let y=c.join(h,O.name);if(O.isDirectory())i(y);else if(r.has(c.extname(O.name))&&!O.name.endsWith(".d.ts")){let S=l.readFileSync(y,"utf8");/oz\.|<oz-/i.test(S)&&t.push({name:c.basename(y),content:S})}}}i(a),t.length===0&&(z("Cannot update: no files calling oz.* found."),process.exit(1));let d=[],u=/oz\.(add|addWithId|addWithUserId|addWithMedia|update|delete)\s*\(\s*['"]([A-Za-z0-9_]+)['"]/g;t.forEach(h=>{u.lastIndex=0;let g;for(;g=u.exec(h.content);){let O=h.content.indexOf("(",g.index);if(O===-1)continue;let y=L(h.content,O)-1;if(y<=O)continue;let S=h.content.slice(O+1,y),E=w=>(S.match(new RegExp(w+"\\s*:\\s*(['\"`])((?:(?!\\1)[\\s\\S])*?)\\1"))||[])[2]||null,b=S.matchAll(/([a-zA-Z0-9_]+)\s*:/g),x=0;for(let w of b)["desc","guard","role"].includes(w[1])||x++;d.push({operation:g[1],table:g[2],fieldCount:x,desc:E("desc"),guard:st(E("guard")),role:E("role"),source:h.name})}});let p=d.filter(h=>!h.desc||!h.role);p.length>0&&(z(`Governance check failed: missing mandatory metadata { desc, role } on ${p.length} write operation(s).`),p.forEach(h=>{let g=[];h.desc||g.push("desc"),h.role||g.push("role"),z(`\u2192 oz.${h.operation}('${h.table}') in ${h.source} [manquant : ${g.join(", ")}]`)}),process.exit(1));let f=new Map;d.forEach(h=>{let g=`${h.table}:${h.operation}`;(!f.has(g)||h.fieldCount>f.get(g).fieldCount)&&f.set(g,h)});let v=Array.from(f.values()).map(({fieldCount:h,...g})=>g);m(`[ozmoZ] Sending ${t.length} component(s) to Alex AI...`);try{let h=await fetch("https://updateprojectlight-jqycakhlxa-uc.a.run.app",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify({data:{keyApp:n,name:n,newViewFiles:t,explicitGovernance:v}})}),g=await h.json();(!h.ok||g.error)&&(z(`Update failed: ${g.error?.message||"Unknown API error"}`),process.exit(1))}catch(h){z(`Network error contacting Cloud: ${h.message}`),process.exit(1)}m("\u2192 Structure modeled. Sealing contract on Edge..."),_(process.execPath,[__filename,"sync"],{stdio:"inherit",cwd:e}).status===0?m(`
|
|
300
308
|
[ozmoZ] Contract successfully updated and sealed at Edge.
|
|
301
309
|
`):(z(`
|
|
302
310
|
[ozmoZ] Edge sync failed. Run "npx ozmoz sync" manually.
|
|
303
311
|
`),process.exit(1))}async function it(){let e=process.cwd(),o=c.join(e,"package.json");if(j==="init"||j==="doctor")m(`
|
|
304
|
-
[ozmoZ] Initializing and configuring ozmoZ...`),await se(e,
|
|
312
|
+
[ozmoZ] Initializing and configuring ozmoZ...`),await se(e,I),oe(e,o),m(`
|
|
305
313
|
[ozmoZ] Configuration completed successfully!
|
|
306
314
|
`),m(`
|
|
307
315
|
Next step:`),m(` npx ozmoz sync (Sync cloud schema & generate IDE types)
|
|
308
|
-
`);else if(j==="sync"){let s=
|
|
316
|
+
`);else if(j==="sync"){let s=I.includes("--dry-run"),n=I.includes("--check-only");m(`[ozmoZ] Syncing schema...${s?" (dry-run)":""}${n?" (check-only, no network)":""}`),s||ze(e);let a=c.join(e,"svro.schema.json"),t=c.join(e,"svro.workflow.json"),r=c.join(e,"ozmoz_contract.md"),i=c.join(e,"src","ozmoz.d.ts"),u=V(e).OZ_ENTERPRISE_ID,p=null,f=null;if(n)m("\u2192 Mode check-only : Local contract used, no cloud fetch..");else if(u)try{m("\u2192 Fetching latest contracts from Cloud..."),p=await Q(u,"svro.schema.json"),p&&(l.writeFileSync(a,JSON.stringify(p,null,2)+`
|
|
309
317
|
`),m("\u2192 Local svro.schema.json updated.")),f=await Q(u,"svro.workflow.json"),f&&(l.writeFileSync(t,JSON.stringify(f,null,2)+`
|
|
310
318
|
`),m("\u2192 Local svro.workflow.json updated."))}catch(g){z(`\u26A0\uFE0F Cloud fetch bypassed: ${g.message}. Using local file fallback.`)}else z("\u26A0\uFE0F OZ_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");let v=p;if(!v&&l.existsSync(a))try{v=JSON.parse(l.readFileSync(a,"utf8"))}catch{}v||(v={context:"Application en cours de mod\xE9lisation initiale.",collections:{}},l.writeFileSync(a,JSON.stringify(v,null,2)+`
|
|
311
319
|
`,"utf8"),m("\u2192 Initial blank svro.schema.json created."));let T=f;if(!T&&l.existsSync(t))try{T=JSON.parse(l.readFileSync(t,"utf8"))}catch{}T||(T={actors:{},sequences:[]},l.writeFileSync(t,JSON.stringify(T,null,2)+`
|
|
312
320
|
`,"utf8"),m("\u2192 Initial blank svro.workflow.json created."));{let g=We(v);g.changed&&(v=g.schema,l.writeFileSync(a,JSON.stringify(v,null,2)+`
|
|
313
|
-
`,"utf8"),m("\u2192 Managed by system, no longer required from your code: "+g.notes.join(", ")+"."))}let h=tt(v,T);l.writeFileSync(r,h,"utf8"),m("\u2192 Contract markdown successfully generated at project root.");try{let g=Object.keys(v.collections||{});if(u&&!n)try{await
|
|
314
|
-
`);return` ${
|
|
321
|
+
`,"utf8"),m("\u2192 Managed by system, no longer required from your code: "+g.notes.join(", ")+"."))}let h=tt(v,T);l.writeFileSync(r,h,"utf8"),m("\u2192 Contract markdown successfully generated at project root.");try{let g=Object.keys(v.collections||{});if(u&&!n)try{await Ze(u,v),m("\u2192 Schema successfully sealed at Global Edge (O(1)).")}catch(w){z(`\u26A0\uFE0F Edge Shield sync warning: ${w.message}`)}let O=v.collections||{},y=Object.entries(O).map(([w,F])=>{let B=F.fields||F.schema||{},D=Object.entries(B).map(([U,C])=>{let M="any",N=String(typeof C=="string"?C:C.type||"").toLowerCase();return N==="string"||N==="text"||N==="media"?M="string":N==="number"?M="number":N==="boolean"||N==="toggle"?M="boolean":N==="array"&&(M="any[]"),` ${U}?:${M};`}).join(`
|
|
322
|
+
`);return` ${w}: {
|
|
315
323
|
${D}
|
|
316
324
|
};`}).join(`
|
|
317
|
-
`),S=g.length>0?g.map(
|
|
325
|
+
`),S=g.length>0?g.map(w=>`'${w}'`).join(" | "):"string";if(l.existsSync(c.dirname(i))){let w=`/* eslint-disable */
|
|
318
326
|
/* prettier-ignore */
|
|
319
327
|
// @ts-nocheck
|
|
320
328
|
// Generated by ozmoZ \u2014 Updated via sync
|
|
@@ -450,13 +458,13 @@ declare module 'svelte/elements' {
|
|
|
450
458
|
'oz-reference': OzProp;
|
|
451
459
|
}
|
|
452
460
|
}
|
|
453
|
-
`;l.writeFileSync(i,
|
|
454
|
-
\u{1F6AB} Sync blocked: ${
|
|
461
|
+
`;l.writeFileSync(i,w)}ge(e),ye(e,o),ve(e),Ee(e),m(`[ozmoZ] Schema synced successfully (${g.length} collection(s)).`);try{He(e,v)}catch{}let E=Je(e);E.length>0&&(z(`
|
|
462
|
+
\u{1F6AB} Sync blocked: ${E.length} write call(s) do not check results (rule 4):`),E.slice(0,20).forEach(w=>z(" "+w.where+" "+w.msg)),z(` \u2192 Inspect res.success and handle res.error on each call before syncing.
|
|
455
463
|
`),process.exit(1));let b=Xe(e);b.length>0&&(z(`
|
|
456
|
-
\u{1F6AB} Sync blocked: ${b.length} workflow guard(s) reference unsealed fields:`),b.slice(0,20).forEach(
|
|
464
|
+
\u{1F6AB} Sync blocked: ${b.length} workflow guard(s) reference unsealed fields:`),b.slice(0,20).forEach(w=>z(" ["+w.where+"] "+w.msg)),z(` \u2192 Update svro.schema.json or adjust workflow guards before continuing.
|
|
457
465
|
`),process.exit(1));let x=et(e);x.length>0&&(z(`
|
|
458
|
-
\u{1F6AB} Sync blocked: ${x.length} write call(s) missing mandatory governance { desc, role }:`),x.slice(0,20).forEach(
|
|
459
|
-
`),process.exit(1)),s&&m("\u2192 [Dry-run] Schema is valid.")}catch(g){z(`Error during synchronization: ${g.message}`),process.exit(1)}}else if(j==="create"){let s=
|
|
466
|
+
\u{1F6AB} Sync blocked: ${x.length} write call(s) missing mandatory governance { desc, role }:`),x.slice(0,20).forEach(w=>z(" "+w.where+" "+w.msg)),z(` \u2192 Add literal { desc, role } to each write call before syncing (optional only on reads).
|
|
467
|
+
`),process.exit(1)),s&&m("\u2192 [Dry-run] Schema is valid.")}catch(g){z(`Error during synchronization: ${g.message}`),process.exit(1)}}else if(j==="create"){let s=I.slice(1).filter(n=>!n.startsWith("--")).join(" ");await ot(e,s),process.exit(0)}else if(j==="update")await rt(e),process.exit(0);else if(j==="mcp"){let s=I.includes("--run"),n=!1;if(!s&&!process.stdin.isTTY&&(s=await new Promise(a=>{let t=process.stdin,r=null,i=p=>{clearTimeout(r),t.removeListener("data",d),t.removeListener("end",u),t.removeListener("error",u),a(p)},d=p=>{t.pause(),t.unshift(p),n=!0,i(!0)},u=()=>i(!1);r=setTimeout(()=>{t.pause(),i(!1)},1500),t.on("data",d),t.once("end",u),t.once("error",u)})),s){try{await import(`file://${H()}`),n&&process.stdin.resume()}catch(a){z(`Failed to start MCP server: ${a.message}`),process.exit(1)}return}await ce(e,I),process.exit(0)}else j==="login"?(await Me(e),process.exit(0)):j==="start"?Fe(e,I):["--help","-h","help"].includes(j)?(m(`ozmoZ CLI
|
|
460
468
|
|
|
461
469
|
Commands:
|
|
462
470
|
login Authenticate this machine (opens the browser: approve once, the command exits by itself)
|
package/dist/ozmoz-mcp.js
CHANGED
|
@@ -67,7 +67,7 @@ ${c}`:c:"",l=Function,d=`return (input) => {
|
|
|
67
67
|
${c}
|
|
68
68
|
}`,m;try{m=new l(...a,d)(...s)}catch(f){throw new K(`this schema (generated code failed to evaluate: ${f.message})`)}return t?.debug&&(m.code=u),m.definite=i.definite,m}function R(e,t){for(let[i,r]of e.constants)if(r===t)return i;let n=`c${e.constantCounter++}`;return e.constants.set(n,t),n}function Pr(e,t){return e.definite=!1,R(e,t)}function D(e){return`v${e.varCounter++}`}function nI(e,t){let n=e._zod.run({value:t,issues:[]},{});if(n&&typeof n.then=="function")return He;let i=n;return i.issues.length===0?i.value:He}function Le(e,t,n,i,r=!0){let o=e.content.length,a=t.constants.size,s=t.constantCounter,c=t.varCounter;try{return ge(e,t,n,i,r)}catch(u){if(!(u instanceof K)||!u.islandable)throw u;if(e.content.length=o,t.constants.size>a){let l=Array.from(t.constants.keys()).slice(a);for(let d of l)t.constants.delete(d)}return t.constantCounter=s,t.varCounter=c,iI(e,t,n,i)}}function iI(e,t,n,i){t.definite=!1;let r=R(t,n),o=R(t,nI),a=D(t);return e.write(`const ${a} = ${o}(${r}, ${i});`),e.write(`if (${a} === INVALID) return INVALID;`),a}var oI=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function aI(e,t,n,i){let r=n._zod.def.checks;if(!r||r.length===0)return i;let o=i;for(let a of r){let s=a._zod.def;if(s.when&&!oI.has(s.check))throw new K('check with a custom "when" condition');switch(s.check){case"greater_than":sI(e,t,s,o);break;case"less_than":cI(e,t,s,o);break;case"multiple_of":uI(e,t,s,o);break;case"number_format":a$(e,s,o);break;case"min_length":{let c=zr(s.minimum,"min_length"),u=Jd(e,t,o,`${o}.length >= ${c} && ${o}.length < ${s.minimum*2}`);e.write(`if (${u} < ${c}) return INVALID;`);break}case"max_length":{let c=zr(s.maximum,"max_length"),u=Jd(e,t,o,`${o}.length > ${c}`);e.write(`if (${u} > ${c}) return INVALID;`);break}case"length_equals":{let c=zr(s.length,"length_equals"),u=Jd(e,t,o,`${o}.length >= ${c} && ${o}.length <= ${s.length*2}`);e.write(`if (${u} !== ${c}) return INVALID;`);break}case"min_size":e.write(`if (${o}.size < ${zr(s.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${o}.size > ${zr(s.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${o}.size !== ${zr(s.size,"size_equals")}) return INVALID;`);break;case"string_format":o=s$(e,t,s,o);break;case"custom":o=hI(e,t,a,o);break;case"bigint_format":lI(e,s,o);break;case"mime_type":dI(e,t,s,o);break;case"property":mI(e,t,s,o);break;case"properties":fI(e,t,s,o);break;case"overwrite":{let c=D(t);pI(e,t,a,o,c),o=c;break}default:throw new K(`check type ${s.check}`)}}return o}function Jd(e,t,n,i){let r=R(t,kr),o=D(t);return e.write(`const ${o} = typeof ${n} === "string" && ${i} ? ${r}(${n}) : ${n}.length;`),o}function zr(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new K(`${t} bound of type ${typeof e}`);return`${e}`}function o$(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new K("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new K("comparison check with Invalid Date bound");return R(e,t)}throw new K(`comparison check bound of type ${typeof t}`)}function sI(e,t,n,i){let r=n.inclusive?"<":"<=";e.write(`if (${i} ${r} ${o$(t,n.value)}) return INVALID;`)}function cI(e,t,n,i){let r=n.inclusive?">":">=";e.write(`if (${i} ${r} ${o$(t,n.value)}) return INVALID;`)}function uI(e,t,n,i){if(typeof n.value=="bigint"){if(n.value===BigInt(0))throw new K("multiple_of check with a zero divisor");e.write(`if (${i} % ${n.value}n !== 0n) return INVALID;`)}else{let r=R(t,ai);e.write(`if (${r}(${i}, ${zr(n.value,"multiple_of")}) !== 0) return INVALID;`)}}function a$(e,t,n){let i=t.format;switch(i){case"safeint":e.write(`if (!Number.isSafeInteger(${n})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${n}) || ${n} < -2147483648 || ${n} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${n}) || ${n} < 0 || ${n} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${n}) || ${n} < -3.4028234663852886e38 || ${n} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${n})) return INVALID;`);break;default:throw new K(`number format ${i}`)}}function lI(e,t,n){let i=t.format;if(i)switch(i){case"int64":e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break;default:throw new K(`bigint format ${i}`)}}function dI(e,t,n,i){let r=n.mime;if(r&&r.length>0){let o=R(t,new Set(r));e.write(`if (!${o}.has(${i}.type)) return INVALID;`)}}function fI(e,t,n,i){if(n.when)throw new K('check with a custom "when" condition');e.write(`if (${i} == null) return INVALID;`);let r=n.shape;for(let o of Reflect.ownKeys(r)){let a=typeof o=="symbol"?R(t,o):Be(o),s=D(t);e.write(`const ${s} = ${i}[${a}];`),Le(e,t,r[o],s,!1)}}function mI(e,t,n,i){let r=`${i}[${JSON.stringify(n.property)}]`;ge(e,t,n.schema,r)}function pI(e,t,n,i,r){let o=n._zod.def.tx;if(!o)throw new K("overwrite check without a transform function");if(Or(o))throw new wt("z.compile: async overwrite transforms are not supported");let a=R(t,o);e.write(`const ${r} = ${a}(${i});`)}function Bd(){throw new tt}function Gd(e){this.issues.push(e)}function hI(e,t,n,i){let r=n._zod.def;if(r.fn){if(Or(r.fn))throw new wt("z.compile: async .refine() predicates are not supported");let o=Pr(t,r.fn),a=R(t,Bd),s=D(t);return e.write(`const ${s} = ${o}(${i});`),e.write(`if (${s} instanceof Promise) ${a}();`),e.write(`if (!${s}) return INVALID;`),i}if(n._zod.check){if(Or(n._zod.check))throw new wt("z.compile: async .superRefine() / check functions are not supported");let o=n._zod.check,s=Pr(t,u=>{let l={value:u,issues:[],addIssue:Gd};return o(l)instanceof Promise&&Bd(),l.issues.length===0?l.value:He}),c=D(t);return e.write(`const ${c} = ${s}(${i});`),e.write(`if (${c} === INVALID) return INVALID;`),c}throw new K("custom check without a predicate or check function")}var gI=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function s$(e,t,n,i,r=!0){let o=n.format;if(o==="base64"){let u=R(t,Si);return e.write(`if (!${u}(${i})) return INVALID;`),i}if(o==="base64url"){let u=R(t,xa);return e.write(`if (!${u}(${i})) return INVALID;`),i}if(o==="jwt"){let u=R(t,Ia),l=R(t,n.alg??null);return e.write(`if (!${u}(${i}, ${l})) return INVALID;`),i}if(o==="ipv6"){let u=R(t,xi);return e.write(`if (!${u}(${i})) return INVALID;`),i}if(o==="cidrv6"){let u=R(t,ka);return e.write(`if (!${u}(${i})) return INVALID;`),i}if(o==="credit_card"){let u=R(t,Sa);return e.write(`if (!${u}(${i})) return INVALID;`),i}if(o==="iban"){let u=R(t,za);return e.write(`if (!${u}(${i})) return INVALID;`),i}let a=n;if(o==="url"||o==="httpurl"||a.normalize||a.hostname!==void 0||a.protocol!==void 0){let u=R(t,$a),l=R(t,n),d=D(t),m=D(t);if(e.write(`const ${d} = ${i}.trim();`),e.write(`const ${m} = ${u}(${d}, ${l});`),e.write(`if (typeof ${m} === "number") return INVALID;`),a.hostname!==void 0){let h=R(t,_a);e.write(`if (!${h}(${m}, ${l}.hostname)) return INVALID;`)}if(a.protocol!==void 0){let h=R(t,ba);e.write(`if (!${h}(${m}, ${l}.protocol)) return INVALID;`)}if(!r)return null;let f=D(t),p=a.normalize?`${m}.href`:`${R(t,wi)}(${d})`;return e.write(`const ${f} = ${p};`),f}let s=n.fn;if(s){if(Or(s))throw new K(`async string format ${o}`);let u=R(t,s);return e.write(`if (!${u}(${i})) return INVALID;`),i}if(gI.has(o)&&n.pattern){let u=R(t,n.pattern);return e.write(`${u}.lastIndex = 0;`),e.write(`if (!${u}.test(${i})) return INVALID;`),i}let c=n.format;switch(c){case"regex":throw new K("regex format without a pattern");case"lowercase":e.write(`if (${i} !== ${i}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${i} !== ${i}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${i}.includes(${Be(n.includes)})) return INVALID;`);break;case"starts_with":{let u=n.prefix;e.write(`if (${i}.slice(0, ${u.length}) !== ${Be(u)}) return INVALID;`);break}case"ends_with":{let u=n.suffix;e.write(`if (${i}.slice(-${u.length}) !== ${Be(u)}) return INVALID;`);break}default:throw new K(`string format ${c}`)}return i}function ge(e,t,n,i,r=!0){let o=n._zod.def,a=o.type;if(o.coerce)throw new K(`coercion (z.coerce.${a}())`);let s=r||!!o.checks?.length,c;switch(a){case"string":c=vI(e,t,n,i,s);break;case"number":c=yI(e,n,i);break;case"boolean":c=$I(e,i);break;case"bigint":c=_I(e,n,i);break;case"symbol":c=bI(e,i);break;case"undefined":c=kI(e,i);break;case"null":c=wI(e,i);break;case"any":case"unknown":c=i;break;case"never":e.write("return INVALID;"),c=i;break;case"void":c=xI(e,i);break;case"nan":c=SI(e,i);break;case"date":c=zI(e,i);break;case"object":c=II(e,t,n,i,s);break;case"optional":c=PI(e,t,n,i,s);break;case"nullable":c=NI(e,t,n,i,s);break;case"array":c=EI(e,t,n,i,s);break;case"literal":c=jI(e,t,n,i);break;case"enum":c=DI(e,t,n,i);break;case"readonly":{let u=r$(e,t,n,i),l=D(t);e.write(`const ${l} = Object.freeze(${u});`),c=l;break}case"success":r$(e,t,n,i),c="true";break;case"default":case"prefault":c=AI(e,t,n,i);break;case"nonoptional":c=RI(e,t,n,i);break;case"tuple":c=UI(e,t,n,i);break;case"union":c=CI(e,t,n,i);break;case"intersection":c=MI(e,t,n,i);break;case"record":c=VI(e,t,n,i);break;case"map":c=qI(e,t,n,i);break;case"set":c=JI(e,t,n,i);break;case"file":c=BI(e,i);break;case"template_literal":c=KI(e,t,n,i);break;case"lazy":c=HI(e,t,n,i);break;case"pipe":c=GI(e,t,n,i);break;case"custom":c=WI(e,t,n,i);break;case"transform":c=QI(e,t,n,i);break;case"catch":c=YI(e,t,n,i);break;default:throw new K(`schema type ${a}`)}return c===null?null:aI(e,t,n,c)}function vI(e,t,n,i,r=!0){e.write(`if (typeof ${i} !== "string") return INVALID;`);let o=n._zod.def;return o.format===void 0?i:s$(e,t,o,i,r)}function yI(e,t,n){e.write(`if (typeof ${n} !== "number" || !Number.isFinite(${n})) return INVALID;`);let i=t._zod.def;return i.check==="number_format"&&i.format&&a$(e,{format:i.format},n),n}function $I(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function _I(e,t,n){e.write(`if (typeof ${n} !== "bigint") return INVALID;`);let i=t._zod.def;if(i.format)switch(i.format){case"int64":e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break}return n}function bI(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function kI(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function wI(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function xI(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function SI(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function zI(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function II(e,t,n,i,r=!0){let o=n._zod.def;e.write(`if (typeof ${i} !== "object" || ${i} === null || Array.isArray(${i})) return INVALID;`);let a=o.shape,s=Object.keys(a),c=Object.getOwnPropertySymbols(a),u=c.length?[...s,...c]:s,l=_=>typeof _=="symbol"?R(t,_):Be(_),d=_=>typeof _=="symbol"?`[${l(_)}]`:Be(_),m=a;if(s.includes("__proto__"))throw new K('object shape key "__proto__"');let f=new Map;for(let _ of u){let S=m[_],O=l(_),I=D(t);if(e.write(`const ${I} = ${i}[${O}];`),S._zod.optin!==void 0){let A=D(t);e.write(`let ${A} = (() => {`),e.indented(q=>{let ke=Le(q,t,S,I);q.write(`return ${ke};`)}),e.write("})();"),S._zod.optout==="optional"?(e.write(`if (${A} === INVALID) {`),e.indented(q=>{q.write(`if (${O} in ${i}) return INVALID;`),q.write(`${A} = undefined;`)}),e.write("}")):e.write(`if (${A} === INVALID) return INVALID;`),f.set(_,A)}else{TI(S)&&e.write(`if (!(${O} in ${i})) return INVALID;`);let A=Le(e,t,S,I,r);A!==null&&f.set(_,A)}}let p=o.catchall,h="none";if(p){let _=p._zod.def.type;if(_==="never"){let S=s.map(O=>`k !== ${Be(O)}`).join(" && ")||"true";e.write(`for (const k in ${i}) {`),e.indented(O=>{O.write(`if (${S}) return INVALID;`)}),e.write("}")}else(_==="unknown"||_==="any")&&!p._zod.def.checks?.length?h="passthrough":h="schema"}let g=D(t),b=u.some(_=>t$(m[_])||Kd(m[_]));if(!r){if(h==="schema"){let _=s.length>0?R(t,new Set(s)):null;e.write(`for (const k in ${i}) {`),e.indented(S=>{S.write('if (k === "__proto__") continue;'),_&&S.write(`if (${_}.has(k)) continue;`);let O=D(t);S.write(`const ${O} = ${i}[k];`),Le(S,t,p,O,!1)}),e.write("}")}return null}if(b){e.write(`const ${g} = {};`);for(let _ of u){let S=l(_),O=f.get(_);Kd(m[_])?e.write(`if (${S} in ${i}) ${g}[${S}] = ${O};`):t$(m[_])?e.write(`if (${O} !== undefined || ${S} in ${i}) ${g}[${S}] = ${O};`):e.write(`${g}[${S}] = ${O};`)}}else{let _=u.map(S=>`${d(S)}: ${f.get(S)}`).join(", ");e.write(`const ${g} = { ${_} };`)}if(h!=="none"){let _=s.length>0?R(t,new Set(s)):null;e.write(`for (const k in ${i}) {`),e.indented(S=>{if(S.write('if (k === "__proto__") continue;'),_&&S.write(`if (${_}.has(k)) continue;`),h==="passthrough")S.write(`${g}[k] = ${i}[k];`);else{let O=D(t);S.write(`const ${O} = ${i}[k];`);let I=Le(S,t,p,O);S.write(`${g}[k] = ${I};`)}}),e.write("}")}return g}function PI(e,t,n,i,r=!0){let o=n._zod.def;if(OI(n))return ge(e,t,o.innerType,i,r);if(o.innerType._zod.optin==="defaulted"){let s=D(t),c=D(t);return e.write(`let ${s};`),e.write(`if (${i} === undefined) {`),e.indented(u=>{u.write(`const ${c} = (() => {`),u.indented(l=>{let d=ge(l,t,o.innerType,i);l.write(`return ${d};`)}),u.write("})();"),u.write(`if (${c} !== INVALID) ${s} = ${c};`)}),e.write("} else {"),e.indented(u=>{let l=ge(u,t,o.innerType,i);u.write(`${s} = ${l};`)}),e.write("}"),s}let a=r?D(t):null;return a&&e.write(`let ${a};`),e.write(`if (${i} !== undefined) {`),e.indented(s=>{let c=ge(s,t,o.innerType,i,r);a&&c!==null&&s.write(`${a} = ${c};`)}),e.write("}"),a}function OI(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function TI(e){return e._zod.optin===void 0&&Ir(e)}function Ir(e){if(e._zod.def.coerce)return!0;let t=e._zod.def;switch(t.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return t.innerType?Ir(t.innerType):!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return t.innerType?Ir(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(Ir):!0;case"intersection":return!t.left||!t.right?!0:Ir(t.left)&&Ir(t.right);case"pipe":return t.in?Ir(t.in):!0;default:return!0}}function Kd(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function t$(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&mn(e)}function mn(e){let t=e._zod.def;switch(t.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return t.innerType?mn(t.innerType):!0;case"union":return t.options?t.options.some(mn):!0;case"intersection":return!t.left||!t.right||mn(t.left)||mn(t.right);case"pipe":return t.out?mn(t.out):!0;default:return!0}}function NI(e,t,n,i,r=!0){let o=n._zod.def,a=r?D(t):null;return a&&e.write(`let ${a} = null;`),e.write(`if (${i} !== null) {`),e.indented(s=>{let c=ge(s,t,o.innerType,i,r);a&&c!==null&&s.write(`${a} = ${c};`)}),e.write("}"),a}function EI(e,t,n,i,r=!0){let o=n._zod.def;e.write(`if (!Array.isArray(${i})) return INVALID;`);let a=r?D(t):null,s=D(t),c=D(t);return a&&e.write(`const ${a} = new Array(${i}.length);`),e.write(`for (let ${s} = 0; ${s} < ${i}.length; ${s}++) {`),e.indented(u=>{u.write(`const ${c} = ${i}[${s}];`);let l=Le(u,t,o.element,c,r);a&&l!==null&&u.write(`${a}[${s}] = ${l};`)}),e.write("}"),a}function jI(e,t,n,i){let o=n._zod.def.values;if(o.length!==1){let s=R(t,new Set(o));return e.write(`if (!${s}.has(${i})) return INVALID;`),i}let a=o[0];if(typeof a=="number"&&Number.isNaN(a)){let s=R(t,new Set(o));return e.write(`if (!${s}.has(${i})) return INVALID;`),i}if(typeof a=="string")e.write(`if (${i} !== ${Be(a)}) return INVALID;`);else if(typeof a=="number"||typeof a=="boolean")e.write(`if (${i} !== ${a}) return INVALID;`);else if(a===null)e.write(`if (${i} !== null) return INVALID;`);else if(a===void 0)e.write(`if (${i} !== undefined) return INVALID;`);else if(typeof a=="bigint")e.write(`if (${i} !== ${a}n) return INVALID;`);else throw new K(`literal type ${typeof a}`);return i}function DI(e,t,n,i){let r=n._zod.values;if(!r)throw new K("enum schema without enumerated values");let o=R(t,r);return e.write(`if (!${o}.has(${i})) return INVALID;`),i}function r$(e,t,n,i){let r=n._zod.def;return ge(e,t,r.innerType,i)}function AI(e,t,n,i){let r=n._zod.def,a=Object.getOwnPropertyDescriptor(n._zod.def,"defaultValue")?()=>n._zod.def.defaultValue:void 0;if(n._zod.def.type==="prefault"){if(!a)return ge(e,t,r.innerType,i);let c=R(t,a),u=D(t);return e.write(`let ${u} = ${i};`),e.write(`if (${i} === undefined) ${u} = ${c}();`),ge(e,t,r.innerType,u)}let s=D(t);if(a){let c=R(t,a),u=R(t,si);e.write(`let ${s};`),e.write(`if (${i} === undefined) {`),e.indented(l=>{l.write(`${s} = ${u}(${c}());`)}),e.write("} else {"),e.indented(l=>{let d=ge(l,t,r.innerType,i);l.write(`${s} = ${d} === undefined ? ${u}(${c}()) : ${d};`)}),e.write("}")}else e.write(`let ${s};`),e.write(`if (${i} !== undefined) {`),e.indented(c=>{let u=ge(c,t,r.innerType,i);c.write(`${s} = ${u};`)}),e.write("}");return s}function RI(e,t,n,i){let r=n._zod.def,o=ge(e,t,r.innerType,i),a=D(t);return e.write(`const ${a} = ${o};`),e.write(`if (${a} === undefined) return INVALID;`),a}function UI(e,t,n,i){let r=n._zod.def,o=r.items,a=r.rest;e.write(`if (!Array.isArray(${i})) return INVALID;`);let s=n$(o,"optin"),c=n$(o,"optout");a?e.write(`if (${i}.length < ${s}) return INVALID;`):e.write(`if (${i}.length < ${s} || ${i}.length > ${o.length}) return INVALID;`);let u=D(t);e.write(`const ${u} = [];`);for(let l=0;l<o.length;l++){let d=o[l];if(l>=c)e.write(`if (${u}.length === ${l}) {`),e.indented(m=>{m.write(`if (${l} < ${i}.length) {`),m.indented(f=>{let p=D(t);f.write(`const ${p} = ${i}[${l}];`);let h=Le(f,t,d,p);f.write(`${u}[${l}] = ${h};`)}),m.write("} else {"),m.indented(f=>{if(Kd(d)){f.write(`${u}.length = ${l};`);return}let p=D(t),h=D(t);f.write(`const ${p} = undefined;`),f.write(`const ${h} = (() => {`),f.indented(g=>{let b=Le(g,t,d,p);g.write(`return ${b};`)}),f.write("})();"),f.write(`if (${h} === INVALID || ${h} === undefined) ${u}.length = ${l};`),f.write(`else ${u}[${l}] = ${h};`)}),m.write("}")}),e.write("}");else{let m=D(t);e.write(`const ${m} = ${i}[${l}];`);let f=Le(e,t,d,m);e.write(`${u}[${l}] = ${f};`)}}if(a){let l=D(t),d=D(t);e.write(`for (let ${l} = ${o.length}; ${l} < ${i}.length; ${l}++) {`),e.indented(m=>{m.write(`const ${d} = ${i}[${l}];`);let f=Le(m,t,a,d);m.write(`${u}[${l}] = ${f};`)}),e.write("}")}return u}function n$(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function CI(e,t,n,i){let r=n._zod.def,o=r.options;if(r.discriminator)return ZI(e,t,r,i);if(r.inclusive===!1)throw new K("exclusive unions (z.xor)");if(o.length===0)return e.write("return INVALID;"),i;if(o.length===1)return ge(e,t,o[0],i);if(o.every(c=>c._zod.def.type==="literal"&&!c._zod.def.checks?.length)){let c=new Set(o.flatMap(l=>l._zod.def.values)),u=R(t,c);return e.write(`if (!${u}.has(${i})) return INVALID;`),i}let s=D(t);e.write(`let ${s};`);for(let c=0;c<o.length;c++){let u=o[c];c===0?e.write(`${s} = (() => {`):e.write(`if (${s} === INVALID) ${s} = (() => {`),e.indented(l=>{let d=ge(l,t,u,i);l.write(`return ${d};`)}),e.write("})();")}return e.write(`if (${s} === INVALID) return INVALID;`),s}function ZI(e,t,n,i){if(n.unionFallback)throw new K("discriminated union with unionFallback");if(n.options.length===0)return e.write("return INVALID;"),i;let r=D(t),o=D(t);e.write(`const ${r} = ${i}?.[${Be(n.discriminator)}];`),e.write(`let ${o};`);let a=!0,s=new Set;for(let c of n.options){let u=c._zod.propValues?.[n.discriminator];if(!u||u.size===0)throw new K("discriminated union option without static discriminator values");for(let m of u){if(s.has(m))throw new K(`duplicate discriminator value ${String(m)}`);s.add(m)}let l=Array.from(u,m=>LI(t,r,m)),d=a?"if":"else if";e.write(`${d} (${l.join(" || ")}) {`),e.indented(m=>{let f=ge(m,t,c,i);m.write(`${o} = ${f};`)}),e.write("}"),a=!1}return e.write("else { return INVALID; }"),o}function LI(e,t,n){if(typeof n=="string")return`${t} === ${Be(n)}`;if(typeof n=="number")return Number.isNaN(n)?`Number.isNaN(${t})`:`${t} === ${n}`;if(typeof n=="boolean")return`${t} === ${n}`;if(n===null)return`${t} === null`;if(n===void 0)return`${t} === undefined`;if(typeof n=="bigint")return`${t} === ${n}n`;if(typeof n=="symbol"){let i=R(e,n);return`${t} === ${i}`}throw new K(`literal discriminator value ${String(n)}`)}function MI(e,t,n,i){let r=n._zod.def;t.definite=!1;let o=Le(e,t,r.left,i),a=Le(e,t,r.right,i),s=R(t,ln),c=D(t);return e.write(`const ${c} = ${s}(${o}, ${a});`),e.write(`if (!${c}.valid) return INVALID;`),`${c}.data`}function VI(e,t,n,i){let r=n._zod.def,o=R(t,mt);e.write(`if (!${o}(${i})) return INVALID;`);let a=D(t),s=D(t),c=D(t);e.write(`const ${a} = {};`);let u=r,l=u.partial?void 0:r.keyType._zod.values;if(l){let f=[];for(let h of l){if(!(typeof h=="string"||typeof h=="number"||typeof h=="symbol"))throw new K(`record key value ${String(h)}`);let g=typeof h=="number"?h.toString():h;if(g==="__proto__")throw new K('record key "__proto__"');f.push(g);let b=R(t,h),_=ge(e,t,r.keyType,b),S=D(t);e.write(`const ${S} = ${i}[${FI(t,g)}];`);let O=Le(e,t,r.valueType,S);e.write(`${a}[${_}] = ${O};`)}let p=R(t,new Set(f));return e.write(`for (const ${s} in ${i}) {`),e.indented(h=>{h.write(`if (${p}.has(${s})) continue;`),u.mode==="loose"?h.write(`if (${s} !== "__proto__") ${a}[${s}] = ${i}[${s}];`):h.write("return INVALID;")}),e.write("}"),a}let d=r.keyType._zod.def;if(!(d.type==="string"&&d.format===void 0&&!d.coerce&&(d.checks?.length??0)===0)){let f=r.mode==="loose",p=Ja(r.keyType);p.definite===!1&&(t.definite=!1);let h=R(t,p),g=R(t,Vt),b=D(t);return i$(e,t,i,s,_=>{_.write(`let ${b} = ${h}(${s});`),_.write(`if (${b} === INVALID && typeof ${s} === "string" && ${g}.test(${s})) ${b} = ${h}(Number(${s}));`),f?_.write(`if (${b} === INVALID) { ${a}[${s}] = ${i}[${s}]; continue; }`):_.write(`if (${b} === INVALID) return INVALID;`),_.write(`if (${b} === "__proto__") continue;`);let S=D(t);_.write(`const ${S} = ${i}[${s}];`);let O=Le(_,t,r.valueType,S);_.write(`${a}[${b}] = ${O};`)}),a}return i$(e,t,i,s,f=>{f.write(`const ${c} = ${i}[${s}];`);let p=Le(f,t,r.valueType,c);f.write(`${a}[${s}] = ${p};`)},"return INVALID;"),a}function i$(e,t,n,i,r,o){let a=R(t,Object.prototype.propertyIsEnumerable),s=D(t),c=D(t),u=D(t);e.write(`const ${s} = Object.getOwnPropertySymbols(${n});`),e.write(`const ${c} = Object.getOwnPropertyNames(${n});`),e.write(`for (let ${u} = 0; ${u} < ${c}.length; ${u}++) {`),e.indented(l=>{l.write(`const ${i} = ${c}[${u}];`),l.write(`if (${i} === "__proto__" || !${a}.call(${n}, ${i})) continue;`),r(l)}),e.write("}"),e.write(`for (let ${u} = 0; ${u} < ${s}.length; ${u}++) {`),e.indented(l=>{l.write(`const ${i} = ${s}[${u}];`),l.write(`if (!${a}.call(${n}, ${i})) continue;`),o?l.write(o):r(l)}),e.write("}")}function FI(e,t){return typeof t=="string"?Be(t):R(e,t)}function qI(e,t,n,i){let r=n._zod.def;e.write(`if (!(${i} instanceof Map)) return INVALID;`);let o=D(t),a=D(t),s=D(t);return e.write(`const ${o} = new Map();`),e.write(`for (const [${a}, ${s}] of ${i}) {`),e.indented(c=>{let u=ge(c,t,r.keyType,a),l=ge(c,t,r.valueType,s);c.write(`${o}.set(${u}, ${l});`)}),e.write("}"),o}function JI(e,t,n,i){let r=n._zod.def;e.write(`if (!(${i} instanceof Set)) return INVALID;`);let o=D(t),a=D(t);return e.write(`const ${o} = new Set();`),e.write(`for (const ${a} of ${i}) {`),e.indented(s=>{let c=ge(s,t,r.valueType,a);s.write(`${o}.add(${c});`)}),e.write("}"),o}function BI(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function KI(e,t,n,i){e.write(`if (typeof ${i} !== "string") return INVALID;`);let r=n._zod.pattern;if(r){let o=R(t,r);e.write(`${o}.lastIndex = 0;`),e.write(`if (!${o}.test(${i})) return INVALID;`)}return i}function HI(e,t,n,i){let r=n._zod.def,o=Pr(t,r.getter),a=R(t,{parser:null});e.write(`if (!${a}.parser) {`),e.indented(c=>{c.write(`const inner = ${o}();`),c.write(`${a}.parser = function(input) {`),c.indented(u=>{u.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),u.write("return result.issues.length === 0 ? result.value : INVALID;")}),c.write("};")}),e.write("}");let s=D(t);return e.write(`const ${s} = ${a}.parser(${i});`),e.write(`if (${s} === INVALID) return INVALID;`),s}function GI(e,t,n,i){let r=n._zod.def,o=ge(e,t,r.in,i);if(r.transform){if(Or(r.transform))throw new wt("z.compile: async transforms in pipes are not supported");let a=r.transform,c=Pr(t,l=>{let d={value:l,issues:[],addIssue:Gd},m=a(l,d);return m instanceof Promise?He:d.issues.length===0?m:He}),u=D(t);return e.write(`const ${u} = ${c}(${o});`),e.write(`if (${u} === INVALID) return INVALID;`),ge(e,t,r.out,u)}else return ge(e,t,r.out,o)}function Or(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function WI(e,t,n,i){let r=n._zod.def;if(r.fn){if(Or(r.fn))throw new wt("z.compile: async custom predicates are not supported");let o=Pr(t,r.fn),a=R(t,Bd),s=D(t);e.write(`const ${s} = ${o}(${i});`),e.write(`if (${s} instanceof Promise) ${a}();`),e.write(`if (!${s}) return INVALID;`)}else throw new K("custom schema without a predicate function");return i}function XI(e,t,n){let i=e._zod.run({value:n,issues:[]},{});if(i&&typeof i.then=="function")return He;let r=i;return r.issues.length===0?r.value:t()}function YI(e,t,n,i){let r=n._zod.def;if(!r.catchValue[Xo])throw new K("catch with a callback (only a constant catch value compiles)",!1);let o=D(t);e.write(`let ${o} = (() => {`),e.indented(u=>{let l=Le(u,t,r.innerType,i);u.write(`return ${l};`)}),e.write("})();");let a=R(t,r.innerType),s=Pr(t,r.catchValue),c=R(t,XI);return e.write(`if (${o} === INVALID) {`),e.indented(u=>{u.write(`${o} = ${c}(${a}, ${s}, ${i});`),u.write(`if (${o} === INVALID) return INVALID;`)}),e.write("}"),o}function QI(e,t,n,i){let r=n._zod.def;if(r.transform){if(Or(r.transform))throw new wt("z.compile: async transforms are not supported");let o=r.transform,s=Pr(t,u=>{let l={value:u,issues:[],addIssue:Gd},d=o(u,l);return d instanceof Promise?He:l.issues.length===0?d:He}),c=D(t);return e.write(`const ${c} = ${s}(${i});`),e.write(`if (${c} === INVALID) return INVALID;`),c}return i}function Ba(e){return e.checks&&(e.checks=[...e.checks]),e}function Wd(e,t){return new e(Ba({type:"string",...z(t)}))}function Xd(e,t){return new e(Ba({type:"string",coerce:!0,...z(t)}))}function Ka(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...z(t)})}function Ha(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...z(t)})}function Ga(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...z(t)})}function Wa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(t)})}function Xa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(t)})}function Ya(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(t)})}function Ri(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...z(t)})}function Qa(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...z(t)})}function es(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(t)})}function ts(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...z(t)})}function rs(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(t)})}function ns(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...z(t)})}function is(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...z(t)})}function os(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(t)})}function as(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(t)})}function ss(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(t)})}function Yd(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...z(t)})}function cs(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(t)})}function us(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(t)})}function ls(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...z(t)})}function ds(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...z(t)})}function fs(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...z(t)})}function Qd(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...z(t)})}function ef(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...z(t)})}function ms(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...z(t)})}var tf={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Ui(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(t)})}function Ci(e,t){return new e({type:"string",format:"date",check:"string_format",...z(t)})}function Zi(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...z(t)})}function Li(e,t){return new e({type:"string",format:"duration",check:"string_format",...z(t)})}function rf(e,t){return new e(Ba({type:"number",checks:[],...z(t)}))}function nf(e,t){return new e(Ba({type:"number",coerce:!0,checks:[],...z(t)}))}function of(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...z(t)})}function af(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...z(t)})}function sf(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...z(t)})}function cf(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...z(t)})}function uf(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...z(t)})}function lf(e,t){return new e({type:"boolean",...z(t)})}function df(e,t){return new e({type:"boolean",coerce:!0,...z(t)})}function ff(e,t){return new e({type:"bigint",...z(t)})}function mf(e,t){return new e({type:"bigint",coerce:!0,...z(t)})}function pf(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...z(t)})}function hf(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...z(t)})}function gf(e,t){return new e({type:"symbol",...z(t)})}function vf(e,t){return new e({type:"undefined",...z(t)})}function yf(e,t){return new e({type:"null",...z(t)})}function $f(e){return new e({type:"any"})}function _f(e){return new e({type:"unknown"})}function bf(e,t){return new e({type:"never",...z(t)})}function kf(e,t){return new e({type:"void",...z(t)})}function wf(e,t){return new e({type:"date",...z(t)})}function xf(e,t){return new e({type:"date",coerce:!0,...z(t)})}function Sf(e,t){return new e({type:"nan",...z(t)})}function Tt(e,t){return new fa({check:"less_than",...z(t),value:e,inclusive:!1})}function lt(e,t){return new fa({check:"less_than",...z(t),value:e,inclusive:!0})}function Nt(e,t){return new ma({check:"greater_than",...z(t),value:e,inclusive:!1})}function dt(e,t){return new ma({check:"greater_than",...z(t),value:e,inclusive:!0})}function ps(e){return Nt(0,e)}function hs(e){return Tt(0,e)}function gs(e){return lt(0,e)}function vs(e){return dt(0,e)}function er(e,t){return new cl({check:"multiple_of",...z(t),value:e})}function tr(e,t){return new dl({check:"max_size",...z(t),maximum:e})}function Et(e,t){return new fl({check:"min_size",...z(t),minimum:e})}function Tr(e,t){return new ml({check:"size_equals",...z(t),size:e})}function Nr(e,t){return new pl({check:"max_length",...z(t),maximum:e})}function Ft(e,t){return new hl({check:"min_length",...z(t),minimum:e})}function Er(e,t){return new gl({check:"length_equals",...z(t),length:e})}function pn(e,t){return new vl({check:"string_format",format:"regex",...z(t),pattern:e})}function hn(e){return new yl({check:"string_format",format:"lowercase",...z(e)})}function gn(e){return new $l({check:"string_format",format:"uppercase",...z(e)})}function vn(e,t){return new _l({check:"string_format",format:"includes",...z(t),includes:e})}function yn(e,t){return new bl({check:"string_format",format:"starts_with",...z(t),prefix:e})}function $n(e,t){return new kl({check:"string_format",format:"ends_with",...z(t),suffix:e})}function ys(e,t,n){return new wl({check:"property",property:e,schema:t,...z(n)})}function _n(e,t){return new xl({check:"properties",shape:e,...z(t)})}function bn(e,t){return new Sl({check:"mime_type",mime:e,...z(t)})}function xt(e){return new zl({check:"overwrite",tx:e})}function kn(e){return xt(t=>t.normalize(e))}function wn(){return xt(e=>e.trim())}function xn(){return xt(e=>e.toLowerCase())}function Sn(){return xt(e=>e.toUpperCase())}function zn(){return xt(e=>uu(e))}function zf(e,t,n){return new e({type:"array",element:t,...z(n)})}function e0(e,t,n){return new e({type:"union",options:t,...z(n)})}function t0(e,t,n){return new e({type:"union",options:t,inclusive:!1,...z(n)})}function r0(e,t,n,i){return new e({type:"union",options:n,discriminator:t,...z(i)})}function n0(e,t,n){return new e({type:"intersection",left:t,right:n})}function i0(e,t,n,i){let r=n instanceof U,o=r?i:n,a=r?n:null;return new e({type:"tuple",items:t,rest:a,...z(o)})}function o0(e,t,n,i){return new e({type:"record",keyType:t,valueType:n,...z(i)})}function a0(e,t,n,i){return new e({type:"map",keyType:t,valueType:n,...z(i)})}function s0(e,t,n){return new e({type:"set",valueType:t,...z(n)})}function c0(e,t,n){let i=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new e({type:"enum",entries:i,...z(n)})}function u0(e,t,n){return new e({type:"enum",entries:t,...z(n)})}function l0(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...z(n)})}function If(e,t){return new e({type:"file",...z(t)})}function d0(e,t){return new e({type:"transform",transform:t})}function f0(e,t){return new e({type:"optional",innerType:t})}function m0(e,t){return new e({type:"nullable",innerType:t})}function p0(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():si(n)}})}function h0(e,t,n){return new e({type:"nonoptional",innerType:t,...z(n)})}function g0(e,t){return new e({type:"success",innerType:t})}function v0(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:hu(n)})}function y0(e,t,n){return new e({type:"pipe",in:t,out:n})}function $0(e,t){return new e({type:"readonly",innerType:t})}function _0(e,t,n){return new e({type:"template_literal",parts:t,...z(n)})}function b0(e,t){return new e({type:"lazy",getter:t})}function k0(e,t){return new e({type:"promise",innerType:t})}function Pf(e,t,n){let i=z(n);return i.abort??(i.abort=!0),new e({type:"custom",check:"custom",fn:t,...i})}function Of(e,t,n){return new e({type:"custom",check:"custom",fn:t,...z(n)})}function Tf(e,t){let n=c$(i=>(i.addIssue=r=>{if(typeof r=="string")i.issues.push(tn(r,i.value,n._zod.def));else{let o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=i.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),i.issues.push(tn(o))}},e(i.value,i)),t);return n}function c$(e,t){let n=new ue({check:"custom",...z(t)});return n._zod.check=e,n}function Nf(e){let t=new ue({check:"describe"});return t._zod.onattach=[n=>{let i=Oe.get(n)??{};Oe.add(n,{...i,description:e})}],t._zod.check=()=>{},t}function Ef(e){let t=new ue({check:"meta"});return t._zod.onattach=[n=>{let i=Oe.get(n)??{};Oe.add(n,{...i,...e})}],t._zod.check=()=>{},t}function jf(e,t){let n=z(t),i=n.truthy??["true","1","yes","on","y","enabled"],r=n.falsy??["false","0","no","off","n","disabled"];n.case!=="sensitive"&&(i=i.map(f=>typeof f=="string"?f.toLowerCase():f),r=r.map(f=>typeof f=="string"?f.toLowerCase():f));let o=new Set(i),a=new Set(r),s=e.Codec??Oi,c=e.Boolean??Ii,u=e.String??Sr,l=new u({type:"string",error:n.error}),d=new c({type:"boolean",error:n.error}),m=new s({type:"pipe",in:l,out:d,transform:((f,p)=>{let h=f;return n.case!=="sensitive"&&(h=h.toLowerCase()),o.has(h)?!0:a.has(h)?!1:(p.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...a],input:p.value,inst:m,continue:!1}),{})}),reverseTransform:((f,p)=>f===!0?i[0]||"true":r[0]||"false"),error:n.error});return m._zod.bag.truthy=i,m._zod.bag.falsy=r,m._zod.bag.case=n.case??"insensitive",m}function jr(e,t,n,i={}){let r=z(i),o={check:"string_format",type:"string",format:t,fn:typeof n=="function"?n:s=>n.test(s),...r};return n instanceof RegExp&&(o.pattern=n),new e(o)}function Mi(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,i)&&Pe(e,i,n[i]);return e}function rr(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??Oe,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:[],deferred:[],external:e?.external??void 0}}function we(e,t,n,i,r){let o=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(r);return Object.assign(n,o),!0}function ie(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;let a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{let l={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,l);else{let m=a.schema,f=t.processors[r.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);f(e,t,m,l)}let d=e._zod.parent;d&&(a.ref||(a.ref=d),ie(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Mi(a.schema,c),t.io==="input"&&Ge(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&"_prefault"in a.schema&&((i=a.schema).default??(i.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function u$(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function nr(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let a of e.seen.entries()){let s=e.metadataRegistry.get(a[0])?.id;if(s){let c=i.get(s);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(s,a[0])}}let r=a=>{let s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(a[0])?.id,m=e.external.uri??(p=>p);if(d)return{ref:m(d)};let f=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=f,{defId:f,ref:`${m("__shared")}#/${s}/${u$(f)}`}}let c="#",u=`${c}/${s}/`;if(a[1]===n&&!a[1].schema.id)return{ref:c};let l=a[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+u$(l)}},o=a=>{if(a[1].schema.$ref)return;let s=a[1],{ref:c,defId:u}=r(a);s.def={...s.schema},u&&(s.defId=u);let l=s.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let a of e.seen.entries()){let s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
|
|
69
69
|
|
|
70
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let s=a[1];if(t===a[0]){o(a);continue}if(e.external){let u=e.external.registry.get(a[0])?.id;if(t!==a[0]&&u){o(a);continue}}if(e.metadataRegistry.get(a[0])?.id){o(a);continue}if(s.cycle){o(a);continue}s.count>1&&e.reused==="ref"&&o(a)}e.external&&(e.sharedDefsExtractedFor=e.external)}function f$(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!="object")return;f$(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let o=i.type;for(let a of Array.isArray(o)?o:[o]){if(typeof a!="string")return;n.includes(a)||n.push(a)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var m$=new Set(["type","properties","required","additionalProperties"]),l$=["oneOf","anyOf"];function d$(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Df(e){let t=[];for(let o of e){if(typeof o!="object"||o.type!=="object")return null;for(let a in o)if(!m$.has(a))return null;t.push(o)}let n={},i=new Set;for(let o of t){for(let a in o.properties){if(Object.prototype.hasOwnProperty.call(n,a))continue;let s=[];for(let u of t){let l=u.properties?.[a]??d$(u);l!=null&&(s.some(d=>JSON.stringify(d)===JSON.stringify(l))||s.push(l))}let c=s.length===1?s[0]:Df(s)??{allOf:s};Pe(n,a,c)}for(let a of o.required??[])i.add(a)}let r={type:"object",properties:n};if(i.size&&(r.required=[...i]),t.every(o=>o.additionalProperties===!1))r.additionalProperties=!1;else{let o=[];for(let a of t){let s=d$(a);s&&!o.some(c=>JSON.stringify(c)===JSON.stringify(s))&&o.push(s)}o.length===1?r.additionalProperties=o[0]:o.length>1&&(r.additionalProperties={allOf:o})}return r}function w0(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of m$)if(r in e)return;let n=t.filter(r=>l$.some(o=>Array.isArray(r[o]))),i=null;if(!n.length)i=Df(t);else{let r=n[0],o=l$.find(c=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let a=t.filter(c=>c!==r),s=r[o].map(c=>Df([...a,c]));if(s.some(c=>!c))return;i={[o]:s}}i&&(delete e.allOf,Mi(e,i))}function ir(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let c=e.seen.get(s);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){i(d);let f=e.seen.get(d),p=f.schema;if(p.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(p)):Mi(u,p),Mi(u,l),s._zod.parent===d)for(let g in u)g==="$ref"||g==="allOf"||g in l||delete u[g];if(p.$ref&&f.def)for(let g in u)g==="$ref"||g==="allOf"||g in f.def&&JSON.stringify(u[g])===JSON.stringify(f.def[g])&&delete u[g]}let m=s._zod.parent;if(m&&m!==d){i(m);let f=e.seen.get(m);if(f?.schema.$ref&&(u.$ref=f.schema.$ref,f.def))for(let p in u)p==="$ref"||p==="allOf"||p in f.def&&JSON.stringify(u[p])===JSON.stringify(f.def[p])&&delete u[p]}e.override({zodSchema:s,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let s of[...e.seen.entries()].reverse())i(s[0]);if(e.target!=="openapi-3.0")for(let s of e.seen.entries())f$(s[1].def??s[1].schema);for(let s of e.deferred)s();if(e.intersections.length){let s=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=s.get(l);d?d.push(u):s.set(l,[u])}for(let c of e.intersections)for(let u of s.get(c)??[])w0(u)}}let r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(s)}Mi(r,n.defId?n.schema:n.def??n.schema);let o=e.metadataRegistry.get(t)?.id;o!==void 0&&r.id===o&&delete r.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let s of e.seen.entries()){let c=s[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,Pe(a,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?r.$defs=a:r.definitions=a);try{let s=JSON.parse(JSON.stringify(r));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:In(t,"input",e.processors),output:In(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function Ge(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Ge(i.element,n);if(i.type==="set")return Ge(i.valueType,n);if(i.type==="lazy")return Ge(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return Ge(i.innerType,n);if(i.type==="intersection")return Ge(i.left,n)||Ge(i.right,n);if(i.type==="record"||i.type==="map")return Ge(i.keyType,n)||Ge(i.valueType,n);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Ge(i.in,n)||Ge(i.out,n);if(i.type==="object"){for(let r in i.shape)if(Ge(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(Ge(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(Ge(r,n))return!0;return!!(i.rest&&Ge(i.rest,n))}return!1}var Af=(e,t={})=>n=>{let i=rr({...n,processors:t});return ie(e,i),nr(i,e),ir(i,e)},In=(e,t,n={})=>i=>{let{libraryOptions:r,target:o}=i??{},a=rr({...r??{},target:o,io:t,processors:n});return ie(e,a),nr(a,e),ir(a,e)};var Pn=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},On=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},p$=(e,t)=>{Pn(e,"minimum",t),On(e,"maximum",t)},y$=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},$$=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},_$=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},b$=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},h$=(e,t)=>Pn(e,"minimum",t.minimum),g$=(e,t)=>On(e,"maximum",t.maximum),v$=e=>(t,n)=>{b$(t,n.format);let[i,r]=e[n.format];Pn(t,"minimum",i),On(t,"maximum",r)},x0={greater_than:(e,t)=>Pn(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>On(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>y$(e,t.value),number_format:v$(ui),bigint_format:v$(li),min_length:h$,max_length:g$,length_equals:(e,t)=>p$(e,t.length),min_size:h$,max_size:g$,size_equals:(e,t)=>p$(e,t.size),string_format:(e,t)=>{b$(e,t.format),t.pattern&&$$(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>_$(e,t.mime)};function xe(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let o of i)x0[o._zod.def.check]?.(t,o._zod.def);let r=e._zod.bag;r.minimum!==void 0&&Pn(t,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&Pn(t,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&On(t,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&On(t,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&y$(t,r.multipleOf),r.format!==void 0&&(t.format??(t.format=r.format),r.format.includes("int")&&(t.isInt=!0)),r.mime&&_$(t,r.mime);for(let o of r.patterns??[])$$(t,o);return t}var S0={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},z0=new Map([[wa,Vu],[zi,Fu]]),k$=e=>z0.get(e)??e,Cf=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:o,maximum:a,format:s,patterns:c,contentEncoding:u,laxFormat:l}=xe(e);if(typeof o=="number"&&(r.minLength=o),typeof a=="number"&&(r.maxLength=a),s&&(r.format=S0[s]??s,r.format===""&&delete r.format,(s==="time"||l)&&delete r.format),u&&(r.contentEncoding=u),c&&c.size>0){let d=[...c].map(k$);d.length===1?r.pattern=d[0].source:d.length>1&&(r.allOf=[...d.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},Zf=(e,t,n,i)=>{let r=n,{minimum:o,maximum:a,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=xe(e);r.type=l?"integer":"number";let d=typeof u=="number"&&u>=(o??Number.NEGATIVE_INFINITY),m=typeof c=="number"&&c<=(a??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(d?f?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u:typeof o=="number"&&(r.minimum=o),m?f?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:typeof a=="number"&&(r.maximum=a),s){let p=new Set;for(let b of s)Number.isFinite(b)&&b!==0?p.add(Math.abs(b)):we(e,t,r,i,`A multipleOf divisor of ${b} cannot be represented in JSON Schema`);let[h,...g]=p;h!==void 0&&(r.multipleOf=h),g.length&&(r.allOf=[...r.allOf??[],...g.map(b=>({multipleOf:b}))])}},Lf=(e,t,n,i)=>{n.type="boolean"},Mf=(e,t,n,i)=>{we(e,t,n,i,"BigInt cannot be represented in JSON Schema")},Vf=(e,t,n,i)=>{we(e,t,n,i,"Symbols cannot be represented in JSON Schema")},Ff=(e,t,n,i)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},qf=(e,t,n,i)=>{we(e,t,n,i,"Undefined cannot be represented in JSON Schema")},Jf=(e,t,n,i)=>{we(e,t,n,i,"Void cannot be represented in JSON Schema")},Bf=(e,t,n,i)=>{n.not={}},Kf=(e,t,n,i)=>{},Hf=(e,t,n,i)=>{},Gf=(e,t,n,i)=>{we(e,t,n,i,"Date cannot be represented in JSON Schema")},Wf=(e,t,n,i)=>{let r=e._zod.def,o=Xr(r.entries);if(o.length===0){n.not={};return}o.every(a=>typeof a=="number")&&(n.type="number"),o.every(a=>typeof a=="string")&&(n.type="string"),n.enum=o},Xf=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let o=[];for(let a of r.values)if(a===void 0){if(we(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(we(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(a))}else o.push(a);if(o.length!==0)if(o.length===1){let a=o[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else o.every(a=>typeof a=="number")&&(n.type="number"),o.every(a=>typeof a=="string")&&(n.type="string"),o.every(a=>typeof a=="boolean")&&(n.type="boolean"),o.every(a=>a===null)&&(n.type="null"),n.enum=o},Yf=(e,t,n,i)=>{we(e,t,n,i,"NaN cannot be represented in JSON Schema")},Qf=(e,t,n,i)=>{let r=n,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");r.type="string",r.pattern=o.source},em=(e,t,n,i)=>{let r=n;r.type="string",r.format="binary",r.contentEncoding="binary";let{minimum:o,maximum:a,mime:s}=xe(e);o!==void 0&&(r.minLength=o),a!==void 0&&(r.maxLength=a),s&&(s.length===0?r.not={}:s.length===1?r.contentMediaType=s[0]:r.anyOf=s.map(c=>({contentMediaType:c})))},tm=(e,t,n,i)=>{n.type="boolean"},rm=(e,t,n,i)=>{we(e,t,n,i,"Custom types cannot be represented in JSON Schema")},nm=(e,t,n,i)=>{we(e,t,n,i,"Function types cannot be represented in JSON Schema")},im=(e,t,n,i)=>{we(e,t,n,i,"Transforms cannot be represented in JSON Schema")},om=(e,t,n,i)=>{we(e,t,n,i,"Map cannot be represented in JSON Schema")},am=(e,t,n,i)=>{we(e,t,n,i,"Set cannot be represented in JSON Schema")},sm=(e,t,n,i)=>{let r=n,o=e._zod.def,{minimum:a,maximum:s}=xe(e);typeof a=="number"&&(r.minItems=a),typeof s=="number"&&(r.maxItems=s),r.type="array",r.items=ie(o.element,t,{...i,path:[...i.path,"items"]})};function Vi(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Vi(t.out):t.type==="catch"?Vi(t.innerType):e._zod.optin}var cm=(e,t,n,i)=>{let r=n,o=e._zod.def,a=o.shape;if(Object.getOwnPropertySymbols(a).length&&we(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let u in a)Pe(r.properties,u,ie(a[u],t,{...i,path:[...i.path,"properties",u]}));let c=[];for(let u of Object.keys(a)){let l=o.shape[u];(t.io==="input"?Vi(l)===void 0:l._zod.optout===void 0)&&c.push(u)}c.length>0&&(r.required=c),o.catchall?._zod.def.type==="never"?r.additionalProperties=!1:o.catchall?o.catchall&&(r.additionalProperties=ie(o.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},_s=(e,t,n,i)=>{let r=e._zod.def,o=r.inclusive===!1,a=r.options.map((s,c)=>ie(s,t,{...i,path:[...i.path,o?"oneOf":"anyOf",c]}));o?n.oneOf=a:n.anyOf=a},um=(e,t,n,i)=>{let r=e._zod.def,o=ie(r.left,t,{...i,path:[...i.path,"allOf",0]}),a=ie(r.right,t,{...i,path:[...i.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(o)?o.allOf:[o],...s(a)?a.allOf:[a]];n.allOf=c,t.intersections.push(c)},lm=(e,t,n,i)=>{let r=n,o=e._zod.def;r.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((h,g)=>ie(h,t,{...i,path:[...i.path,a,g]})),u=o.rest?ie(o.rest,t,{...i,path:[...i.path,s,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null,l=o.items.length;for(;l>0;){let h=o.items[l-1];if(!(t.io==="input"?Vi(h)!==void 0:h._zod.optout==="optional"))break;l--}let d=o.items.length,m=!o.rest;t.target==="draft-2020-12"?(r.prefixItems=c,m?r.items=!1:u&&(r.items=u),l>0&&(r.minItems=l),m&&(r.maxItems=d)):t.target==="openapi-3.0"?(r.items={anyOf:c},u&&r.items.anyOf.push(u),l>0&&(r.minItems=l),m&&(r.maxItems=d)):(r.items=c,m?r.additionalItems=!1:u&&(r.additionalItems=u),l>0&&(r.minItems=l),m&&(r.maxItems=d));let{minimum:f,maximum:p}=xe(e);typeof f=="number"&&(r.minItems=f),typeof p=="number"&&(r.maxItems=p)};function Rf(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let p=e.get(t)?.def;if(!p)return t;let h=Rf(e,p,n);return h===p?t:h}for(let p of["anyOf","oneOf"]){let h=t[p];if(!Array.isArray(h))continue;let g=h.map(b=>Rf(e,b,n));g.some((b,_)=>b!==h[_])&&(t={...t,[p]:g})}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some(p=>p==="number"||p==="integer"),o=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!o?.some(p=>typeof p=="number"))return t;let{minimum:a,maximum:s,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:m,...f}=t;return f.enum?f.enum=f.enum.map(p=>typeof p=="number"?String(p):p):typeof f.const=="number"&&(f.const=String(f.const)),r&&(f.type="string",o||(f.pattern=(i.includes("number")?Vt:$i).source)),f}var Uf=new WeakMap;function I0(e){let t=new Map;for(let i of e.seen.values())i.def&&!t.has(i.schema)&&t.set(i.schema,i);let n=new Map;for(let i of Uf.get(e)??[]){let r=e.seen.get(i),o=(r?.def??r?.schema)?.propertyNames;if(!o||o===!0||n.has(o))continue;let a=Rf(t,o,new Set);a!==o&&n.set(o,a)}if(n.size)for(let i of e.seen.values())for(let r of[i.schema,i.def]){let o=r&&n.get(r.propertyNames);o&&(r.propertyNames=o)}}var dm=(e,t,n,i)=>{let r=n,o=e._zod.def;r.type="object";let a=o.keyType,s=xe(a).patterns;if(o.mode==="loose"&&s&&s.size>0){let l=ie(o.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let d of s)Pe(r.patternProperties,k$(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=ie(o.keyType,t,{...i,path:[...i.path,"propertyNames"]});let l=Uf.get(t);l||(l=[],Uf.set(t,l),t.deferred.push(()=>I0(t))),l.push(e)}r.additionalProperties=ie(o.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=a._zod.values,u=t.io==="input"&&Vi(o.valueType)!==void 0;if(c&&!o.partial&&!u){let l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(r.required=l.map(String))}},fm=(e,t,n,i)=>{let r=e._zod.def,o=ie(r.innerType,t,i),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=r.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},mm=(e,t,n,i)=>{let r=e._zod.def;ie(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType},pm=Symbol();function w$(e,t,n,i,r){let o=!1,a=JSON.stringify(e,(s,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(we(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),pm):JSON.parse(a)}var hm=(e,t,n,i)=>{let r=e._zod.def;ie(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType;let a=w$(r.defaultValue,e,t,n,i);a!==pm&&(n.default=a)},gm=(e,t,n,i)=>{let r=e._zod.def;ie(r.innerType,t,i);let o=t.seen.get(e);if(o.ref=r.innerType,t.io!=="input")return;let a=w$(r.defaultValue,e,t,n,i);a!==pm&&(n._prefault=a)},vm=(e,t,n,i)=>{let r=e._zod.def;ie(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType;let a;try{a=r.catchValue(void 0)}catch{we(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=a},ym=(e,t,n,i)=>{let r=e._zod.def,o=r.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?o?r.out:r.in:r.out;ie(a,t,i);let s=t.seen.get(e);s.ref=a},$m=(e,t,n,i)=>{let r=e._zod.def;ie(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType,n.readOnly=!0},_m=(e,t,n,i)=>{let r=e._zod.def;ie(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType},bs=(e,t,n,i)=>{let r=e._zod.def;ie(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType},bm=(e,t,n,i)=>{let r=e._zod.innerType;ie(r,t,i);let o=t.seen.get(e);o.ref=r},$s={string:Cf,number:Zf,boolean:Lf,bigint:Mf,symbol:Vf,null:Ff,undefined:qf,void:Jf,never:Bf,any:Kf,unknown:Hf,date:Gf,enum:Wf,literal:Xf,nan:Yf,template_literal:Qf,file:em,success:tm,custom:rm,function:nm,transform:im,map:om,set:am,array:sm,object:cm,union:_s,intersection:um,tuple:lm,record:dm,nullable:fm,nonoptional:mm,default:hm,prefault:gm,catch:vm,pipe:ym,readonly:$m,promise:_m,optional:bs,lazy:bm};function ks(e,t){if("_idmap"in e){let i=e,r=rr({...t,processors:$s}),o={};for(let c of i._idmap.entries()){let[u,l]=c;ie(l,r)}let a={},s={registry:i,uri:t?.uri,defs:o};r.external=s;for(let c of i._idmap.entries()){let[u,l]=c;nr(r,l),Pe(a,u,ir(r,l))}if(Object.keys(o).length>0){let c=r.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[c]:o}}return{schemas:a}}let n=rr({...t,processors:$s});return ie(e,n),nr(n,e),ir(n,e)}var ws=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let n=t?.target??"draft-2020-12";n==="draft-4"&&(n="draft-04"),n==="draft-7"&&(n="draft-07"),this.ctx=rr({processors:$s,target:n,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,n={path:[],schemaPath:[]}){return ie(t,this.ctx,n)}emit(t,n){n&&(n.cycles&&(this.ctx.cycles=n.cycles),n.reused&&(this.ctx.reused=n.reused),n.external&&(this.ctx.external=n.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,nr(this.ctx,t);let i=ir(this.ctx,t),{"~standard":r,...o}=i;return o}};var x$={};var S$=Symbol("z.visit/resolving");function Fi(e,t){let n=typeof t=="function"?t:(a,s)=>{let c=t[a._zod.def.type];return c?c(a,s):a},i=new Map;function r(a){let s=i.get(a);if(s===S$)return new Ti({type:"lazy",getter:()=>i.get(a)});if(s!==void 0)return s;i.set(a,S$);let c=o(a),u=n(c,c!==a);return i.set(a,u),u}function o(a){let s=a._zod.def,c=s.type;switch(c){case"object":{let u=s.shape,l=Object.keys(u),d=!1,m={};for(let p of l){let h=r(u[p]);h!==u[p]&&(d=!0),m[p]=h}let f=s.catchall;return s.catchall&&(f=r(s.catchall),f!==s.catchall&&(d=!0)),d?re(a,{...s,shape:m,catchall:f}):a}case"array":{let u=r(s.element);return u===s.element?a:re(a,{...s,element:u})}case"tuple":{let u=s.items,l=!1,d=[];for(let f of u){let p=r(f);p!==f&&(l=!0),d.push(p)}let m=s.rest;return s.rest&&(m=r(s.rest),m!==s.rest&&(l=!0)),l?re(a,{...s,items:d,rest:m}):a}case"record":case"map":{let u=r(s.keyType),l=r(s.valueType);return u===s.keyType&&l===s.valueType?a:re(a,{...s,keyType:u,valueType:l})}case"set":{let u=r(s.valueType);return u===s.valueType?a:re(a,{...s,valueType:u})}case"union":{let u=s.options,l=!1,d=[];for(let m of u){let f=r(m);f!==m&&(l=!0),d.push(f)}return l?re(a,{...s,options:d}):a}case"intersection":{let u=r(s.left),l=r(s.right);return u===s.left&&l===s.right?a:re(a,{...s,left:u,right:l})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let u=r(s.innerType);return u===s.innerType?a:re(a,{...s,innerType:u})}case"pipe":{let u=r(s.in),l=r(s.out);return u===s.in&&l===s.out?a:re(a,{...s,in:u,out:l})}case"function":{let u=r(s.input),l=r(s.output);return u===s.input&&l===s.output?a:re(a,{...s,input:u,output:l})}case"lazy":{let u=s.getter,{_cachedInner:l,...d}=s;return re(a,{...d,getter:()=>r(u())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return a;default:return a}}return r(e)}function xs(e){return!!e._zod}function or(e,t){return xs(e)?Qo(e,t):e.safeParse(t)}function Ss(e){if(!e)return;let t;if(xs(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function zs(e){if(xs(e)){let o=e._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}let n=e._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}let i=e.value;if(i!==void 0)return i}var ve={};Zt(ve,{$brand:()=>yu,$input:()=>qd,$output:()=>Fd,INVALID:()=>He,NEVER:()=>vu,TimePrecision:()=>tf,ZodAny:()=>Lm,ZodArray:()=>qm,ZodBase64:()=>Js,ZodBase64URL:()=>Bs,ZodBigInt:()=>An,ZodBigIntFormat:()=>Gs,ZodBoolean:()=>Dn,ZodCIDRv4:()=>Fs,ZodCIDRv6:()=>qs,ZodCUID:()=>Rs,ZodCUID2:()=>Us,ZodCatch:()=>up,ZodCodec:()=>Qi,ZodCompileAsyncError:()=>wt,ZodCompileUnsupportedError:()=>K,ZodCreditCard:()=>Am,ZodCustom:()=>eo,ZodCustomStringFormat:()=>Ar,ZodDate:()=>Ki,ZodDefault:()=>np,ZodDiscriminatedUnion:()=>Bm,ZodE164:()=>Ks,ZodEmail:()=>Es,ZodEmoji:()=>Ds,ZodEnum:()=>Nn,ZodError:()=>O0,ZodExactOptional:()=>Ys,ZodFile:()=>Qm,ZodFirstPartyTypeKind:()=>wp,ZodFunction:()=>$p,ZodGUID:()=>js,ZodIBAN:()=>Rm,ZodIPv4:()=>Ms,ZodIPv6:()=>Vs,ZodISODate:()=>sr,ZodISODateTime:()=>ar,ZodISODuration:()=>ur,ZodISOTime:()=>cr,ZodInstanceOf:()=>kp,ZodIntersection:()=>Km,ZodIssueCode:()=>E0,ZodJWT:()=>Hs,ZodKSUID:()=>Ls,ZodLazy:()=>gp,ZodLiteral:()=>Ym,ZodMAC:()=>Dm,ZodMap:()=>Wm,ZodNaN:()=>dp,ZodNanoID:()=>As,ZodNever:()=>Vm,ZodNonOptional:()=>Qs,ZodNull:()=>Zm,ZodNullable:()=>rp,ZodNumber:()=>jn,ZodNumberFormat:()=>Rr,ZodObject:()=>Hi,ZodOptional:()=>Xi,ZodPipe:()=>Yi,ZodPrefault:()=>op,ZodPreprocess:()=>fp,ZodPromise:()=>yp,ZodReadonly:()=>mp,ZodRealError:()=>nt,ZodRecord:()=>Tn,ZodSet:()=>Xm,ZodString:()=>En,ZodStringFormat:()=>se,ZodSuccess:()=>cp,ZodSymbol:()=>Um,ZodTemplateLiteral:()=>hp,ZodTransform:()=>ep,ZodTuple:()=>Hm,ZodType:()=>Z,ZodULID:()=>Cs,ZodURL:()=>Ji,ZodUUID:()=>jt,ZodUndefined:()=>Cm,ZodUnion:()=>Gi,ZodUnknown:()=>Mm,ZodVoid:()=>Fm,ZodXID:()=>Zs,ZodXor:()=>Jm,_ZodString:()=>Ns,_default:()=>ip,_function:()=>j_,any:()=>p_,array:()=>J,base64:()=>H$,base64url:()=>G$,bigint:()=>u_,boolean:()=>$e,catch:()=>lp,check:()=>D_,cidrv4:()=>B$,cidrv6:()=>K$,clone:()=>re,codec:()=>O_,coerce:()=>Sp,compile:()=>Hd,config:()=>ye,core:()=>qt,creditCard:()=>X$,cuid:()=>C$,cuid2:()=>Z$,currencyCode:()=>n_,custom:()=>ec,date:()=>g_,decode:()=>Im,decodeAsync:()=>Om,deepPartial:()=>J_,describe:()=>A_,discriminatedUnion:()=>Wi,e164:()=>W$,email:()=>P$,emoji:()=>R$,encode:()=>zm,encodeAsync:()=>Pm,endsWith:()=>$n,enum:()=>Ne,exactOptional:()=>tp,file:()=>S_,flattenError:()=>pi,float32:()=>o_,float64:()=>a_,formatError:()=>hi,fromJSONSchema:()=>q_,function:()=>j_,getDiscriminatedOption:()=>vd,getErrorMap:()=>D0,globalRegistry:()=>Oe,gt:()=>Nt,gte:()=>dt,guid:()=>O$,hash:()=>i_,hex:()=>r_,hostname:()=>t_,httpUrl:()=>A$,iban:()=>Y$,includes:()=>vn,input:()=>K_,instanceof:()=>U_,int:()=>Os,int32:()=>s_,int64:()=>l_,intersection:()=>Rn,invertCodec:()=>T_,ipv4:()=>F$,ipv6:()=>J$,iso:()=>Ur,json:()=>Z_,jwt:()=>Q$,keyof:()=>v_,ksuid:()=>V$,lazy:()=>vp,length:()=>Er,literal:()=>E,locales:()=>Ai,looseObject:()=>Te,looseRecord:()=>b_,lowercase:()=>hn,lt:()=>Tt,lte:()=>lt,mac:()=>q$,map:()=>k_,maxLength:()=>Nr,maxSize:()=>tr,memoizer:()=>ji,meta:()=>R_,mime:()=>bn,minLength:()=>Ft,minSize:()=>Et,multipleOf:()=>er,nan:()=>P_,nanoid:()=>U$,nativeEnum:()=>x_,negative:()=>hs,never:()=>Ws,nonnegative:()=>vs,nonoptional:()=>sp,nonpositive:()=>gs,normalize:()=>kn,null:()=>Bi,nullable:()=>qi,nullish:()=>z_,number:()=>ee,object:()=>N,optional:()=>ae,output:()=>H_,overwrite:()=>xt,parse:()=>km,parseAsync:()=>wm,partialRecord:()=>__,pipe:()=>Ts,positive:()=>ps,prefault:()=>ap,preprocess:()=>to,prettifyError:()=>wu,promise:()=>E_,properties:()=>_n,property:()=>ys,readonly:()=>pp,record:()=>ce,refine:()=>_p,regex:()=>pn,regexes:()=>ht,registry:()=>Fa,safeDecode:()=>Nm,safeDecodeAsync:()=>jm,safeEncode:()=>Tm,safeEncodeAsync:()=>Em,safeParse:()=>xm,safeParseAsync:()=>Sm,set:()=>w_,setErrorMap:()=>j0,size:()=>Tr,slugify:()=>zn,startsWith:()=>yn,strictObject:()=>y_,string:()=>$,stringFormat:()=>e_,stringbool:()=>C_,success:()=>I_,superRefine:()=>bp,symbol:()=>f_,templateLiteral:()=>N_,toJSONSchema:()=>ks,toLowerCase:()=>xn,toUpperCase:()=>Sn,toZod:()=>oi,transform:()=>Xs,treeifyError:()=>ku,trim:()=>wn,tuple:()=>Gm,uint32:()=>c_,uint64:()=>d_,ulid:()=>L$,undefined:()=>m_,union:()=>oe,unknown:()=>le,uppercase:()=>gn,url:()=>D$,util:()=>k,uuid:()=>T$,uuidv4:()=>N$,uuidv6:()=>E$,uuidv7:()=>j$,validate:()=>sn,validateAsync:()=>cn,void:()=>h_,withParser:()=>qa,xid:()=>M$,xor:()=>$_});var Un={};Zt(Un,{ZodAny:()=>Lm,ZodArray:()=>qm,ZodBase64:()=>Js,ZodBase64URL:()=>Bs,ZodBigInt:()=>An,ZodBigIntFormat:()=>Gs,ZodBoolean:()=>Dn,ZodCIDRv4:()=>Fs,ZodCIDRv6:()=>qs,ZodCUID:()=>Rs,ZodCUID2:()=>Us,ZodCatch:()=>up,ZodCodec:()=>Qi,ZodCreditCard:()=>Am,ZodCustom:()=>eo,ZodCustomStringFormat:()=>Ar,ZodDate:()=>Ki,ZodDefault:()=>np,ZodDiscriminatedUnion:()=>Bm,ZodE164:()=>Ks,ZodEmail:()=>Es,ZodEmoji:()=>Ds,ZodEnum:()=>Nn,ZodExactOptional:()=>Ys,ZodFile:()=>Qm,ZodFunction:()=>$p,ZodGUID:()=>js,ZodIBAN:()=>Rm,ZodIPv4:()=>Ms,ZodIPv6:()=>Vs,ZodISODate:()=>sr,ZodISODateTime:()=>ar,ZodISODuration:()=>ur,ZodISOTime:()=>cr,ZodInstanceOf:()=>kp,ZodIntersection:()=>Km,ZodJWT:()=>Hs,ZodKSUID:()=>Ls,ZodLazy:()=>gp,ZodLiteral:()=>Ym,ZodMAC:()=>Dm,ZodMap:()=>Wm,ZodNaN:()=>dp,ZodNanoID:()=>As,ZodNever:()=>Vm,ZodNonOptional:()=>Qs,ZodNull:()=>Zm,ZodNullable:()=>rp,ZodNumber:()=>jn,ZodNumberFormat:()=>Rr,ZodObject:()=>Hi,ZodOptional:()=>Xi,ZodPipe:()=>Yi,ZodPrefault:()=>op,ZodPreprocess:()=>fp,ZodPromise:()=>yp,ZodReadonly:()=>mp,ZodRecord:()=>Tn,ZodSet:()=>Xm,ZodString:()=>En,ZodStringFormat:()=>se,ZodSuccess:()=>cp,ZodSymbol:()=>Um,ZodTemplateLiteral:()=>hp,ZodTransform:()=>ep,ZodTuple:()=>Hm,ZodType:()=>Z,ZodULID:()=>Cs,ZodURL:()=>Ji,ZodUUID:()=>jt,ZodUndefined:()=>Cm,ZodUnion:()=>Gi,ZodUnknown:()=>Mm,ZodVoid:()=>Fm,ZodXID:()=>Zs,ZodXor:()=>Jm,_ZodString:()=>Ns,_default:()=>ip,_function:()=>j_,any:()=>p_,array:()=>J,base64:()=>H$,base64url:()=>G$,bigint:()=>u_,boolean:()=>$e,catch:()=>lp,check:()=>D_,cidrv4:()=>B$,cidrv6:()=>K$,codec:()=>O_,creditCard:()=>X$,cuid:()=>C$,cuid2:()=>Z$,currencyCode:()=>n_,custom:()=>ec,date:()=>g_,describe:()=>A_,discriminatedUnion:()=>Wi,e164:()=>W$,email:()=>P$,emoji:()=>R$,enum:()=>Ne,exactOptional:()=>tp,file:()=>S_,float32:()=>o_,float64:()=>a_,function:()=>j_,guid:()=>O$,hash:()=>i_,hex:()=>r_,hostname:()=>t_,httpUrl:()=>A$,iban:()=>Y$,instanceof:()=>U_,int:()=>Os,int32:()=>s_,int64:()=>l_,intersection:()=>Rn,invertCodec:()=>T_,ipv4:()=>F$,ipv6:()=>J$,json:()=>Z_,jwt:()=>Q$,keyof:()=>v_,ksuid:()=>V$,lazy:()=>vp,literal:()=>E,looseObject:()=>Te,looseRecord:()=>b_,mac:()=>q$,map:()=>k_,meta:()=>R_,nan:()=>P_,nanoid:()=>U$,nativeEnum:()=>x_,never:()=>Ws,nonoptional:()=>sp,null:()=>Bi,nullable:()=>qi,nullish:()=>z_,number:()=>ee,object:()=>N,optional:()=>ae,partialRecord:()=>__,pipe:()=>Ts,prefault:()=>ap,preprocess:()=>to,promise:()=>E_,readonly:()=>pp,record:()=>ce,refine:()=>_p,set:()=>w_,strictObject:()=>y_,string:()=>$,stringFormat:()=>e_,stringbool:()=>C_,success:()=>I_,superRefine:()=>bp,symbol:()=>f_,templateLiteral:()=>N_,transform:()=>Xs,tuple:()=>Gm,uint32:()=>c_,uint64:()=>d_,ulid:()=>L$,undefined:()=>m_,union:()=>oe,unknown:()=>le,url:()=>D$,uuid:()=>T$,uuidv4:()=>N$,uuidv6:()=>E$,uuidv7:()=>j$,void:()=>h_,xid:()=>M$,xor:()=>$_});var Is={};Zt(Is,{endsWith:()=>$n,gt:()=>Nt,gte:()=>dt,includes:()=>vn,length:()=>Er,lowercase:()=>hn,lt:()=>Tt,lte:()=>lt,maxLength:()=>Nr,maxSize:()=>tr,mime:()=>bn,minLength:()=>Ft,minSize:()=>Et,multipleOf:()=>er,negative:()=>hs,nonnegative:()=>vs,nonpositive:()=>gs,normalize:()=>kn,overwrite:()=>xt,positive:()=>ps,properties:()=>_n,property:()=>ys,regex:()=>pn,size:()=>Tr,slugify:()=>zn,startsWith:()=>yn,toLowerCase:()=>xn,toUpperCase:()=>Sn,trim:()=>wn,uppercase:()=>gn});var z$=new WeakSet([Object.prototype,Error.prototype]);function Ps(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var I$=(e,t)=>{bu.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);z$.has(n)||(z$.add(n),Ps(n,"format",i=>r=>hi(i,r)),Ps(n,"flatten",i=>r=>pi(i,r)),Ps(n,"addIssue",i=>r=>{i.issues.push(r),i.message=JSON.stringify(i.issues,Yr,2)}),Ps(n,"addIssues",i=>r=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,Yr,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},O0=v("ZodError",I$),nt=v("ZodError",I$,void 0,{Parent:Error});var km=rn(nt),wm=nn(nt),xm=on(nt),Sm=an(nt),zm=ea(nt),Im=ta(nt),Pm=ra(nt),Om=na(nt),Tm=ia(nt),Nm=oa(nt),Em=aa(nt),jm=sa(nt);function N0(){ze.localeError||ye(Za())}function Dr(){ze.memoizer||ye({memoizer:ji()})}var Z=v("ZodType",(e,t)=>(N0(),U.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(k.mergeDefs(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return re(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(_p(e,t))},superRefine(e,t){return this.check(bp(e,t))},overwrite(e){return this.check(xt(e))},optional(){return ae(this)},exactOptional(){return tp(this)},nullable(){return qi(this)},nullish(){return ae(qi(this))},nonoptional(e){return sp(this,e)},array(){return J(this)},or(e){return oe([this,e])},and(e){return Rn(this,e)},transform(e){return Ts(this,Xs(e))},default(e){return ip(this,e)},prefault(e){return ap(this,e)},catch(e){return lp(this,e)},pipe(e){return Ts(this,e)},readonly(){return pp(this)},describe(e){let t=this.clone();return Oe.add(t,{description:e}),t},meta(...e){if(e.length===0)return Oe.get(this);let t=this.clone();return Oe.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 k.hide(this,"~standard",{...ya(this),jsonSchema:{input:In(this,"input"),output:In(this,"output")}})},set"~standard"(e){k.own(this,"~standard",e)},parse:function e(t,n){return km(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await wm(this,t,n,{callee:e})},safeParse(e,t){return xm(this,e,t)},async safeParseAsync(e,t){return Sm(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){k.own(this,"spa",e)},validate(e,t){return sn(this,e,t)},validateAsync(e,t){return cn(this,e,t)},encode:function e(t,n){return zm(this,t,n,{callee:e})},decode:function e(t,n){return Im(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Pm(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Om(this,t,n,{callee:e})},safeEncode(e,t){return Tm(this,e,t)},safeDecode(e,t){return Nm(this,e,t)},async safeEncodeAsync(e,t){return Em(this,e,t)},async safeDecodeAsync(e,t){return jm(this,e,t)},toJSONSchema(e){return Af(this,{})(e)},get description(){return Oe.get(this)?.description},get _def(){return this._zod.def}}),Ns=v("_ZodString",(e,t)=>{Sr.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Cf(e,n,i,r)},k.derived({format:e=>xe(e).format??null,minLength:e=>xe(e).minimum??null,maxLength:e=>xe(e).maximum??null},{regex(...e){return this.check(pn(...e))},includes(...e){return this.check(vn(...e))},startsWith(...e){return this.check(yn(...e))},endsWith(...e){return this.check($n(...e))},min(...e){return this.check(Ft(...e))},max(...e){return this.check(Nr(...e))},length(...e){return this.check(Er(...e))},nonempty(...e){return this.check(Ft(1,...e))},lowercase(e){return this.check(hn(e))},uppercase(e){return this.check(gn(e))},trim(){return this.check(wn())},normalize(...e){return this.check(kn(...e))},toLowerCase(){return this.check(xn())},toUpperCase(){return this.check(Sn())},slugify(){return this.check(zn())}})),En=v("ZodString",(e,t)=>{Sr.init(e,t),Ns.init(e,t)},{email(e){return this.check(Ka(Es,e))},url(e){return this.check(Ri(Ji,e))},jwt(e){return this.check(ms(Hs,e))},emoji(e){return this.check(Qa(Ds,e))},guid(e){return this.check(Ha(js,e))},uuid(e){return this.check(Ga(jt,e))},uuidv4(e){return this.check(Wa(jt,e))},uuidv6(e){return this.check(Xa(jt,e))},uuidv7(e){return this.check(Ya(jt,e))},nanoid(e){return this.check(es(As,e))},cuid(e){return this.check(ts(Rs,e))},cuid2(e){return this.check(rs(Us,e))},ulid(e){return this.check(ns(Cs,e))},base64(e){return this.check(ls(Js,e))},base64url(e){return this.check(ds(Bs,e))},xid(e){return this.check(is(Zs,e))},ksuid(e){return this.check(os(Ls,e))},ipv4(e){return this.check(as(Ms,e))},ipv6(e){return this.check(ss(Vs,e))},cidrv4(e){return this.check(cs(Fs,e))},cidrv6(e){return this.check(us(qs,e))},e164(e){return this.check(fs(Ks,e))},datetime(e){return this.check(Ui(ar,e))},date(e){return this.check(Ci(sr,e))},time(e){return this.check(Zi(cr,e))},duration(e){return this.check(Li(ur,e))}});function $(e){return Wd(En,e)}var se=v("ZodStringFormat",(e,t)=>{ne.init(e,t),Ns.init(e,t)}),ar=v("ZodISODateTime",(e,t)=>{Vl.init(e,t),se.init(e,t)}),sr=v("ZodISODate",(e,t)=>{Fl.init(e,t),se.init(e,t)}),cr=v("ZodISOTime",(e,t)=>{ql.init(e,t),se.init(e,t)}),ur=v("ZodISODuration",(e,t)=>{Jl.init(e,t),se.init(e,t)}),Es=v("ZodEmail",(e,t)=>{Nl.init(e,t),se.init(e,t)});function P$(e){return Ka(Es,e)}var js=v("ZodGUID",(e,t)=>{Ol.init(e,t),se.init(e,t)});function O$(e){return Ha(js,e)}var jt=v("ZodUUID",(e,t)=>{Tl.init(e,t),se.init(e,t)});function T$(e){return Ga(jt,e)}function N$(e){return Wa(jt,e)}function E$(e){return Xa(jt,e)}function j$(e){return Ya(jt,e)}var Ji=v("ZodURL",(e,t)=>{Dl.init(e,t),se.init(e,t)});function D$(e){return Ri(Ji,e)}function A$(e){return Ri(Ji,{protocol:yi,hostname:Ju,...k.normalizeParams(e)})}var Ds=v("ZodEmoji",(e,t)=>{Al.init(e,t),se.init(e,t)});function R$(e){return Qa(Ds,e)}var As=v("ZodNanoID",(e,t)=>{Rl.init(e,t),se.init(e,t)});function U$(e){return es(As,e)}var Rs=v("ZodCUID",(e,t)=>{Ul.init(e,t),se.init(e,t)});function C$(e){return ts(Rs,e)}var Us=v("ZodCUID2",(e,t)=>{Cl.init(e,t),se.init(e,t)});function Z$(e){return rs(Us,e)}var Cs=v("ZodULID",(e,t)=>{Zl.init(e,t),se.init(e,t)});function L$(e){return ns(Cs,e)}var Zs=v("ZodXID",(e,t)=>{Ll.init(e,t),se.init(e,t)});function M$(e){return is(Zs,e)}var Ls=v("ZodKSUID",(e,t)=>{Ml.init(e,t),se.init(e,t)});function V$(e){return os(Ls,e)}var Ms=v("ZodIPv4",(e,t)=>{Bl.init(e,t),se.init(e,t)});function F$(e){return as(Ms,e)}var Dm=v("ZodMAC",(e,t)=>{Hl.init(e,t),se.init(e,t)});function q$(e){return Yd(Dm,e)}var Vs=v("ZodIPv6",(e,t)=>{Kl.init(e,t),se.init(e,t)});function J$(e){return ss(Vs,e)}var Fs=v("ZodCIDRv4",(e,t)=>{Gl.init(e,t),se.init(e,t)});function B$(e){return cs(Fs,e)}var qs=v("ZodCIDRv6",(e,t)=>{Wl.init(e,t),se.init(e,t)});function K$(e){return us(qs,e)}var Js=v("ZodBase64",(e,t)=>{Xl.init(e,t),se.init(e,t)});function H$(e){return ls(Js,e)}var Bs=v("ZodBase64URL",(e,t)=>{Yl.init(e,t),se.init(e,t)});function G$(e){return ds(Bs,e)}var Ks=v("ZodE164",(e,t)=>{Ql.init(e,t),se.init(e,t)});function W$(e){return fs(Ks,e)}var Am=v("ZodCreditCard",(e,t)=>{ed.init(e,t),se.init(e,t)});function X$(e){return Qd(Am,e)}var Rm=v("ZodIBAN",(e,t)=>{td.init(e,t),se.init(e,t)});function Y$(e){return ef(Rm,e)}var Hs=v("ZodJWT",(e,t)=>{rd.init(e,t),se.init(e,t)});function Q$(e){return ms(Hs,e)}var Ar=v("ZodCustomStringFormat",(e,t)=>{nd.init(e,t),se.init(e,t)});function e_(e,t,n={}){return jr(Ar,e,t,n)}function t_(e){return jr(Ar,"hostname",qu,e)}function r_(e){return jr(Ar,"hex",ol,e)}function n_(e){return jr(Ar,"currency_code",Ku,e)}function i_(e,t){let n=t?.enc??"hex",i=`${e}_${n}`,r=ht[i];if(!r)throw new Error(`Unrecognized hash format: ${i}`);return jr(Ar,i,r,t)}var jn=v("ZodNumber",(e,t)=>{Pa.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Zf(e,n,i,r),e.isFinite=!0},k.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=xe(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=xe(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:n}=xe(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>xe(e).format??null},{gt(e,t){return this.check(Nt(e,t))},gte(e,t){return this.check(dt(e,t))},min(e,t){return this.check(dt(e,t))},lt(e,t){return this.check(Tt(e,t))},lte(e,t){return this.check(lt(e,t))},max(e,t){return this.check(lt(e,t))},int(e){return this.check(Os(e))},safe(e){return this.check(Os(e))},positive(e){return this.check(Nt(0,e))},nonnegative(e){return this.check(dt(0,e))},negative(e){return this.check(Tt(0,e))},nonpositive(e){return this.check(lt(0,e))},multipleOf(e,t){return this.check(er(e,t))},step(e,t){return this.check(er(e,t))},finite(){return this}}));function ee(e){return rf(jn,e)}var Rr=v("ZodNumberFormat",(e,t)=>{id.init(e,t),jn.init(e,t)});function Os(e){return of(Rr,e)}function o_(e){return af(Rr,e)}function a_(e){return sf(Rr,e)}function s_(e){return cf(Rr,e)}function c_(e){return uf(Rr,e)}var Dn=v("ZodBoolean",(e,t)=>{Ii.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Lf(e,n,i,r)});function $e(e){return lf(Dn,e)}var An=v("ZodBigInt",(e,t)=>{Oa.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Mf(e,n,i,r)},k.derived({minValue:e=>xe(e).minimum??null,maxValue:e=>xe(e).maximum??null,format:e=>xe(e).format??null},{gte(e,t){return this.check(dt(e,t))},min(e,t){return this.check(dt(e,t))},gt(e,t){return this.check(Nt(e,t))},lt(e,t){return this.check(Tt(e,t))},lte(e,t){return this.check(lt(e,t))},max(e,t){return this.check(lt(e,t))},positive(e){return this.check(Nt(BigInt(0),e))},negative(e){return this.check(Tt(BigInt(0),e))},nonpositive(e){return this.check(lt(BigInt(0),e))},nonnegative(e){return this.check(dt(BigInt(0),e))},multipleOf(e,t){return this.check(er(e,t))}}));function u_(e){return ff(An,e)}var Gs=v("ZodBigIntFormat",(e,t)=>{od.init(e,t),An.init(e,t)});function l_(e){return pf(Gs,e)}function d_(e){return hf(Gs,e)}var Um=v("ZodSymbol",(e,t)=>{ad.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Vf(e,n,i,r)});function f_(e){return gf(Um,e)}var Cm=v("ZodUndefined",(e,t)=>{sd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>qf(e,n,i,r)});function m_(e){return vf(Cm,e)}var Zm=v("ZodNull",(e,t)=>{cd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ff(e,n,i,r)});function Bi(e){return yf(Zm,e)}var Lm=v("ZodAny",(e,t)=>{ud.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Kf(e,n,i,r)});function p_(){return $f(Lm)}var Mm=v("ZodUnknown",(e,t)=>{ld.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Hf(e,n,i,r)});function le(){return _f(Mm)}var Vm=v("ZodNever",(e,t)=>{dd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Bf(e,n,i,r)});function Ws(e){return bf(Vm,e)}var Fm=v("ZodVoid",(e,t)=>{fd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Jf(e,n,i,r)});function h_(e){return kf(Fm,e)}var Ki=v("ZodDate",(e,t)=>{md.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Gf(e,n,i,r),e.min=(n,i)=>e.check(dt(n,i)),e.max=(n,i)=>e.check(lt(n,i))},k.derived({minDate:e=>{let{minimum:t}=xe(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=xe(e);return t?new Date(t):null}},{}));function g_(e){return wf(Ki,e)}var qm=v("ZodArray",(e,t)=>{Dr(),pd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>sm(e,n,i,r),e.element=t.element},{min(e,t){return this.check(Ft(e,t))},nonempty(e){return this.check(Ft(1,e))},max(e,t){return this.check(Nr(e,t))},length(e,t){return this.check(Er(e,t))},unwrap(){return this.element}});function J(e,t){return zf(qm,e,t)}function v_(e){let t=e._zod.def.shape;return Ne(Object.keys(t))}var Hi=v("ZodObject",(e,t)=>{Dr(),hd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>cm(e,n,i,r),k.installLazyProp(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return Ne(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(k.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(k.mergeDefs(this._zod.def,{catchall:le()}))},loose(){return this.clone(k.mergeDefs(this._zod.def,{catchall:le()}))},strict(){return this.clone(k.mergeDefs(this._zod.def,{catchall:Ws()}))},strip(){return this.clone(k.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return k.extend(this,e)},safeExtend(e){return k.safeExtend(this,e)},merge(e){return k.merge(this,e)},pick(e){return k.pick(this,e)},omit(e){return k.omit(this,e)},partial(...e){return k.partial(Xi,this,e[0])},exactPartial(...e){return k.partial(Ys,this,e[0],"exactPartial")},required(...e){return k.required(Qs,this,e[0])}});function N(e,t){let n={type:"object",shape:e??{},...k.normalizeParams(t)};return new Hi(n)}function y_(e,t){return new Hi({type:"object",shape:e,catchall:Ws(),...k.normalizeParams(t)})}function Te(e,t){return new Hi({type:"object",shape:e,catchall:le(),...k.normalizeParams(t)})}var Gi=v("ZodUnion",(e,t)=>{Pi.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_s(e,n,i,r),e.options=t.options});function oe(e,t){return new Gi({type:"union",options:e,...k.normalizeParams(t)})}var Jm=v("ZodXor",(e,t)=>{Gi.init(e,t),gd.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_s(e,n,i,r),e.options=t.options});function $_(e,t){return new Jm({type:"union",options:e,inclusive:!1,...k.normalizeParams(t)})}var Bm=v("ZodDiscriminatedUnion",(e,t)=>{Gi.init(e,t),yd.init(e,t)});function Wi(e,t,n){return new Bm({type:"union",options:t,discriminator:e,...k.normalizeParams(n)})}var Km=v("ZodIntersection",(e,t)=>{$d.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>um(e,n,i,r)});function Rn(e,t){return new Km({type:"intersection",left:e,right:t})}var Hm=v("ZodTuple",(e,t)=>{Dr(),Ta.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>lm(e,n,i,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new Xi({type:"optional",innerType:t}))})}});function Gm(e,t,n){let i=t instanceof U,r=i?n:t,o=i?t:null;return new Hm({type:"tuple",items:e,rest:o,...k.normalizeParams(r)})}var Tn=v("ZodRecord",(e,t)=>{Dr(),_d.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>dm(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function ce(e,t,n){return!t||!t._zod?new Tn({type:"record",keyType:$(),valueType:e,...k.normalizeParams(t)}):new Tn({type:"record",keyType:e,valueType:t,...k.normalizeParams(n)})}function __(e,t,n){return new Tn({type:"record",keyType:e,valueType:t,...k.normalizeParams(n),partial:!0})}function b_(e,t,n){return new Tn({type:"record",keyType:e,valueType:t,mode:"loose",...k.normalizeParams(n)})}var Wm=v("ZodMap",(e,t)=>{Dr(),bd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>om(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(Et(...n)),e.nonempty=n=>e.check(Et(1,n)),e.max=(...n)=>e.check(tr(...n)),e.size=(...n)=>e.check(Tr(...n))});function k_(e,t,n){return new Wm({type:"map",keyType:e,valueType:t,...k.normalizeParams(n)})}var Xm=v("ZodSet",(e,t)=>{Dr(),kd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>am(e,n,i,r),e.min=(...n)=>e.check(Et(...n)),e.nonempty=n=>e.check(Et(1,n)),e.max=(...n)=>e.check(tr(...n)),e.size=(...n)=>e.check(Tr(...n))});function w_(e,t){return new Xm({type:"set",valueType:e,...k.normalizeParams(t)})}var Nn=v("ZodEnum",(e,t)=>{wd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(i,r,o)=>Wf(e,i,r,o),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let o={};for(let a of i)if(n.has(a))o[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Nn({...t,checks:[],...k.normalizeParams(r),entries:o})},e.exclude=(i,r)=>{let o={...t.entries};for(let a of i)if(n.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new Nn({...t,checks:[],...k.normalizeParams(r),entries:o})}});function Ne(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new Nn({type:"enum",entries:n,...k.normalizeParams(t)})}function x_(e,t){return new Nn({type:"enum",entries:e,...k.normalizeParams(t)})}var Ym=v("ZodLiteral",(e,t)=>{xd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Xf(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function E(e,t){return new Ym({type:"literal",values:Array.isArray(e)?e:[e],...k.normalizeParams(t)})}var Qm=v("ZodFile",(e,t)=>{Sd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>em(e,n,i,r),e.min=(n,i)=>e.check(Et(n,i)),e.max=(n,i)=>e.check(tr(n,i)),e.mime=(n,i)=>e.check(bn(Array.isArray(n)?n:[n],i))});function S_(e){return If(Qm,e)}var ep=v("ZodTransform",(e,t)=>{Dr(),zd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>im(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Qt(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(k.issue(o,n.value,t));else{let a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=n.value),a.inst??(a.inst=e),n.issues.push(k.issue(a))}};let r=t.transform(n.value,n);return r instanceof Promise?r.then(o=>(n.value=o,n)):(n.value=r,n)}});function Xs(e){return new ep({type:"transform",transform:e})}var Xi=v("ZodOptional",(e,t)=>{Na.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>bs(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function ae(e){return new Xi({type:"optional",innerType:e})}var Ys=v("ZodExactOptional",(e,t)=>{Id.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>bs(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function tp(e){return new Ys({type:"optional",innerType:e})}var rp=v("ZodNullable",(e,t)=>{Pd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>fm(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function qi(e){return new rp({type:"nullable",innerType:e})}function z_(e){return ae(qi(e))}var np=v("ZodDefault",(e,t)=>{Od.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>hm(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ip(e,t){return new np({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():k.shallowClone(t)}})}var op=v("ZodPrefault",(e,t)=>{Td.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>gm(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function ap(e,t){return new op({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():k.shallowClone(t)}})}var Qs=v("ZodNonOptional",(e,t)=>{Nd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>mm(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function sp(e,t){return new Qs({type:"nonoptional",innerType:e,...k.normalizeParams(t)})}var cp=v("ZodSuccess",(e,t)=>{Ed.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>tm(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function I_(e){return new cp({type:"success",innerType:e})}var up=v("ZodCatch",(e,t)=>{jd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>vm(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function lp(e,t){return new up({type:"catch",innerType:e,catchValue:typeof t=="function"?t:k.constantCatch(t)})}var dp=v("ZodNaN",(e,t)=>{Dd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Yf(e,n,i,r)});function P_(e){return Sf(dp,e)}var Yi=v("ZodPipe",(e,t)=>{Ea.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ym(e,n,i,r),e.in=t.in,e.out=t.out});function Ts(e,t){return new Yi({type:"pipe",in:e,out:t})}var Qi=v("ZodCodec",(e,t)=>{Yi.init(e,t),Oi.init(e,t)});function O_(e,t,n){return new Qi({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function T_(e){let t=e._zod.def;return new Qi({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var fp=v("ZodPreprocess",(e,t)=>{Yi.init(e,t),Ad.init(e,t)}),mp=v("ZodReadonly",(e,t)=>{Rd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>$m(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function pp(e){return new mp({type:"readonly",innerType:e})}var hp=v("ZodTemplateLiteral",(e,t)=>{Ud.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Qf(e,n,i,r)});function N_(e,t){return new hp({type:"template_literal",parts:e,...k.normalizeParams(t)})}var gp=v("ZodLazy",(e,t)=>{Ti.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>bm(e,n,i,r),e.unwrap=()=>e._zod.def.getter()});function vp(e){return new gp({type:"lazy",getter:e})}var yp=v("ZodPromise",(e,t)=>{Zd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_m(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function E_(e){return new yp({type:"promise",innerType:e})}var $p=v("ZodFunction",(e,t)=>{Cd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>nm(e,n,i,r)});function j_(e){return new $p({type:"function",input:Array.isArray(e?.input)?Gm(e?.input):e?.input??J(le()),output:e?.output??le()})}var eo=v("ZodCustom",(e,t)=>{Ld.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>rm(e,n,i,r)});function D_(e){let t=new ue({check:"custom"});return t._zod.check=e,t}function ec(e,t){return Pf(eo,e??(()=>!0),t)}function _p(e,t={}){return Of(eo,e,t)}function bp(e,t){return Tf(e,t)}var A_=Nf,R_=Ef,kp=v("ZodInstanceOf",(e,t)=>{eo.init(e,t)},{properties(e,t){return this.check(_n(e,t))}});function U_(e,t={}){let n=new kp({type:"custom",check:"custom",fn:i=>i instanceof e,abort:!0,...k.normalizeParams(t)});return n._zod.bag.Class=e,n._zod.check=i=>{i.value instanceof e||i.issues.push({code:"invalid_type",expected:e.name,input:i.value,inst:n,path:[...n._zod.def.path??[]]})},n}var C_=(...e)=>jf({Codec:Qi,Boolean:Dn,String:En},...e);function Z_(e){let t=vp(()=>oe([$(e),ee(),$e(),Bi(),J(t),ce($(),t)]));return t}function to(e,t){return new fp({type:"pipe",in:Xs(e),out:t})}var E0={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function j0(e){ye({customError:e})}function D0(){return ye().customError}var wp;wp||(wp={});var Ur={};Zt(Ur,{ZodISODate:()=>sr,ZodISODateTime:()=>ar,ZodISODuration:()=>ur,ZodISOTime:()=>cr,date:()=>R0,datetime:()=>A0,duration:()=>C0,time:()=>U0});function A0(e){return Ui(ar,e)}function R0(e){return Ci(sr,e)}function U0(e){return Zi(cr,e)}function C0(e){return Li(ur,e)}var P={...Un,...Is,iso:Ur},Z0=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function L0(e,t){let n=e.$schema;return n==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":n==="http://json-schema.org/draft-07/schema#"?"draft-7":n==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function L_(e,t){return e.map((n,i)=>i<t?n:n.optional())}function M0(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function V0(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let n=e.slice(1).split("/").filter(Boolean);if(n.length===0)return t.rootSchema;let i=t.version==="draft-2020-12"?"$defs":"definitions";if(n[0]===i){let r=n[1]===void 0?void 0:M0(n[1]);if(!r||!t.defs[r])throw new Error(`Reference not found: ${e}`);return t.defs[r]}throw new Error(`Reference not found: ${e}`)}function F0(e,t){return P.transform(i=>i).check(i=>{let r=i.value;if(typeof r!="object"||r===null||Array.isArray(r))return;let o=Object.getOwnPropertyNames(r);if(t.minProperties!==void 0&&o.length<t.minProperties&&i.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:r,inst:e,continue:!0}),t.maxProperties!==void 0&&o.length>t.maxProperties&&i.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:r,inst:e,continue:!0}),t.keySchema)for(let a of o){let s=t.keySchema.safeParse(a);s.success||i.issues.push({code:"invalid_key",origin:"record",issues:s.error.issues,input:a,path:[a],continue:!0})}}).pipe(e)}function xp(e,t){if(e===null)return"z";let n=typeof e;if(n!=="object"){if(n==="number"&&Number.isNaN(e))return null;let i=String(e);return`${n[0]}${i.length}:${i}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let o=[];for(let a of e){let s=xp(a,t);if(s===null)return null;o.push(s)}return`a${o.length}:[${o.join(",")}]`}let i=Object.keys(e).sort(),r=[];for(let o of i){let a=xp(e[o],t);if(a===null)return null;r.push(`${o.length}:${o}=${a}`)}return`o${r.length}:{${r.join(",")}}`}finally{t.delete(e)}}var q0=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),J0=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function ro(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(ro):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,n])=>q0.has(t)?ro(n):!J0.has(t)||typeof n!="object"||n===null?!1:Object.values(n).some(ro))}function M_(e){return e===1?"element":"elements"}function B0(e,t){return P.transform(i=>i).check(i=>{let r=i.value;if(Array.isArray(r)){if(t.uniqueItems===!0){let o=new Map;for(let a=0;a<r.length;a++){let s=xp(r[a],new Set);if(s===null)continue;let c=o.get(s);if(c===void 0){o.set(s,a);continue}i.issues.push({code:"custom",message:`Array items must be unique: element at index ${a} duplicates the one at index ${c}`,input:r,path:[a],continue:!0})}}if(t.containsSchema){let o=t.minContains??1,a=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY,s=0;for(let c of r)if(t.containsSchema.safeParse(c).success&&++s>=a)break;s<o&&i.issues.push({code:"custom",message:`Array must contain at least ${o} matching ${M_(o)}; found ${s}`,input:r,continue:!0}),t.maxContains!==void 0&&s>t.maxContains&&i.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${M_(t.maxContains)}`,input:r,continue:!0})}}}).pipe(e)}function V_(e,t){if(e!==!1)return e===void 0||e===!0?P.any():We(e,t)}var K0=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function F_(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return P.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let r=e.$ref;if(t.refs.has(r))return t.refs.get(r);if(t.processing.has(r))return P.lazy(()=>{if(!t.refs.has(r))throw new Error(`Circular reference not resolved: ${r}`);return t.refs.get(r)});t.processing.add(r);let o=V0(r,t),a=We(o,t);return t.refs.set(r,a),t.processing.delete(r),a}if(e.enum!==void 0){let r=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&r.length===1&&r[0]===null)return P.null();if(r.length===0)return P.never();if(r.length===1)return P.literal(r[0]);if(r.every(a=>typeof a=="string"))return P.enum(r);let o=r.map(a=>P.literal(a));return o.length<2?o[0]:P.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return P.literal(e.const);let n=e.type;if(Array.isArray(n)){let r=n.map(o=>{let a={...e,type:o};return F_(a,t)});return r.length===0?P.never():r.length===1?r[0]:P.union(r)}if(!n)return P.any();let i;switch(n){case"string":{let r=P.string();if(e.format){let o=e.format;o==="email"?r=r.check(P.email()):o==="uri"||o==="uri-reference"?r=r.check(P.url()):o==="uuid"||o==="guid"?r=r.check(P.uuid()):o==="date-time"?r=r.check(P.iso.datetime({offset:!0})):o==="date"?r=r.check(P.iso.date()):o==="time"?r=r.check(P.regex(K0)):o==="duration"?r=r.check(P.iso.duration()):o==="hostname"?r=r.check(P.hostname()):o==="ipv4"?r=r.check(P.ipv4()):o==="ipv6"?r=r.check(P.ipv6()):o==="mac"?r=r.check(P.mac()):o==="cidr"?r=r.check(P.cidrv4()):o==="cidr-v6"?r=r.check(P.cidrv6()):o==="base64"?r=r.check(P.base64()):o==="base64url"?r=r.check(P.base64url()):o==="e164"?r=r.check(P.e164()):o==="credit_card"?r=r.check(P.creditCard()):o==="iban"?r=r.check(P.iban()):o==="jwt"?r=r.check(P.jwt()):o==="emoji"?r=r.check(P.emoji()):o==="nanoid"?r=r.check(P.nanoid()):o==="cuid"?r=r.check(P.cuid()):o==="cuid2"?r=r.check(P.cuid2()):o==="ulid"?r=r.check(P.ulid()):o==="xid"?r=r.check(P.xid()):o==="ksuid"&&(r=r.check(P.ksuid()))}typeof e.minLength=="number"&&(r=r.min(e.minLength)),typeof e.maxLength=="number"&&(r=r.max(e.maxLength)),e.pattern&&(r=r.regex(new RegExp(e.pattern))),i=r;break}case"number":case"integer":{let r=n==="integer"?P.number().int():P.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(r=r.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(r=r.max(e.maximum)),typeof e.exclusiveMinimum=="number"?r=r.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(r=r.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?r=r.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(r=r.lt(e.maximum)),typeof e.multipleOf=="number"&&(r=r.multipleOf(e.multipleOf)),i=r;break}case"boolean":{i=P.boolean();break}case"null":{i=P.null();break}case"object":{let r={},o=e.properties||{},a=new Set(e.required||[]),s=typeof e.additionalProperties=="object"?We(e.additionalProperties,t):void 0;for(let[d,m]of Object.entries(o)){let f=We(m,t);Pe(r,d,a.has(d)?f:f.optional())}if(e.patternProperties){let d=e.patternProperties,m=Object.keys(d),f=[];for(let h of m){let g=We(d[h],t),b=P.string().regex(new RegExp(h));f.push(P.looseRecord(b,g))}let p=[];if(Object.keys(r).length>0&&p.push(P.object(r).passthrough()),p.push(...f),p.length===0)i=P.object({}).passthrough();else if(p.length===1)i=p[0];else{let h=P.intersection(p[0],p[1]);for(let g=2;g<p.length;g++)h=P.intersection(h,p[g]);i=h}if(e.additionalProperties===!1){let h=Object.keys(r),g=m.map(_=>new RegExp(_)),b=i;i=i.check(_=>{if(!mt(_.value))return;let S=[];for(let O of Object.keys(_.value))h.includes(O)||g.some(I=>I.test(O))||S.push(O);S.length&&_.issues.push({code:"unrecognized_keys",keys:S,input:_.value,inst:b})})}}else{let d=P.object(r);e.additionalProperties===!1?i=d.strict():s?i=d.catchall(s):i=d.passthrough()}let c=e.propertyNames!==void 0&&e.propertyNames!==!0,u=typeof e.minProperties=="number"?e.minProperties:void 0,l=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(c||u!==void 0||l!==void 0){let d;if(c){let m=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;d=We(m,t)}i=F0(i,{keySchema:d,minProperties:u,maxProperties:l})}break}case"array":{let r=e.prefixItems,o=e.items;if(r&&Array.isArray(r)){let a=typeof e.minItems=="number"?e.minItems:0,s=r.map(d=>We(d,t)),c=L_(s,a),u=Array.isArray(o)?void 0:V_(o,t),l=P.tuple(c);i=u?l.rest(u):l,typeof e.minItems=="number"&&(i=i.check(P.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(P.maxLength(e.maxItems)))}else if(Array.isArray(o)){let a=typeof e.minItems=="number"?e.minItems:0,s=o.map(d=>We(d,t)),c=L_(s,a),u=V_(e.additionalItems,t),l=P.tuple(c);i=u?l.rest(u):l,typeof e.minItems=="number"&&(i=i.check(P.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(P.maxLength(e.maxItems)))}else if(o!==void 0){let a=We(o,t),s=P.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),i=s}else i=P.array(P.any());(e.uniqueItems===!0||e.contains!==void 0)&&(i=B0(i,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?We(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${n}`)}return i}function We(e,t){if(typeof e=="boolean")return e?P.any():P.never();let n=F_(e,t),i=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(u=>We(u,t)),c=P.union(s);n=i?P.intersection(n,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(u=>We(u,t)),c=P.xor(s);n=i?P.intersection(n,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=i?n:P.any();else{let s=i?n:We(e.allOf[0],t),c=i?0:1;for(let u=c;u<e.allOf.length;u++)s=P.intersection(s,We(e.allOf[u],t));n=s}e.nullable===!0&&t.version==="openapi-3.0"&&(n=P.nullable(n)),e.readOnly===!0&&(n=P.readonly(n)),e.default!==void 0&&(n=n.default(e.default));let r={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of o)s in e&&(r[s]=e[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in e&&(r[s]=e[s]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!ro(e.propertyNames)&&(r.propertyNames=e.propertyNames);for(let s of["minProperties","maxProperties"])e[s]!==void 0&&(r[s]=e[s])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!ro(e.contains)&&(r.contains=e.contains);for(let s of["uniqueItems","minContains","maxContains"])e[s]!==void 0&&(r[s]=e[s])}for(let s of Object.keys(e))Z0.has(s)||Pe(r,s,e[s]);return Object.keys(r).length>0&&t.registry.add(n,r),e.description&&(n=n.describe(e.description)),n}function q_(e,t){if(typeof e=="boolean")return e?P.any():P.never();let n;try{n=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let i=L0(n,t?.defaultTarget),r=n.$defs||n.definitions||{},o={version:i,defs:r,refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??Oe};return We(n,o)}function J_(e){return Fi(e,{object:t=>t.partial(),union:t=>{let n=t._zod.def;return n.discriminator===void 0?t:oe(n.options)}})}function H0(e,t){if(!t?.length)return e;let n=e._zod.def;return re(e,kt(n,{checks:[...n.checks??[],...t]}),{parent:!0})}function B_(e){return H0(e.out,e.checks)}function G0(e){return e.in._zod.traits.has("$ZodTransform")?B_(e):e.in}function K_(e){return Fi(e,{pipe:t=>G0(t._zod.def),default:(t,n)=>n?ae(t._zod.def.innerType):t,catch:(t,n)=>n?t._zod.def.innerType:t})}function H_(e){return Fi(e,{pipe:t=>B_(t._zod.def),prefault:(t,n)=>n?t._zod.def.innerType:t})}var Sp={};Zt(Sp,{bigint:()=>Q0,boolean:()=>Y0,date:()=>eP,number:()=>X0,string:()=>W0});function W0(e){return Xd(En,e)}function X0(e){return nf(jn,e)}function Y0(e){return df(Dn,e)}function Q0(e){return mf(An,e)}function eP(e){return xf(Ki,e)}var Ip="2025-11-25";var G_=[Ip,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],lr="io.modelcontextprotocol/related-task",rc="2.0",Se=ec(e=>e!==null&&(typeof e=="object"||typeof e=="function")),W_=oe([$(),ee().int()]),X_=$(),YU=Te({ttl:ee().optional(),pollInterval:ee().optional()}),tP=N({ttl:ee().optional()}),rP=N({taskId:$()}),Pp=Te({progressToken:W_.optional(),[lr]:rP.optional()}),ft=N({_meta:Pp.optional()}),no=ft.extend({task:tP.optional()}),Y_=e=>no.safeParse(e).success,Ee=N({method:$(),params:ft.loose().optional()}),gt=N({_meta:Pp.optional()}),vt=N({method:$(),params:gt.loose().optional()}),je=Te({_meta:Pp.optional()}),nc=oe([$(),ee().int()]),Q_=N({jsonrpc:E(rc),id:nc,...Ee.shape}).strict(),Op=e=>Q_.safeParse(e).success,eb=N({jsonrpc:E(rc),...vt.shape}).strict(),tb=e=>eb.safeParse(e).success,Tp=N({jsonrpc:E(rc),id:nc,result:je}).strict(),io=e=>Tp.safeParse(e).success;var G;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(G||(G={}));var Np=N({jsonrpc:E(rc),id:nc.optional(),error:N({code:ee().int(),message:$(),data:le().optional()})}).strict();var rb=e=>Np.safeParse(e).success;var nb=oe([Q_,eb,Tp,Np]),QU=oe([Tp,Np]),ic=je.strict(),nP=gt.extend({requestId:nc.optional(),reason:$().optional()}),oc=vt.extend({method:E("notifications/cancelled"),params:nP}),iP=N({src:$(),mimeType:$().optional(),sizes:J($()).optional(),theme:Ne(["light","dark"]).optional()}),oo=N({icons:J(iP).optional()}),Cn=N({name:$(),title:$().optional()}),ib=Cn.extend({...Cn.shape,...oo.shape,version:$(),websiteUrl:$().optional(),description:$().optional()}),oP=Rn(N({applyDefaults:$e().optional()}),ce($(),le())),aP=to(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Rn(N({form:oP.optional(),url:Se.optional()}),ce($(),le()).optional())),sP=Te({list:Se.optional(),cancel:Se.optional(),requests:Te({sampling:Te({createMessage:Se.optional()}).optional(),elicitation:Te({create:Se.optional()}).optional()}).optional()}),cP=Te({list:Se.optional(),cancel:Se.optional(),requests:Te({tools:Te({call:Se.optional()}).optional()}).optional()}),uP=N({experimental:ce($(),Se).optional(),sampling:N({context:Se.optional(),tools:Se.optional()}).optional(),elicitation:aP.optional(),roots:N({listChanged:$e().optional()}).optional(),tasks:sP.optional(),extensions:ce($(),Se).optional()}),lP=ft.extend({protocolVersion:$(),capabilities:uP,clientInfo:ib}),Ep=Ee.extend({method:E("initialize"),params:lP});var dP=N({experimental:ce($(),Se).optional(),logging:Se.optional(),completions:Se.optional(),prompts:N({listChanged:$e().optional()}).optional(),resources:N({subscribe:$e().optional(),listChanged:$e().optional()}).optional(),tools:N({listChanged:$e().optional()}).optional(),tasks:cP.optional(),extensions:ce($(),Se).optional()}),fP=je.extend({protocolVersion:$(),capabilities:dP,serverInfo:ib,instructions:$().optional()}),jp=vt.extend({method:E("notifications/initialized"),params:gt.optional()});var ac=Ee.extend({method:E("ping"),params:ft.optional()}),mP=N({progress:ee(),total:ae(ee()),message:ae($())}),pP=N({...gt.shape,...mP.shape,progressToken:W_}),sc=vt.extend({method:E("notifications/progress"),params:pP}),hP=ft.extend({cursor:X_.optional()}),ao=Ee.extend({params:hP.optional()}),so=je.extend({nextCursor:X_.optional()}),gP=Ne(["working","input_required","completed","failed","cancelled"]),co=N({taskId:$(),status:gP,ttl:oe([ee(),Bi()]),createdAt:$(),lastUpdatedAt:$(),pollInterval:ae(ee()),statusMessage:ae($())}),Zn=je.extend({task:co}),vP=gt.merge(co),uo=vt.extend({method:E("notifications/tasks/status"),params:vP}),cc=Ee.extend({method:E("tasks/get"),params:ft.extend({taskId:$()})}),uc=je.merge(co),lc=Ee.extend({method:E("tasks/result"),params:ft.extend({taskId:$()})}),e6=je.loose(),dc=ao.extend({method:E("tasks/list")}),fc=so.extend({tasks:J(co)}),mc=Ee.extend({method:E("tasks/cancel"),params:ft.extend({taskId:$()})}),ob=je.merge(co),ab=N({uri:$(),mimeType:ae($()),_meta:ce($(),le()).optional()}),sb=ab.extend({text:$()}),Dp=$().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),cb=ab.extend({blob:Dp}),lo=Ne(["user","assistant"]),Ln=N({audience:J(lo).optional(),priority:ee().min(0).max(1).optional(),lastModified:Ur.datetime({offset:!0}).optional()}),ub=N({...Cn.shape,...oo.shape,uri:$(),description:ae($()),mimeType:ae($()),size:ae(ee()),annotations:Ln.optional(),_meta:ae(Te({}))}),yP=N({...Cn.shape,...oo.shape,uriTemplate:$(),description:ae($()),mimeType:ae($()),annotations:Ln.optional(),_meta:ae(Te({}))}),$P=ao.extend({method:E("resources/list")}),_P=so.extend({resources:J(ub)}),bP=ao.extend({method:E("resources/templates/list")}),kP=so.extend({resourceTemplates:J(yP)}),Ap=ft.extend({uri:$()}),wP=Ap,xP=Ee.extend({method:E("resources/read"),params:wP}),SP=je.extend({contents:J(oe([sb,cb]))}),zP=vt.extend({method:E("notifications/resources/list_changed"),params:gt.optional()}),IP=Ap,PP=Ee.extend({method:E("resources/subscribe"),params:IP}),OP=Ap,TP=Ee.extend({method:E("resources/unsubscribe"),params:OP}),NP=gt.extend({uri:$()}),EP=vt.extend({method:E("notifications/resources/updated"),params:NP}),jP=N({name:$(),description:ae($()),required:ae($e())}),DP=N({...Cn.shape,...oo.shape,description:ae($()),arguments:ae(J(jP)),_meta:ae(Te({}))}),Rp=ao.extend({method:E("prompts/list")}),AP=so.extend({prompts:J(DP)}),RP=ft.extend({name:$(),arguments:ce($(),$()).optional()}),Up=Ee.extend({method:E("prompts/get"),params:RP}),Cp=N({type:E("text"),text:$(),annotations:Ln.optional(),_meta:ce($(),le()).optional()}),Zp=N({type:E("image"),data:Dp,mimeType:$(),annotations:Ln.optional(),_meta:ce($(),le()).optional()}),Lp=N({type:E("audio"),data:Dp,mimeType:$(),annotations:Ln.optional(),_meta:ce($(),le()).optional()}),UP=N({type:E("tool_use"),name:$(),id:$(),input:ce($(),le()),_meta:ce($(),le()).optional()}),CP=N({type:E("resource"),resource:oe([sb,cb]),annotations:Ln.optional(),_meta:ce($(),le()).optional()}),ZP=ub.extend({type:E("resource_link")}),Mp=oe([Cp,Zp,Lp,ZP,CP]),LP=N({role:lo,content:Mp}),MP=je.extend({description:$().optional(),messages:J(LP)}),VP=vt.extend({method:E("notifications/prompts/list_changed"),params:gt.optional()}),FP=N({title:$().optional(),readOnlyHint:$e().optional(),destructiveHint:$e().optional(),idempotentHint:$e().optional(),openWorldHint:$e().optional()}),qP=N({taskSupport:Ne(["required","optional","forbidden"]).optional()}),lb=N({...Cn.shape,...oo.shape,description:$().optional(),inputSchema:N({type:E("object"),properties:ce($(),Se).optional(),required:J($()).optional()}).catchall(le()),outputSchema:N({type:E("object"),properties:ce($(),Se).optional(),required:J($()).optional()}).catchall(le()).optional(),annotations:FP.optional(),execution:qP.optional(),_meta:ce($(),le()).optional()}),Vp=ao.extend({method:E("tools/list")}),JP=so.extend({tools:J(lb)}),pc=je.extend({content:J(Mp).default([]),structuredContent:ce($(),le()).optional(),isError:$e().optional()}),t6=pc.or(je.extend({toolResult:le()})),BP=no.extend({name:$(),arguments:ce($(),le()).optional()}),fo=Ee.extend({method:E("tools/call"),params:BP}),KP=vt.extend({method:E("notifications/tools/list_changed"),params:gt.optional()}),r6=N({autoRefresh:$e().default(!0),debounceMs:ee().int().nonnegative().default(300)}),mo=Ne(["debug","info","notice","warning","error","critical","alert","emergency"]),HP=ft.extend({level:mo}),Fp=Ee.extend({method:E("logging/setLevel"),params:HP}),GP=gt.extend({level:mo,logger:$().optional(),data:le()}),WP=vt.extend({method:E("notifications/message"),params:GP}),XP=N({name:$().optional()}),YP=N({hints:J(XP).optional(),costPriority:ee().min(0).max(1).optional(),speedPriority:ee().min(0).max(1).optional(),intelligencePriority:ee().min(0).max(1).optional()}),QP=N({mode:Ne(["auto","required","none"]).optional()}),eO=N({type:E("tool_result"),toolUseId:$().describe("The unique identifier for the corresponding tool call."),content:J(Mp).default([]),structuredContent:N({}).loose().optional(),isError:$e().optional(),_meta:ce($(),le()).optional()}),tO=Wi("type",[Cp,Zp,Lp]),tc=Wi("type",[Cp,Zp,Lp,UP,eO]),rO=N({role:lo,content:oe([tc,J(tc)]),_meta:ce($(),le()).optional()}),nO=no.extend({messages:J(rO),modelPreferences:YP.optional(),systemPrompt:$().optional(),includeContext:Ne(["none","thisServer","allServers"]).optional(),temperature:ee().optional(),maxTokens:ee().int(),stopSequences:J($()).optional(),metadata:Se.optional(),tools:J(lb).optional(),toolChoice:QP.optional()}),iO=Ee.extend({method:E("sampling/createMessage"),params:nO}),po=je.extend({model:$(),stopReason:ae(Ne(["endTurn","stopSequence","maxTokens"]).or($())),role:lo,content:tO}),qp=je.extend({model:$(),stopReason:ae(Ne(["endTurn","stopSequence","maxTokens","toolUse"]).or($())),role:lo,content:oe([tc,J(tc)])}),oO=N({type:E("boolean"),title:$().optional(),description:$().optional(),default:$e().optional()}),aO=N({type:E("string"),title:$().optional(),description:$().optional(),minLength:ee().optional(),maxLength:ee().optional(),format:Ne(["email","uri","date","date-time"]).optional(),default:$().optional()}),sO=N({type:Ne(["number","integer"]),title:$().optional(),description:$().optional(),minimum:ee().optional(),maximum:ee().optional(),default:ee().optional()}),cO=N({type:E("string"),title:$().optional(),description:$().optional(),enum:J($()),default:$().optional()}),uO=N({type:E("string"),title:$().optional(),description:$().optional(),oneOf:J(N({const:$(),title:$()})),default:$().optional()}),lO=N({type:E("string"),title:$().optional(),description:$().optional(),enum:J($()),enumNames:J($()).optional(),default:$().optional()}),dO=oe([cO,uO]),fO=N({type:E("array"),title:$().optional(),description:$().optional(),minItems:ee().optional(),maxItems:ee().optional(),items:N({type:E("string"),enum:J($())}),default:J($()).optional()}),mO=N({type:E("array"),title:$().optional(),description:$().optional(),minItems:ee().optional(),maxItems:ee().optional(),items:N({anyOf:J(N({const:$(),title:$()}))}),default:J($()).optional()}),pO=oe([fO,mO]),hO=oe([lO,dO,pO]),gO=oe([hO,oO,aO,sO]),vO=no.extend({mode:E("form").optional(),message:$(),requestedSchema:N({type:E("object"),properties:ce($(),gO),required:J($()).optional()})}),yO=no.extend({mode:E("url"),message:$(),elicitationId:$(),url:$().url()}),$O=oe([vO,yO]),_O=Ee.extend({method:E("elicitation/create"),params:$O}),bO=gt.extend({elicitationId:$()}),kO=vt.extend({method:E("notifications/elicitation/complete"),params:bO}),Mn=je.extend({action:Ne(["accept","decline","cancel"]),content:to(e=>e===null?void 0:e,ce($(),oe([$(),ee(),$e(),J($())])).optional())}),wO=N({type:E("ref/resource"),uri:$()});var xO=N({type:E("ref/prompt"),name:$()}),SO=ft.extend({ref:oe([xO,wO]),argument:N({name:$(),value:$()}),context:N({arguments:ce($(),$()).optional()}).optional()}),zO=Ee.extend({method:E("completion/complete"),params:SO});var IO=je.extend({completion:Te({values:J($()).max(100),total:ae(ee().int()),hasMore:ae($e())})}),PO=N({uri:$().startsWith("file://"),name:$().optional(),_meta:ce($(),le()).optional()}),OO=Ee.extend({method:E("roots/list"),params:ft.optional()}),Jp=je.extend({roots:J(PO)}),TO=vt.extend({method:E("notifications/roots/list_changed"),params:gt.optional()}),n6=oe([ac,Ep,zO,Fp,Up,Rp,$P,bP,xP,PP,TP,fo,Vp,cc,lc,dc,mc]),i6=oe([oc,sc,jp,TO,uo]),o6=oe([ic,po,qp,Mn,Jp,uc,fc,Zn]),a6=oe([ac,iO,_O,OO,cc,lc,dc,mc]),s6=oe([oc,sc,WP,EP,zP,KP,VP,uo,kO]),c6=oe([ic,fP,IO,MP,AP,_P,kP,SP,pc,JP,uc,fc,Zn]),M=class e extends Error{constructor(t,n,i){super(`MCP error ${t}: ${n}`),this.code=t,this.data=i,this.name="McpError"}static fromError(t,n,i){if(t===G.UrlElicitationRequired&&i){let r=i;if(r.elicitations)return new zp(r.elicitations,n)}return new e(t,n,i)}},zp=class extends M{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(G.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function dr(e){return e==="completed"||e==="failed"||e==="cancelled"}var M6=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Bp(e){let n=Ss(e)?.method;if(!n)throw new Error("Schema is missing a method literal");let i=zs(n);if(typeof i!="string")throw new Error("Schema method literal must be a string");return i}function Kp(e,t){let n=or(e,t);if(!n.success)throw n.error;return n.data}var RO=6e4,hc=class{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(oc,n=>{this._oncancel(n)}),this.setNotificationHandler(sc,n=>{this._onprogress(n)}),this.setRequestHandler(ac,n=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(cc,async(n,i)=>{let r=await this._taskStore.getTask(n.params.taskId,i.sessionId);if(!r)throw new M(G.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler(lc,async(n,i)=>{let r=async()=>{let o=n.params.taskId;if(this._taskMessageQueue){let s;for(;s=await this._taskMessageQueue.dequeue(o,i.sessionId);){if(s.type==="response"||s.type==="error"){let c=s.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),s.type==="response")l(c);else{let d=c,m=new M(d.error.code,d.error.message,d.error.data);l(m)}else{let d=s.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(s.message,{relatedRequestId:i.requestId})}}let a=await this._taskStore.getTask(o,i.sessionId);if(!a)throw new M(G.InvalidParams,`Task not found: ${o}`);if(!dr(a.status))return await this._waitForTaskUpdate(o,i.signal),await r();if(dr(a.status)){let s=await this._taskStore.getTaskResult(o,i.sessionId);return this._clearTaskQueue(o),{...s,_meta:{...s._meta,[lr]:{taskId:o}}}}return await r()};return await r()}),this.setRequestHandler(dc,async(n,i)=>{try{let{tasks:r,nextCursor:o}=await this._taskStore.listTasks(n.params?.cursor,i.sessionId);return{tasks:r,nextCursor:o,_meta:{}}}catch(r){throw new M(G.InvalidParams,`Failed to list tasks: ${r instanceof Error?r.message:String(r)}`)}}),this.setRequestHandler(mc,async(n,i)=>{try{let r=await this._taskStore.getTask(n.params.taskId,i.sessionId);if(!r)throw new M(G.InvalidParams,`Task not found: ${n.params.taskId}`);if(dr(r.status))throw new M(G.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(n.params.taskId,"cancelled","Client cancelled task execution.",i.sessionId),this._clearTaskQueue(n.params.taskId);let o=await this._taskStore.getTask(n.params.taskId,i.sessionId);if(!o)throw new M(G.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...o}}catch(r){throw r instanceof M?r:new M(G.InvalidRequest,`Failed to cancel task: ${r instanceof Error?r.message:String(r)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,n,i,r,o=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(r,n),startTime:Date.now(),timeout:n,maxTotalTimeout:i,resetTimeoutOnProgress:o,onTimeout:r})}_resetTimeout(t){let n=this._timeoutInfo.get(t);if(!n)return!1;let i=Date.now()-n.startTime;if(n.maxTotalTimeout&&i>=n.maxTotalTimeout)throw this._timeoutInfo.delete(t),M.fromError(G.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:i});return clearTimeout(n.timeoutId),n.timeoutId=setTimeout(n.onTimeout,n.timeout),!0}_cleanupTimeout(t){let n=this._timeoutInfo.get(t);n&&(clearTimeout(n.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let n=this.transport?.onclose;this._transport.onclose=()=>{n?.(),this._onclose()};let i=this.transport?.onerror;this._transport.onerror=o=>{i?.(o),this._onerror(o)};let r=this._transport?.onmessage;this._transport.onmessage=(o,a)=>{r?.(o,a),io(o)||rb(o)?this._onresponse(o):Op(o)?this._onrequest(o,a):tb(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let i of this._timeoutInfo.values())clearTimeout(i.timeoutId);this._timeoutInfo.clear();for(let i of this._requestHandlerAbortControllers.values())i.abort();this._requestHandlerAbortControllers.clear();let n=M.fromError(G.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let i of t.values())i(n)}_onerror(t){this.onerror?.(t)}_onnotification(t){let n=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(t)).catch(i=>this._onerror(new Error(`Uncaught error in notification handler: ${i}`)))}_onrequest(t,n){let i=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,r=this._transport,o=t.params?._meta?.[lr]?.taskId;if(i===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:G.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:l,timestamp:Date.now()},r?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):r?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(t.id,a);let s=Y_(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,r?.sessionId):void 0,u={signal:a.signal,sessionId:r?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(a.signal.aborted)return;let d={relatedRequestId:t.id};o&&(d.relatedTask={taskId:o}),await this.notification(l,d)},sendRequest:async(l,d,m)=>{if(a.signal.aborted)throw new M(G.ConnectionClosed,"Request was cancelled");let f={...m,relatedRequestId:t.id};o&&!f.relatedTask&&(f.relatedTask={taskId:o});let p=f.relatedTask?.taskId??o;return p&&c&&await c.updateTaskStatus(p,"input_required"),await this.request(l,d,f)},authInfo:n?.authInfo,requestId:t.id,requestInfo:n?.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:s?.ttl,closeSSEStream:n?.closeSSEStream,closeStandaloneSSEStream:n?.closeStandaloneSSEStream};Promise.resolve().then(()=>{s&&this.assertTaskHandlerCapability(t.method)}).then(()=>i(t,u)).then(async l=>{if(a.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:d,timestamp:Date.now()},r?.sessionId):await r?.send(d)},async l=>{if(a.signal.aborted)return;let d={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:G.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:d,timestamp:Date.now()},r?.sessionId):await r?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===a&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:n,...i}=t.params,r=Number(n),o=this._progressHandlers.get(r);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let a=this._responseHandlers.get(r),s=this._timeoutInfo.get(r);if(s&&a&&s.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(c){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(c);return}o(i)}_onresponse(t){let n=Number(t.id),i=this._requestResolvers.get(n);if(i){if(this._requestResolvers.delete(n),io(t))i(t);else{let a=new M(t.error.code,t.error.message,t.error.data);i(a)}return}let r=this._responseHandlers.get(n);if(r===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(n),this._cleanupTimeout(n);let o=!1;if(io(t)&&t.result&&typeof t.result=="object"){let a=t.result;if(a.task&&typeof a.task=="object"){let s=a.task;typeof s.taskId=="string"&&(o=!0,this._taskProgressTokens.set(s.taskId,n))}}if(o||this._progressHandlers.delete(n),io(t))r(t);else{let a=M.fromError(t.error.code,t.error.message,t.error.data);r(a)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,n,i){let{task:r}=i??{};if(!r){try{yield{type:"result",result:await this.request(t,n,i)}}catch(a){yield{type:"error",error:a instanceof M?a:new M(G.InternalError,String(a))}}return}let o;try{let a=await this.request(t,Zn,i);if(a.task)o=a.task.taskId,yield{type:"taskCreated",task:a.task};else throw new M(G.InternalError,"Task creation did not return a task");for(;;){let s=await this.getTask({taskId:o},i);if(yield{type:"taskStatus",task:s},dr(s.status)){s.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},n,i)}:s.status==="failed"?yield{type:"error",error:new M(G.InternalError,`Task ${o} failed`)}:s.status==="cancelled"&&(yield{type:"error",error:new M(G.InternalError,`Task ${o} was cancelled`)});return}if(s.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},n,i)};return}let c=s.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),i?.signal?.throwIfAborted()}}catch(a){yield{type:"error",error:a instanceof M?a:new M(G.InternalError,String(a))}}}request(t,n,i){let{relatedRequestId:r,resumptionToken:o,onresumptiontoken:a,task:s,relatedTask:c}=i??{};return new Promise((u,l)=>{let d=_=>{l(_)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),s&&this.assertTaskCapability(t.method)}catch(_){d(_);return}i?.signal?.throwIfAborted();let m=this._requestMessageId++,f={...t,jsonrpc:"2.0",id:m};i?.onprogress&&(this._progressHandlers.set(m,i.onprogress),f.params={...t.params,_meta:{...t.params?._meta||{},progressToken:m}}),s&&(f.params={...f.params,task:s}),c&&(f.params={...f.params,_meta:{...f.params?._meta||{},[lr]:c}});let p=_=>{this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(_)}},{relatedRequestId:r,resumptionToken:o,onresumptiontoken:a}).catch(O=>this._onerror(new Error(`Failed to send cancellation: ${O}`)));let S=_ instanceof M?_:new M(G.RequestTimeout,String(_));l(S)};this._responseHandlers.set(m,_=>{if(!i?.signal?.aborted){if(_ instanceof Error)return l(_);try{let S=or(n,_.result);S.success?u(S.data):l(S.error)}catch(S){l(S)}}}),i?.signal?.addEventListener("abort",()=>{p(i?.signal?.reason)});let h=i?.timeout??RO,g=()=>p(M.fromError(G.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(m,h,i?.maxTotalTimeout,g,i?.resetTimeoutOnProgress??!1);let b=c?.taskId;if(b){let _=S=>{let O=this._responseHandlers.get(m);O?O(S):this._onerror(new Error(`Response handler missing for side-channeled request ${m}`))};this._requestResolvers.set(m,_),this._enqueueTaskMessage(b,{type:"request",message:f,timestamp:Date.now()}).catch(S=>{this._cleanupTimeout(m),l(S)})}else this._transport.send(f,{relatedRequestId:r,resumptionToken:o,onresumptiontoken:a}).catch(_=>{this._cleanupTimeout(m),l(_)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},uc,n)}async getTaskResult(t,n,i){return this.request({method:"tasks/result",params:t},n,i)}async listTasks(t,n){return this.request({method:"tasks/list",params:t},fc,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},ob,n)}async notification(t,n){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let i=n?.relatedTask?.taskId;if(i){let s={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[lr]:n.relatedTask}}};await this._enqueueTaskMessage(i,{type:"notification",message:s,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!n?.relatedRequestId&&!n?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let s={...t,jsonrpc:"2.0"};n?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[lr]:n.relatedTask}}}),this._transport?.send(s,n).catch(c=>this._onerror(c))});return}let a={...t,jsonrpc:"2.0"};n?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[lr]:n.relatedTask}}}),await this._transport.send(a,n)}setRequestHandler(t,n){let i=Bp(t);this.assertRequestHandlerCapability(i),this._requestHandlers.set(i,(r,o)=>{let a=Kp(t,r);return Promise.resolve(n(a,o))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,n){let i=Bp(t);this._notificationHandlers.set(i,r=>{let o=Kp(t,r);return Promise.resolve(n(o))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let n=this._taskProgressTokens.get(t);n!==void 0&&(this._progressHandlers.delete(n),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,n,i){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,n,i,r)}async _clearTaskQueue(t,n){if(this._taskMessageQueue){let i=await this._taskMessageQueue.dequeueAll(t,n);for(let r of i)if(r.type==="request"&&Op(r.message)){let o=r.message.id,a=this._requestResolvers.get(o);a?(a(new M(G.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,n){let i=this._options?.defaultTaskPollInterval??1e3;try{let r=await this._taskStore?.getTask(t);r?.pollInterval&&(i=r.pollInterval)}catch{}return new Promise((r,o)=>{if(n.aborted){o(new M(G.InvalidRequest,"Request cancelled"));return}let a=setTimeout(r,i);n.addEventListener("abort",()=>{clearTimeout(a),o(new M(G.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,n){let i=this._taskStore;if(!i)throw new Error("No task store configured");return{createTask:async r=>{if(!t)throw new Error("No request provided");return await i.createTask(r,t.id,{method:t.method,params:t.params},n)},getTask:async r=>{let o=await i.getTask(r,n);if(!o)throw new M(G.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(r,o,a)=>{await i.storeTaskResult(r,o,a,n);let s=await i.getTask(r,n);if(s){let c=uo.parse({method:"notifications/tasks/status",params:s});await this.notification(c),dr(s.status)&&this._cleanupTaskProgressHandler(r)}},getTaskResult:r=>i.getTaskResult(r,n),updateTaskStatus:async(r,o,a)=>{let s=await i.getTask(r,n);if(!s)throw new M(G.InvalidParams,`Task "${r}" not found - it may have been cleaned up`);if(dr(s.status))throw new M(G.InvalidParams,`Cannot update task "${r}" from terminal status "${s.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await i.updateTaskStatus(r,o,a,n);let c=await i.getTask(r,n);if(c){let u=uo.parse({method:"notifications/tasks/status",params:c});await this.notification(u),dr(c.status)&&this._cleanupTaskProgressHandler(r)}},listTasks:r=>i.listTasks(r,n)}}};function db(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function fb(e,t){let n={...e};for(let i in t){let r=i,o=t[r];if(o===void 0)continue;let a=n[r];db(a)&&db(o)?n[r]={...a,...o}:n[r]=o}return n}var dx=Hg(Zg(),1),fx=Hg(lx(),1);function KA(){let e=new dx.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,fx.default)(e),e}var Yc=class{constructor(t){this._ajv=t??KA()}getValidator(t){let n="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return i=>n(i)?{valid:!0,data:i,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(n.errors)}}};var Qc=class{constructor(t){this._server=t}requestStream(t,n,i){return this._server.requestStream(t,n,i)}createMessageStream(t,n){let i=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!i?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let r=t.messages[t.messages.length-1],o=Array.isArray(r.content)?r.content:[r.content],a=o.some(l=>l.type==="tool_result"),s=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=s?Array.isArray(s.content)?s.content:[s.content]:[],u=c.some(l=>l.type==="tool_use");if(a){if(o.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(m=>m.type==="tool_use").map(m=>m.id)),d=new Set(o.filter(m=>m.type==="tool_result").map(m=>m.toolUseId));if(l.size!==d.size||![...l].every(m=>d.has(m)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},po,n)}elicitInputStream(t,n){let i=this._server.getClientCapabilities(),r=t.mode??"form";switch(r){case"url":{if(!i?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!i?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let o=r==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:o},Mn,n)}async getTask(t,n){return this._server.getTask({taskId:t},n)}async getTaskResult(t,n,i){return this._server.getTaskResult({taskId:t},n,i)}async listTasks(t,n){return this._server.listTasks(t?{cursor:t}:void 0,n)}async cancelTask(t,n){return this._server.cancelTask({taskId:t},n)}};function mx(e,t,n){if(!e)throw new Error(`${n} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${n} does not support task creation for tools/call (required for ${t})`);break;default:break}}function px(e,t,n){if(!e)throw new Error(`${n} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${n} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${n} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var eu=class extends hc{constructor(t,n){super(n),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(mo.options.map((i,r)=>[i,r])),this.isMessageIgnored=(i,r)=>{let o=this._loggingLevels.get(r);return o?this.LOG_LEVEL_SEVERITY.get(i)<this.LOG_LEVEL_SEVERITY.get(o):!1},this._capabilities=n?.capabilities??{},this._instructions=n?.instructions,this._jsonSchemaValidator=n?.jsonSchemaValidator??new Yc,this.setRequestHandler(Ep,i=>this._oninitialize(i)),this.setNotificationHandler(jp,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Fp,async(i,r)=>{let o=r.sessionId||r.requestInfo?.headers["mcp-session-id"]||void 0,{level:a}=i.params,s=mo.safeParse(a);return s.success&&this._loggingLevels.set(o,s.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Qc(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=fb(this._capabilities,t)}setRequestHandler(t,n){let r=Ss(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let o=zs(r);if(typeof o!="string")throw new Error("Schema method literal must be a string");if(o==="tools/call"){let s=async(c,u)=>{let l=or(fo,c);if(!l.success){let p=l.error instanceof Error?l.error.message:String(l.error);throw new M(G.InvalidParams,`Invalid tools/call request: ${p}`)}let{params:d}=l.data,m=await Promise.resolve(n(c,u));if(d.task){let p=or(Zn,m);if(!p.success){let h=p.error instanceof Error?p.error.message:String(p.error);throw new M(G.InvalidParams,`Invalid task creation result: ${h}`)}return p.data}let f=or(pc,m);if(!f.success){let p=f.error instanceof Error?f.error.message:String(f.error);throw new M(G.InvalidParams,`Invalid tools/call result: ${p}`)}return f.data};return super.setRequestHandler(t,s)}return super.setRequestHandler(t,n)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){px(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&mx(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let n=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:G_.includes(n)?n:Ip,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},ic)}async createMessage(t,n){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let i=t.messages[t.messages.length-1],r=Array.isArray(i.content)?i.content:[i.content],o=r.some(u=>u.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,s=a?Array.isArray(a.content)?a.content:[a.content]:[],c=s.some(u=>u.type==="tool_use");if(o){if(r.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(s.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(r.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},qp,n):this.request({method:"sampling/createMessage",params:t},po,n)}async elicitInput(t,n){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let r=t;return this.request({method:"elicitation/create",params:r},Mn,n)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let r=t.mode==="form"?t:{...t,mode:"form"},o=await this.request({method:"elicitation/create",params:r},Mn,n);if(o.action==="accept"&&o.content&&r.requestedSchema)try{let s=this._jsonSchemaValidator.getValidator(r.requestedSchema)(o.content);if(!s.valid)throw new M(G.InvalidParams,`Elicitation response content does not match requested schema: ${s.errorMessage}`)}catch(a){throw a instanceof M?a:new M(G.InternalError,`Error validating elicitation response: ${a instanceof Error?a.message:String(a)}`)}return o}}}createElicitationCompletionNotifier(t,n){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},n)}async listRoots(t,n){return this.request({method:"roots/list",params:t},Jp,n)}async sendLoggingMessage(t,n){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,n))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};import gx from"node:process";var HA=10*1024*1024,tu=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??HA}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
|
|
70
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let s=a[1];if(t===a[0]){o(a);continue}if(e.external){let u=e.external.registry.get(a[0])?.id;if(t!==a[0]&&u){o(a);continue}}if(e.metadataRegistry.get(a[0])?.id){o(a);continue}if(s.cycle){o(a);continue}s.count>1&&e.reused==="ref"&&o(a)}e.external&&(e.sharedDefsExtractedFor=e.external)}function f$(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!="object")return;f$(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let o=i.type;for(let a of Array.isArray(o)?o:[o]){if(typeof a!="string")return;n.includes(a)||n.push(a)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var m$=new Set(["type","properties","required","additionalProperties"]),l$=["oneOf","anyOf"];function d$(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Df(e){let t=[];for(let o of e){if(typeof o!="object"||o.type!=="object")return null;for(let a in o)if(!m$.has(a))return null;t.push(o)}let n={},i=new Set;for(let o of t){for(let a in o.properties){if(Object.prototype.hasOwnProperty.call(n,a))continue;let s=[];for(let u of t){let l=u.properties?.[a]??d$(u);l!=null&&(s.some(d=>JSON.stringify(d)===JSON.stringify(l))||s.push(l))}let c=s.length===1?s[0]:Df(s)??{allOf:s};Pe(n,a,c)}for(let a of o.required??[])i.add(a)}let r={type:"object",properties:n};if(i.size&&(r.required=[...i]),t.every(o=>o.additionalProperties===!1))r.additionalProperties=!1;else{let o=[];for(let a of t){let s=d$(a);s&&!o.some(c=>JSON.stringify(c)===JSON.stringify(s))&&o.push(s)}o.length===1?r.additionalProperties=o[0]:o.length>1&&(r.additionalProperties={allOf:o})}return r}function w0(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of m$)if(r in e)return;let n=t.filter(r=>l$.some(o=>Array.isArray(r[o]))),i=null;if(!n.length)i=Df(t);else{let r=n[0],o=l$.find(c=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let a=t.filter(c=>c!==r),s=r[o].map(c=>Df([...a,c]));if(s.some(c=>!c))return;i={[o]:s}}i&&(delete e.allOf,Mi(e,i))}function ir(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let c=e.seen.get(s);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){i(d);let f=e.seen.get(d),p=f.schema;if(p.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(p)):Mi(u,p),Mi(u,l),s._zod.parent===d)for(let g in u)g==="$ref"||g==="allOf"||g in l||delete u[g];if(p.$ref&&f.def)for(let g in u)g==="$ref"||g==="allOf"||g in f.def&&JSON.stringify(u[g])===JSON.stringify(f.def[g])&&delete u[g]}let m=s._zod.parent;if(m&&m!==d){i(m);let f=e.seen.get(m);if(f?.schema.$ref&&(u.$ref=f.schema.$ref,f.def))for(let p in u)p==="$ref"||p==="allOf"||p in f.def&&JSON.stringify(u[p])===JSON.stringify(f.def[p])&&delete u[p]}e.override({zodSchema:s,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let s of[...e.seen.entries()].reverse())i(s[0]);if(e.target!=="openapi-3.0")for(let s of e.seen.entries())f$(s[1].def??s[1].schema);for(let s of e.deferred)s();if(e.intersections.length){let s=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=s.get(l);d?d.push(u):s.set(l,[u])}for(let c of e.intersections)for(let u of s.get(c)??[])w0(u)}}let r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(s)}Mi(r,n.defId?n.schema:n.def??n.schema);let o=e.metadataRegistry.get(t)?.id;o!==void 0&&r.id===o&&delete r.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let s of e.seen.entries()){let c=s[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,Pe(a,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?r.$defs=a:r.definitions=a);try{let s=JSON.parse(JSON.stringify(r));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:In(t,"input",e.processors),output:In(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function Ge(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Ge(i.element,n);if(i.type==="set")return Ge(i.valueType,n);if(i.type==="lazy")return Ge(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return Ge(i.innerType,n);if(i.type==="intersection")return Ge(i.left,n)||Ge(i.right,n);if(i.type==="record"||i.type==="map")return Ge(i.keyType,n)||Ge(i.valueType,n);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Ge(i.in,n)||Ge(i.out,n);if(i.type==="object"){for(let r in i.shape)if(Ge(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(Ge(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(Ge(r,n))return!0;return!!(i.rest&&Ge(i.rest,n))}return!1}var Af=(e,t={})=>n=>{let i=rr({...n,processors:t});return ie(e,i),nr(i,e),ir(i,e)},In=(e,t,n={})=>i=>{let{libraryOptions:r,target:o}=i??{},a=rr({...r??{},target:o,io:t,processors:n});return ie(e,a),nr(a,e),ir(a,e)};var Pn=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},On=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},p$=(e,t)=>{Pn(e,"minimum",t),On(e,"maximum",t)},y$=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},$$=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},_$=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},b$=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},h$=(e,t)=>Pn(e,"minimum",t.minimum),g$=(e,t)=>On(e,"maximum",t.maximum),v$=e=>(t,n)=>{b$(t,n.format);let[i,r]=e[n.format];Pn(t,"minimum",i),On(t,"maximum",r)},x0={greater_than:(e,t)=>Pn(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>On(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>y$(e,t.value),number_format:v$(ui),bigint_format:v$(li),min_length:h$,max_length:g$,length_equals:(e,t)=>p$(e,t.length),min_size:h$,max_size:g$,size_equals:(e,t)=>p$(e,t.size),string_format:(e,t)=>{b$(e,t.format),t.pattern&&$$(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>_$(e,t.mime)};function xe(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let o of i)x0[o._zod.def.check]?.(t,o._zod.def);let r=e._zod.bag;r.minimum!==void 0&&Pn(t,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&Pn(t,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&On(t,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&On(t,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&y$(t,r.multipleOf),r.format!==void 0&&(t.format??(t.format=r.format),r.format.includes("int")&&(t.isInt=!0)),r.mime&&_$(t,r.mime);for(let o of r.patterns??[])$$(t,o);return t}var S0={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},z0=new Map([[wa,Vu],[zi,Fu]]),k$=e=>z0.get(e)??e,Cf=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:o,maximum:a,format:s,patterns:c,contentEncoding:u,laxFormat:l}=xe(e);if(typeof o=="number"&&(r.minLength=o),typeof a=="number"&&(r.maxLength=a),s&&(r.format=S0[s]??s,r.format===""&&delete r.format,(s==="time"||l)&&delete r.format),u&&(r.contentEncoding=u),c&&c.size>0){let d=[...c].map(k$);d.length===1?r.pattern=d[0].source:d.length>1&&(r.allOf=[...d.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},Zf=(e,t,n,i)=>{let r=n,{minimum:o,maximum:a,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=xe(e);r.type=l?"integer":"number";let d=typeof u=="number"&&u>=(o??Number.NEGATIVE_INFINITY),m=typeof c=="number"&&c<=(a??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(d?f?(r.minimum=u,r.exclusiveMinimum=!0):r.exclusiveMinimum=u:typeof o=="number"&&(r.minimum=o),m?f?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:typeof a=="number"&&(r.maximum=a),s){let p=new Set;for(let b of s)Number.isFinite(b)&&b!==0?p.add(Math.abs(b)):we(e,t,r,i,`A multipleOf divisor of ${b} cannot be represented in JSON Schema`);let[h,...g]=p;h!==void 0&&(r.multipleOf=h),g.length&&(r.allOf=[...r.allOf??[],...g.map(b=>({multipleOf:b}))])}},Lf=(e,t,n,i)=>{n.type="boolean"},Mf=(e,t,n,i)=>{we(e,t,n,i,"BigInt cannot be represented in JSON Schema")},Vf=(e,t,n,i)=>{we(e,t,n,i,"Symbols cannot be represented in JSON Schema")},Ff=(e,t,n,i)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},qf=(e,t,n,i)=>{we(e,t,n,i,"Undefined cannot be represented in JSON Schema")},Jf=(e,t,n,i)=>{we(e,t,n,i,"Void cannot be represented in JSON Schema")},Bf=(e,t,n,i)=>{n.not={}},Kf=(e,t,n,i)=>{},Hf=(e,t,n,i)=>{},Gf=(e,t,n,i)=>{we(e,t,n,i,"Date cannot be represented in JSON Schema")},Wf=(e,t,n,i)=>{let r=e._zod.def,o=Xr(r.entries);if(o.length===0){n.not={};return}o.every(a=>typeof a=="number")&&(n.type="number"),o.every(a=>typeof a=="string")&&(n.type="string"),n.enum=o},Xf=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let o=[];for(let a of r.values)if(a===void 0){if(we(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(we(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(a))}else o.push(a);if(o.length!==0)if(o.length===1){let a=o[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else o.every(a=>typeof a=="number")&&(n.type="number"),o.every(a=>typeof a=="string")&&(n.type="string"),o.every(a=>typeof a=="boolean")&&(n.type="boolean"),o.every(a=>a===null)&&(n.type="null"),n.enum=o},Yf=(e,t,n,i)=>{we(e,t,n,i,"NaN cannot be represented in JSON Schema")},Qf=(e,t,n,i)=>{let r=n,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");r.type="string",r.pattern=o.source},em=(e,t,n,i)=>{let r=n;r.type="string",r.format="binary",r.contentEncoding="binary";let{minimum:o,maximum:a,mime:s}=xe(e);o!==void 0&&(r.minLength=o),a!==void 0&&(r.maxLength=a),s&&(s.length===0?r.not={}:s.length===1?r.contentMediaType=s[0]:r.anyOf=s.map(c=>({contentMediaType:c})))},tm=(e,t,n,i)=>{n.type="boolean"},rm=(e,t,n,i)=>{we(e,t,n,i,"Custom types cannot be represented in JSON Schema")},nm=(e,t,n,i)=>{we(e,t,n,i,"Function types cannot be represented in JSON Schema")},im=(e,t,n,i)=>{we(e,t,n,i,"Transforms cannot be represented in JSON Schema")},om=(e,t,n,i)=>{we(e,t,n,i,"Map cannot be represented in JSON Schema")},am=(e,t,n,i)=>{we(e,t,n,i,"Set cannot be represented in JSON Schema")},sm=(e,t,n,i)=>{let r=n,o=e._zod.def,{minimum:a,maximum:s}=xe(e);typeof a=="number"&&(r.minItems=a),typeof s=="number"&&(r.maxItems=s),r.type="array",r.items=ie(o.element,t,{...i,path:[...i.path,"items"]})};function Vi(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Vi(t.out):t.type==="catch"?Vi(t.innerType):e._zod.optin}var cm=(e,t,n,i)=>{let r=n,o=e._zod.def,a=o.shape;if(Object.getOwnPropertySymbols(a).length&&we(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let u in a)Pe(r.properties,u,ie(a[u],t,{...i,path:[...i.path,"properties",u]}));let c=[];for(let u of Object.keys(a)){let l=o.shape[u];(t.io==="input"?Vi(l)===void 0:l._zod.optout===void 0)&&c.push(u)}c.length>0&&(r.required=c),o.catchall?._zod.def.type==="never"?r.additionalProperties=!1:o.catchall?o.catchall&&(r.additionalProperties=ie(o.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},_s=(e,t,n,i)=>{let r=e._zod.def,o=r.inclusive===!1,a=r.options.map((s,c)=>ie(s,t,{...i,path:[...i.path,o?"oneOf":"anyOf",c]}));o?n.oneOf=a:n.anyOf=a},um=(e,t,n,i)=>{let r=e._zod.def,o=ie(r.left,t,{...i,path:[...i.path,"allOf",0]}),a=ie(r.right,t,{...i,path:[...i.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,c=[...s(o)?o.allOf:[o],...s(a)?a.allOf:[a]];n.allOf=c,t.intersections.push(c)},lm=(e,t,n,i)=>{let r=n,o=e._zod.def;r.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((h,g)=>ie(h,t,{...i,path:[...i.path,a,g]})),u=o.rest?ie(o.rest,t,{...i,path:[...i.path,s,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null,l=o.items.length;for(;l>0;){let h=o.items[l-1];if(!(t.io==="input"?Vi(h)!==void 0:h._zod.optout==="optional"))break;l--}let d=o.items.length,m=!o.rest;t.target==="draft-2020-12"?(r.prefixItems=c,m?r.items=!1:u&&(r.items=u),l>0&&(r.minItems=l),m&&(r.maxItems=d)):t.target==="openapi-3.0"?(r.items={anyOf:c},u&&r.items.anyOf.push(u),l>0&&(r.minItems=l),m&&(r.maxItems=d)):(r.items=c,m?r.additionalItems=!1:u&&(r.additionalItems=u),l>0&&(r.minItems=l),m&&(r.maxItems=d));let{minimum:f,maximum:p}=xe(e);typeof f=="number"&&(r.minItems=f),typeof p=="number"&&(r.maxItems=p)};function Rf(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let p=e.get(t)?.def;if(!p)return t;let h=Rf(e,p,n);return h===p?t:h}for(let p of["anyOf","oneOf"]){let h=t[p];if(!Array.isArray(h))continue;let g=h.map(b=>Rf(e,b,n));g.some((b,_)=>b!==h[_])&&(t={...t,[p]:g})}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some(p=>p==="number"||p==="integer"),o=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!o?.some(p=>typeof p=="number"))return t;let{minimum:a,maximum:s,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:m,...f}=t;return f.enum?f.enum=f.enum.map(p=>typeof p=="number"?String(p):p):typeof f.const=="number"&&(f.const=String(f.const)),r&&(f.type="string",o||(f.pattern=(i.includes("number")?Vt:$i).source)),f}var Uf=new WeakMap;function I0(e){let t=new Map;for(let i of e.seen.values())i.def&&!t.has(i.schema)&&t.set(i.schema,i);let n=new Map;for(let i of Uf.get(e)??[]){let r=e.seen.get(i),o=(r?.def??r?.schema)?.propertyNames;if(!o||o===!0||n.has(o))continue;let a=Rf(t,o,new Set);a!==o&&n.set(o,a)}if(n.size)for(let i of e.seen.values())for(let r of[i.schema,i.def]){let o=r&&n.get(r.propertyNames);o&&(r.propertyNames=o)}}var dm=(e,t,n,i)=>{let r=n,o=e._zod.def;r.type="object";let a=o.keyType,s=xe(a).patterns;if(o.mode==="loose"&&s&&s.size>0){let l=ie(o.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let d of s)Pe(r.patternProperties,k$(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=ie(o.keyType,t,{...i,path:[...i.path,"propertyNames"]});let l=Uf.get(t);l||(l=[],Uf.set(t,l),t.deferred.push(()=>I0(t))),l.push(e)}r.additionalProperties=ie(o.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=a._zod.values,u=t.io==="input"&&Vi(o.valueType)!==void 0;if(c&&!o.partial&&!u){let l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(r.required=l.map(String))}},fm=(e,t,n,i)=>{let r=e._zod.def,o=ie(r.innerType,t,i),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=r.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},mm=(e,t,n,i)=>{let r=e._zod.def;ie(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType},pm=Symbol();function w$(e,t,n,i,r){let o=!1,a=JSON.stringify(e,(s,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(we(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),pm):JSON.parse(a)}var hm=(e,t,n,i)=>{let r=e._zod.def;ie(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType;let a=w$(r.defaultValue,e,t,n,i);a!==pm&&(n.default=a)},gm=(e,t,n,i)=>{let r=e._zod.def;ie(r.innerType,t,i);let o=t.seen.get(e);if(o.ref=r.innerType,t.io!=="input")return;let a=w$(r.defaultValue,e,t,n,i);a!==pm&&(n._prefault=a)},vm=(e,t,n,i)=>{let r=e._zod.def;ie(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType;let a;try{a=r.catchValue(void 0)}catch{we(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=a},ym=(e,t,n,i)=>{let r=e._zod.def,o=r.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?o?r.out:r.in:r.out;ie(a,t,i);let s=t.seen.get(e);s.ref=a},$m=(e,t,n,i)=>{let r=e._zod.def;ie(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType,n.readOnly=!0},_m=(e,t,n,i)=>{let r=e._zod.def;ie(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType},bs=(e,t,n,i)=>{let r=e._zod.def;ie(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType},bm=(e,t,n,i)=>{let r=e._zod.innerType;ie(r,t,i);let o=t.seen.get(e);o.ref=r},$s={string:Cf,number:Zf,boolean:Lf,bigint:Mf,symbol:Vf,null:Ff,undefined:qf,void:Jf,never:Bf,any:Kf,unknown:Hf,date:Gf,enum:Wf,literal:Xf,nan:Yf,template_literal:Qf,file:em,success:tm,custom:rm,function:nm,transform:im,map:om,set:am,array:sm,object:cm,union:_s,intersection:um,tuple:lm,record:dm,nullable:fm,nonoptional:mm,default:hm,prefault:gm,catch:vm,pipe:ym,readonly:$m,promise:_m,optional:bs,lazy:bm};function ks(e,t){if("_idmap"in e){let i=e,r=rr({...t,processors:$s}),o={};for(let c of i._idmap.entries()){let[u,l]=c;ie(l,r)}let a={},s={registry:i,uri:t?.uri,defs:o};r.external=s;for(let c of i._idmap.entries()){let[u,l]=c;nr(r,l),Pe(a,u,ir(r,l))}if(Object.keys(o).length>0){let c=r.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[c]:o}}return{schemas:a}}let n=rr({...t,processors:$s});return ie(e,n),nr(n,e),ir(n,e)}var ws=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let n=t?.target??"draft-2020-12";n==="draft-4"&&(n="draft-04"),n==="draft-7"&&(n="draft-07"),this.ctx=rr({processors:$s,target:n,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,n={path:[],schemaPath:[]}){return ie(t,this.ctx,n)}emit(t,n){n&&(n.cycles&&(this.ctx.cycles=n.cycles),n.reused&&(this.ctx.reused=n.reused),n.external&&(this.ctx.external=n.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,nr(this.ctx,t);let i=ir(this.ctx,t),{"~standard":r,...o}=i;return o}};var x$={};var S$=Symbol("z.visit/resolving");function Fi(e,t){let n=typeof t=="function"?t:(a,s)=>{let c=t[a._zod.def.type];return c?c(a,s):a},i=new Map;function r(a){let s=i.get(a);if(s===S$)return new Ti({type:"lazy",getter:()=>i.get(a)});if(s!==void 0)return s;i.set(a,S$);let c=o(a),u=n(c,c!==a);return i.set(a,u),u}function o(a){let s=a._zod.def,c=s.type;switch(c){case"object":{let u=s.shape,l=Object.keys(u),d=!1,m={};for(let p of l){let h=r(u[p]);h!==u[p]&&(d=!0),m[p]=h}let f=s.catchall;return s.catchall&&(f=r(s.catchall),f!==s.catchall&&(d=!0)),d?re(a,{...s,shape:m,catchall:f}):a}case"array":{let u=r(s.element);return u===s.element?a:re(a,{...s,element:u})}case"tuple":{let u=s.items,l=!1,d=[];for(let f of u){let p=r(f);p!==f&&(l=!0),d.push(p)}let m=s.rest;return s.rest&&(m=r(s.rest),m!==s.rest&&(l=!0)),l?re(a,{...s,items:d,rest:m}):a}case"record":case"map":{let u=r(s.keyType),l=r(s.valueType);return u===s.keyType&&l===s.valueType?a:re(a,{...s,keyType:u,valueType:l})}case"set":{let u=r(s.valueType);return u===s.valueType?a:re(a,{...s,valueType:u})}case"union":{let u=s.options,l=!1,d=[];for(let m of u){let f=r(m);f!==m&&(l=!0),d.push(f)}return l?re(a,{...s,options:d}):a}case"intersection":{let u=r(s.left),l=r(s.right);return u===s.left&&l===s.right?a:re(a,{...s,left:u,right:l})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let u=r(s.innerType);return u===s.innerType?a:re(a,{...s,innerType:u})}case"pipe":{let u=r(s.in),l=r(s.out);return u===s.in&&l===s.out?a:re(a,{...s,in:u,out:l})}case"function":{let u=r(s.input),l=r(s.output);return u===s.input&&l===s.output?a:re(a,{...s,input:u,output:l})}case"lazy":{let u=s.getter,{_cachedInner:l,...d}=s;return re(a,{...d,getter:()=>r(u())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return a;default:return a}}return r(e)}function xs(e){return!!e._zod}function or(e,t){return xs(e)?Qo(e,t):e.safeParse(t)}function Ss(e){if(!e)return;let t;if(xs(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function zs(e){if(xs(e)){let o=e._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.values[0]}}let n=e._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}let i=e.value;if(i!==void 0)return i}var ve={};Zt(ve,{$brand:()=>yu,$input:()=>qd,$output:()=>Fd,INVALID:()=>He,NEVER:()=>vu,TimePrecision:()=>tf,ZodAny:()=>Lm,ZodArray:()=>qm,ZodBase64:()=>Js,ZodBase64URL:()=>Bs,ZodBigInt:()=>An,ZodBigIntFormat:()=>Gs,ZodBoolean:()=>Dn,ZodCIDRv4:()=>Fs,ZodCIDRv6:()=>qs,ZodCUID:()=>Rs,ZodCUID2:()=>Us,ZodCatch:()=>up,ZodCodec:()=>Qi,ZodCompileAsyncError:()=>wt,ZodCompileUnsupportedError:()=>K,ZodCreditCard:()=>Am,ZodCustom:()=>eo,ZodCustomStringFormat:()=>Ar,ZodDate:()=>Ki,ZodDefault:()=>np,ZodDiscriminatedUnion:()=>Bm,ZodE164:()=>Ks,ZodEmail:()=>Es,ZodEmoji:()=>Ds,ZodEnum:()=>Nn,ZodError:()=>O0,ZodExactOptional:()=>Ys,ZodFile:()=>Qm,ZodFirstPartyTypeKind:()=>wp,ZodFunction:()=>$p,ZodGUID:()=>js,ZodIBAN:()=>Rm,ZodIPv4:()=>Ms,ZodIPv6:()=>Vs,ZodISODate:()=>sr,ZodISODateTime:()=>ar,ZodISODuration:()=>ur,ZodISOTime:()=>cr,ZodInstanceOf:()=>kp,ZodIntersection:()=>Km,ZodIssueCode:()=>E0,ZodJWT:()=>Hs,ZodKSUID:()=>Ls,ZodLazy:()=>gp,ZodLiteral:()=>Ym,ZodMAC:()=>Dm,ZodMap:()=>Wm,ZodNaN:()=>dp,ZodNanoID:()=>As,ZodNever:()=>Vm,ZodNonOptional:()=>Qs,ZodNull:()=>Zm,ZodNullable:()=>rp,ZodNumber:()=>jn,ZodNumberFormat:()=>Rr,ZodObject:()=>Hi,ZodOptional:()=>Xi,ZodPipe:()=>Yi,ZodPrefault:()=>op,ZodPreprocess:()=>fp,ZodPromise:()=>yp,ZodReadonly:()=>mp,ZodRealError:()=>nt,ZodRecord:()=>Tn,ZodSet:()=>Xm,ZodString:()=>En,ZodStringFormat:()=>se,ZodSuccess:()=>cp,ZodSymbol:()=>Um,ZodTemplateLiteral:()=>hp,ZodTransform:()=>ep,ZodTuple:()=>Hm,ZodType:()=>Z,ZodULID:()=>Cs,ZodURL:()=>Ji,ZodUUID:()=>jt,ZodUndefined:()=>Cm,ZodUnion:()=>Gi,ZodUnknown:()=>Mm,ZodVoid:()=>Fm,ZodXID:()=>Zs,ZodXor:()=>Jm,_ZodString:()=>Ns,_default:()=>ip,_function:()=>j_,any:()=>p_,array:()=>J,base64:()=>H$,base64url:()=>G$,bigint:()=>u_,boolean:()=>$e,catch:()=>lp,check:()=>D_,cidrv4:()=>B$,cidrv6:()=>K$,clone:()=>re,codec:()=>O_,coerce:()=>Sp,compile:()=>Hd,config:()=>ye,core:()=>qt,creditCard:()=>X$,cuid:()=>C$,cuid2:()=>Z$,currencyCode:()=>n_,custom:()=>ec,date:()=>g_,decode:()=>Im,decodeAsync:()=>Om,deepPartial:()=>J_,describe:()=>A_,discriminatedUnion:()=>Wi,e164:()=>W$,email:()=>P$,emoji:()=>R$,encode:()=>zm,encodeAsync:()=>Pm,endsWith:()=>$n,enum:()=>Ne,exactOptional:()=>tp,file:()=>S_,flattenError:()=>pi,float32:()=>o_,float64:()=>a_,formatError:()=>hi,fromJSONSchema:()=>q_,function:()=>j_,getDiscriminatedOption:()=>vd,getErrorMap:()=>D0,globalRegistry:()=>Oe,gt:()=>Nt,gte:()=>dt,guid:()=>O$,hash:()=>i_,hex:()=>r_,hostname:()=>t_,httpUrl:()=>A$,iban:()=>Y$,includes:()=>vn,input:()=>K_,instanceof:()=>U_,int:()=>Os,int32:()=>s_,int64:()=>l_,intersection:()=>Rn,invertCodec:()=>T_,ipv4:()=>F$,ipv6:()=>J$,iso:()=>Ur,json:()=>Z_,jwt:()=>Q$,keyof:()=>v_,ksuid:()=>V$,lazy:()=>vp,length:()=>Er,literal:()=>E,locales:()=>Ai,looseObject:()=>Te,looseRecord:()=>b_,lowercase:()=>hn,lt:()=>Tt,lte:()=>lt,mac:()=>q$,map:()=>k_,maxLength:()=>Nr,maxSize:()=>tr,memoizer:()=>ji,meta:()=>R_,mime:()=>bn,minLength:()=>Ft,minSize:()=>Et,multipleOf:()=>er,nan:()=>P_,nanoid:()=>U$,nativeEnum:()=>x_,negative:()=>hs,never:()=>Ws,nonnegative:()=>vs,nonoptional:()=>sp,nonpositive:()=>gs,normalize:()=>kn,null:()=>Bi,nullable:()=>qi,nullish:()=>z_,number:()=>ee,object:()=>N,optional:()=>ae,output:()=>H_,overwrite:()=>xt,parse:()=>km,parseAsync:()=>wm,partialRecord:()=>__,pipe:()=>Ts,positive:()=>ps,prefault:()=>ap,preprocess:()=>to,prettifyError:()=>wu,promise:()=>E_,properties:()=>_n,property:()=>ys,readonly:()=>pp,record:()=>ce,refine:()=>_p,regex:()=>pn,regexes:()=>ht,registry:()=>Fa,safeDecode:()=>Nm,safeDecodeAsync:()=>jm,safeEncode:()=>Tm,safeEncodeAsync:()=>Em,safeParse:()=>xm,safeParseAsync:()=>Sm,set:()=>w_,setErrorMap:()=>j0,size:()=>Tr,slugify:()=>zn,startsWith:()=>yn,strictObject:()=>y_,string:()=>$,stringFormat:()=>e_,stringbool:()=>C_,success:()=>I_,superRefine:()=>bp,symbol:()=>f_,templateLiteral:()=>N_,toJSONSchema:()=>ks,toLowerCase:()=>xn,toUpperCase:()=>Sn,toZod:()=>oi,transform:()=>Xs,treeifyError:()=>ku,trim:()=>wn,tuple:()=>Gm,uint32:()=>c_,uint64:()=>d_,ulid:()=>L$,undefined:()=>m_,union:()=>oe,unknown:()=>le,uppercase:()=>gn,url:()=>D$,util:()=>k,uuid:()=>T$,uuidv4:()=>N$,uuidv6:()=>E$,uuidv7:()=>j$,validate:()=>sn,validateAsync:()=>cn,void:()=>h_,withParser:()=>qa,xid:()=>M$,xor:()=>$_});var Un={};Zt(Un,{ZodAny:()=>Lm,ZodArray:()=>qm,ZodBase64:()=>Js,ZodBase64URL:()=>Bs,ZodBigInt:()=>An,ZodBigIntFormat:()=>Gs,ZodBoolean:()=>Dn,ZodCIDRv4:()=>Fs,ZodCIDRv6:()=>qs,ZodCUID:()=>Rs,ZodCUID2:()=>Us,ZodCatch:()=>up,ZodCodec:()=>Qi,ZodCreditCard:()=>Am,ZodCustom:()=>eo,ZodCustomStringFormat:()=>Ar,ZodDate:()=>Ki,ZodDefault:()=>np,ZodDiscriminatedUnion:()=>Bm,ZodE164:()=>Ks,ZodEmail:()=>Es,ZodEmoji:()=>Ds,ZodEnum:()=>Nn,ZodExactOptional:()=>Ys,ZodFile:()=>Qm,ZodFunction:()=>$p,ZodGUID:()=>js,ZodIBAN:()=>Rm,ZodIPv4:()=>Ms,ZodIPv6:()=>Vs,ZodISODate:()=>sr,ZodISODateTime:()=>ar,ZodISODuration:()=>ur,ZodISOTime:()=>cr,ZodInstanceOf:()=>kp,ZodIntersection:()=>Km,ZodJWT:()=>Hs,ZodKSUID:()=>Ls,ZodLazy:()=>gp,ZodLiteral:()=>Ym,ZodMAC:()=>Dm,ZodMap:()=>Wm,ZodNaN:()=>dp,ZodNanoID:()=>As,ZodNever:()=>Vm,ZodNonOptional:()=>Qs,ZodNull:()=>Zm,ZodNullable:()=>rp,ZodNumber:()=>jn,ZodNumberFormat:()=>Rr,ZodObject:()=>Hi,ZodOptional:()=>Xi,ZodPipe:()=>Yi,ZodPrefault:()=>op,ZodPreprocess:()=>fp,ZodPromise:()=>yp,ZodReadonly:()=>mp,ZodRecord:()=>Tn,ZodSet:()=>Xm,ZodString:()=>En,ZodStringFormat:()=>se,ZodSuccess:()=>cp,ZodSymbol:()=>Um,ZodTemplateLiteral:()=>hp,ZodTransform:()=>ep,ZodTuple:()=>Hm,ZodType:()=>Z,ZodULID:()=>Cs,ZodURL:()=>Ji,ZodUUID:()=>jt,ZodUndefined:()=>Cm,ZodUnion:()=>Gi,ZodUnknown:()=>Mm,ZodVoid:()=>Fm,ZodXID:()=>Zs,ZodXor:()=>Jm,_ZodString:()=>Ns,_default:()=>ip,_function:()=>j_,any:()=>p_,array:()=>J,base64:()=>H$,base64url:()=>G$,bigint:()=>u_,boolean:()=>$e,catch:()=>lp,check:()=>D_,cidrv4:()=>B$,cidrv6:()=>K$,codec:()=>O_,creditCard:()=>X$,cuid:()=>C$,cuid2:()=>Z$,currencyCode:()=>n_,custom:()=>ec,date:()=>g_,describe:()=>A_,discriminatedUnion:()=>Wi,e164:()=>W$,email:()=>P$,emoji:()=>R$,enum:()=>Ne,exactOptional:()=>tp,file:()=>S_,float32:()=>o_,float64:()=>a_,function:()=>j_,guid:()=>O$,hash:()=>i_,hex:()=>r_,hostname:()=>t_,httpUrl:()=>A$,iban:()=>Y$,instanceof:()=>U_,int:()=>Os,int32:()=>s_,int64:()=>l_,intersection:()=>Rn,invertCodec:()=>T_,ipv4:()=>F$,ipv6:()=>J$,json:()=>Z_,jwt:()=>Q$,keyof:()=>v_,ksuid:()=>V$,lazy:()=>vp,literal:()=>E,looseObject:()=>Te,looseRecord:()=>b_,mac:()=>q$,map:()=>k_,meta:()=>R_,nan:()=>P_,nanoid:()=>U$,nativeEnum:()=>x_,never:()=>Ws,nonoptional:()=>sp,null:()=>Bi,nullable:()=>qi,nullish:()=>z_,number:()=>ee,object:()=>N,optional:()=>ae,partialRecord:()=>__,pipe:()=>Ts,prefault:()=>ap,preprocess:()=>to,promise:()=>E_,readonly:()=>pp,record:()=>ce,refine:()=>_p,set:()=>w_,strictObject:()=>y_,string:()=>$,stringFormat:()=>e_,stringbool:()=>C_,success:()=>I_,superRefine:()=>bp,symbol:()=>f_,templateLiteral:()=>N_,transform:()=>Xs,tuple:()=>Gm,uint32:()=>c_,uint64:()=>d_,ulid:()=>L$,undefined:()=>m_,union:()=>oe,unknown:()=>le,url:()=>D$,uuid:()=>T$,uuidv4:()=>N$,uuidv6:()=>E$,uuidv7:()=>j$,void:()=>h_,xid:()=>M$,xor:()=>$_});var Is={};Zt(Is,{endsWith:()=>$n,gt:()=>Nt,gte:()=>dt,includes:()=>vn,length:()=>Er,lowercase:()=>hn,lt:()=>Tt,lte:()=>lt,maxLength:()=>Nr,maxSize:()=>tr,mime:()=>bn,minLength:()=>Ft,minSize:()=>Et,multipleOf:()=>er,negative:()=>hs,nonnegative:()=>vs,nonpositive:()=>gs,normalize:()=>kn,overwrite:()=>xt,positive:()=>ps,properties:()=>_n,property:()=>ys,regex:()=>pn,size:()=>Tr,slugify:()=>zn,startsWith:()=>yn,toLowerCase:()=>xn,toUpperCase:()=>Sn,trim:()=>wn,uppercase:()=>gn});var z$=new WeakSet([Object.prototype,Error.prototype]);function Ps(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var I$=(e,t)=>{bu.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);z$.has(n)||(z$.add(n),Ps(n,"format",i=>r=>hi(i,r)),Ps(n,"flatten",i=>r=>pi(i,r)),Ps(n,"addIssue",i=>r=>{i.issues.push(r),i.message=JSON.stringify(i.issues,Yr,2)}),Ps(n,"addIssues",i=>r=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,Yr,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},O0=v("ZodError",I$),nt=v("ZodError",I$,void 0,{Parent:Error});var km=rn(nt),wm=nn(nt),xm=on(nt),Sm=an(nt),zm=ea(nt),Im=ta(nt),Pm=ra(nt),Om=na(nt),Tm=ia(nt),Nm=oa(nt),Em=aa(nt),jm=sa(nt);function N0(){ze.localeError||ye(Za())}function Dr(){ze.memoizer||ye({memoizer:ji()})}var Z=v("ZodType",(e,t)=>(N0(),U.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(k.mergeDefs(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return re(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(_p(e,t))},superRefine(e,t){return this.check(bp(e,t))},overwrite(e){return this.check(xt(e))},optional(){return ae(this)},exactOptional(){return tp(this)},nullable(){return qi(this)},nullish(){return ae(qi(this))},nonoptional(e){return sp(this,e)},array(){return J(this)},or(e){return oe([this,e])},and(e){return Rn(this,e)},transform(e){return Ts(this,Xs(e))},default(e){return ip(this,e)},prefault(e){return ap(this,e)},catch(e){return lp(this,e)},pipe(e){return Ts(this,e)},readonly(){return pp(this)},describe(e){let t=this.clone();return Oe.add(t,{description:e}),t},meta(...e){if(e.length===0)return Oe.get(this);let t=this.clone();return Oe.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 k.hide(this,"~standard",{...ya(this),jsonSchema:{input:In(this,"input"),output:In(this,"output")}})},set"~standard"(e){k.own(this,"~standard",e)},parse:function e(t,n){return km(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await wm(this,t,n,{callee:e})},safeParse(e,t){return xm(this,e,t)},async safeParseAsync(e,t){return Sm(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){k.own(this,"spa",e)},validate(e,t){return sn(this,e,t)},validateAsync(e,t){return cn(this,e,t)},encode:function e(t,n){return zm(this,t,n,{callee:e})},decode:function e(t,n){return Im(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Pm(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Om(this,t,n,{callee:e})},safeEncode(e,t){return Tm(this,e,t)},safeDecode(e,t){return Nm(this,e,t)},async safeEncodeAsync(e,t){return Em(this,e,t)},async safeDecodeAsync(e,t){return jm(this,e,t)},toJSONSchema(e){return Af(this,{})(e)},get description(){return Oe.get(this)?.description},get _def(){return this._zod.def}}),Ns=v("_ZodString",(e,t)=>{Sr.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Cf(e,n,i,r)},k.derived({format:e=>xe(e).format??null,minLength:e=>xe(e).minimum??null,maxLength:e=>xe(e).maximum??null},{regex(...e){return this.check(pn(...e))},includes(...e){return this.check(vn(...e))},startsWith(...e){return this.check(yn(...e))},endsWith(...e){return this.check($n(...e))},min(...e){return this.check(Ft(...e))},max(...e){return this.check(Nr(...e))},length(...e){return this.check(Er(...e))},nonempty(...e){return this.check(Ft(1,...e))},lowercase(e){return this.check(hn(e))},uppercase(e){return this.check(gn(e))},trim(){return this.check(wn())},normalize(...e){return this.check(kn(...e))},toLowerCase(){return this.check(xn())},toUpperCase(){return this.check(Sn())},slugify(){return this.check(zn())}})),En=v("ZodString",(e,t)=>{Sr.init(e,t),Ns.init(e,t)},{email(e){return this.check(Ka(Es,e))},url(e){return this.check(Ri(Ji,e))},jwt(e){return this.check(ms(Hs,e))},emoji(e){return this.check(Qa(Ds,e))},guid(e){return this.check(Ha(js,e))},uuid(e){return this.check(Ga(jt,e))},uuidv4(e){return this.check(Wa(jt,e))},uuidv6(e){return this.check(Xa(jt,e))},uuidv7(e){return this.check(Ya(jt,e))},nanoid(e){return this.check(es(As,e))},cuid(e){return this.check(ts(Rs,e))},cuid2(e){return this.check(rs(Us,e))},ulid(e){return this.check(ns(Cs,e))},base64(e){return this.check(ls(Js,e))},base64url(e){return this.check(ds(Bs,e))},xid(e){return this.check(is(Zs,e))},ksuid(e){return this.check(os(Ls,e))},ipv4(e){return this.check(as(Ms,e))},ipv6(e){return this.check(ss(Vs,e))},cidrv4(e){return this.check(cs(Fs,e))},cidrv6(e){return this.check(us(qs,e))},e164(e){return this.check(fs(Ks,e))},datetime(e){return this.check(Ui(ar,e))},date(e){return this.check(Ci(sr,e))},time(e){return this.check(Zi(cr,e))},duration(e){return this.check(Li(ur,e))}});function $(e){return Wd(En,e)}var se=v("ZodStringFormat",(e,t)=>{ne.init(e,t),Ns.init(e,t)}),ar=v("ZodISODateTime",(e,t)=>{Vl.init(e,t),se.init(e,t)}),sr=v("ZodISODate",(e,t)=>{Fl.init(e,t),se.init(e,t)}),cr=v("ZodISOTime",(e,t)=>{ql.init(e,t),se.init(e,t)}),ur=v("ZodISODuration",(e,t)=>{Jl.init(e,t),se.init(e,t)}),Es=v("ZodEmail",(e,t)=>{Nl.init(e,t),se.init(e,t)});function P$(e){return Ka(Es,e)}var js=v("ZodGUID",(e,t)=>{Ol.init(e,t),se.init(e,t)});function O$(e){return Ha(js,e)}var jt=v("ZodUUID",(e,t)=>{Tl.init(e,t),se.init(e,t)});function T$(e){return Ga(jt,e)}function N$(e){return Wa(jt,e)}function E$(e){return Xa(jt,e)}function j$(e){return Ya(jt,e)}var Ji=v("ZodURL",(e,t)=>{Dl.init(e,t),se.init(e,t)});function D$(e){return Ri(Ji,e)}function A$(e){return Ri(Ji,{protocol:yi,hostname:Ju,...k.normalizeParams(e)})}var Ds=v("ZodEmoji",(e,t)=>{Al.init(e,t),se.init(e,t)});function R$(e){return Qa(Ds,e)}var As=v("ZodNanoID",(e,t)=>{Rl.init(e,t),se.init(e,t)});function U$(e){return es(As,e)}var Rs=v("ZodCUID",(e,t)=>{Ul.init(e,t),se.init(e,t)});function C$(e){return ts(Rs,e)}var Us=v("ZodCUID2",(e,t)=>{Cl.init(e,t),se.init(e,t)});function Z$(e){return rs(Us,e)}var Cs=v("ZodULID",(e,t)=>{Zl.init(e,t),se.init(e,t)});function L$(e){return ns(Cs,e)}var Zs=v("ZodXID",(e,t)=>{Ll.init(e,t),se.init(e,t)});function M$(e){return is(Zs,e)}var Ls=v("ZodKSUID",(e,t)=>{Ml.init(e,t),se.init(e,t)});function V$(e){return os(Ls,e)}var Ms=v("ZodIPv4",(e,t)=>{Bl.init(e,t),se.init(e,t)});function F$(e){return as(Ms,e)}var Dm=v("ZodMAC",(e,t)=>{Hl.init(e,t),se.init(e,t)});function q$(e){return Yd(Dm,e)}var Vs=v("ZodIPv6",(e,t)=>{Kl.init(e,t),se.init(e,t)});function J$(e){return ss(Vs,e)}var Fs=v("ZodCIDRv4",(e,t)=>{Gl.init(e,t),se.init(e,t)});function B$(e){return cs(Fs,e)}var qs=v("ZodCIDRv6",(e,t)=>{Wl.init(e,t),se.init(e,t)});function K$(e){return us(qs,e)}var Js=v("ZodBase64",(e,t)=>{Xl.init(e,t),se.init(e,t)});function H$(e){return ls(Js,e)}var Bs=v("ZodBase64URL",(e,t)=>{Yl.init(e,t),se.init(e,t)});function G$(e){return ds(Bs,e)}var Ks=v("ZodE164",(e,t)=>{Ql.init(e,t),se.init(e,t)});function W$(e){return fs(Ks,e)}var Am=v("ZodCreditCard",(e,t)=>{ed.init(e,t),se.init(e,t)});function X$(e){return Qd(Am,e)}var Rm=v("ZodIBAN",(e,t)=>{td.init(e,t),se.init(e,t)});function Y$(e){return ef(Rm,e)}var Hs=v("ZodJWT",(e,t)=>{rd.init(e,t),se.init(e,t)});function Q$(e){return ms(Hs,e)}var Ar=v("ZodCustomStringFormat",(e,t)=>{nd.init(e,t),se.init(e,t)});function e_(e,t,n={}){return jr(Ar,e,t,n)}function t_(e){return jr(Ar,"hostname",qu,e)}function r_(e){return jr(Ar,"hex",ol,e)}function n_(e){return jr(Ar,"currency_code",Ku,e)}function i_(e,t){let n=t?.enc??"hex",i=`${e}_${n}`,r=ht[i];if(!r)throw new Error(`Unrecognized hash format: ${i}`);return jr(Ar,i,r,t)}var jn=v("ZodNumber",(e,t)=>{Pa.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Zf(e,n,i,r),e.isFinite=!0},k.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=xe(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=xe(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:n}=xe(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>xe(e).format??null},{gt(e,t){return this.check(Nt(e,t))},gte(e,t){return this.check(dt(e,t))},min(e,t){return this.check(dt(e,t))},lt(e,t){return this.check(Tt(e,t))},lte(e,t){return this.check(lt(e,t))},max(e,t){return this.check(lt(e,t))},int(e){return this.check(Os(e))},safe(e){return this.check(Os(e))},positive(e){return this.check(Nt(0,e))},nonnegative(e){return this.check(dt(0,e))},negative(e){return this.check(Tt(0,e))},nonpositive(e){return this.check(lt(0,e))},multipleOf(e,t){return this.check(er(e,t))},step(e,t){return this.check(er(e,t))},finite(){return this}}));function ee(e){return rf(jn,e)}var Rr=v("ZodNumberFormat",(e,t)=>{id.init(e,t),jn.init(e,t)});function Os(e){return of(Rr,e)}function o_(e){return af(Rr,e)}function a_(e){return sf(Rr,e)}function s_(e){return cf(Rr,e)}function c_(e){return uf(Rr,e)}var Dn=v("ZodBoolean",(e,t)=>{Ii.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Lf(e,n,i,r)});function $e(e){return lf(Dn,e)}var An=v("ZodBigInt",(e,t)=>{Oa.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Mf(e,n,i,r)},k.derived({minValue:e=>xe(e).minimum??null,maxValue:e=>xe(e).maximum??null,format:e=>xe(e).format??null},{gte(e,t){return this.check(dt(e,t))},min(e,t){return this.check(dt(e,t))},gt(e,t){return this.check(Nt(e,t))},lt(e,t){return this.check(Tt(e,t))},lte(e,t){return this.check(lt(e,t))},max(e,t){return this.check(lt(e,t))},positive(e){return this.check(Nt(BigInt(0),e))},negative(e){return this.check(Tt(BigInt(0),e))},nonpositive(e){return this.check(lt(BigInt(0),e))},nonnegative(e){return this.check(dt(BigInt(0),e))},multipleOf(e,t){return this.check(er(e,t))}}));function u_(e){return ff(An,e)}var Gs=v("ZodBigIntFormat",(e,t)=>{od.init(e,t),An.init(e,t)});function l_(e){return pf(Gs,e)}function d_(e){return hf(Gs,e)}var Um=v("ZodSymbol",(e,t)=>{ad.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Vf(e,n,i,r)});function f_(e){return gf(Um,e)}var Cm=v("ZodUndefined",(e,t)=>{sd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>qf(e,n,i,r)});function m_(e){return vf(Cm,e)}var Zm=v("ZodNull",(e,t)=>{cd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Ff(e,n,i,r)});function Bi(e){return yf(Zm,e)}var Lm=v("ZodAny",(e,t)=>{ud.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Kf(e,n,i,r)});function p_(){return $f(Lm)}var Mm=v("ZodUnknown",(e,t)=>{ld.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Hf(e,n,i,r)});function le(){return _f(Mm)}var Vm=v("ZodNever",(e,t)=>{dd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Bf(e,n,i,r)});function Ws(e){return bf(Vm,e)}var Fm=v("ZodVoid",(e,t)=>{fd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Jf(e,n,i,r)});function h_(e){return kf(Fm,e)}var Ki=v("ZodDate",(e,t)=>{md.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Gf(e,n,i,r),e.min=(n,i)=>e.check(dt(n,i)),e.max=(n,i)=>e.check(lt(n,i))},k.derived({minDate:e=>{let{minimum:t}=xe(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=xe(e);return t?new Date(t):null}},{}));function g_(e){return wf(Ki,e)}var qm=v("ZodArray",(e,t)=>{Dr(),pd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>sm(e,n,i,r),e.element=t.element},{min(e,t){return this.check(Ft(e,t))},nonempty(e){return this.check(Ft(1,e))},max(e,t){return this.check(Nr(e,t))},length(e,t){return this.check(Er(e,t))},unwrap(){return this.element}});function J(e,t){return zf(qm,e,t)}function v_(e){let t=e._zod.def.shape;return Ne(Object.keys(t))}var Hi=v("ZodObject",(e,t)=>{Dr(),hd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>cm(e,n,i,r),k.installLazyProp(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return Ne(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(k.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(k.mergeDefs(this._zod.def,{catchall:le()}))},loose(){return this.clone(k.mergeDefs(this._zod.def,{catchall:le()}))},strict(){return this.clone(k.mergeDefs(this._zod.def,{catchall:Ws()}))},strip(){return this.clone(k.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return k.extend(this,e)},safeExtend(e){return k.safeExtend(this,e)},merge(e){return k.merge(this,e)},pick(e){return k.pick(this,e)},omit(e){return k.omit(this,e)},partial(...e){return k.partial(Xi,this,e[0])},exactPartial(...e){return k.partial(Ys,this,e[0],"exactPartial")},required(...e){return k.required(Qs,this,e[0])}});function N(e,t){let n={type:"object",shape:e??{},...k.normalizeParams(t)};return new Hi(n)}function y_(e,t){return new Hi({type:"object",shape:e,catchall:Ws(),...k.normalizeParams(t)})}function Te(e,t){return new Hi({type:"object",shape:e,catchall:le(),...k.normalizeParams(t)})}var Gi=v("ZodUnion",(e,t)=>{Pi.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_s(e,n,i,r),e.options=t.options});function oe(e,t){return new Gi({type:"union",options:e,...k.normalizeParams(t)})}var Jm=v("ZodXor",(e,t)=>{Gi.init(e,t),gd.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_s(e,n,i,r),e.options=t.options});function $_(e,t){return new Jm({type:"union",options:e,inclusive:!1,...k.normalizeParams(t)})}var Bm=v("ZodDiscriminatedUnion",(e,t)=>{Gi.init(e,t),yd.init(e,t)});function Wi(e,t,n){return new Bm({type:"union",options:t,discriminator:e,...k.normalizeParams(n)})}var Km=v("ZodIntersection",(e,t)=>{$d.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>um(e,n,i,r)});function Rn(e,t){return new Km({type:"intersection",left:e,right:t})}var Hm=v("ZodTuple",(e,t)=>{Dr(),Ta.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>lm(e,n,i,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new Xi({type:"optional",innerType:t}))})}});function Gm(e,t,n){let i=t instanceof U,r=i?n:t,o=i?t:null;return new Hm({type:"tuple",items:e,rest:o,...k.normalizeParams(r)})}var Tn=v("ZodRecord",(e,t)=>{Dr(),_d.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>dm(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function ce(e,t,n){return!t||!t._zod?new Tn({type:"record",keyType:$(),valueType:e,...k.normalizeParams(t)}):new Tn({type:"record",keyType:e,valueType:t,...k.normalizeParams(n)})}function __(e,t,n){return new Tn({type:"record",keyType:e,valueType:t,...k.normalizeParams(n),partial:!0})}function b_(e,t,n){return new Tn({type:"record",keyType:e,valueType:t,mode:"loose",...k.normalizeParams(n)})}var Wm=v("ZodMap",(e,t)=>{Dr(),bd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>om(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(Et(...n)),e.nonempty=n=>e.check(Et(1,n)),e.max=(...n)=>e.check(tr(...n)),e.size=(...n)=>e.check(Tr(...n))});function k_(e,t,n){return new Wm({type:"map",keyType:e,valueType:t,...k.normalizeParams(n)})}var Xm=v("ZodSet",(e,t)=>{Dr(),kd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>am(e,n,i,r),e.min=(...n)=>e.check(Et(...n)),e.nonempty=n=>e.check(Et(1,n)),e.max=(...n)=>e.check(tr(...n)),e.size=(...n)=>e.check(Tr(...n))});function w_(e,t){return new Xm({type:"set",valueType:e,...k.normalizeParams(t)})}var Nn=v("ZodEnum",(e,t)=>{wd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(i,r,o)=>Wf(e,i,r,o),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let o={};for(let a of i)if(n.has(a))o[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Nn({...t,checks:[],...k.normalizeParams(r),entries:o})},e.exclude=(i,r)=>{let o={...t.entries};for(let a of i)if(n.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new Nn({...t,checks:[],...k.normalizeParams(r),entries:o})}});function Ne(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new Nn({type:"enum",entries:n,...k.normalizeParams(t)})}function x_(e,t){return new Nn({type:"enum",entries:e,...k.normalizeParams(t)})}var Ym=v("ZodLiteral",(e,t)=>{xd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Xf(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function E(e,t){return new Ym({type:"literal",values:Array.isArray(e)?e:[e],...k.normalizeParams(t)})}var Qm=v("ZodFile",(e,t)=>{Sd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>em(e,n,i,r),e.min=(n,i)=>e.check(Et(n,i)),e.max=(n,i)=>e.check(tr(n,i)),e.mime=(n,i)=>e.check(bn(Array.isArray(n)?n:[n],i))});function S_(e){return If(Qm,e)}var ep=v("ZodTransform",(e,t)=>{Dr(),zd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>im(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Qt(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(k.issue(o,n.value,t));else{let a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=n.value),a.inst??(a.inst=e),n.issues.push(k.issue(a))}};let r=t.transform(n.value,n);return r instanceof Promise?r.then(o=>(n.value=o,n)):(n.value=r,n)}});function Xs(e){return new ep({type:"transform",transform:e})}var Xi=v("ZodOptional",(e,t)=>{Na.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>bs(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function ae(e){return new Xi({type:"optional",innerType:e})}var Ys=v("ZodExactOptional",(e,t)=>{Id.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>bs(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function tp(e){return new Ys({type:"optional",innerType:e})}var rp=v("ZodNullable",(e,t)=>{Pd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>fm(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function qi(e){return new rp({type:"nullable",innerType:e})}function z_(e){return ae(qi(e))}var np=v("ZodDefault",(e,t)=>{Od.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>hm(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ip(e,t){return new np({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():k.shallowClone(t)}})}var op=v("ZodPrefault",(e,t)=>{Td.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>gm(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function ap(e,t){return new op({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():k.shallowClone(t)}})}var Qs=v("ZodNonOptional",(e,t)=>{Nd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>mm(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function sp(e,t){return new Qs({type:"nonoptional",innerType:e,...k.normalizeParams(t)})}var cp=v("ZodSuccess",(e,t)=>{Ed.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>tm(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function I_(e){return new cp({type:"success",innerType:e})}var up=v("ZodCatch",(e,t)=>{jd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>vm(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function lp(e,t){return new up({type:"catch",innerType:e,catchValue:typeof t=="function"?t:k.constantCatch(t)})}var dp=v("ZodNaN",(e,t)=>{Dd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Yf(e,n,i,r)});function P_(e){return Sf(dp,e)}var Yi=v("ZodPipe",(e,t)=>{Ea.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>ym(e,n,i,r),e.in=t.in,e.out=t.out});function Ts(e,t){return new Yi({type:"pipe",in:e,out:t})}var Qi=v("ZodCodec",(e,t)=>{Yi.init(e,t),Oi.init(e,t)});function O_(e,t,n){return new Qi({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function T_(e){let t=e._zod.def;return new Qi({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var fp=v("ZodPreprocess",(e,t)=>{Yi.init(e,t),Ad.init(e,t)}),mp=v("ZodReadonly",(e,t)=>{Rd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>$m(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function pp(e){return new mp({type:"readonly",innerType:e})}var hp=v("ZodTemplateLiteral",(e,t)=>{Ud.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Qf(e,n,i,r)});function N_(e,t){return new hp({type:"template_literal",parts:e,...k.normalizeParams(t)})}var gp=v("ZodLazy",(e,t)=>{Ti.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>bm(e,n,i,r),e.unwrap=()=>e._zod.def.getter()});function vp(e){return new gp({type:"lazy",getter:e})}var yp=v("ZodPromise",(e,t)=>{Zd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>_m(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function E_(e){return new yp({type:"promise",innerType:e})}var $p=v("ZodFunction",(e,t)=>{Cd.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>nm(e,n,i,r)});function j_(e){return new $p({type:"function",input:Array.isArray(e?.input)?Gm(e?.input):e?.input??J(le()),output:e?.output??le()})}var eo=v("ZodCustom",(e,t)=>{Ld.init(e,t),Z.init(e,t),e._zod.processJSONSchema=(n,i,r)=>rm(e,n,i,r)});function D_(e){let t=new ue({check:"custom"});return t._zod.check=e,t}function ec(e,t){return Pf(eo,e??(()=>!0),t)}function _p(e,t={}){return Of(eo,e,t)}function bp(e,t){return Tf(e,t)}var A_=Nf,R_=Ef,kp=v("ZodInstanceOf",(e,t)=>{eo.init(e,t)},{properties(e,t){return this.check(_n(e,t))}});function U_(e,t={}){let n=new kp({type:"custom",check:"custom",fn:i=>i instanceof e,abort:!0,...k.normalizeParams(t)});return n._zod.bag.Class=e,n._zod.check=i=>{i.value instanceof e||i.issues.push({code:"invalid_type",expected:e.name,input:i.value,inst:n,path:[...n._zod.def.path??[]]})},n}var C_=(...e)=>jf({Codec:Qi,Boolean:Dn,String:En},...e);function Z_(e){let t=vp(()=>oe([$(e),ee(),$e(),Bi(),J(t),ce($(),t)]));return t}function to(e,t){return new fp({type:"pipe",in:Xs(e),out:t})}var E0={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function j0(e){ye({customError:e})}function D0(){return ye().customError}var wp;wp||(wp={});var Ur={};Zt(Ur,{ZodISODate:()=>sr,ZodISODateTime:()=>ar,ZodISODuration:()=>ur,ZodISOTime:()=>cr,date:()=>R0,datetime:()=>A0,duration:()=>C0,time:()=>U0});function A0(e){return Ui(ar,e)}function R0(e){return Ci(sr,e)}function U0(e){return Zi(cr,e)}function C0(e){return Li(ur,e)}var P={...Un,...Is,iso:Ur},Z0=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function L0(e,t){let n=e.$schema;return n==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":n==="http://json-schema.org/draft-07/schema#"?"draft-7":n==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function L_(e,t){return e.map((n,i)=>i<t?n:n.optional())}function M0(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function V0(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let n=e.slice(1).split("/").filter(Boolean);if(n.length===0)return t.rootSchema;let i=t.version==="draft-2020-12"?"$defs":"definitions";if(n[0]===i){let r=n[1]===void 0?void 0:M0(n[1]);if(!r||!t.defs[r])throw new Error(`Reference not found: ${e}`);return t.defs[r]}throw new Error(`Reference not found: ${e}`)}function F0(e,t){return P.transform(i=>i).check(i=>{let r=i.value;if(typeof r!="object"||r===null||Array.isArray(r))return;let o=Object.getOwnPropertyNames(r);if(t.minProperties!==void 0&&o.length<t.minProperties&&i.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:r,inst:e,continue:!0}),t.maxProperties!==void 0&&o.length>t.maxProperties&&i.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:r,inst:e,continue:!0}),t.keySchema)for(let a of o){let s=t.keySchema.safeParse(a);s.success||i.issues.push({code:"invalid_key",origin:"record",issues:s.error.issues,input:a,path:[a],continue:!0})}}).pipe(e)}function xp(e,t){if(e===null)return"z";let n=typeof e;if(n!=="object"){if(n==="number"&&Number.isNaN(e))return null;let i=String(e);return`${n[0]}${i.length}:${i}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let o=[];for(let a of e){let s=xp(a,t);if(s===null)return null;o.push(s)}return`a${o.length}:[${o.join(",")}]`}let i=Object.keys(e).sort(),r=[];for(let o of i){let a=xp(e[o],t);if(a===null)return null;r.push(`${o.length}:${o}=${a}`)}return`o${r.length}:{${r.join(",")}}`}finally{t.delete(e)}}var q0=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),J0=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function ro(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(ro):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,n])=>q0.has(t)?ro(n):!J0.has(t)||typeof n!="object"||n===null?!1:Object.values(n).some(ro))}function M_(e){return e===1?"element":"elements"}function B0(e,t){return P.transform(i=>i).check(i=>{let r=i.value;if(Array.isArray(r)){if(t.uniqueItems===!0){let o=new Map;for(let a=0;a<r.length;a++){let s=xp(r[a],new Set);if(s===null)continue;let c=o.get(s);if(c===void 0){o.set(s,a);continue}i.issues.push({code:"custom",message:`Array items must be unique: element at index ${a} duplicates the one at index ${c}`,input:r,path:[a],continue:!0})}}if(t.containsSchema){let o=t.minContains??1,a=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY,s=0;for(let c of r)if(t.containsSchema.safeParse(c).success&&++s>=a)break;s<o&&i.issues.push({code:"custom",message:`Array must contain at least ${o} matching ${M_(o)}; found ${s}`,input:r,continue:!0}),t.maxContains!==void 0&&s>t.maxContains&&i.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${M_(t.maxContains)}`,input:r,continue:!0})}}}).pipe(e)}function V_(e,t){if(e!==!1)return e===void 0||e===!0?P.any():We(e,t)}var K0=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function F_(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return P.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let r=e.$ref;if(t.refs.has(r))return t.refs.get(r);if(t.processing.has(r))return P.lazy(()=>{if(!t.refs.has(r))throw new Error(`Circular reference not resolved: ${r}`);return t.refs.get(r)});t.processing.add(r);let o=V0(r,t),a=We(o,t);return t.refs.set(r,a),t.processing.delete(r),a}if(e.enum!==void 0){let r=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&r.length===1&&r[0]===null)return P.null();if(r.length===0)return P.never();if(r.length===1)return P.literal(r[0]);if(r.every(a=>typeof a=="string"))return P.enum(r);let o=r.map(a=>P.literal(a));return o.length<2?o[0]:P.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return P.literal(e.const);let n=e.type;if(Array.isArray(n)){let r=n.map(o=>{let a={...e,type:o};return F_(a,t)});return r.length===0?P.never():r.length===1?r[0]:P.union(r)}if(!n)return P.any();let i;switch(n){case"string":{let r=P.string();if(e.format){let o=e.format;o==="email"?r=r.check(P.email()):o==="uri"||o==="uri-reference"?r=r.check(P.url()):o==="uuid"||o==="guid"?r=r.check(P.uuid()):o==="date-time"?r=r.check(P.iso.datetime({offset:!0})):o==="date"?r=r.check(P.iso.date()):o==="time"?r=r.check(P.regex(K0)):o==="duration"?r=r.check(P.iso.duration()):o==="hostname"?r=r.check(P.hostname()):o==="ipv4"?r=r.check(P.ipv4()):o==="ipv6"?r=r.check(P.ipv6()):o==="mac"?r=r.check(P.mac()):o==="cidr"?r=r.check(P.cidrv4()):o==="cidr-v6"?r=r.check(P.cidrv6()):o==="base64"?r=r.check(P.base64()):o==="base64url"?r=r.check(P.base64url()):o==="e164"?r=r.check(P.e164()):o==="credit_card"?r=r.check(P.creditCard()):o==="iban"?r=r.check(P.iban()):o==="jwt"?r=r.check(P.jwt()):o==="emoji"?r=r.check(P.emoji()):o==="nanoid"?r=r.check(P.nanoid()):o==="cuid"?r=r.check(P.cuid()):o==="cuid2"?r=r.check(P.cuid2()):o==="ulid"?r=r.check(P.ulid()):o==="xid"?r=r.check(P.xid()):o==="ksuid"&&(r=r.check(P.ksuid()))}typeof e.minLength=="number"&&(r=r.min(e.minLength)),typeof e.maxLength=="number"&&(r=r.max(e.maxLength)),e.pattern&&(r=r.regex(new RegExp(e.pattern))),i=r;break}case"number":case"integer":{let r=n==="integer"?P.number().int():P.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(r=r.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(r=r.max(e.maximum)),typeof e.exclusiveMinimum=="number"?r=r.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(r=r.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?r=r.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(r=r.lt(e.maximum)),typeof e.multipleOf=="number"&&(r=r.multipleOf(e.multipleOf)),i=r;break}case"boolean":{i=P.boolean();break}case"null":{i=P.null();break}case"object":{let r={},o=e.properties||{},a=new Set(e.required||[]),s=typeof e.additionalProperties=="object"?We(e.additionalProperties,t):void 0;for(let[d,m]of Object.entries(o)){let f=We(m,t);Pe(r,d,a.has(d)?f:f.optional())}if(e.patternProperties){let d=e.patternProperties,m=Object.keys(d),f=[];for(let h of m){let g=We(d[h],t),b=P.string().regex(new RegExp(h));f.push(P.looseRecord(b,g))}let p=[];if(Object.keys(r).length>0&&p.push(P.object(r).passthrough()),p.push(...f),p.length===0)i=P.object({}).passthrough();else if(p.length===1)i=p[0];else{let h=P.intersection(p[0],p[1]);for(let g=2;g<p.length;g++)h=P.intersection(h,p[g]);i=h}if(e.additionalProperties===!1){let h=Object.keys(r),g=m.map(_=>new RegExp(_)),b=i;i=i.check(_=>{if(!mt(_.value))return;let S=[];for(let O of Object.keys(_.value))h.includes(O)||g.some(I=>I.test(O))||S.push(O);S.length&&_.issues.push({code:"unrecognized_keys",keys:S,input:_.value,inst:b})})}}else{let d=P.object(r);e.additionalProperties===!1?i=d.strict():s?i=d.catchall(s):i=d.passthrough()}let c=e.propertyNames!==void 0&&e.propertyNames!==!0,u=typeof e.minProperties=="number"?e.minProperties:void 0,l=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(c||u!==void 0||l!==void 0){let d;if(c){let m=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;d=We(m,t)}i=F0(i,{keySchema:d,minProperties:u,maxProperties:l})}break}case"array":{let r=e.prefixItems,o=e.items;if(r&&Array.isArray(r)){let a=typeof e.minItems=="number"?e.minItems:0,s=r.map(d=>We(d,t)),c=L_(s,a),u=Array.isArray(o)?void 0:V_(o,t),l=P.tuple(c);i=u?l.rest(u):l,typeof e.minItems=="number"&&(i=i.check(P.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(P.maxLength(e.maxItems)))}else if(Array.isArray(o)){let a=typeof e.minItems=="number"?e.minItems:0,s=o.map(d=>We(d,t)),c=L_(s,a),u=V_(e.additionalItems,t),l=P.tuple(c);i=u?l.rest(u):l,typeof e.minItems=="number"&&(i=i.check(P.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(P.maxLength(e.maxItems)))}else if(o!==void 0){let a=We(o,t),s=P.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),i=s}else i=P.array(P.any());(e.uniqueItems===!0||e.contains!==void 0)&&(i=B0(i,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?We(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${n}`)}return i}function We(e,t){if(typeof e=="boolean")return e?P.any():P.never();let n=F_(e,t),i=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(u=>We(u,t)),c=P.union(s);n=i?P.intersection(n,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(u=>We(u,t)),c=P.xor(s);n=i?P.intersection(n,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=i?n:P.any();else{let s=i?n:We(e.allOf[0],t),c=i?0:1;for(let u=c;u<e.allOf.length;u++)s=P.intersection(s,We(e.allOf[u],t));n=s}e.nullable===!0&&t.version==="openapi-3.0"&&(n=P.nullable(n)),e.readOnly===!0&&(n=P.readonly(n)),e.default!==void 0&&(n=n.default(e.default));let r={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of o)s in e&&(r[s]=e[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in e&&(r[s]=e[s]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!ro(e.propertyNames)&&(r.propertyNames=e.propertyNames);for(let s of["minProperties","maxProperties"])e[s]!==void 0&&(r[s]=e[s])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!ro(e.contains)&&(r.contains=e.contains);for(let s of["uniqueItems","minContains","maxContains"])e[s]!==void 0&&(r[s]=e[s])}for(let s of Object.keys(e))Z0.has(s)||Pe(r,s,e[s]);return Object.keys(r).length>0&&t.registry.add(n,r),e.description&&(n=n.describe(e.description)),n}function q_(e,t){if(typeof e=="boolean")return e?P.any():P.never();let n;try{n=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let i=L0(n,t?.defaultTarget),r=n.$defs||n.definitions||{},o={version:i,defs:r,refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??Oe};return We(n,o)}function J_(e){return Fi(e,{object:t=>t.partial(),union:t=>{let n=t._zod.def;return n.discriminator===void 0?t:oe(n.options)}})}function H0(e,t){if(!t?.length)return e;let n=e._zod.def;return re(e,kt(n,{checks:[...n.checks??[],...t]}),{parent:!0})}function B_(e){return H0(e.out,e.checks)}function G0(e){return e.in._zod.traits.has("$ZodTransform")?B_(e):e.in}function K_(e){return Fi(e,{pipe:t=>G0(t._zod.def),default:(t,n)=>n?ae(t._zod.def.innerType):t,catch:(t,n)=>n?t._zod.def.innerType:t})}function H_(e){return Fi(e,{pipe:t=>B_(t._zod.def),prefault:(t,n)=>n?t._zod.def.innerType:t})}var Sp={};Zt(Sp,{bigint:()=>Q0,boolean:()=>Y0,date:()=>eP,number:()=>X0,string:()=>W0});function W0(e){return Xd(En,e)}function X0(e){return nf(jn,e)}function Y0(e){return df(Dn,e)}function Q0(e){return mf(An,e)}function eP(e){return xf(Ki,e)}var Ip="2025-11-25";var G_=[Ip,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],lr="io.modelcontextprotocol/related-task",rc="2.0",Se=ec(e=>e!==null&&(typeof e=="object"||typeof e=="function")),W_=oe([$(),ee().int()]),X_=$(),YU=Te({ttl:ee().optional(),pollInterval:ee().optional()}),tP=N({ttl:ee().optional()}),rP=N({taskId:$()}),Pp=Te({progressToken:W_.optional(),[lr]:rP.optional()}),ft=N({_meta:Pp.optional()}),no=ft.extend({task:tP.optional()}),Y_=e=>no.safeParse(e).success,Ee=N({method:$(),params:ft.loose().optional()}),gt=N({_meta:Pp.optional()}),vt=N({method:$(),params:gt.loose().optional()}),je=Te({_meta:Pp.optional()}),nc=oe([$(),ee().int()]),Q_=N({jsonrpc:E(rc),id:nc,...Ee.shape}).strict(),Op=e=>Q_.safeParse(e).success,eb=N({jsonrpc:E(rc),...vt.shape}).strict(),tb=e=>eb.safeParse(e).success,Tp=N({jsonrpc:E(rc),id:nc,result:je}).strict(),io=e=>Tp.safeParse(e).success;var G;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(G||(G={}));var Np=N({jsonrpc:E(rc),id:nc.optional(),error:N({code:ee().int(),message:$(),data:le().optional()})}).strict();var rb=e=>Np.safeParse(e).success;var nb=oe([Q_,eb,Tp,Np]),QU=oe([Tp,Np]),ic=je.strict(),nP=gt.extend({requestId:nc.optional(),reason:$().optional()}),oc=vt.extend({method:E("notifications/cancelled"),params:nP}),iP=N({src:$(),mimeType:$().optional(),sizes:J($()).optional(),theme:Ne(["light","dark"]).optional()}),oo=N({icons:J(iP).optional()}),Cn=N({name:$(),title:$().optional()}),ib=Cn.extend({...Cn.shape,...oo.shape,version:$(),websiteUrl:$().optional(),description:$().optional()}),oP=Rn(N({applyDefaults:$e().optional()}),ce($(),le())),aP=to(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Rn(N({form:oP.optional(),url:Se.optional()}),ce($(),le()).optional())),sP=Te({list:Se.optional(),cancel:Se.optional(),requests:Te({sampling:Te({createMessage:Se.optional()}).optional(),elicitation:Te({create:Se.optional()}).optional()}).optional()}),cP=Te({list:Se.optional(),cancel:Se.optional(),requests:Te({tools:Te({call:Se.optional()}).optional()}).optional()}),uP=N({experimental:ce($(),Se).optional(),sampling:N({context:Se.optional(),tools:Se.optional()}).optional(),elicitation:aP.optional(),roots:N({listChanged:$e().optional()}).optional(),tasks:sP.optional(),extensions:ce($(),Se).optional()}),lP=ft.extend({protocolVersion:$(),capabilities:uP,clientInfo:ib}),Ep=Ee.extend({method:E("initialize"),params:lP});var dP=N({experimental:ce($(),Se).optional(),logging:Se.optional(),completions:Se.optional(),prompts:N({listChanged:$e().optional()}).optional(),resources:N({subscribe:$e().optional(),listChanged:$e().optional()}).optional(),tools:N({listChanged:$e().optional()}).optional(),tasks:cP.optional(),extensions:ce($(),Se).optional()}),fP=je.extend({protocolVersion:$(),capabilities:dP,serverInfo:ib,instructions:$().optional()}),jp=vt.extend({method:E("notifications/initialized"),params:gt.optional()});var ac=Ee.extend({method:E("ping"),params:ft.optional()}),mP=N({progress:ee(),total:ae(ee()),message:ae($())}),pP=N({...gt.shape,...mP.shape,progressToken:W_}),sc=vt.extend({method:E("notifications/progress"),params:pP}),hP=ft.extend({cursor:X_.optional()}),ao=Ee.extend({params:hP.optional()}),so=je.extend({nextCursor:X_.optional()}),gP=Ne(["working","input_required","completed","failed","cancelled"]),co=N({taskId:$(),status:gP,ttl:oe([ee(),Bi()]),createdAt:$(),lastUpdatedAt:$(),pollInterval:ae(ee()),statusMessage:ae($())}),Zn=je.extend({task:co}),vP=gt.merge(co),uo=vt.extend({method:E("notifications/tasks/status"),params:vP}),cc=Ee.extend({method:E("tasks/get"),params:ft.extend({taskId:$()})}),uc=je.merge(co),lc=Ee.extend({method:E("tasks/result"),params:ft.extend({taskId:$()})}),eC=je.loose(),dc=ao.extend({method:E("tasks/list")}),fc=so.extend({tasks:J(co)}),mc=Ee.extend({method:E("tasks/cancel"),params:ft.extend({taskId:$()})}),ob=je.merge(co),ab=N({uri:$(),mimeType:ae($()),_meta:ce($(),le()).optional()}),sb=ab.extend({text:$()}),Dp=$().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),cb=ab.extend({blob:Dp}),lo=Ne(["user","assistant"]),Ln=N({audience:J(lo).optional(),priority:ee().min(0).max(1).optional(),lastModified:Ur.datetime({offset:!0}).optional()}),ub=N({...Cn.shape,...oo.shape,uri:$(),description:ae($()),mimeType:ae($()),size:ae(ee()),annotations:Ln.optional(),_meta:ae(Te({}))}),yP=N({...Cn.shape,...oo.shape,uriTemplate:$(),description:ae($()),mimeType:ae($()),annotations:Ln.optional(),_meta:ae(Te({}))}),$P=ao.extend({method:E("resources/list")}),_P=so.extend({resources:J(ub)}),bP=ao.extend({method:E("resources/templates/list")}),kP=so.extend({resourceTemplates:J(yP)}),Ap=ft.extend({uri:$()}),wP=Ap,xP=Ee.extend({method:E("resources/read"),params:wP}),SP=je.extend({contents:J(oe([sb,cb]))}),zP=vt.extend({method:E("notifications/resources/list_changed"),params:gt.optional()}),IP=Ap,PP=Ee.extend({method:E("resources/subscribe"),params:IP}),OP=Ap,TP=Ee.extend({method:E("resources/unsubscribe"),params:OP}),NP=gt.extend({uri:$()}),EP=vt.extend({method:E("notifications/resources/updated"),params:NP}),jP=N({name:$(),description:ae($()),required:ae($e())}),DP=N({...Cn.shape,...oo.shape,description:ae($()),arguments:ae(J(jP)),_meta:ae(Te({}))}),Rp=ao.extend({method:E("prompts/list")}),AP=so.extend({prompts:J(DP)}),RP=ft.extend({name:$(),arguments:ce($(),$()).optional()}),Up=Ee.extend({method:E("prompts/get"),params:RP}),Cp=N({type:E("text"),text:$(),annotations:Ln.optional(),_meta:ce($(),le()).optional()}),Zp=N({type:E("image"),data:Dp,mimeType:$(),annotations:Ln.optional(),_meta:ce($(),le()).optional()}),Lp=N({type:E("audio"),data:Dp,mimeType:$(),annotations:Ln.optional(),_meta:ce($(),le()).optional()}),UP=N({type:E("tool_use"),name:$(),id:$(),input:ce($(),le()),_meta:ce($(),le()).optional()}),CP=N({type:E("resource"),resource:oe([sb,cb]),annotations:Ln.optional(),_meta:ce($(),le()).optional()}),ZP=ub.extend({type:E("resource_link")}),Mp=oe([Cp,Zp,Lp,ZP,CP]),LP=N({role:lo,content:Mp}),MP=je.extend({description:$().optional(),messages:J(LP)}),VP=vt.extend({method:E("notifications/prompts/list_changed"),params:gt.optional()}),FP=N({title:$().optional(),readOnlyHint:$e().optional(),destructiveHint:$e().optional(),idempotentHint:$e().optional(),openWorldHint:$e().optional()}),qP=N({taskSupport:Ne(["required","optional","forbidden"]).optional()}),lb=N({...Cn.shape,...oo.shape,description:$().optional(),inputSchema:N({type:E("object"),properties:ce($(),Se).optional(),required:J($()).optional()}).catchall(le()),outputSchema:N({type:E("object"),properties:ce($(),Se).optional(),required:J($()).optional()}).catchall(le()).optional(),annotations:FP.optional(),execution:qP.optional(),_meta:ce($(),le()).optional()}),Vp=ao.extend({method:E("tools/list")}),JP=so.extend({tools:J(lb)}),pc=je.extend({content:J(Mp).default([]),structuredContent:ce($(),le()).optional(),isError:$e().optional()}),tC=pc.or(je.extend({toolResult:le()})),BP=no.extend({name:$(),arguments:ce($(),le()).optional()}),fo=Ee.extend({method:E("tools/call"),params:BP}),KP=vt.extend({method:E("notifications/tools/list_changed"),params:gt.optional()}),rC=N({autoRefresh:$e().default(!0),debounceMs:ee().int().nonnegative().default(300)}),mo=Ne(["debug","info","notice","warning","error","critical","alert","emergency"]),HP=ft.extend({level:mo}),Fp=Ee.extend({method:E("logging/setLevel"),params:HP}),GP=gt.extend({level:mo,logger:$().optional(),data:le()}),WP=vt.extend({method:E("notifications/message"),params:GP}),XP=N({name:$().optional()}),YP=N({hints:J(XP).optional(),costPriority:ee().min(0).max(1).optional(),speedPriority:ee().min(0).max(1).optional(),intelligencePriority:ee().min(0).max(1).optional()}),QP=N({mode:Ne(["auto","required","none"]).optional()}),eO=N({type:E("tool_result"),toolUseId:$().describe("The unique identifier for the corresponding tool call."),content:J(Mp).default([]),structuredContent:N({}).loose().optional(),isError:$e().optional(),_meta:ce($(),le()).optional()}),tO=Wi("type",[Cp,Zp,Lp]),tc=Wi("type",[Cp,Zp,Lp,UP,eO]),rO=N({role:lo,content:oe([tc,J(tc)]),_meta:ce($(),le()).optional()}),nO=no.extend({messages:J(rO),modelPreferences:YP.optional(),systemPrompt:$().optional(),includeContext:Ne(["none","thisServer","allServers"]).optional(),temperature:ee().optional(),maxTokens:ee().int(),stopSequences:J($()).optional(),metadata:Se.optional(),tools:J(lb).optional(),toolChoice:QP.optional()}),iO=Ee.extend({method:E("sampling/createMessage"),params:nO}),po=je.extend({model:$(),stopReason:ae(Ne(["endTurn","stopSequence","maxTokens"]).or($())),role:lo,content:tO}),qp=je.extend({model:$(),stopReason:ae(Ne(["endTurn","stopSequence","maxTokens","toolUse"]).or($())),role:lo,content:oe([tc,J(tc)])}),oO=N({type:E("boolean"),title:$().optional(),description:$().optional(),default:$e().optional()}),aO=N({type:E("string"),title:$().optional(),description:$().optional(),minLength:ee().optional(),maxLength:ee().optional(),format:Ne(["email","uri","date","date-time"]).optional(),default:$().optional()}),sO=N({type:Ne(["number","integer"]),title:$().optional(),description:$().optional(),minimum:ee().optional(),maximum:ee().optional(),default:ee().optional()}),cO=N({type:E("string"),title:$().optional(),description:$().optional(),enum:J($()),default:$().optional()}),uO=N({type:E("string"),title:$().optional(),description:$().optional(),oneOf:J(N({const:$(),title:$()})),default:$().optional()}),lO=N({type:E("string"),title:$().optional(),description:$().optional(),enum:J($()),enumNames:J($()).optional(),default:$().optional()}),dO=oe([cO,uO]),fO=N({type:E("array"),title:$().optional(),description:$().optional(),minItems:ee().optional(),maxItems:ee().optional(),items:N({type:E("string"),enum:J($())}),default:J($()).optional()}),mO=N({type:E("array"),title:$().optional(),description:$().optional(),minItems:ee().optional(),maxItems:ee().optional(),items:N({anyOf:J(N({const:$(),title:$()}))}),default:J($()).optional()}),pO=oe([fO,mO]),hO=oe([lO,dO,pO]),gO=oe([hO,oO,aO,sO]),vO=no.extend({mode:E("form").optional(),message:$(),requestedSchema:N({type:E("object"),properties:ce($(),gO),required:J($()).optional()})}),yO=no.extend({mode:E("url"),message:$(),elicitationId:$(),url:$().url()}),$O=oe([vO,yO]),_O=Ee.extend({method:E("elicitation/create"),params:$O}),bO=gt.extend({elicitationId:$()}),kO=vt.extend({method:E("notifications/elicitation/complete"),params:bO}),Mn=je.extend({action:Ne(["accept","decline","cancel"]),content:to(e=>e===null?void 0:e,ce($(),oe([$(),ee(),$e(),J($())])).optional())}),wO=N({type:E("ref/resource"),uri:$()});var xO=N({type:E("ref/prompt"),name:$()}),SO=ft.extend({ref:oe([xO,wO]),argument:N({name:$(),value:$()}),context:N({arguments:ce($(),$()).optional()}).optional()}),zO=Ee.extend({method:E("completion/complete"),params:SO});var IO=je.extend({completion:Te({values:J($()).max(100),total:ae(ee().int()),hasMore:ae($e())})}),PO=N({uri:$().startsWith("file://"),name:$().optional(),_meta:ce($(),le()).optional()}),OO=Ee.extend({method:E("roots/list"),params:ft.optional()}),Jp=je.extend({roots:J(PO)}),TO=vt.extend({method:E("notifications/roots/list_changed"),params:gt.optional()}),nC=oe([ac,Ep,zO,Fp,Up,Rp,$P,bP,xP,PP,TP,fo,Vp,cc,lc,dc,mc]),iC=oe([oc,sc,jp,TO,uo]),oC=oe([ic,po,qp,Mn,Jp,uc,fc,Zn]),aC=oe([ac,iO,_O,OO,cc,lc,dc,mc]),sC=oe([oc,sc,WP,EP,zP,KP,VP,uo,kO]),cC=oe([ic,fP,IO,MP,AP,_P,kP,SP,pc,JP,uc,fc,Zn]),M=class e extends Error{constructor(t,n,i){super(`MCP error ${t}: ${n}`),this.code=t,this.data=i,this.name="McpError"}static fromError(t,n,i){if(t===G.UrlElicitationRequired&&i){let r=i;if(r.elicitations)return new zp(r.elicitations,n)}return new e(t,n,i)}},zp=class extends M{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(G.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function dr(e){return e==="completed"||e==="failed"||e==="cancelled"}var MC=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Bp(e){let n=Ss(e)?.method;if(!n)throw new Error("Schema is missing a method literal");let i=zs(n);if(typeof i!="string")throw new Error("Schema method literal must be a string");return i}function Kp(e,t){let n=or(e,t);if(!n.success)throw n.error;return n.data}var RO=6e4,hc=class{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(oc,n=>{this._oncancel(n)}),this.setNotificationHandler(sc,n=>{this._onprogress(n)}),this.setRequestHandler(ac,n=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(cc,async(n,i)=>{let r=await this._taskStore.getTask(n.params.taskId,i.sessionId);if(!r)throw new M(G.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler(lc,async(n,i)=>{let r=async()=>{let o=n.params.taskId;if(this._taskMessageQueue){let s;for(;s=await this._taskMessageQueue.dequeue(o,i.sessionId);){if(s.type==="response"||s.type==="error"){let c=s.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),s.type==="response")l(c);else{let d=c,m=new M(d.error.code,d.error.message,d.error.data);l(m)}else{let d=s.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(s.message,{relatedRequestId:i.requestId})}}let a=await this._taskStore.getTask(o,i.sessionId);if(!a)throw new M(G.InvalidParams,`Task not found: ${o}`);if(!dr(a.status))return await this._waitForTaskUpdate(o,i.signal),await r();if(dr(a.status)){let s=await this._taskStore.getTaskResult(o,i.sessionId);return this._clearTaskQueue(o),{...s,_meta:{...s._meta,[lr]:{taskId:o}}}}return await r()};return await r()}),this.setRequestHandler(dc,async(n,i)=>{try{let{tasks:r,nextCursor:o}=await this._taskStore.listTasks(n.params?.cursor,i.sessionId);return{tasks:r,nextCursor:o,_meta:{}}}catch(r){throw new M(G.InvalidParams,`Failed to list tasks: ${r instanceof Error?r.message:String(r)}`)}}),this.setRequestHandler(mc,async(n,i)=>{try{let r=await this._taskStore.getTask(n.params.taskId,i.sessionId);if(!r)throw new M(G.InvalidParams,`Task not found: ${n.params.taskId}`);if(dr(r.status))throw new M(G.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(n.params.taskId,"cancelled","Client cancelled task execution.",i.sessionId),this._clearTaskQueue(n.params.taskId);let o=await this._taskStore.getTask(n.params.taskId,i.sessionId);if(!o)throw new M(G.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...o}}catch(r){throw r instanceof M?r:new M(G.InvalidRequest,`Failed to cancel task: ${r instanceof Error?r.message:String(r)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,n,i,r,o=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(r,n),startTime:Date.now(),timeout:n,maxTotalTimeout:i,resetTimeoutOnProgress:o,onTimeout:r})}_resetTimeout(t){let n=this._timeoutInfo.get(t);if(!n)return!1;let i=Date.now()-n.startTime;if(n.maxTotalTimeout&&i>=n.maxTotalTimeout)throw this._timeoutInfo.delete(t),M.fromError(G.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:i});return clearTimeout(n.timeoutId),n.timeoutId=setTimeout(n.onTimeout,n.timeout),!0}_cleanupTimeout(t){let n=this._timeoutInfo.get(t);n&&(clearTimeout(n.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let n=this.transport?.onclose;this._transport.onclose=()=>{n?.(),this._onclose()};let i=this.transport?.onerror;this._transport.onerror=o=>{i?.(o),this._onerror(o)};let r=this._transport?.onmessage;this._transport.onmessage=(o,a)=>{r?.(o,a),io(o)||rb(o)?this._onresponse(o):Op(o)?this._onrequest(o,a):tb(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let i of this._timeoutInfo.values())clearTimeout(i.timeoutId);this._timeoutInfo.clear();for(let i of this._requestHandlerAbortControllers.values())i.abort();this._requestHandlerAbortControllers.clear();let n=M.fromError(G.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let i of t.values())i(n)}_onerror(t){this.onerror?.(t)}_onnotification(t){let n=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(t)).catch(i=>this._onerror(new Error(`Uncaught error in notification handler: ${i}`)))}_onrequest(t,n){let i=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,r=this._transport,o=t.params?._meta?.[lr]?.taskId;if(i===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:G.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:l,timestamp:Date.now()},r?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):r?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(t.id,a);let s=Y_(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,r?.sessionId):void 0,u={signal:a.signal,sessionId:r?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(a.signal.aborted)return;let d={relatedRequestId:t.id};o&&(d.relatedTask={taskId:o}),await this.notification(l,d)},sendRequest:async(l,d,m)=>{if(a.signal.aborted)throw new M(G.ConnectionClosed,"Request was cancelled");let f={...m,relatedRequestId:t.id};o&&!f.relatedTask&&(f.relatedTask={taskId:o});let p=f.relatedTask?.taskId??o;return p&&c&&await c.updateTaskStatus(p,"input_required"),await this.request(l,d,f)},authInfo:n?.authInfo,requestId:t.id,requestInfo:n?.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:s?.ttl,closeSSEStream:n?.closeSSEStream,closeStandaloneSSEStream:n?.closeStandaloneSSEStream};Promise.resolve().then(()=>{s&&this.assertTaskHandlerCapability(t.method)}).then(()=>i(t,u)).then(async l=>{if(a.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:d,timestamp:Date.now()},r?.sessionId):await r?.send(d)},async l=>{if(a.signal.aborted)return;let d={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:G.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:d,timestamp:Date.now()},r?.sessionId):await r?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===a&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:n,...i}=t.params,r=Number(n),o=this._progressHandlers.get(r);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let a=this._responseHandlers.get(r),s=this._timeoutInfo.get(r);if(s&&a&&s.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(c){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(c);return}o(i)}_onresponse(t){let n=Number(t.id),i=this._requestResolvers.get(n);if(i){if(this._requestResolvers.delete(n),io(t))i(t);else{let a=new M(t.error.code,t.error.message,t.error.data);i(a)}return}let r=this._responseHandlers.get(n);if(r===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(n),this._cleanupTimeout(n);let o=!1;if(io(t)&&t.result&&typeof t.result=="object"){let a=t.result;if(a.task&&typeof a.task=="object"){let s=a.task;typeof s.taskId=="string"&&(o=!0,this._taskProgressTokens.set(s.taskId,n))}}if(o||this._progressHandlers.delete(n),io(t))r(t);else{let a=M.fromError(t.error.code,t.error.message,t.error.data);r(a)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,n,i){let{task:r}=i??{};if(!r){try{yield{type:"result",result:await this.request(t,n,i)}}catch(a){yield{type:"error",error:a instanceof M?a:new M(G.InternalError,String(a))}}return}let o;try{let a=await this.request(t,Zn,i);if(a.task)o=a.task.taskId,yield{type:"taskCreated",task:a.task};else throw new M(G.InternalError,"Task creation did not return a task");for(;;){let s=await this.getTask({taskId:o},i);if(yield{type:"taskStatus",task:s},dr(s.status)){s.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},n,i)}:s.status==="failed"?yield{type:"error",error:new M(G.InternalError,`Task ${o} failed`)}:s.status==="cancelled"&&(yield{type:"error",error:new M(G.InternalError,`Task ${o} was cancelled`)});return}if(s.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},n,i)};return}let c=s.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),i?.signal?.throwIfAborted()}}catch(a){yield{type:"error",error:a instanceof M?a:new M(G.InternalError,String(a))}}}request(t,n,i){let{relatedRequestId:r,resumptionToken:o,onresumptiontoken:a,task:s,relatedTask:c}=i??{};return new Promise((u,l)=>{let d=_=>{l(_)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),s&&this.assertTaskCapability(t.method)}catch(_){d(_);return}i?.signal?.throwIfAborted();let m=this._requestMessageId++,f={...t,jsonrpc:"2.0",id:m};i?.onprogress&&(this._progressHandlers.set(m,i.onprogress),f.params={...t.params,_meta:{...t.params?._meta||{},progressToken:m}}),s&&(f.params={...f.params,task:s}),c&&(f.params={...f.params,_meta:{...f.params?._meta||{},[lr]:c}});let p=_=>{this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(_)}},{relatedRequestId:r,resumptionToken:o,onresumptiontoken:a}).catch(O=>this._onerror(new Error(`Failed to send cancellation: ${O}`)));let S=_ instanceof M?_:new M(G.RequestTimeout,String(_));l(S)};this._responseHandlers.set(m,_=>{if(!i?.signal?.aborted){if(_ instanceof Error)return l(_);try{let S=or(n,_.result);S.success?u(S.data):l(S.error)}catch(S){l(S)}}}),i?.signal?.addEventListener("abort",()=>{p(i?.signal?.reason)});let h=i?.timeout??RO,g=()=>p(M.fromError(G.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(m,h,i?.maxTotalTimeout,g,i?.resetTimeoutOnProgress??!1);let b=c?.taskId;if(b){let _=S=>{let O=this._responseHandlers.get(m);O?O(S):this._onerror(new Error(`Response handler missing for side-channeled request ${m}`))};this._requestResolvers.set(m,_),this._enqueueTaskMessage(b,{type:"request",message:f,timestamp:Date.now()}).catch(S=>{this._cleanupTimeout(m),l(S)})}else this._transport.send(f,{relatedRequestId:r,resumptionToken:o,onresumptiontoken:a}).catch(_=>{this._cleanupTimeout(m),l(_)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},uc,n)}async getTaskResult(t,n,i){return this.request({method:"tasks/result",params:t},n,i)}async listTasks(t,n){return this.request({method:"tasks/list",params:t},fc,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},ob,n)}async notification(t,n){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let i=n?.relatedTask?.taskId;if(i){let s={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[lr]:n.relatedTask}}};await this._enqueueTaskMessage(i,{type:"notification",message:s,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!n?.relatedRequestId&&!n?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let s={...t,jsonrpc:"2.0"};n?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[lr]:n.relatedTask}}}),this._transport?.send(s,n).catch(c=>this._onerror(c))});return}let a={...t,jsonrpc:"2.0"};n?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[lr]:n.relatedTask}}}),await this._transport.send(a,n)}setRequestHandler(t,n){let i=Bp(t);this.assertRequestHandlerCapability(i),this._requestHandlers.set(i,(r,o)=>{let a=Kp(t,r);return Promise.resolve(n(a,o))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,n){let i=Bp(t);this._notificationHandlers.set(i,r=>{let o=Kp(t,r);return Promise.resolve(n(o))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let n=this._taskProgressTokens.get(t);n!==void 0&&(this._progressHandlers.delete(n),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,n,i){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,n,i,r)}async _clearTaskQueue(t,n){if(this._taskMessageQueue){let i=await this._taskMessageQueue.dequeueAll(t,n);for(let r of i)if(r.type==="request"&&Op(r.message)){let o=r.message.id,a=this._requestResolvers.get(o);a?(a(new M(G.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,n){let i=this._options?.defaultTaskPollInterval??1e3;try{let r=await this._taskStore?.getTask(t);r?.pollInterval&&(i=r.pollInterval)}catch{}return new Promise((r,o)=>{if(n.aborted){o(new M(G.InvalidRequest,"Request cancelled"));return}let a=setTimeout(r,i);n.addEventListener("abort",()=>{clearTimeout(a),o(new M(G.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,n){let i=this._taskStore;if(!i)throw new Error("No task store configured");return{createTask:async r=>{if(!t)throw new Error("No request provided");return await i.createTask(r,t.id,{method:t.method,params:t.params},n)},getTask:async r=>{let o=await i.getTask(r,n);if(!o)throw new M(G.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(r,o,a)=>{await i.storeTaskResult(r,o,a,n);let s=await i.getTask(r,n);if(s){let c=uo.parse({method:"notifications/tasks/status",params:s});await this.notification(c),dr(s.status)&&this._cleanupTaskProgressHandler(r)}},getTaskResult:r=>i.getTaskResult(r,n),updateTaskStatus:async(r,o,a)=>{let s=await i.getTask(r,n);if(!s)throw new M(G.InvalidParams,`Task "${r}" not found - it may have been cleaned up`);if(dr(s.status))throw new M(G.InvalidParams,`Cannot update task "${r}" from terminal status "${s.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await i.updateTaskStatus(r,o,a,n);let c=await i.getTask(r,n);if(c){let u=uo.parse({method:"notifications/tasks/status",params:c});await this.notification(u),dr(c.status)&&this._cleanupTaskProgressHandler(r)}},listTasks:r=>i.listTasks(r,n)}}};function db(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function fb(e,t){let n={...e};for(let i in t){let r=i,o=t[r];if(o===void 0)continue;let a=n[r];db(a)&&db(o)?n[r]={...a,...o}:n[r]=o}return n}var dx=Hg(Zg(),1),fx=Hg(lx(),1);function KA(){let e=new dx.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,fx.default)(e),e}var Yc=class{constructor(t){this._ajv=t??KA()}getValidator(t){let n="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return i=>n(i)?{valid:!0,data:i,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(n.errors)}}};var Qc=class{constructor(t){this._server=t}requestStream(t,n,i){return this._server.requestStream(t,n,i)}createMessageStream(t,n){let i=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!i?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let r=t.messages[t.messages.length-1],o=Array.isArray(r.content)?r.content:[r.content],a=o.some(l=>l.type==="tool_result"),s=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=s?Array.isArray(s.content)?s.content:[s.content]:[],u=c.some(l=>l.type==="tool_use");if(a){if(o.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(m=>m.type==="tool_use").map(m=>m.id)),d=new Set(o.filter(m=>m.type==="tool_result").map(m=>m.toolUseId));if(l.size!==d.size||![...l].every(m=>d.has(m)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},po,n)}elicitInputStream(t,n){let i=this._server.getClientCapabilities(),r=t.mode??"form";switch(r){case"url":{if(!i?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!i?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let o=r==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:o},Mn,n)}async getTask(t,n){return this._server.getTask({taskId:t},n)}async getTaskResult(t,n,i){return this._server.getTaskResult({taskId:t},n,i)}async listTasks(t,n){return this._server.listTasks(t?{cursor:t}:void 0,n)}async cancelTask(t,n){return this._server.cancelTask({taskId:t},n)}};function mx(e,t,n){if(!e)throw new Error(`${n} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${n} does not support task creation for tools/call (required for ${t})`);break;default:break}}function px(e,t,n){if(!e)throw new Error(`${n} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${n} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${n} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var eu=class extends hc{constructor(t,n){super(n),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(mo.options.map((i,r)=>[i,r])),this.isMessageIgnored=(i,r)=>{let o=this._loggingLevels.get(r);return o?this.LOG_LEVEL_SEVERITY.get(i)<this.LOG_LEVEL_SEVERITY.get(o):!1},this._capabilities=n?.capabilities??{},this._instructions=n?.instructions,this._jsonSchemaValidator=n?.jsonSchemaValidator??new Yc,this.setRequestHandler(Ep,i=>this._oninitialize(i)),this.setNotificationHandler(jp,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Fp,async(i,r)=>{let o=r.sessionId||r.requestInfo?.headers["mcp-session-id"]||void 0,{level:a}=i.params,s=mo.safeParse(a);return s.success&&this._loggingLevels.set(o,s.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Qc(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=fb(this._capabilities,t)}setRequestHandler(t,n){let r=Ss(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let o=zs(r);if(typeof o!="string")throw new Error("Schema method literal must be a string");if(o==="tools/call"){let s=async(c,u)=>{let l=or(fo,c);if(!l.success){let p=l.error instanceof Error?l.error.message:String(l.error);throw new M(G.InvalidParams,`Invalid tools/call request: ${p}`)}let{params:d}=l.data,m=await Promise.resolve(n(c,u));if(d.task){let p=or(Zn,m);if(!p.success){let h=p.error instanceof Error?p.error.message:String(p.error);throw new M(G.InvalidParams,`Invalid task creation result: ${h}`)}return p.data}let f=or(pc,m);if(!f.success){let p=f.error instanceof Error?f.error.message:String(f.error);throw new M(G.InvalidParams,`Invalid tools/call result: ${p}`)}return f.data};return super.setRequestHandler(t,s)}return super.setRequestHandler(t,n)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){px(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&mx(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let n=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:G_.includes(n)?n:Ip,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},ic)}async createMessage(t,n){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let i=t.messages[t.messages.length-1],r=Array.isArray(i.content)?i.content:[i.content],o=r.some(u=>u.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,s=a?Array.isArray(a.content)?a.content:[a.content]:[],c=s.some(u=>u.type==="tool_use");if(o){if(r.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(s.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(r.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},qp,n):this.request({method:"sampling/createMessage",params:t},po,n)}async elicitInput(t,n){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let r=t;return this.request({method:"elicitation/create",params:r},Mn,n)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let r=t.mode==="form"?t:{...t,mode:"form"},o=await this.request({method:"elicitation/create",params:r},Mn,n);if(o.action==="accept"&&o.content&&r.requestedSchema)try{let s=this._jsonSchemaValidator.getValidator(r.requestedSchema)(o.content);if(!s.valid)throw new M(G.InvalidParams,`Elicitation response content does not match requested schema: ${s.errorMessage}`)}catch(a){throw a instanceof M?a:new M(G.InternalError,`Error validating elicitation response: ${a instanceof Error?a.message:String(a)}`)}return o}}}createElicitationCompletionNotifier(t,n){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},n)}async listRoots(t,n){return this.request({method:"roots/list",params:t},Jp,n)}async sendLoggingMessage(t,n){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,n))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};import gx from"node:process";var HA=10*1024*1024,tu=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??HA}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
|
|
71
71
|
`);if(t===-1)return null;let n=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),GA(n)}clear(){this._buffer=void 0}};function GA(e){return nb.parse(JSON.parse(e))}function hx(e){return JSON.stringify(e)+`
|
|
72
72
|
`}var ru=class{constructor(t=gx.stdin,n=gx.stdout,i){this._stdin=t,this._stdout=n,this._started=!1,this._ondata=r=>{try{this._readBuffer.append(r),this.processReadBuffer()}catch(o){this.onerror?.(o),this.close().catch(()=>{})}},this._onerror=r=>{this.onerror?.(r)},this._readBuffer=new tu({maxBufferSize:i?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(n=>{let i=hx(t);this._stdout.write(i)?n():this._stdout.once("drain",n)})}};import ut from"node:fs";import Ie from"node:path";import WA from"node:os";var XA="AIzaSyAC5ROxI3bnIO1DyNflMhFRrtnR-45p4RE";function YA(e){try{let t=JSON.parse(Buffer.from(e.split(".")[1],"base64url").toString("utf8"));return typeof t.exp=="number"&&t.exp*1e3<Date.now()+6e4}catch{return!1}}async function QA(e,t){let n=await fetch(`https://securetoken.googleapis.com/v1/token?key=${XA}`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:`grant_type=refresh_token&refresh_token=${encodeURIComponent(t)}`});if(!n.ok)return null;let i=await n.json();return i.id_token?(ut.writeFileSync(e,JSON.stringify({devToken:i.id_token,refreshToken:i.refresh_token||t,updatedAt:new Date().toISOString()},null,2)),i.id_token):null}async function e4(){if(process.env.FLEETBO_DEV_TOKEN)return process.env.FLEETBO_DEV_TOKEN;try{let e=Ie.join(WA.homedir(),".fleetbo","credentials.json");if(ut.existsSync(e)){let t=JSON.parse(ut.readFileSync(e,"utf8"));if(t.devToken&&!YA(t.devToken))return t.devToken;if(t.refreshToken)try{let n=await QA(e,t.refreshToken);if(n)return n}catch{}}}catch{}return null}var Kg="jqycakhlxa-uc.a.run.app";function t4(e){try{let t=Ie.join(e,".env");if(!ut.existsSync(t))return null;let i=ut.readFileSync(t,"utf8").match(/^\s*OZ_KEY_APP\s*=\s*(.+?)\s*$/m);if(!i)return null;let r=i[1].replace(/\s+#.*$/,"").replace(/^["']|["']$/g,"").trim();return r.length>=2?r:null}catch{return null}}var vx=`
|
|
73
73
|
# OZMOZ SVRO \u2014 STRICT AI DIRECTIVES (SYSTEM INSTRUCTIONS)
|
|
@@ -88,6 +88,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
88
88
|
\u{1F449} Call 'oz.*' directly as a bare identifier (e.g., 'await oz.sendotpsvro(email)').
|
|
89
89
|
\u{1F449} NEVER access the SDK via 'window.oz' or optional chains like 'window.oz?.'.
|
|
90
90
|
\u{1F449} The identifier is globally declared in 'src/ozmoz.d.ts'. Using 'window.' circumvents static contract audits, breaks CLI regexes, and triggers false linter workarounds.
|
|
91
|
+
5. CONTRACT DISCIPLINE & LAST-RESORT SUPPORT:
|
|
92
|
+
\u{1F449} ALWAYS consult 'ozmoz_contract.md' before writing or debugging data calls.
|
|
93
|
+
\u{1F449} Resolve errors inside your frontend components (arguments, state, tags). Do not run exploratory shell commands or web searches.
|
|
94
|
+
\u{1F449} ONLY as an absolute last resort \u2014 if every code fix and contract check has failed and no solution exists on your side \u2014 invite the user to contact support:
|
|
95
|
+
"Si aucune solution n'est trouv\xE9e et que le blocage persiste, vous pouvez ouvrir un ticket sur https://ozmoz.io".
|
|
91
96
|
|
|
92
97
|
================================================================================
|
|
93
98
|
\u{1F6A8} UNIVERSAL FRONTEND \u2194 ALEX AI PROTOCOL: THE AUTHORITY OF THE CONTRACT \u{1F6A8}
|