broods 0.37.0 → 0.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -4
- package/dist/account.d.ts +1 -1
- package/dist/account.js +1 -1
- package/dist/chunk-1vpr1s8y.js +4 -0
- package/dist/{chunk-mqsvqhkj.js → chunk-9m85p3e3.js} +2 -2
- package/dist/chunk-ck8t5hr5.js +1 -0
- package/dist/chunk-g60t36xv.js +1 -0
- package/dist/chunk-gtn2fwy2.js +1 -0
- package/dist/chunk-hd4f1h39.js +1 -0
- package/dist/chunk-js5cjmhp.js +66 -0
- package/dist/chunk-qkytyr75.js +15 -0
- package/dist/{chunk-pxzdwb6g.js → chunk-tgqhxn4k.js} +5 -5
- package/dist/chunk-z0awwr22.js +17 -0
- package/dist/cli/index.js +71 -161
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -6
- package/dist/chunk-3spnn9yh.js +0 -4
- package/dist/chunk-794tw7dm.js +0 -1
- package/dist/chunk-a9yb7pfr.js +0 -1
- package/dist/chunk-gcm6m7md.js +0 -15
- package/dist/chunk-n1cm22m2.js +0 -1
- package/dist/chunk-txsgyj2d.js +0 -1
package/README.md
CHANGED
|
@@ -31,10 +31,9 @@ broods dev
|
|
|
31
31
|
`broods update` installs the newest release over the copy you are running, and
|
|
32
32
|
`broods dev` says so when one is out.
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
agent config fails to compile:
|
|
34
|
+
`ai` is a peer dependency that bun, npm and pnpm install automatically, so the
|
|
35
|
+
CLI and your project share one copy. On a package manager that does not
|
|
36
|
+
auto-install peers, add it yourself:
|
|
38
37
|
|
|
39
38
|
```bash
|
|
40
39
|
npm install broods ai
|
package/dist/account.d.ts
CHANGED
|
@@ -227,7 +227,7 @@ interface AgentSubagentConfig {
|
|
|
227
227
|
visibility?: "full" | "result" | "none";
|
|
228
228
|
[key: string]: unknown;
|
|
229
229
|
}
|
|
230
|
-
interface AgentModelConfig extends LanguageModelCallOptions, Pick<RequestOptions, "maxRetries" | "timeout"
|
|
230
|
+
interface AgentModelConfig extends LanguageModelCallOptions, Partial<Pick<RequestOptions, "maxRetries" | "timeout">> {
|
|
231
231
|
provider?: AccountModelProviderName;
|
|
232
232
|
modelId?: string;
|
|
233
233
|
/**
|
package/dist/account.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m,
|
|
1
|
+
import{m,Te,L,D}from"./chunk-9m85p3e3.js";export{m as BroodsAccountApiError,D as BroodsAccountClient,Te as envPlaceholder,L as resolveEnvCredential};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{E}from"./chunk-tgqhxn4k.js";import{e,o,a,l,n,t,d,R,s,p,r}from"./chunk-js5cjmhp.js";import{de,pe}from"./cli/index.js";import{spawn as V}from"node:child_process";import{hostname as ee}from"node:os";import{performance as T}from"node:perf_hooks";var j=["cursor_position","double_click","hold_key","key","left_click","left_click_drag","left_mouse_down","left_mouse_up","middle_click","mouse_move","right_click","screenshot","scroll","triple_click","type","wait","zoom"];var k={badFrame:{code:4400,reason:"Malformed frame"},occupied:{code:4423,reason:"Already connected from another daemon"},replaced:{code:4409,reason:"Replaced by a newer connection"},unauthorized:{code:4401,reason:"Unauthorized; check BROODS_API_KEY"},unknownSandbox:{code:4404,reason:"No machine sandbox with that name in this account"}},N="/v1/machines/ws",H=t({action:p(j),coordinate:n(o().int()).length(2).optional().describe("[x, y] in screenshot pixels for mouse actions."),start_coordinate:n(o().int()).length(2).optional().describe("[x, y] where a left_click_drag starts."),text:e().optional().describe("Text for type, the key chord for key and hold_key, or modifiers to hold during a click, drag or scroll."),scroll_direction:p(["down","left","right","up"]).optional(),scroll_amount:o().int().min(1).optional().describe("Scroll clicks, default 3."),duration:o().min(0).max(300).optional().describe("Seconds for wait and hold_key."),region:n(o().int()).length(4).optional().describe("[x0, y0, x1, y1] of the screenshot to zoom into."),repeat:o().int().min(1).max(100).optional().describe("How many times to press the key.")}),P=H.extend({type:r("computer"),id:e()}),U=t({type:r("computer-result"),id:e(),text:e().optional(),image:t({data:e(),mediaType:e()}).optional(),app:e().optional(),error:e().optional()}),B=t({type:r("exec"),id:e(),code:e(),cwd:e().optional(),env:s(e(),e()).optional(),timeoutSeconds:o().positive(),outputLimitBytes:o().positive()}),K=t({type:r("hello"),sandbox:e().min(1),hostname:e().optional(),platform:e().optional(),computer:a().optional(),mcp:n(e()).optional(),instance:e().optional(),force:a().optional()}),W=t({type:r("mcp-call"),id:e(),server:e(),tool:e(),args:s(e(),l())}),G=t({type:r("mcp-list"),id:e(),server:e()}),J=t({type:r("mcp-result"),id:e(),result:d({content:n(l())}).optional(),error:e().optional()}),X=t({type:r("mcp-tools"),id:e(),tools:n(d({name:e(),inputSchema:s(e(),l())})).optional(),error:e().optional()}),Y=t({type:r("ready"),sandboxId:e()}),q=t({type:r("result"),id:e(),exitCode:o().nullable(),stdout:e(),stderr:e(),durationMs:o(),timedOut:a(),truncated:a()}),Z=R("type",[P,B,W,G,Y]),me=R("type",[U,K,J,X,q]);function O(i){let c=new URL(N,i);return c.protocol=c.protocol==="https:"?"wss:":"ws:",c.toString()}function D(i){return Q(Z,i)}function Q(i,c){if(typeof c!=="string")return null;try{let u=i.safeParse(JSON.parse(c));return u.success?u.data:null}catch{return null}}var te=new Set([k.occupied.code,k.replaced.code,k.unauthorized.code,k.unknownSandbox.code]),L=72,z=30000,A=1000;function oe(i,c,u){return new Promise((y)=>{let m=T.now(),b=new S(i.outputLimitBytes),h=new S(i.outputLimitBytes),M=!1,_=!1,w=(v,C)=>{if(_)return;if(_=!0,clearTimeout(g),u?.removeEventListener("abort",f),C)h.append(Buffer.from(`${C}
|
|
2
|
+
`));y({type:"result",id:i.id,exitCode:v,stdout:b.text(),stderr:h.text(),durationMs:Math.round(T.now()-m),timedOut:M,truncated:b.truncated||h.truncated})},x=V("bash",["-lc",i.code],{cwd:i.cwd??c,env:{...process.env,...i.env},detached:!0,stdio:["ignore","pipe","pipe"]}),F=()=>{if(!x.pid)return;try{process.kill(-x.pid,"SIGKILL")}catch{x.kill("SIGKILL")}},g=setTimeout(()=>{M=!0,F()},i.timeoutSeconds*1000),f=()=>{F(),w(null,"stopped: the daemon closed its socket")};if(u?.addEventListener("abort",f,{once:!0}),x.stdout.on("data",(v)=>b.append(v)),x.stderr.on("data",(v)=>h.append(v)),x.on("error",(v)=>w(null,v.message)),x.on("close",(v)=>w(v)),u?.aborted)f()})}async function Fe(i){let c=pe(),u=crypto.randomUUID(),y=i.mcpFile?await ie(i.mcpFile,i.log):null,m=i.computer?await ne(i.log):null,b=A;try{while(!i.signal.aborted){let h=Date.now(),M=await ce(i,u,c,m,y);if(i.signal.aborted)return;if(te.has(M.code))throw Error(M.reason||`core closed the socket (${M.code})`);if(Date.now()-h>z)b=A;i.log(`disconnected (${M.reason||M.code}), reconnecting in ${Math.round(b/1000)}s`),await de(b,i.signal),b=Math.min(b*2,z)}}finally{m?.stop(),await y?.stop()}}class S{#o=[];#e;#t=0;truncated=!1;constructor(i){this.#e=i}append(i){if(this.#t>=this.#e){this.truncated=!0;return}let c=this.#e-this.#t;if(i.byteLength>c){this.#o.push(i.subarray(0,c)),this.#t=this.#e,this.truncated=!0;return}this.#o.push(i),this.#t+=i.byteLength}text(){let i=Buffer.concat(this.#o).toString("utf8");return this.truncated?`${i}
|
|
3
|
+
[output truncated]`:i}}function re(i){let c=[i.action];if(i.coordinate)c.push(`at ${i.coordinate.join(",")}`);if(i.text!==void 0)c.push(JSON.stringify(I(i.text)));if(i.region)c.push(`region ${i.region.join(",")}`);return c.join(" ")}function I(i){let c=i.trim().split(`
|
|
4
|
+
`)[0]??"";return c.length>L?`${c.slice(0,L)}…`:c}async function ne(i){let{startDesktop:c}=await import("./chunk-5tnnqapc.js"),{display:u,driver:y,permissions:m}=await c(!1);if(i(`computer use on, ${u.width}x${u.height} screenshots`),!m.screenRecording||!m.accessibility)i(" screen recording or accessibility is missing, run `broods machine --doctor --request`");return y}async function ie(i,c){let{McpHost:u,readMcpServersFile:y}=await import("./chunk-ck8t5hr5.js"),m=new u(y(i),c);return c(`mcp servers from ${i}: ${m.names().join(", ")}`),m}async function se(i,c,u){try{if(i.type==="mcp-list"){let m=await c.listTools(i.server);return u(` mcp ${i.server}: ${m.length} tools`),{type:"mcp-tools",id:i.id,tools:m}}u(` mcp ${i.server}.${i.tool}`);let y=await c.callTool(i.server,i.tool,i.args);return{type:"mcp-result",id:i.id,result:y}}catch(y){let m=y instanceof Error?y.message:String(y);return u(` mcp ${i.server}: ${m}`),{type:i.type==="mcp-call"?"mcp-result":"mcp-tools",id:i.id,error:m}}}function ce(i,c,u,y,m){return new Promise((b)=>{let h=new u(O(i.baseUrl),E(i.apiKey)),M=new AbortController,_=()=>h.close(1000,"daemon stopped"),w=(F)=>{if(h.readyState===h.OPEN)h.send(JSON.stringify(F))},x=(F,g)=>{i.signal.removeEventListener("abort",_),M.abort(),b({code:F,reason:g})};i.signal.addEventListener("abort",_,{once:!0}),h.onopen=()=>w({type:"hello",sandbox:i.sandbox,hostname:ee(),platform:process.platform,computer:y!==null,mcp:m?.names(),instance:c,force:i.force}),h.onmessage=(F)=>{let g=D(F.data);if(g?.type==="ready"){i.log(`connected as ${i.sandbox} (${g.sandboxId})`);return}if(g?.type==="computer"&&y){i.log(` ${re(g)}`),y.run(g).then((f)=>{if(f.error)i.log(` error: ${f.error}`);w(f)});return}if((g?.type==="mcp-call"||g?.type==="mcp-list")&&m){se(g,m,i.log).then(w);return}if(g?.type!=="exec")return;i.log(`$ ${I(g.code)}`),oe(g,i.cwd,M.signal).then((f)=>{i.log(` exit ${f.exitCode??"none"} in ${f.durationMs}ms${f.timedOut?" (timed out)":""}`),w(f)})},h.onerror=()=>x(1006,"connection failed"),h.onclose=(F)=>x(F.code,F.reason)})}export{Fe as runMachineDaemon};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var u=/^[A-Z][A-Z0-9_]*$/;class m extends Error{status;body;constructor(e,t,n,s){super(`${e} ${t} failed with ${n}: ${s}`);this.name="BroodsAccountApiError",this.status=n,this.body=s}}function
|
|
2
|
-
export{m,
|
|
1
|
+
var u=/^[A-Z][A-Z0-9_]*$/;class m extends Error{status;body;constructor(e,t,n,s){super(`${e} ${t} failed with ${n}: ${s}`);this.name="BroodsAccountApiError",this.status=n,this.body=s}}function Te(e){if(!u.test(e)||e.length>64)throw Error("envPlaceholder name must match /^[A-Z][A-Z0-9_]*$/ and be at most 64 characters.");return`\${${e}}`}function L(){return o("BROODS_SESSION_TOKEN")??o("BROODS_ACCOUNT_SECRET")}class D{baseUrl;bearerToken;fetchImpl;constructor(e={}){let t=e.baseUrl??o("BROODS_BASE_URL")??"https://gateway.broods.app",n=e.sessionToken??e.accountSecret??L();if(!n)throw Error("BroodsAccountClient requires an accountSecret or sessionToken (or BROODS_ACCOUNT_SECRET / BROODS_SESSION_TOKEN).");let s=t.length;while(s>0&&t.charCodeAt(s-1)===47)s-=1;this.baseUrl=t.slice(0,s),this.bearerToken=n,this.fetchImpl=e.fetch??fetch}async getAccount(){let e=await this.request("GET","/v1/account");if(!e)throw new m("GET","/v1/account",404,"Account not found");return e.account}async updateAccount(e){return(await this.request("PATCH","/v1/account",e))?.account??null}async assumeRole(e,t={}){let n=await this.request("POST","/v1/account/assume-role",{roleId:e,...t.ttlSeconds!==void 0?{ttlSeconds:t.ttlSeconds}:{}});if(!n)throw new m("POST","/v1/account/assume-role",404,"Role not found");return n}async rotateSecret(){let e=await this.request("POST","/v1/account/rotate-secret");if(!e)throw new m("POST","/v1/account/rotate-secret",404,"Account not found");return e}async deleteAccount(){return await this.request("DELETE","/v1/account")??{deleted:!1}}webhookUrl(e,t){let n=[e,t].map(encodeURIComponent);return`${this.baseUrl}/v1/webhooks/${n.join("/")}`}async listAgents(){return(await this.request("GET","/v1/agents"))?.agents??[]}async createAgent(e){let t=await this.request("POST","/v1/agents",e);if(!t)throw new m("POST","/v1/agents",404,"Not found");return t}async getAgent(e){return await this.request("GET",`/v1/agents/${encodeURIComponent(e)}`)}async updateAgent(e,t){return await this.request("PATCH",`/v1/agents/${encodeURIComponent(e)}`,t)}async deleteAgent(e){return(await this.request("DELETE",`/v1/agents/${encodeURIComponent(e)}`))?.deleted??!1}async listEnvVars(){return(await this.request("GET","/v1/env"))?.env??[]}async setEnvVar(e,t){await this.request("PUT",`/v1/env/${encodeURIComponent(e)}`,{value:t})}async deleteEnvVar(e){return(await this.request("DELETE",`/v1/env/${encodeURIComponent(e)}`))?.deleted??!1}async listCrons(){return(await this.request("GET","/v1/crons"))?.crons??[]}async createCron(e){let t=await this.request("POST","/v1/crons",e);if(!t)throw new m("POST","/v1/crons",404,"Not found");return t}async getCron(e){return await this.request("GET",`/v1/crons/${encodeURIComponent(e)}`)}async updateCron(e,t){return await this.request("PATCH",`/v1/crons/${encodeURIComponent(e)}`,t)}async deleteCron(e){return(await this.request("DELETE",`/v1/crons/${encodeURIComponent(e)}`))?.deleted??!1}async listCronRuns(e,t={}){let n=t.limit!==void 0?`?limit=${t.limit}`:"";return(await this.request("GET",`/v1/crons/${encodeURIComponent(e)}/runs${n}`))?.runs??[]}async listWorkspaces(){return(await this.request("GET","/v1/workspaces"))?.workspaces??[]}async createWorkspace(e){let t=await this.request("POST","/v1/workspaces",e);if(!t)throw new m("POST","/v1/workspaces",404,"Not found");return t}async getWorkspace(e){return await this.request("GET",`/v1/workspaces/${encodeURIComponent(e)}`)}async updateWorkspace(e,t){return await this.request("PATCH",`/v1/workspaces/${encodeURIComponent(e)}`,t)}async deleteWorkspace(e){return(await this.request("DELETE",`/v1/workspaces/${encodeURIComponent(e)}`))?.deleted??!1}async listWorkspaceFiles(e){return(await this.request("GET",`/v1/workspaces/${encodeURIComponent(e)}/files`))?.files??[]}async getWorkspaceFileUrl(e,t){let n=`?path=${encodeURIComponent(t)}`;return(await this.request("GET",`/v1/workspaces/${encodeURIComponent(e)}/files${n}`))?.url??null}async uploadWorkspaceFile(e,t){let n=`/v1/workspaces/${encodeURIComponent(e)}/files`,s=await this.request("POST",n,t);if(!s)throw new m("POST",n,404,"Workspace not found");return s.file}async renameWorkspaceFile(e,t,n){return(await this.request("PATCH",`/v1/workspaces/${encodeURIComponent(e)}/files`,{path:t,newPath:n}))?.renamed??!1}async deleteWorkspaceFile(e,t){return(await this.request("DELETE",`/v1/workspaces/${encodeURIComponent(e)}/files`,{path:t}))?.deleted??!1}async listSandboxes(){return(await this.request("GET","/v1/sandboxes"))?.sandboxes??[]}async createSandbox(e){let t=await this.request("POST","/v1/sandboxes",e);if(!t)throw new m("POST","/v1/sandboxes",404,"Not found");return t}async getSandbox(e){return await this.request("GET",`/v1/sandboxes/${encodeURIComponent(e)}`)}async updateSandbox(e,t){return await this.request("PATCH",`/v1/sandboxes/${encodeURIComponent(e)}`,t)}async deleteSandbox(e){return(await this.request("DELETE",`/v1/sandboxes/${encodeURIComponent(e)}`))?.deleted??!1}async suspendSandbox(e,t){return await this.sandboxAction(e,"suspend",{reservationKey:t})}async resumeSandbox(e,t){return await this.sandboxAction(e,"resume",{reservationKey:t})}async terminateSandbox(e,t){return await this.sandboxAction(e,"terminate",{reservationKey:t})}async snapshotSandbox(e,t,n){return await this.sandboxAction(e,"snapshot",{reservationKey:t,name:n})}async openSandboxTerminal(e,t){return await this.sandboxAction(e,"terminal",{reservationKey:t})}async listMcp(e){let t=`/v1/mcp${i(e)}`,n=await this.request("GET",t);if(!n)throw new m("GET",t,404,"Not found");return n.servers??[]}async createMcp(e,t){let n=`/v1/mcp${i(e)}`,s=await this.request("POST",n,t);if(!s)throw new m("POST",n,404,"Not found");return s}async uploadMcpBundle(e){let n=await this.request("POST","/v1/mcp/uploads");if(!n?.uploadUrl)throw new m("POST","/v1/mcp/uploads",502,"response omitted uploadUrl");let s=await this.fetchImpl(n.uploadUrl,{method:"POST",headers:{"Content-Type":"application/javascript"},body:e});if(!s.ok)throw new m("POST","/v1/mcp/uploads",s.status,await s.text());let{storageId:r}=await s.json();if(!r)throw new m("POST","/v1/mcp/uploads",502,"upload response omitted storageId");let a=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e)),c=Array.from(new Uint8Array(a)).map((l)=>l.toString(16).padStart(2,"0")).join("");return{bundleStorageId:r,sha256:c}}async getMcp(e){return await this.request("GET",`/v1/mcp/${encodeURIComponent(e)}`)}async updateMcp(e,t){return await this.request("PATCH",`/v1/mcp/${encodeURIComponent(e)}`,t)}async deleteMcp(e){return(await this.request("DELETE",`/v1/mcp/${encodeURIComponent(e)}`))?.deleted??!1}async listPolicies(){return(await this.request("GET","/v1/policies"))?.policies??[]}async createPolicy(e){let t=await this.request("POST","/v1/policies",e);if(!t)throw new m("POST","/v1/policies",404,"Not found");return t}async getPolicy(e){return await this.request("GET",`/v1/policies/${encodeURIComponent(e)}`)}async updatePolicy(e,t){return await this.request("PATCH",`/v1/policies/${encodeURIComponent(e)}`,t)}async deletePolicy(e){return(await this.request("DELETE",`/v1/policies/${encodeURIComponent(e)}`))?.deleted??!1}async listRoles(){return(await this.request("GET","/v1/roles"))?.roles??[]}async createRole(e){let t=await this.request("POST","/v1/roles",e);if(!t)throw new m("POST","/v1/roles",404,"Not found");return t}async getRole(e){return await this.request("GET",`/v1/roles/${encodeURIComponent(e)}`)}async updateRole(e,t){return await this.request("PATCH",`/v1/roles/${encodeURIComponent(e)}`,t)}async deleteRole(e){return(await this.request("DELETE",`/v1/roles/${encodeURIComponent(e)}`))?.deleted??!1}async listChannels(){return(await this.request("GET","/v1/channels"))?.channels??[]}async createChannel(e){let t=await this.request("POST","/v1/channels",e);if(!t)throw new m("POST","/v1/channels",404,"Not found");return t}async getChannel(e){return await this.request("GET",`/v1/channels/${encodeURIComponent(e)}`)}async updateChannel(e,t){return await this.request("PATCH",`/v1/channels/${encodeURIComponent(e)}`,t)}async deleteChannel(e){return(await this.request("DELETE",`/v1/channels/${encodeURIComponent(e)}`))?.deleted??!1}async listSkills(){return(await this.request("GET","/v1/skills"))?.skills??[]}async createSkill(e){let t=await this.request("POST","/v1/skills",e);if(!t)throw new m("POST","/v1/skills",404,"Not found");return t}async getSkill(e){return await this.request("GET",`/v1/skills/${encodeURIComponent(e)}`)}async uploadSkill(e,t){let n=`/v1/skills/${encodeURIComponent(e)}`,s=await this.request("PUT",n,t);if(!s)throw new m("PUT",n,404,"Skill not found");return s}async deleteSkill(e){return(await this.request("DELETE",`/v1/skills/${encodeURIComponent(e)}`))?.deleted??!1}async sandboxAction(e,t,n){let s=`/v1/sandboxes/${encodeURIComponent(e)}/${t}`,r=await this.request("POST",s,n);if(!r)throw new m("POST",s,404,"Sandbox not found");return r}async request(e,t,n){let s=await this.fetchImpl(`${this.baseUrl}${t}`,{method:e,headers:{Authorization:`Bearer ${this.bearerToken}`,...n!==void 0?{"Content-Type":"application/json"}:{}},...n!==void 0?{body:JSON.stringify(n)}:{}});if(s.status===404)return null;if(!s.ok)throw new m(e,t,s.status,await s.text());return await s.json()}}function o(e){return typeof process<"u"?process?.env?.[e]:void 0}function i(e){return`?${new URLSearchParams({project:e.project,stage:e.stage}).toString()}`}
|
|
2
|
+
export{m,Te,L,D};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ie,e,n,t,s}from"./chunk-js5cjmhp.js";import{readFileSync as d}from"node:fs";import{dirname as m,resolve as p}from"node:path";import{Client as g}from"@modelcontextprotocol/client";import{StdioClientTransport as h}from"@modelcontextprotocol/client/stdio";var f={name:"broods-machine",version:"1.0.0"},u=t({command:e().min(1),args:n(e()).default([]),env:s(e(),e()).optional(),cwd:e().optional()}),w=t({mcpServers:s(e(),u).refine((r)=>Object.keys(r).length>0,"lists no MCP servers")});class y{#t=new Map;#e;#r;constructor(r,i){this.#r=r,this.#e=i}async callTool(r,i,o){return await(await this.#n(r)).callTool({name:i,arguments:o})}async listTools(r){return(await(await this.#n(r)).listTools()).tools}names(){return[...this.#r.keys()]}async stop(){let r=[...this.#t.values()];this.#t.clear(),await Promise.all(r.map((i)=>i.then((o)=>o.close()).catch(()=>{})))}#n(r){let i=this.#r.get(r);if(!i)return Promise.reject(Error(`no MCP server named "${r}" in the --mcp file`));let o=this.#t.get(r);if(o)return o;let c=(async()=>{this.#e(`mcp ${r}: ${[i.command,...i.args].join(" ")}`);let a=new h({...i,env:{...v(),...i.env},stderr:"inherit"});a.onclose=()=>{if(this.#e(`mcp ${r}: exited`),this.#t.get(r)===c)this.#t.delete(r)};let l=new g(f);return await l.connect(a),l})();return c.catch(()=>{if(this.#t.get(r)===c)this.#t.delete(r)}),this.#t.set(r,c),c}}function R(r){let i=p(r),o=w.safeParse(S(i));if(!o.success)throw Error(`${i}: ${Ie(o.error)}`);return new Map(Object.entries(o.data.mcpServers).map(([c,a])=>[c,a.cwd?{...a,cwd:p(m(i),a.cwd)}:a]))}function v(){let r={};for(let[i,o]of Object.entries(process.env))if(typeof o==="string")r[i]=o;return r}function S(r){try{return JSON.parse(d(r,"utf8"))}catch(i){throw Error(`could not read ${r}: ${i instanceof Error?i.message:String(i)}`)}}export{y as McpHost,R as readMcpServersFile};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{P,i,q,A,W,G,J,b,T,Y,re,oe,fe,ge,ye,Se,se,ie,be,ve,_e,M}from"./chunk-qkytyr75.js";var L=class{_readBuffer;_started=!1;_closed=!1;constructor(r=se.stdin,s=se.stdout,c){this._stdin=r,this._stdout=s,this._readBuffer=new ye({maxBufferSize:c?.maxBufferSize})}onclose;onerror;onmessage;_ondata=(r)=>{try{this._readBuffer.append(r),this.processReadBuffer()}catch(s){this.onerror?.(s),this.close().catch(()=>{})}};_onerror=(r)=>{this.onerror?.(r)};_onstdouterror=(r)=>{this.onerror?.(r),this.close().catch(()=>{})};async start(){if(this._started)throw 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),this._stdout.on("error",this._onstdouterror)}processReadBuffer(){while(!0)try{let r=this._readBuffer.readMessage();if(r===null)break;this.onmessage?.(r)}catch(r){this.onerror?.(r)}}async close(){if(this._closed)return;if(this._closed=!0,this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdout.off("error",this._onstdouterror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(r){if(this._closed)return Promise.reject(Error("StdioServerTransport is closed"));return new Promise((s,c)=>{let l=Se(r),t=!1,f=(_)=>{if(t)return;t=!0,this._stdout.off("error",f),this._stdout.off("drain",p),c(_)},p=()=>{if(t)return;t=!0,this._stdout.off("error",f),this._stdout.off("drain",p),s()};if(this._stdout.once("error",f),this._stdout.write(l)){if(t)return;t=!0,this._stdout.off("error",f),s()}else if(!t)this._stdout.once("drain",p)})}},k=3000,U=class{onclose;onerror;onmessage;_closed=!1;_pendingRequests=new Set;_drainWaiters=[];constructor(r,s,c){this._wire=r,this._onInstanceClose=s,this._outboundIntercept=c}async start(){}async send(r,s){if(Y(r)||re(r)){let{id:c}=r;if(c!==void 0)this._settle(c)}if(this._closed)return;if(this._outboundIntercept?.(r)==="handled")return;return this._wire.send(r,s)}setProtocolVersion=(r)=>{this._wire.setProtocolVersion?.(r)};deliver(r,s){if(this._closed)return;if(b(r))this._pendingRequests.add(r.id);else if(T(r)&&r.method==="notifications/cancelled"){let c=r.params?.requestId;if(c!==void 0)this._settle(c)}this.onmessage?.(r,s)}async whenRequestsAnswered(r){if(this._closed||this._pendingRequests.size===0)return!0;return await new Promise((s)=>{let c=()=>{clearTimeout(l),s(!0)},l=setTimeout(()=>{this._drainWaiters=this._drainWaiters.filter((t)=>t!==c),s(!1)},r);this._drainWaiters.push(c)})}async close(){if(this._closed)return;this._closed=!0,this._pendingRequests.clear(),this._releaseDrainWaiters();try{this._onInstanceClose()}finally{this.onclose?.()}}_settle(r){if(this._pendingRequests.delete(r),this._pendingRequests.size===0)this._releaseDrainWaiters()}_releaseDrainWaiters(){let r=this._drainWaiters;this._drainWaiters=[];for(let s of r)s()}};function x(r){let s=r.params;if(r.method==="initialize"&&!oe(s)){let f=s!==null&&typeof s==="object"&&typeof s.protocolVersion==="string"?s.protocolVersion:void 0;return{kind:"legacy",reason:"initialize",...f!==void 0&&{requestedVersion:f}}}if(!W(s))return{kind:"legacy",reason:"no-claim"};let c=A(s),l=(c===void 0?[]:J(c))[0];if(l!==void 0)return{kind:"invalid-envelope",issue:l};let t=G(s);if(t===void 0||!P.includes(t))return{kind:"unsupported-revision",requested:t??"unknown"};return{kind:"modern",revision:t,classification:{era:"modern",revision:t}}}function H(r,s={}){let c=s.legacy??"serve",l=s.transport??new L,t={phase:"opening"},f,p=!1,_=()=>p||t.phase==="closed",d=(e)=>{try{s.onerror?.(e)}catch{}},y=(e,n,o,a)=>l.send({jsonrpc:"2.0",id:e,error:{code:n,message:o,...a!==void 0&&{data:a}}}).catch((u)=>d(h(u))),w=new be(s.maxSubscriptions??ie),D=(e)=>{if(!T(e))return;let n=w.routeOutbound(e);if(n==="passthrough")return;for(let o of n)l.send({jsonrpc:"2.0",...o}).catch((a)=>d(h(a)));return"handled"},I=async(e)=>{if(b(e)&&e.method==="subscriptions/listen"){let n=A(e.params),o=W(e.params)?(n===void 0?[]:J(n))[0]:{key:"_meta",problem:"the per-request envelope is required on protocol revision 2026-07-28"},a=G(e.params),u;if(o!==void 0)u={jsonrpc:"2.0",id:e.id,error:{code:-32602,message:`Invalid _meta envelope: ${o.key}: ${o.problem}`}};else if(a===void 0||!P.includes(a)){let v=new q({supported:[...P],requested:a??"unknown"});u={jsonrpc:"2.0",id:e.id,error:{code:v.code,message:v.message,data:v.data}}}else u=w.serve(e);return await l.send("error"in u?u:{jsonrpc:"2.0",method:u.method,params:u.params}).catch((v)=>d(h(v))),!0}if(T(e)&&e.method==="notifications/cancelled"){let n=e.params?.requestId;if(n!==void 0&&w.cancel(n))return!0}return!1},C=(e,n,o)=>{let a=fe({kind:"legacy",reason:n,...o!==void 0&&{requestedVersion:o}},P);if(a===void 0)return Promise.resolve();return d(Error(`Rejected 2025-era request on a modern-only stdio connection (${a.cell}): ${a.message}`)),y(e.id,a.code,a.message,a.data)},V=(e)=>{if(p||e===f)return;O()},m=async(e,n)=>{let o=await r({era:e}),a=o instanceof M?o.server:o;if(e==="modern")ge(a,n),ve(a,P),w.setServerCapabilities(a.getCapabilities(),_e(a));let u=new U(l,()=>V(u),e==="modern"?D:void 0);return await o.connect(u),{product:o,channel:u}},R=(e)=>e.product.close().catch((n)=>d(h(n))),B=async(e)=>{f=e.channel;try{if(!await e.channel.whenRequestsAnswered(k))d(Error(`Discarded the probe instance with requests still unanswered after ${k}ms; continuing with the fallback`));await e.product.close()}catch(n){d(h(n))}finally{f=void 0}},N=async(e)=>{if(t.phase==="closed")return;if(t.phase==="pinned"){if(t.era==="modern"&&b(e)&&e.method==="initialize"&&!oe(e.params)){await C(e,"initialize",e.params!==null&&typeof e.params==="object"&&typeof e.params.protocolVersion==="string"?e.params.protocolVersion:void 0);return}if(t.era==="modern"&&await I(e))return;t.instance.channel.deliver(e);return}if(!b(e)&&!T(e)){d(Error("Discarded a JSON-RPC response received before the connection negotiated an era"));return}let n=x(e);switch(n.kind){case"invalid-envelope":{let o=`Invalid _meta envelope for protocol revision 2026-07-28: ${n.issue.key}: ${n.issue.problem}`;if(b(e))await y(e.id,i.InvalidParams,o,{envelope:n.issue});else d(Error(`Discarded a notification with a malformed envelope: ${o}`));return}case"unsupported-revision":if(b(e)){let o=new q({supported:[...P],requested:n.requested});d(o),await y(e.id,o.code,o.message,o.data)}else d(Error(`Discarded a notification claiming unsupported protocol revision ${n.requested}`));return;case"modern":if(b(e)&&e.method==="server/discover"){if(t.phase==="probe"){t.instance.channel.deliver(e,{classification:n.classification});return}let o=await m("modern",n.revision);if(_()){await R(o);return}t={phase:"probe",instance:o},o.channel.deliver(e,{classification:n.classification});return}if(t.phase==="probe"){if(T(e)){t.instance.channel.deliver(e,{classification:n.classification});return}t={phase:"pinned",era:"modern",instance:t.instance}}else{let o=await m("modern",n.revision);if(_()){await R(o);return}t={phase:"pinned",era:"modern",instance:o}}if(await I(e))return;t.instance.channel.deliver(e,{classification:n.classification});return;case"legacy":{if(c==="reject"){if(b(e))await C(e,n.reason,n.requestedVersion);return}if(t.phase==="probe"){if(await B(t.instance),_())return;t={phase:"opening"}}let o=await m("legacy");if(_()){await R(o);return}t={phase:"pinned",era:"legacy",instance:o},t.instance.channel.deliver(e);return}}},S=[],E=!1,z=async()=>{if(E)return;E=!0;try{while(S.length>0){let e=S.shift();try{await N(e)}catch(n){if(b(e))await y(e.id,i.InternalError,"Internal server error");d(h(n))}}}finally{E=!1}},O=async()=>{if(p||t.phase==="closed")return;p=!0;let e=t;t={phase:"closed"};for(let n of w.teardownAll())await l.send(n).catch((o)=>d(h(o)));if(e.phase==="probe"||e.phase==="pinned")await e.instance.product.close().catch((n)=>d(h(n)));await l.close().catch((n)=>d(h(n)))};l.onmessage=(e)=>{S.push(e),z()},l.onerror=(e)=>{if(d(e),t.phase==="probe"||t.phase==="pinned")t.instance.channel.onerror?.(e)},l.onclose=()=>{if(p||t.phase==="closed")return;p=!0;let e=t;if(t={phase:"closed"},e.phase==="probe"||e.phase==="pinned")e.instance.product.close().catch((n)=>d(h(n)))};let j=l.start().catch((e)=>{throw d(h(e)),e});return j.catch(()=>{}),{close:async()=>{await j.catch(()=>{}),await O()}}}function h(r){return r instanceof Error?r:Error(String(r))}export{H as serveStdio};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{M}from"./chunk-qkytyr75.js";import{L,D}from"./chunk-9m85p3e3.js";import{e,o,a,l,s}from"./chunk-js5cjmhp.js";var R={project:e().optional(),stage:e().optional()},C={sandboxId:e().min(1),reservationKey:e().min(1)},v=a().describe("Must be true, after the owner has agreed to this delete."),E="'********' keeps a stored secret and null deletes a field: never send a placeholder you did not read from a get.",A=[{singular:"agent",plural:"agents",key:"agentId",createHint:"Needs name and config; a 409 returns the existing agentId.",deleteHint:"Deleting an agent also drops its runtime rows.",updateHint:E,list:(t)=>t.listAgents(),get:(t,r)=>t.getAgent(r),create:(t,r)=>t.createAgent(r),update:(t,r,n)=>t.updateAgent(r,n),remove:(t,r)=>t.deleteAgent(r)},{singular:"cron",plural:"crons",key:"cronId",createHint:"Needs name, agentId, scheduleExpression (rate/cron/at) and input or events.",list:(t)=>t.listCrons(),get:(t,r)=>t.getCron(r),create:(t,r)=>t.createCron(r),update:(t,r,n)=>t.updateCron(r,n),remove:(t,r)=>t.deleteCron(r)},{singular:"sandbox",plural:"sandboxes",key:"sandboxId",updateHint:E,list:(t)=>t.listSandboxes(),get:(t,r)=>t.getSandbox(r),create:(t,r)=>t.createSandbox(r),update:(t,r,n)=>t.updateSandbox(r,n),remove:(t,r)=>t.deleteSandbox(r)},{singular:"workspace",plural:"workspaces",key:"workspaceId",list:(t)=>t.listWorkspaces(),get:(t,r)=>t.getWorkspace(r),create:(t,r)=>t.createWorkspace(r),update:(t,r,n)=>t.updateWorkspace(r,n),remove:(t,r)=>t.deleteWorkspace(r)},{singular:"policy",plural:"policies",key:"policyId",createHint:"Agent-runtime policy document (tool.call, skill.load), not API credential scoping.",list:(t)=>t.listPolicies(),get:(t,r)=>t.getPolicy(r),create:(t,r)=>t.createPolicy(r),update:(t,r,n)=>t.updatePolicy(r,n),remove:(t,r)=>t.deletePolicy(r)},{singular:"role",plural:"roles",key:"roleId",createHint:"Needs name and a version-1 policy over the API namespace, e.g. agents:read. Account secret only.",list:(t)=>t.listRoles(),get:(t,r)=>t.getRole(r),create:(t,r)=>t.createRole(r),update:(t,r,n)=>t.updateRole(r,n),remove:(t,r)=>t.deleteRole(r)},{singular:"channel",plural:"channels",key:"channelId",list:(t)=>t.listChannels(),get:(t,r)=>t.getChannel(r),create:(t,r)=>t.createChannel(r),update:(t,r,n)=>t.updateChannel(r,n),remove:(t,r)=>t.deleteChannel(r)},{singular:"skill",plural:"skills",key:"skillName",createHint:'source is "files" (base64), "json" or "github". The stored name comes from the SKILL.md frontmatter.',list:(t)=>t.listSkills(),get:(t,r)=>t.getSkill(r),create:(t,r)=>t.createSkill(r),remove:(t,r)=>t.deleteSkill(r)},{singular:"mcp",plural:"mcp",key:"serverId",scoped:!0,list:(t,r)=>t.listMcp(r),get:(t,r)=>t.getMcp(r),create:(t,r,n)=>t.createMcp(n,r),update:(t,r,n)=>t.updateMcp(r,n),remove:(t,r)=>t.deleteMcp(r)}];function Pt(t={}){let r=L()?new D({}):null;if(!r&&!t.cli)throw Error("broods mcp needs a credential: set BROODS_SESSION_TOKEN or BROODS_ACCOUNT_SECRET, or run `broods login`.");let n=new M({name:"broods",version:"1"},{capabilities:{tools:{}}});if(r){for(let i of A)N(n,r,i,t.scope??{});j(n,r)}if(t.cli)O(n,t.cli);if(t.allowDestructive)q(n,r,t.cli??null);return n}function w(t,r){if(!t)throw Error(`Refusing without confirm:true. ${r}`)}async function d(t){try{return P(await t())}catch(r){return k(r)}}function k(t){return{content:[{type:"text",text:t instanceof Error?t.message:String(t)}],isError:!0}}function P(t){return{content:[{type:"text",text:JSON.stringify(t??null,null,2)}]}}function b(t,r,n,i){if(!t.scoped)return;let c=n??r.project,p=i??r.stage;if(!c||!p)throw Error(`${t.plural} live in one stage, so this call needs both 'project' and 'stage'`);return{project:c,stage:p}}function O(t,r){t.registerTool("list-orgs",{description:"Every organization this login can reach, with the current one marked.",inputSchema:{}},async()=>await d(async()=>{let n=await r.getOnboarding();return{currentOrgId:n.currentOrgId,orgs:n.orgs}})),t.registerTool("create-org",{description:"Create an organization and switch this login to it. Later calls act in the new org.",inputSchema:{name:e().min(1)}},async({name:n})=>await d(async()=>await r.createOnboardingOrg(n))),t.registerTool("select-org",{description:"Switch this login to another organization, by an orgId from list-orgs.",inputSchema:{orgId:e().min(1)}},async({orgId:n})=>await d(async()=>await r.selectOnboardingOrg(n))),t.registerTool("list-projects",{description:"Every project in the current org, empty ones last. Project names are not unique, so take the id from here.",inputSchema:{}},async()=>await d(async()=>await r.listProjects())),t.registerTool("list-stages",{description:"Every stage of one project, by project name.",inputSchema:{project:e().min(1)}},async({project:n})=>await d(async()=>await r.listStages(n))),t.registerTool("create-stage",{description:"Create a stage in a project, optionally cloning another stage's architecture and env vars. A project name that does not exist yet is created with it, which is the only way to make a project without deploying a manifest.",inputSchema:{project:e().min(1),name:e().min(1),from:e().optional().describe("Stage to clone architecture and env vars from.")}},async({project:n,name:i,from:c})=>await d(async()=>await r.createStage(n,i,c)))}function q(t,r,n){if(r)t.registerTool("rotate-secret",{description:"Rotate the account secret. The current secret stops working immediately and the new one is shown once, so this breaks every deployment and CI job still holding the old one. Requires confirm:true.",inputSchema:{confirm:v}},async({confirm:i})=>await d(async()=>(w(i,"Everything holding the current secret breaks the moment this runs."),await r.rotateSecret())));if(n)t.registerTool("delete-project",{description:"Delete a project and everything under it: stages, agents, canvas, env vars, crons and workspace files. Takes a projectId from list-projects and requires confirm:true.",inputSchema:{projectId:e().min(1),confirm:v}},async({projectId:i,confirm:c})=>await d(async()=>(w(c,`Project '${i}' and everything under it goes away: name it, get the owner's agreement, then retry.`),await n.deleteProject(i))))}function j(t,r){t.registerTool("list-cron-runs",{description:"Run history for one cron, newest first. Check this before telling anyone a cron fired.",inputSchema:{cronId:e().min(1),limit:o().int().positive().max(100).optional()}},async({cronId:i,limit:c})=>await d(async()=>await r.listCronRuns(i,c===void 0?{}:{limit:c})));let n=[["suspend-sandbox","Suspend a persistent sandbox reservation.",(i,c)=>r.suspendSandbox(i,c)],["resume-sandbox","Resume a suspended sandbox reservation.",(i,c)=>r.resumeSandbox(i,c)],["terminate-sandbox","Terminate a sandbox reservation and drop its live-instance row. Terminate only a sandbox you created, and never one holding state you did not put there.",(i,c)=>r.terminateSandbox(i,c)],["open-sandbox-terminal","Mint a short-lived sealed ticket for an interactive PTY session on a persistent sandbox.",(i,c)=>r.openSandboxTerminal(i,c)]];for(let[i,c,p]of n)t.registerTool(i,{description:c,inputSchema:C},async({sandboxId:f,reservationKey:g})=>await d(async()=>await p(f,g)));t.registerTool("snapshot-sandbox",{description:"Snapshot a sandbox reservation into a reusable image (self-hosted provider).",inputSchema:{sandboxId:e().min(1),reservationKey:e().min(1),name:e().min(1)}},async({sandboxId:i,reservationKey:c,name:p})=>await d(async()=>await r.snapshotSandbox(i,c,p))),t.registerTool("upload-skill",{description:"Replace one skill's bundle wholesale (PUT, not a merge) by skillName. 'body' is the same source shape create-skill takes.",inputSchema:{id:e().min(1).describe("The skillName."),body:s(e(),l())}},async({id:i,body:c})=>await d(async()=>await r.uploadSkill(i,c))),t.registerTool("list-env-vars",{description:"List environment variable names. Values are write-only: the plane never returns them, so there is no read.",inputSchema:{}},async()=>await d(async()=>await r.listEnvVars())),t.registerTool("set-env-var",{description:"Create or replace one write-only environment variable. Reference it from a config as ${NAME} rather than inlining the value.",inputSchema:{name:e().min(1),value:e()}},async({name:i,value:c})=>await d(async()=>(await r.setEnvVar(i,c),{name:i,stored:!0}))),t.registerTool("delete-env-var",{description:"Delete one environment variable.",inputSchema:{name:e().min(1),confirm:v}},async({name:i,confirm:c})=>await d(async()=>(w(c,`Anything referencing \${${i}} breaks the moment this env var goes.`),{deleted:await r.deleteEnvVar(i),name:i}))),t.registerTool("assume-role",{description:"Exchange a role for a short-lived session token (default 1h, max 12h). Hand the returned token to whatever tool needs narrow access, as BROODS_SESSION_TOKEN. It is shown once and is not stored here.",inputSchema:{roleId:e().min(1),ttlSeconds:o().int().positive().max(43200).optional()}},async({roleId:i,ttlSeconds:c})=>await d(async()=>await r.assumeRole(i,c===void 0?{}:{ttlSeconds:c}))),t.registerTool("update-account",{description:"Rename this account or change its description. Everything else about an account is derived, not settable.",inputSchema:{username:e().optional(),description:e().nullable().optional()}},async({username:i,description:c})=>await d(async()=>await r.updateAccount({...i===void 0?{}:{username:i},...c===void 0?{}:{description:c}}))),t.registerTool("get-account",{description:"The account this server's credential resolves to. Run it first to confirm which tenant you are about to change.",inputSchema:{}},async()=>await d(async()=>await r.getAccount()))}function N(t,r,n,i){let c=e().min(1).describe(`The ${n.key}.`),p=n.scoped?` ${n.plural} live in one stage, so this also takes 'project' and 'stage'.`:"",{list:f,get:g,create:y,update:S,remove:_}=n;if(f){let u=`List every ${n.singular} on the account.${p}`;if(n.scoped)t.registerTool(`list-${n.plural}`,{description:u,inputSchema:R},async({project:h,stage:m})=>await d(async()=>await f(r,b(n,i,h,m))));else t.registerTool(`list-${n.plural}`,{description:u,inputSchema:{}},async()=>await d(async()=>await f(r)))}if(g)t.registerTool(`get-${n.singular}`,{description:`Read one ${n.singular} by ${n.key}.`,inputSchema:{id:c}},async({id:u})=>await d(async()=>await g(r,u)));if(y){let u=`Create one ${n.singular}. 'body' is the request body the config plane documents.`+(n.createHint?` ${n.createHint}`:"")+p+" Prefer changing the broods/ manifest and deploying for anything the project already declares.",h=s(e(),l());if(n.scoped)t.registerTool(`create-${n.singular}`,{description:u,inputSchema:{body:h,...R}},async({body:m,project:T,stage:I})=>await d(async()=>await y(r,m,b(n,i,T,I))));else t.registerTool(`create-${n.singular}`,{description:u,inputSchema:{body:h}},async({body:m})=>await d(async()=>await y(r,m)))}if(S)t.registerTool(`update-${n.singular}`,{description:`Deep-merge a patch into one ${n.singular} and return the updated record, so there is no need to read it back.`+(n.updateHint?` ${n.updateHint}`:""),inputSchema:{id:c,body:s(e(),l())}},async({id:u,body:h})=>await d(async()=>await S(r,u,h)));if(_)t.registerTool(`delete-${n.singular}`,{description:`Delete one ${n.singular}. Requires confirm:true, and takes one ${n.key} per call: never loop this over a list.`+(n.deleteHint?` ${n.deleteHint}`:""),inputSchema:{id:c,confirm:v}},async({id:u,confirm:h})=>await d(async()=>(w(h,`Deleting ${n.singular} '${u}' goes away for good: name it, get the owner's agreement, then retry.`),{deleted:await _(r,u),id:u})))}export{Pt as createBroodsMcpServer};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{y,ae,ce,Re}from"./chunk-js5cjmhp.js";var c=()=>{let a={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function n(t){return a[t]??null}let d={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},o={nan:"NaN"};return(t)=>{switch(t.code){case"invalid_type":{let e=o[t.expected]??t.expected,r=Re(t.input),l=o[r]??r;return`Invalid input: expected ${e}, received ${l}`}case"invalid_value":if(t.values.length===1)return`Invalid input: expected ${ce(t.values[0])}`;return`Invalid option: expected one of ${ae(t.values,"|")}`;case"too_big":{let e=t.inclusive?"<=":"<",r=n(t.origin);if(r)return`Too big: expected ${t.origin??"value"} to have ${e}${t.maximum.toString()} ${r.unit??"elements"}`;return`Too big: expected ${t.origin??"value"} to be ${e}${t.maximum.toString()}`}case"too_small":{let e=t.inclusive?">=":">",r=n(t.origin);if(r)return`Too small: expected ${t.origin} to have ${e}${t.minimum.toString()} ${r.unit}`;return`Too small: expected ${t.origin} to be ${e}${t.minimum.toString()}`}case"invalid_format":{let e=t;if(e.format==="starts_with")return`Invalid string: must start with "${e.prefix}"`;if(e.format==="ends_with")return`Invalid string: must end with "${e.suffix}"`;if(e.format==="includes")return`Invalid string: must include "${e.includes}"`;if(e.format==="regex")return`Invalid string: must match pattern ${e.pattern}`;return`Invalid ${d[e.format]??t.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${t.divisor}`;case"unrecognized_keys":return`Unrecognized key${t.keys.length>1?"s":""}: ${ae(t.keys,", ")}`;case"invalid_key":return`Invalid key in ${t.origin}`;case"invalid_union":if(t.options&&Array.isArray(t.options)&&t.options.length>0)return`Invalid discriminator value. Expected ${t.options.map((r)=>`'${r}'`).join(" | ")}`;return"Invalid input";case"invalid_element":return`Invalid value in ${t.origin}`;default:return"Invalid input"}}};function i(){return{localeError:c()}}y(i());
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var at,we=Object.freeze({status:"aborted"});function Z(i,f,m){function h(v,b){if(!v._zod)Object.defineProperty(v,"_zod",{value:{def:b,constr:z,traits:new Set},enumerable:!1});if(v._zod.traits.has(i))return;v._zod.traits.add(i),f(v,b);let w=z.prototype,P=Object.keys(w);for(let O=0;O<P.length;O++){let T=P[O];if(!(T in v))v[T]=w[T].bind(v)}}let _=m?.Parent??Object;class g extends _{}Object.defineProperty(g,"name",{value:i});function z(v){var b;let w=m?.Parent?new g:this;h(w,v),(b=w._zod).deferred??(b.deferred=[]);for(let P of w._zod.deferred)P();return w}return Object.defineProperty(z,"init",{value:h}),Object.defineProperty(z,Symbol.hasInstance,{value:(v)=>{if(m?.Parent&&v instanceof m.Parent)return!0;return v?._zod?.traits?.has(i)}}),Object.defineProperty(z,"name",{value:i}),z}var yc=Symbol("zod_brand");class re extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class ve extends Error{constructor(i){super(`Encountered unidirectional transform during encode: ${i}`);this.name="ZodEncodeError"}}(at=globalThis).__zod_globalConfig??(at.__zod_globalConfig={});var _e=globalThis.__zod_globalConfig;function y(i){if(i)Object.assign(_e,i);return _e}function Fe(i){let f=Object.values(i).filter((h)=>typeof h==="number");return Object.entries(i).filter(([h,_])=>f.indexOf(+h)===-1).map(([h,_])=>_)}function ae(i,f="|"){return i.map((m)=>ce(m)).join(f)}function ye(i,f){if(typeof f==="bigint")return f.toString();return f}function be(i){return{get value(){{let m=i();return Object.defineProperty(this,"value",{value:m}),m}throw Error("cached value already set")}}}function Ue(i){return i===null||i===void 0}function Me(i){let f=i.startsWith("^")?1:0,m=i.endsWith("$")?i.length-1:i.length;return i.slice(f,m)}function lt(i,f){let m=i/f,h=Math.round(m),_=Number.EPSILON*Math.max(Math.abs(m),1);if(Math.abs(m-h)<_)return 0;return m-h}var pt=Symbol("evaluating");function A(i,f,m){let h=void 0;Object.defineProperty(i,f,{get(){if(h===pt)return;if(h===void 0)h=pt,h=m();return h},set(_){Object.defineProperty(i,f,{value:_})},configurable:!0})}function pe(i,f,m){Object.defineProperty(i,f,{value:m,writable:!0,enumerable:!0,configurable:!0})}function te(...i){let f={};for(let m of i){let h=Object.getOwnPropertyDescriptors(m);Object.assign(f,h)}return Object.defineProperties({},f)}function cr(i){return JSON.stringify(i)}function ft(i){return i.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var ur="captureStackTrace"in Error?Error.captureStackTrace:(...i)=>{};function ge(i){return typeof i==="object"&&i!==null&&!Array.isArray(i)}var dt=be(()=>{if(_e.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(i){return!1}});function fe(i){if(ge(i)===!1)return!1;let f=i.constructor;if(f===void 0)return!0;if(typeof f!=="function")return!0;let m=f.prototype;if(ge(m)===!1)return!1;if(Object.prototype.hasOwnProperty.call(m,"isPrototypeOf")===!1)return!1;return!0}function ar(i){if(fe(i))return{...i};if(Array.isArray(i))return[...i];if(i instanceof Map)return new Map(i);if(i instanceof Set)return new Set(i);return i}var mt=new Set(["string","number","symbol"]);function oe(i){return i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function H(i,f,m){let h=new i._zod.constr(f??i._zod.def);if(!f||m?.parent)h._zod.parent=i;return h}function S(i){let f=i;if(!f)return{};if(typeof f==="string")return{error:()=>f};if(f?.message!==void 0){if(f?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");f.error=f.message}if(delete f.message,typeof f.error==="string")return{...f,error:()=>f.error};return f}function ce(i){if(typeof i==="bigint")return i.toString()+"n";if(typeof i==="string")return`"${i}"`;return`${i}`}function ht(i){return Object.keys(i).filter((f)=>i[f]._zod.optin==="optional"&&i[f]._zod.optout==="optional")}var _t={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ei(i,f){let m=i._zod.def,h=m.checks;if(h&&h.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let g=te(i._zod.def,{get shape(){let z={};for(let v in f){if(!(v in m.shape))throw Error(`Unrecognized key: "${v}"`);if(!f[v])continue;z[v]=m.shape[v]}return pe(this,"shape",z),z},checks:[]});return H(i,g)}function ri(i,f){let m=i._zod.def,h=m.checks;if(h&&h.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let g=te(i._zod.def,{get shape(){let z={...i._zod.def.shape};for(let v in f){if(!(v in m.shape))throw Error(`Unrecognized key: "${v}"`);if(!f[v])continue;delete z[v]}return pe(this,"shape",z),z},checks:[]});return H(i,g)}function ti(i,f){if(!fe(f))throw Error("Invalid input to extend: expected a plain object");let m=i._zod.def.checks;if(m&&m.length>0){let g=i._zod.def.shape;for(let z in f)if(Object.getOwnPropertyDescriptor(g,z)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let _=te(i._zod.def,{get shape(){let g={...i._zod.def.shape,...f};return pe(this,"shape",g),g}});return H(i,_)}function oi(i,f){if(!fe(f))throw Error("Invalid input to safeExtend: expected a plain object");let m=te(i._zod.def,{get shape(){let h={...i._zod.def.shape,...f};return pe(this,"shape",h),h}});return H(i,m)}function ni(i,f){if(i._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let m=te(i._zod.def,{get shape(){let h={...i._zod.def.shape,...f._zod.def.shape};return pe(this,"shape",h),h},get catchall(){return f._zod.def.catchall},checks:f._zod.def.checks??[]});return H(i,m)}function si(i,f,m){let _=f._zod.def.checks;if(_&&_.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let z=te(f._zod.def,{get shape(){let v=f._zod.def.shape,b={...v};if(m)for(let w in m){if(!(w in v))throw Error(`Unrecognized key: "${w}"`);if(!m[w])continue;b[w]=i?new i({type:"optional",innerType:v[w]}):v[w]}else for(let w in v)b[w]=i?new i({type:"optional",innerType:v[w]}):v[w];return pe(this,"shape",b),b},checks:[]});return H(f,z)}function ii(i,f,m){let h=te(f._zod.def,{get shape(){let _=f._zod.def.shape,g={..._};if(m)for(let z in m){if(!(z in g))throw Error(`Unrecognized key: "${z}"`);if(!m[z])continue;g[z]=new i({type:"nonoptional",innerType:_[z]})}else for(let z in _)g[z]=new i({type:"nonoptional",innerType:_[z]});return pe(this,"shape",g),g}});return H(f,h)}function de(i,f=0){if(i.aborted===!0)return!0;for(let m=f;m<i.issues.length;m++)if(i.issues[m]?.continue!==!0)return!0;return!1}function gt(i,f=0){if(i.aborted===!0)return!0;for(let m=f;m<i.issues.length;m++)if(i.issues[m]?.continue===!1)return!0;return!1}function ne(i,f){return f.map((m)=>{var h;return(h=m).path??(h.path=[]),m.path.unshift(i),m})}function Le(i){return typeof i==="string"?i:i?.message}function q(i,f,m){let h=i.message?i.message:Le(i.inst?._zod.def?.error?.(i))??Le(f?.error?.(i))??Le(m.customError?.(i))??Le(m.localeError?.(i))??"Invalid input",{inst:_,continue:g,input:z,...v}=i;if(v.path??(v.path=[]),v.message=h,f?.reportInput)v.input=z;return v}function Je(i){if(Array.isArray(i))return"array";if(typeof i==="string")return"string";return"unknown"}function Re(i){let f=typeof i;switch(f){case"number":return Number.isNaN(i)?"nan":"number";case"object":{if(i===null)return"null";if(Array.isArray(i))return"array";let m=i;if(m&&Object.getPrototypeOf(m)!==Object.prototype&&"constructor"in m&&m.constructor)return m.constructor.name}}return f}function me(...i){let[f,m,h]=i;if(typeof f==="string")return{message:f,code:"custom",input:m,inst:h};return{...f}}var xt=(i,f)=>{i.name="$ZodError",Object.defineProperty(i,"_zod",{value:i._zod,enumerable:!1}),Object.defineProperty(i,"issues",{value:f,enumerable:!1}),i.message=JSON.stringify(f,ye,2),Object.defineProperty(i,"toString",{value:()=>i.message,enumerable:!1})},Be=Z("$ZodError",xt),pr=Z("$ZodError",xt,{Parent:Error});function zt(i,f=(m)=>m.message){let m={},h=[];for(let _ of i.issues)if(_.path.length>0)m[_.path[0]]=m[_.path[0]]||[],m[_.path[0]].push(f(_));else h.push(f(_));return{formErrors:h,fieldErrors:m}}function vt(i,f=(m)=>m.message){let m={_errors:[]},h=(_,g=[])=>{for(let z of _.issues)if(z.code==="invalid_union"&&z.errors.length)z.errors.map((v)=>h({issues:v},[...g,...z.path]));else if(z.code==="invalid_key")h({issues:z.issues},[...g,...z.path]);else if(z.code==="invalid_element")h({issues:z.issues},[...g,...z.path]);else{let v=[...g,...z.path];if(v.length===0)m._errors.push(f(z));else{let b=m,w=0;while(w<v.length){let P=v[w];if(w!==v.length-1)b[P]=b[P]||{_errors:[]};else b[P]=b[P]||{_errors:[]},b[P]._errors.push(f(z));b=b[P],w++}}}};return h(i),m}function ci(i){let f=[],m=i.map((h)=>typeof h==="object"?h.key:h);for(let h of m)if(typeof h==="number")f.push(`[${h}]`);else if(typeof h==="symbol")f.push(`[${JSON.stringify(String(h))}]`);else if(/[^\w$]/.test(h))f.push(`[${JSON.stringify(h)}]`);else{if(f.length)f.push(".");f.push(h)}return f.join("")}function Ie(i){let f=[],m=[...i.issues].sort((h,_)=>(h.path??[]).length-(_.path??[]).length);for(let h of m)if(f.push(`✖ ${h.message}`),h.path?.length)f.push(` → at ${ci(h.path)}`);return f.join(`
|
|
2
|
+
`)}var Ve=(i)=>(f,m,h,_)=>{let g=h?{...h,async:!1}:{async:!1},z=f._zod.run({value:m,issues:[]},g);if(z instanceof Promise)throw new re;if(z.issues.length){let v=new(_?.Err??i)(z.issues.map((b)=>q(b,g,y())));throw ur(v,_?.callee),v}return z.value};var We=(i)=>async(f,m,h,_)=>{let g=h?{...h,async:!0}:{async:!0},z=f._zod.run({value:m,issues:[]},g);if(z instanceof Promise)z=await z;if(z.issues.length){let v=new(_?.Err??i)(z.issues.map((b)=>q(b,g,y())));throw ur(v,_?.callee),v}return z.value};var Ze=(i)=>(f,m,h)=>{let _=h?{...h,async:!1}:{async:!1},g=f._zod.run({value:m,issues:[]},_);if(g instanceof Promise)throw new re;return g.issues.length?{success:!1,error:new(i??Be)(g.issues.map((z)=>q(z,_,y())))}:{success:!0,data:g.value}},yt=Ze(pr),Pe=(i)=>async(f,m,h)=>{let _=h?{...h,async:!0}:{async:!0},g=f._zod.run({value:m,issues:[]},_);if(g instanceof Promise)g=await g;return g.issues.length?{success:!1,error:new i(g.issues.map((z)=>q(z,_,y())))}:{success:!0,data:g.value}},$t=Pe(pr),bt=(i)=>(f,m,h)=>{let _=h?{...h,direction:"backward"}:{direction:"backward"};return Ve(i)(f,m,_)};var wt=(i)=>(f,m,h)=>Ve(i)(f,m,h);var kt=(i)=>async(f,m,h)=>{let _=h?{...h,direction:"backward"}:{direction:"backward"};return We(i)(f,m,_)};var Zt=(i)=>async(f,m,h)=>We(i)(f,m,h);var Pt=(i)=>(f,m,h)=>{let _=h?{...h,direction:"backward"}:{direction:"backward"};return Ze(i)(f,m,_)};var St=(i)=>(f,m,h)=>Ze(i)(f,m,h);var Ot=(i)=>async(f,m,h)=>{let _=h?{...h,direction:"backward"}:{direction:"backward"};return Pe(i)(f,m,_)};var Et=(i)=>async(f,m,h)=>Pe(i)(f,m,h);var It=/^[cC][0-9a-z]{6,}$/,Tt=/^[0-9a-z]+$/,Nt=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,At=/^[0-9a-vA-V]{20}$/,jt=/^[A-Za-z0-9]{27}$/,Ct=/^[a-zA-Z0-9_-]{21}$/,Rt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Dt=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,lr=(i)=>{if(!i)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${i}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var Lt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var ai="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Ft(){return new RegExp(ai,"u")}var Ut=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Mt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Jt=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Bt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Vt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,fr=/^[A-Za-z0-9_-]*$/;var Wt=/^https?$/,Kt=/^\+[1-9]\d{6,14}$/,Gt="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",qt=new RegExp(`^${Gt}$`);function Yt(i){return typeof i.precision==="number"?i.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":i.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${i.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function Xt(i){return new RegExp(`^${Yt(i)}$`)}function Ht(i){let f=Yt({precision:i.precision}),m=["Z"];if(i.local)m.push("");if(i.offset)m.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let h=`${f}(?:${m.join("|")})`;return new RegExp(`^${Gt}T(?:${h})$`)}var Qt=(i)=>{let f=i?`[\\s\\S]{${i?.minimum??0},${i?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${f}$`)};var eo=/^-?\d+$/,dr=/^-?\d+(?:\.\d+)?$/,ro=/^(?:true|false)$/i,to=/^null$/i;var oo=/^[^A-Z]*$/,no=/^[^a-z]*$/;var W=Z("$ZodCheck",(i,f)=>{var m;i._zod??(i._zod={}),i._zod.def=f,(m=i._zod).onattach??(m.onattach=[])}),so={number:"number",bigint:"bigint",object:"date"},mr=Z("$ZodCheckLessThan",(i,f)=>{W.init(i,f);let m=so[typeof f.value];i._zod.onattach.push((h)=>{let _=h._zod.bag,g=(f.inclusive?_.maximum:_.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(f.value<g)if(f.inclusive)_.maximum=f.value;else _.exclusiveMaximum=f.value}),i._zod.check=(h)=>{if(f.inclusive?h.value<=f.value:h.value<f.value)return;h.issues.push({origin:m,code:"too_big",maximum:typeof f.value==="object"?f.value.getTime():f.value,input:h.value,inclusive:f.inclusive,inst:i,continue:!f.abort})}}),hr=Z("$ZodCheckGreaterThan",(i,f)=>{W.init(i,f);let m=so[typeof f.value];i._zod.onattach.push((h)=>{let _=h._zod.bag,g=(f.inclusive?_.minimum:_.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(f.value>g)if(f.inclusive)_.minimum=f.value;else _.exclusiveMinimum=f.value}),i._zod.check=(h)=>{if(f.inclusive?h.value>=f.value:h.value>f.value)return;h.issues.push({origin:m,code:"too_small",minimum:typeof f.value==="object"?f.value.getTime():f.value,input:h.value,inclusive:f.inclusive,inst:i,continue:!f.abort})}}),io=Z("$ZodCheckMultipleOf",(i,f)=>{W.init(i,f),i._zod.onattach.push((m)=>{var h;(h=m._zod.bag).multipleOf??(h.multipleOf=f.value)}),i._zod.check=(m)=>{if(typeof m.value!==typeof f.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof m.value==="bigint"?m.value%f.value===BigInt(0):lt(m.value,f.value)===0)return;m.issues.push({origin:typeof m.value,code:"not_multiple_of",divisor:f.value,input:m.value,inst:i,continue:!f.abort})}}),co=Z("$ZodCheckNumberFormat",(i,f)=>{W.init(i,f),f.format=f.format||"float64";let m=f.format?.includes("int"),h=m?"int":"number",[_,g]=_t[f.format];i._zod.onattach.push((z)=>{let v=z._zod.bag;if(v.format=f.format,v.minimum=_,v.maximum=g,m)v.pattern=eo}),i._zod.check=(z)=>{let v=z.value;if(m){if(!Number.isInteger(v)){z.issues.push({expected:h,format:f.format,code:"invalid_type",continue:!1,input:v,inst:i});return}if(!Number.isSafeInteger(v)){if(v>0)z.issues.push({input:v,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:i,origin:h,inclusive:!0,continue:!f.abort});else z.issues.push({input:v,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:i,origin:h,inclusive:!0,continue:!f.abort});return}}if(v<_)z.issues.push({origin:"number",input:v,code:"too_small",minimum:_,inclusive:!0,inst:i,continue:!f.abort});if(v>g)z.issues.push({origin:"number",input:v,code:"too_big",maximum:g,inclusive:!0,inst:i,continue:!f.abort})}});var uo=Z("$ZodCheckMaxLength",(i,f)=>{var m;W.init(i,f),(m=i._zod.def).when??(m.when=(h)=>{let _=h.value;return!Ue(_)&&_.length!==void 0}),i._zod.onattach.push((h)=>{let _=h._zod.bag.maximum??Number.POSITIVE_INFINITY;if(f.maximum<_)h._zod.bag.maximum=f.maximum}),i._zod.check=(h)=>{let _=h.value;if(_.length<=f.maximum)return;let z=Je(_);h.issues.push({origin:z,code:"too_big",maximum:f.maximum,inclusive:!0,input:_,inst:i,continue:!f.abort})}}),ao=Z("$ZodCheckMinLength",(i,f)=>{var m;W.init(i,f),(m=i._zod.def).when??(m.when=(h)=>{let _=h.value;return!Ue(_)&&_.length!==void 0}),i._zod.onattach.push((h)=>{let _=h._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(f.minimum>_)h._zod.bag.minimum=f.minimum}),i._zod.check=(h)=>{let _=h.value;if(_.length>=f.minimum)return;let z=Je(_);h.issues.push({origin:z,code:"too_small",minimum:f.minimum,inclusive:!0,input:_,inst:i,continue:!f.abort})}}),po=Z("$ZodCheckLengthEquals",(i,f)=>{var m;W.init(i,f),(m=i._zod.def).when??(m.when=(h)=>{let _=h.value;return!Ue(_)&&_.length!==void 0}),i._zod.onattach.push((h)=>{let _=h._zod.bag;_.minimum=f.length,_.maximum=f.length,_.length=f.length}),i._zod.check=(h)=>{let _=h.value,g=_.length;if(g===f.length)return;let z=Je(_),v=g>f.length;h.issues.push({origin:z,...v?{code:"too_big",maximum:f.length}:{code:"too_small",minimum:f.length},inclusive:!0,exact:!0,input:h.value,inst:i,continue:!f.abort})}}),Se=Z("$ZodCheckStringFormat",(i,f)=>{var m,h;if(W.init(i,f),i._zod.onattach.push((_)=>{let g=_._zod.bag;if(g.format=f.format,f.pattern)g.patterns??(g.patterns=new Set),g.patterns.add(f.pattern)}),f.pattern)(m=i._zod).check??(m.check=(_)=>{if(f.pattern.lastIndex=0,f.pattern.test(_.value))return;_.issues.push({origin:"string",code:"invalid_format",format:f.format,input:_.value,...f.pattern?{pattern:f.pattern.toString()}:{},inst:i,continue:!f.abort})});else(h=i._zod).check??(h.check=()=>{})}),lo=Z("$ZodCheckRegex",(i,f)=>{Se.init(i,f),i._zod.check=(m)=>{if(f.pattern.lastIndex=0,f.pattern.test(m.value))return;m.issues.push({origin:"string",code:"invalid_format",format:"regex",input:m.value,pattern:f.pattern.toString(),inst:i,continue:!f.abort})}}),fo=Z("$ZodCheckLowerCase",(i,f)=>{f.pattern??(f.pattern=oo),Se.init(i,f)}),mo=Z("$ZodCheckUpperCase",(i,f)=>{f.pattern??(f.pattern=no),Se.init(i,f)}),ho=Z("$ZodCheckIncludes",(i,f)=>{W.init(i,f);let m=oe(f.includes),h=new RegExp(typeof f.position==="number"?`^.{${f.position}}${m}`:m);f.pattern=h,i._zod.onattach.push((_)=>{let g=_._zod.bag;g.patterns??(g.patterns=new Set),g.patterns.add(h)}),i._zod.check=(_)=>{if(_.value.includes(f.includes,f.position))return;_.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:f.includes,input:_.value,inst:i,continue:!f.abort})}}),_o=Z("$ZodCheckStartsWith",(i,f)=>{W.init(i,f);let m=new RegExp(`^${oe(f.prefix)}.*`);f.pattern??(f.pattern=m),i._zod.onattach.push((h)=>{let _=h._zod.bag;_.patterns??(_.patterns=new Set),_.patterns.add(m)}),i._zod.check=(h)=>{if(h.value.startsWith(f.prefix))return;h.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:f.prefix,input:h.value,inst:i,continue:!f.abort})}}),go=Z("$ZodCheckEndsWith",(i,f)=>{W.init(i,f);let m=new RegExp(`.*${oe(f.suffix)}$`);f.pattern??(f.pattern=m),i._zod.onattach.push((h)=>{let _=h._zod.bag;_.patterns??(_.patterns=new Set),_.patterns.add(m)}),i._zod.check=(h)=>{if(h.value.endsWith(f.suffix))return;h.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:f.suffix,input:h.value,inst:i,continue:!f.abort})}});var xo=Z("$ZodCheckOverwrite",(i,f)=>{W.init(i,f),i._zod.check=(m)=>{m.value=f.tx(m.value)}});class _r{constructor(i=[]){if(this.content=[],this.indent=0,this)this.args=i}indented(i){this.indent+=1,i(this),this.indent-=1}write(i){if(typeof i==="function"){i(this,{execution:"sync"}),i(this,{execution:"async"});return}let m=i.split(`
|
|
3
|
+
`).filter((g)=>g),h=Math.min(...m.map((g)=>g.length-g.trimStart().length)),_=m.map((g)=>g.slice(h)).map((g)=>" ".repeat(this.indent*2)+g);for(let g of _)this.content.push(g)}compile(){let i=Function,f=this?.args,h=[...(this?.content??[""]).map((_)=>` ${_}`)];return new i(...f,h.join(`
|
|
4
|
+
`))}}var vo={major:4,minor:4,patch:3};var C=Z("$ZodType",(i,f)=>{var m;i??(i={}),i._zod.def=f,i._zod.bag=i._zod.bag||{},i._zod.version=vo;let h=[...i._zod.def.checks??[]];if(i._zod.traits.has("$ZodCheck"))h.unshift(i);for(let _ of h)for(let g of _._zod.onattach)g(i);if(h.length===0)(m=i._zod).deferred??(m.deferred=[]),i._zod.deferred?.push(()=>{i._zod.run=i._zod.parse});else{let _=(z,v,b)=>{let w=de(z),P;for(let O of v){if(O._zod.def.when){if(gt(z))continue;if(!O._zod.def.when(z))continue}else if(w)continue;let T=z.issues.length,E=O._zod.check(z);if(E instanceof Promise&&b?.async===!1)throw new re;if(P||E instanceof Promise)P=(P??Promise.resolve()).then(async()=>{if(await E,z.issues.length===T)return;if(!w)w=de(z,T)});else{if(z.issues.length===T)continue;if(!w)w=de(z,T)}}if(P)return P.then(()=>z);return z},g=(z,v,b)=>{if(de(z))return z.aborted=!0,z;let w=_(v,h,b);if(w instanceof Promise){if(b.async===!1)throw new re;return w.then((P)=>i._zod.parse(P,b))}return i._zod.parse(w,b)};i._zod.run=(z,v)=>{if(v.skipChecks)return i._zod.parse(z,v);if(v.direction==="backward"){let w=i._zod.parse({value:z.value,issues:[]},{...v,skipChecks:!0});if(w instanceof Promise)return w.then((P)=>g(P,z,v));return g(w,z,v)}let b=i._zod.parse(z,v);if(b instanceof Promise){if(v.async===!1)throw new re;return b.then((w)=>_(w,h,v))}return _(b,h,v)}}A(i,"~standard",()=>({validate:(_)=>{try{let g=yt(i,_);return g.success?{value:g.data}:{issues:g.error?.issues}}catch(g){return $t(i,_).then((z)=>z.success?{value:z.data}:{issues:z.error?.issues})}},vendor:"zod",version:1}))}),Ye=Z("$ZodString",(i,f)=>{C.init(i,f),i._zod.pattern=[...i?._zod.bag?.patterns??[]].pop()??Qt(i._zod.bag),i._zod.parse=(m,h)=>{if(f.coerce)try{m.value=String(m.value)}catch(_){}if(typeof m.value==="string")return m;return m.issues.push({expected:"string",code:"invalid_type",input:m.value,inst:i}),m}}),F=Z("$ZodStringFormat",(i,f)=>{Se.init(i,f),Ye.init(i,f)}),Oo=Z("$ZodGUID",(i,f)=>{f.pattern??(f.pattern=Dt),F.init(i,f)}),Eo=Z("$ZodUUID",(i,f)=>{if(f.version){let h={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[f.version];if(h===void 0)throw Error(`Invalid UUID version: "${f.version}"`);f.pattern??(f.pattern=lr(h))}else f.pattern??(f.pattern=lr());F.init(i,f)}),Io=Z("$ZodEmail",(i,f)=>{f.pattern??(f.pattern=Lt),F.init(i,f)}),To=Z("$ZodURL",(i,f)=>{F.init(i,f),i._zod.check=(m)=>{try{let h=m.value.trim();if(!f.normalize&&f.protocol?.source===Wt.source){if(!/^https?:\/\//i.test(h)){m.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:m.value,inst:i,continue:!f.abort});return}}let _=new URL(h);if(f.hostname){if(f.hostname.lastIndex=0,!f.hostname.test(_.hostname))m.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:f.hostname.source,input:m.value,inst:i,continue:!f.abort})}if(f.protocol){if(f.protocol.lastIndex=0,!f.protocol.test(_.protocol.endsWith(":")?_.protocol.slice(0,-1):_.protocol))m.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:f.protocol.source,input:m.value,inst:i,continue:!f.abort})}if(f.normalize)m.value=_.href;else m.value=h;return}catch(h){m.issues.push({code:"invalid_format",format:"url",input:m.value,inst:i,continue:!f.abort})}}}),No=Z("$ZodEmoji",(i,f)=>{f.pattern??(f.pattern=Ft()),F.init(i,f)}),Ao=Z("$ZodNanoID",(i,f)=>{f.pattern??(f.pattern=Ct),F.init(i,f)}),jo=Z("$ZodCUID",(i,f)=>{f.pattern??(f.pattern=It),F.init(i,f)}),Co=Z("$ZodCUID2",(i,f)=>{f.pattern??(f.pattern=Tt),F.init(i,f)}),Ro=Z("$ZodULID",(i,f)=>{f.pattern??(f.pattern=Nt),F.init(i,f)}),Do=Z("$ZodXID",(i,f)=>{f.pattern??(f.pattern=At),F.init(i,f)}),Lo=Z("$ZodKSUID",(i,f)=>{f.pattern??(f.pattern=jt),F.init(i,f)}),Fo=Z("$ZodISODateTime",(i,f)=>{f.pattern??(f.pattern=Ht(f)),F.init(i,f)}),Uo=Z("$ZodISODate",(i,f)=>{f.pattern??(f.pattern=qt),F.init(i,f)}),Mo=Z("$ZodISOTime",(i,f)=>{f.pattern??(f.pattern=Xt(f)),F.init(i,f)}),Jo=Z("$ZodISODuration",(i,f)=>{f.pattern??(f.pattern=Rt),F.init(i,f)}),Bo=Z("$ZodIPv4",(i,f)=>{f.pattern??(f.pattern=Ut),F.init(i,f),i._zod.bag.format="ipv4"}),Vo=Z("$ZodIPv6",(i,f)=>{f.pattern??(f.pattern=Mt),F.init(i,f),i._zod.bag.format="ipv6",i._zod.check=(m)=>{try{new URL(`http://[${m.value}]`)}catch{m.issues.push({code:"invalid_format",format:"ipv6",input:m.value,inst:i,continue:!f.abort})}}});var Wo=Z("$ZodCIDRv4",(i,f)=>{f.pattern??(f.pattern=Jt),F.init(i,f)}),Ko=Z("$ZodCIDRv6",(i,f)=>{f.pattern??(f.pattern=Bt),F.init(i,f),i._zod.check=(m)=>{let h=m.value.split("/");try{if(h.length!==2)throw Error();let[_,g]=h;if(!g)throw Error();let z=Number(g);if(`${z}`!==g)throw Error();if(z<0||z>128)throw Error();new URL(`http://[${_}]`)}catch{m.issues.push({code:"invalid_format",format:"cidrv6",input:m.value,inst:i,continue:!f.abort})}}});function Go(i){if(i==="")return!0;if(/\s/.test(i))return!1;if(i.length%4!==0)return!1;try{return atob(i),!0}catch{return!1}}var qo=Z("$ZodBase64",(i,f)=>{f.pattern??(f.pattern=Vt),F.init(i,f),i._zod.bag.contentEncoding="base64",i._zod.check=(m)=>{if(Go(m.value))return;m.issues.push({code:"invalid_format",format:"base64",input:m.value,inst:i,continue:!f.abort})}});function pi(i){if(!fr.test(i))return!1;let f=i.replace(/[-_]/g,(h)=>h==="-"?"+":"/"),m=f.padEnd(Math.ceil(f.length/4)*4,"=");return Go(m)}var Yo=Z("$ZodBase64URL",(i,f)=>{f.pattern??(f.pattern=fr),F.init(i,f),i._zod.bag.contentEncoding="base64url",i._zod.check=(m)=>{if(pi(m.value))return;m.issues.push({code:"invalid_format",format:"base64url",input:m.value,inst:i,continue:!f.abort})}}),Xo=Z("$ZodE164",(i,f)=>{f.pattern??(f.pattern=Kt),F.init(i,f)});function li(i,f=null){try{let m=i.split(".");if(m.length!==3)return!1;let[h]=m;if(!h)return!1;let _=JSON.parse(atob(h));if("typ"in _&&_?.typ!=="JWT")return!1;if(!_.alg)return!1;if(f&&(!("alg"in _)||_.alg!==f))return!1;return!0}catch{return!1}}var Ho=Z("$ZodJWT",(i,f)=>{F.init(i,f),i._zod.check=(m)=>{if(li(m.value,f.alg))return;m.issues.push({code:"invalid_format",format:"jwt",input:m.value,inst:i,continue:!f.abort})}});var xr=Z("$ZodNumber",(i,f)=>{C.init(i,f),i._zod.pattern=i._zod.bag.pattern??dr,i._zod.parse=(m,h)=>{if(f.coerce)try{m.value=Number(m.value)}catch(z){}let _=m.value;if(typeof _==="number"&&!Number.isNaN(_)&&Number.isFinite(_))return m;let g=typeof _==="number"?Number.isNaN(_)?"NaN":!Number.isFinite(_)?"Infinity":void 0:void 0;return m.issues.push({expected:"number",code:"invalid_type",input:_,inst:i,...g?{received:g}:{}}),m}}),Qo=Z("$ZodNumberFormat",(i,f)=>{co.init(i,f),xr.init(i,f)}),en=Z("$ZodBoolean",(i,f)=>{C.init(i,f),i._zod.pattern=ro,i._zod.parse=(m,h)=>{if(f.coerce)try{m.value=Boolean(m.value)}catch(g){}let _=m.value;if(typeof _==="boolean")return m;return m.issues.push({expected:"boolean",code:"invalid_type",input:_,inst:i}),m}});var rn=Z("$ZodNull",(i,f)=>{C.init(i,f),i._zod.pattern=to,i._zod.values=new Set([null]),i._zod.parse=(m,h)=>{let _=m.value;if(_===null)return m;return m.issues.push({expected:"null",code:"invalid_type",input:_,inst:i}),m}}),tn=Z("$ZodAny",(i,f)=>{C.init(i,f),i._zod.parse=(m)=>m}),on=Z("$ZodUnknown",(i,f)=>{C.init(i,f),i._zod.parse=(m)=>m}),nn=Z("$ZodNever",(i,f)=>{C.init(i,f),i._zod.parse=(m,h)=>(m.issues.push({expected:"never",code:"invalid_type",input:m.value,inst:i}),m)});function yo(i,f,m){if(i.issues.length)f.issues.push(...ne(m,i.issues));f.value[m]=i.value}var sn=Z("$ZodArray",(i,f)=>{C.init(i,f),i._zod.parse=(m,h)=>{let _=m.value;if(!Array.isArray(_))return m.issues.push({expected:"array",code:"invalid_type",input:_,inst:i}),m;m.value=Array(_.length);let g=[];for(let z=0;z<_.length;z++){let v=_[z],b=f.element._zod.run({value:v,issues:[]},h);if(b instanceof Promise)g.push(b.then((w)=>yo(w,m,z)));else yo(b,m,z)}if(g.length)return Promise.all(g).then(()=>m);return m}});function qe(i,f,m,h,_,g){let z=m in h;if(i.issues.length){if(_&&g&&!z)return;f.issues.push(...ne(m,i.issues))}if(!z&&!_){if(!i.issues.length)f.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[m]});return}if(i.value===void 0){if(z)f.value[m]=void 0}else f.value[m]=i.value}function cn(i){let f=Object.keys(i.shape);for(let h of f)if(!i.shape?.[h]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${h}": expected a Zod schema`);let m=ht(i.shape);return{...i,keys:f,keySet:new Set(f),numKeys:f.length,optionalKeys:new Set(m)}}function un(i,f,m,h,_,g){let z=[],v=_.keySet,b=_.catchall._zod,w=b.def.type,P=b.optin==="optional",O=b.optout==="optional";for(let T in f){if(T==="__proto__")continue;if(v.has(T))continue;if(w==="never"){z.push(T);continue}let E=b.run({value:f[T],issues:[]},h);if(E instanceof Promise)i.push(E.then((j)=>qe(j,m,T,f,P,O)));else qe(E,m,T,f,P,O)}if(z.length)m.issues.push({code:"unrecognized_keys",keys:z,input:f,inst:g});if(!i.length)return m;return Promise.all(i).then(()=>m)}var fi=Z("$ZodObject",(i,f)=>{if(C.init(i,f),!Object.getOwnPropertyDescriptor(f,"shape")?.get){let v=f.shape;Object.defineProperty(f,"shape",{get:()=>{let b={...v};return Object.defineProperty(f,"shape",{value:b}),b}})}let h=be(()=>cn(f));A(i._zod,"propValues",()=>{let v=f.shape,b={};for(let w in v){let P=v[w]._zod;if(P.values){b[w]??(b[w]=new Set);for(let O of P.values)b[w].add(O)}}return b});let _=ge,g=f.catchall,z;i._zod.parse=(v,b)=>{z??(z=h.value);let w=v.value;if(!_(w))return v.issues.push({expected:"object",code:"invalid_type",input:w,inst:i}),v;v.value={};let P=[],O=z.shape;for(let T of z.keys){let E=O[T],j=E._zod.optin==="optional",ze=E._zod.optout==="optional",B=E._zod.run({value:w[T],issues:[]},b);if(B instanceof Promise)P.push(B.then((sr)=>qe(sr,v,T,w,j,ze)));else qe(B,v,T,w,j,ze)}if(!g)return P.length?Promise.all(P).then(()=>v):v;return un(P,w,v,b,h.value,i)}}),an=Z("$ZodObjectJIT",(i,f)=>{fi.init(i,f);let m=i._zod.parse,h=be(()=>cn(f)),_=(T)=>{let E=new _r(["shape","payload","ctx"]),j=h.value,ze=(Y)=>{let J=cr(Y);return`shape[${J}]._zod.run({ value: input[${J}], issues: [] }, ctx)`};E.write("const input = payload.value;");let B=Object.create(null),sr=0;for(let Y of j.keys)B[Y]=`key_${sr++}`;E.write("const newResult = {};");for(let Y of j.keys){let J=B[Y],V=cr(Y),ct=T[Y],ut=ct?._zod?.optin==="optional",Qs=ct?._zod?.optout==="optional";if(E.write(`const ${J} = ${ze(Y)};`),ut&&Qs)E.write(`
|
|
5
|
+
if (${J}.issues.length) {
|
|
6
|
+
if (${V} in input) {
|
|
7
|
+
payload.issues = payload.issues.concat(${J}.issues.map(iss => ({
|
|
8
|
+
...iss,
|
|
9
|
+
path: iss.path ? [${V}, ...iss.path] : [${V}]
|
|
10
|
+
})));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (${J}.value === undefined) {
|
|
15
|
+
if (${V} in input) {
|
|
16
|
+
newResult[${V}] = undefined;
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
newResult[${V}] = ${J}.value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
`);else if(!ut)E.write(`
|
|
23
|
+
const ${J}_present = ${V} in input;
|
|
24
|
+
if (${J}.issues.length) {
|
|
25
|
+
payload.issues = payload.issues.concat(${J}.issues.map(iss => ({
|
|
26
|
+
...iss,
|
|
27
|
+
path: iss.path ? [${V}, ...iss.path] : [${V}]
|
|
28
|
+
})));
|
|
29
|
+
}
|
|
30
|
+
if (!${J}_present && !${J}.issues.length) {
|
|
31
|
+
payload.issues.push({
|
|
32
|
+
code: "invalid_type",
|
|
33
|
+
expected: "nonoptional",
|
|
34
|
+
input: undefined,
|
|
35
|
+
path: [${V}]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (${J}_present) {
|
|
40
|
+
if (${J}.value === undefined) {
|
|
41
|
+
newResult[${V}] = undefined;
|
|
42
|
+
} else {
|
|
43
|
+
newResult[${V}] = ${J}.value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
`);else E.write(`
|
|
48
|
+
if (${J}.issues.length) {
|
|
49
|
+
payload.issues = payload.issues.concat(${J}.issues.map(iss => ({
|
|
50
|
+
...iss,
|
|
51
|
+
path: iss.path ? [${V}, ...iss.path] : [${V}]
|
|
52
|
+
})));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (${J}.value === undefined) {
|
|
56
|
+
if (${V} in input) {
|
|
57
|
+
newResult[${V}] = undefined;
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
newResult[${V}] = ${J}.value;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
`)}E.write("payload.value = newResult;"),E.write("return payload;");let Hs=E.compile();return(Y,J)=>Hs(T,Y,J)},g,z=ge,v=!_e.jitless,w=v&&dt.value,P=f.catchall,O;i._zod.parse=(T,E)=>{O??(O=h.value);let j=T.value;if(!z(j))return T.issues.push({expected:"object",code:"invalid_type",input:j,inst:i}),T;if(v&&w&&E?.async===!1&&E.jitless!==!0){if(!g)g=_(f.shape);if(T=g(T,E),!P)return T;return un([],j,T,E,O,i)}return m(T,E)}});function $o(i,f,m,h){for(let g of i)if(g.issues.length===0)return f.value=g.value,f;let _=i.filter((g)=>!de(g));if(_.length===1)return f.value=_[0].value,_[0];return f.issues.push({code:"invalid_union",input:f.value,inst:m,errors:i.map((g)=>g.issues.map((z)=>q(z,h,y())))}),f}var zr=Z("$ZodUnion",(i,f)=>{C.init(i,f),A(i._zod,"optin",()=>f.options.some((h)=>h._zod.optin==="optional")?"optional":void 0),A(i._zod,"optout",()=>f.options.some((h)=>h._zod.optout==="optional")?"optional":void 0),A(i._zod,"values",()=>{if(f.options.every((h)=>h._zod.values))return new Set(f.options.flatMap((h)=>Array.from(h._zod.values)));return}),A(i._zod,"pattern",()=>{if(f.options.every((h)=>h._zod.pattern)){let h=f.options.map((_)=>_._zod.pattern);return new RegExp(`^(${h.map((_)=>Me(_.source)).join("|")})$`)}return});let m=f.options.length===1?f.options[0]._zod.run:null;i._zod.parse=(h,_)=>{if(m)return m(h,_);let g=!1,z=[];for(let v of f.options){let b=v._zod.run({value:h.value,issues:[]},_);if(b instanceof Promise)z.push(b),g=!0;else{if(b.issues.length===0)return b;z.push(b)}}if(!g)return $o(z,h,i,_);return Promise.all(z).then((v)=>$o(v,h,i,_))}});var pn=Z("$ZodDiscriminatedUnion",(i,f)=>{f.inclusive=!1,zr.init(i,f);let m=i._zod.parse;A(i._zod,"propValues",()=>{let _={};for(let g of f.options){let z=g._zod.propValues;if(!z||Object.keys(z).length===0)throw Error(`Invalid discriminated union option at index "${f.options.indexOf(g)}"`);for(let[v,b]of Object.entries(z)){if(!_[v])_[v]=new Set;for(let w of b)_[v].add(w)}}return _});let h=be(()=>{let _=f.options,g=new Map;for(let z of _){let v=z._zod.propValues?.[f.discriminator];if(!v||v.size===0)throw Error(`Invalid discriminated union option at index "${f.options.indexOf(z)}"`);for(let b of v){if(g.has(b))throw Error(`Duplicate discriminator value "${String(b)}"`);g.set(b,z)}}return g});i._zod.parse=(_,g)=>{let z=_.value;if(!ge(z))return _.issues.push({code:"invalid_type",expected:"object",input:z,inst:i}),_;let v=h.value.get(z?.[f.discriminator]);if(v)return v._zod.run(_,g);if(f.unionFallback||g.direction==="backward")return m(_,g);return _.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:f.discriminator,options:Array.from(h.value.keys()),input:z,path:[f.discriminator],inst:i}),_}}),ln=Z("$ZodIntersection",(i,f)=>{C.init(i,f),i._zod.parse=(m,h)=>{let _=m.value,g=f.left._zod.run({value:_,issues:[]},h),z=f.right._zod.run({value:_,issues:[]},h);if(g instanceof Promise||z instanceof Promise)return Promise.all([g,z]).then(([b,w])=>bo(m,b,w));return bo(m,g,z)}});function gr(i,f){if(i===f)return{valid:!0,data:i};if(i instanceof Date&&f instanceof Date&&+i===+f)return{valid:!0,data:i};if(fe(i)&&fe(f)){let m=Object.keys(f),h=Object.keys(i).filter((g)=>m.indexOf(g)!==-1),_={...i,...f};for(let g of h){let z=gr(i[g],f[g]);if(!z.valid)return{valid:!1,mergeErrorPath:[g,...z.mergeErrorPath]};_[g]=z.data}return{valid:!0,data:_}}if(Array.isArray(i)&&Array.isArray(f)){if(i.length!==f.length)return{valid:!1,mergeErrorPath:[]};let m=[];for(let h=0;h<i.length;h++){let _=i[h],g=f[h],z=gr(_,g);if(!z.valid)return{valid:!1,mergeErrorPath:[h,...z.mergeErrorPath]};m.push(z.data)}return{valid:!0,data:m}}return{valid:!1,mergeErrorPath:[]}}function bo(i,f,m){let h=new Map,_;for(let v of f.issues)if(v.code==="unrecognized_keys"){_??(_=v);for(let b of v.keys){if(!h.has(b))h.set(b,{});h.get(b).l=!0}}else i.issues.push(v);for(let v of m.issues)if(v.code==="unrecognized_keys")for(let b of v.keys){if(!h.has(b))h.set(b,{});h.get(b).r=!0}else i.issues.push(v);let g=[...h].filter(([,v])=>v.l&&v.r).map(([v])=>v);if(g.length&&_)i.issues.push({..._,keys:g});if(de(i))return i;let z=gr(f.value,m.value);if(!z.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(z.mergeErrorPath)}`);return i.value=z.data,i}var fn=Z("$ZodRecord",(i,f)=>{C.init(i,f),i._zod.parse=(m,h)=>{let _=m.value;if(!fe(_))return m.issues.push({expected:"record",code:"invalid_type",input:_,inst:i}),m;let g=[],z=f.keyType._zod.values;if(z){m.value={};let v=new Set;for(let w of z)if(typeof w==="string"||typeof w==="number"||typeof w==="symbol"){v.add(typeof w==="number"?w.toString():w);let P=f.keyType._zod.run({value:w,issues:[]},h);if(P instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(P.issues.length){m.issues.push({code:"invalid_key",origin:"record",issues:P.issues.map((E)=>q(E,h,y())),input:w,path:[w],inst:i});continue}let O=P.value,T=f.valueType._zod.run({value:_[w],issues:[]},h);if(T instanceof Promise)g.push(T.then((E)=>{if(E.issues.length)m.issues.push(...ne(w,E.issues));m.value[O]=E.value}));else{if(T.issues.length)m.issues.push(...ne(w,T.issues));m.value[O]=T.value}}let b;for(let w in _)if(!v.has(w))b=b??[],b.push(w);if(b&&b.length>0)m.issues.push({code:"unrecognized_keys",input:_,inst:i,keys:b})}else{m.value={};for(let v of Reflect.ownKeys(_)){if(v==="__proto__")continue;if(!Object.prototype.propertyIsEnumerable.call(_,v))continue;let b=f.keyType._zod.run({value:v,issues:[]},h);if(b instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(typeof v==="string"&&dr.test(v)&&b.issues.length){let O=f.keyType._zod.run({value:Number(v),issues:[]},h);if(O instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(O.issues.length===0)b=O}if(b.issues.length){if(f.mode==="loose")m.value[v]=_[v];else m.issues.push({code:"invalid_key",origin:"record",issues:b.issues.map((O)=>q(O,h,y())),input:v,path:[v],inst:i});continue}let P=f.valueType._zod.run({value:_[v],issues:[]},h);if(P instanceof Promise)g.push(P.then((O)=>{if(O.issues.length)m.issues.push(...ne(v,O.issues));m.value[b.value]=O.value}));else{if(P.issues.length)m.issues.push(...ne(v,P.issues));m.value[b.value]=P.value}}}if(g.length)return Promise.all(g).then(()=>m);return m}});var dn=Z("$ZodEnum",(i,f)=>{C.init(i,f);let m=Fe(f.entries),h=new Set(m);i._zod.values=h,i._zod.pattern=new RegExp(`^(${m.filter((_)=>mt.has(typeof _)).map((_)=>typeof _==="string"?oe(_):_.toString()).join("|")})$`),i._zod.parse=(_,g)=>{let z=_.value;if(h.has(z))return _;return _.issues.push({code:"invalid_value",values:m,input:z,inst:i}),_}}),mn=Z("$ZodLiteral",(i,f)=>{if(C.init(i,f),f.values.length===0)throw Error("Cannot create literal schema with no valid values");let m=new Set(f.values);i._zod.values=m,i._zod.pattern=new RegExp(`^(${f.values.map((h)=>typeof h==="string"?oe(h):h?oe(h.toString()):String(h)).join("|")})$`),i._zod.parse=(h,_)=>{let g=h.value;if(m.has(g))return h;return h.issues.push({code:"invalid_value",values:f.values,input:g,inst:i}),h}});var hn=Z("$ZodTransform",(i,f)=>{C.init(i,f),i._zod.optin="optional",i._zod.parse=(m,h)=>{if(h.direction==="backward")throw new ve(i.constructor.name);let _=f.transform(m.value,m);if(h.async)return(_ instanceof Promise?_:Promise.resolve(_)).then((z)=>(m.value=z,m.fallback=!0,m));if(_ instanceof Promise)throw new re;return m.value=_,m.fallback=!0,m}});function wo(i,f){if(f===void 0&&(i.issues.length||i.fallback))return{issues:[],value:void 0};return i}var vr=Z("$ZodOptional",(i,f)=>{C.init(i,f),i._zod.optin="optional",i._zod.optout="optional",A(i._zod,"values",()=>f.innerType._zod.values?new Set([...f.innerType._zod.values,void 0]):void 0),A(i._zod,"pattern",()=>{let m=f.innerType._zod.pattern;return m?new RegExp(`^(${Me(m.source)})?$`):void 0}),i._zod.parse=(m,h)=>{if(f.innerType._zod.optin==="optional"){let _=m.value,g=f.innerType._zod.run(m,h);if(g instanceof Promise)return g.then((z)=>wo(z,_));return wo(g,_)}if(m.value===void 0)return m;return f.innerType._zod.run(m,h)}}),_n=Z("$ZodExactOptional",(i,f)=>{vr.init(i,f),A(i._zod,"values",()=>f.innerType._zod.values),A(i._zod,"pattern",()=>f.innerType._zod.pattern),i._zod.parse=(m,h)=>f.innerType._zod.run(m,h)}),gn=Z("$ZodNullable",(i,f)=>{C.init(i,f),A(i._zod,"optin",()=>f.innerType._zod.optin),A(i._zod,"optout",()=>f.innerType._zod.optout),A(i._zod,"pattern",()=>{let m=f.innerType._zod.pattern;return m?new RegExp(`^(${Me(m.source)}|null)$`):void 0}),A(i._zod,"values",()=>f.innerType._zod.values?new Set([...f.innerType._zod.values,null]):void 0),i._zod.parse=(m,h)=>{if(m.value===null)return m;return f.innerType._zod.run(m,h)}}),xn=Z("$ZodDefault",(i,f)=>{C.init(i,f),i._zod.optin="optional",A(i._zod,"values",()=>f.innerType._zod.values),i._zod.parse=(m,h)=>{if(h.direction==="backward")return f.innerType._zod.run(m,h);if(m.value===void 0)return m.value=f.defaultValue,m;let _=f.innerType._zod.run(m,h);if(_ instanceof Promise)return _.then((g)=>ko(g,f));return ko(_,f)}});function ko(i,f){if(i.value===void 0)i.value=f.defaultValue;return i}var zn=Z("$ZodPrefault",(i,f)=>{C.init(i,f),i._zod.optin="optional",A(i._zod,"values",()=>f.innerType._zod.values),i._zod.parse=(m,h)=>{if(h.direction==="backward")return f.innerType._zod.run(m,h);if(m.value===void 0)m.value=f.defaultValue;return f.innerType._zod.run(m,h)}}),vn=Z("$ZodNonOptional",(i,f)=>{C.init(i,f),A(i._zod,"values",()=>{let m=f.innerType._zod.values;return m?new Set([...m].filter((h)=>h!==void 0)):void 0}),i._zod.parse=(m,h)=>{let _=f.innerType._zod.run(m,h);if(_ instanceof Promise)return _.then((g)=>Zo(g,i));return Zo(_,i)}});function Zo(i,f){if(!i.issues.length&&i.value===void 0)i.issues.push({code:"invalid_type",expected:"nonoptional",input:i.value,inst:f});return i}var yn=Z("$ZodCatch",(i,f)=>{C.init(i,f),i._zod.optin="optional",A(i._zod,"optout",()=>f.innerType._zod.optout),A(i._zod,"values",()=>f.innerType._zod.values),i._zod.parse=(m,h)=>{if(h.direction==="backward")return f.innerType._zod.run(m,h);let _=f.innerType._zod.run(m,h);if(_ instanceof Promise)return _.then((g)=>{if(m.value=g.value,g.issues.length)m.value=f.catchValue({...m,error:{issues:g.issues.map((z)=>q(z,h,y()))},input:m.value}),m.issues=[],m.fallback=!0;return m});if(m.value=_.value,_.issues.length)m.value=f.catchValue({...m,error:{issues:_.issues.map((g)=>q(g,h,y()))},input:m.value}),m.issues=[],m.fallback=!0;return m}});var yr=Z("$ZodPipe",(i,f)=>{C.init(i,f),A(i._zod,"values",()=>f.in._zod.values),A(i._zod,"optin",()=>f.in._zod.optin),A(i._zod,"optout",()=>f.out._zod.optout),A(i._zod,"propValues",()=>f.in._zod.propValues),i._zod.parse=(m,h)=>{if(h.direction==="backward"){let g=f.out._zod.run(m,h);if(g instanceof Promise)return g.then((z)=>Ge(z,f.in,h));return Ge(g,f.in,h)}let _=f.in._zod.run(m,h);if(_ instanceof Promise)return _.then((g)=>Ge(g,f.out,h));return Ge(_,f.out,h)}});function Ge(i,f,m){if(i.issues.length)return i.aborted=!0,i;return f._zod.run({value:i.value,issues:i.issues,fallback:i.fallback},m)}var $n=Z("$ZodPreprocess",(i,f)=>{yr.init(i,f)}),bn=Z("$ZodReadonly",(i,f)=>{C.init(i,f),A(i._zod,"propValues",()=>f.innerType._zod.propValues),A(i._zod,"values",()=>f.innerType._zod.values),A(i._zod,"optin",()=>f.innerType?._zod?.optin),A(i._zod,"optout",()=>f.innerType?._zod?.optout),i._zod.parse=(m,h)=>{if(h.direction==="backward")return f.innerType._zod.run(m,h);let _=f.innerType._zod.run(m,h);if(_ instanceof Promise)return _.then(Po);return Po(_)}});function Po(i){return i.value=Object.freeze(i.value),i}var wn=Z("$ZodLazy",(i,f)=>{C.init(i,f),A(i._zod,"innerType",()=>{let m=f;if(!m._cachedInner)m._cachedInner=f.getter();return m._cachedInner}),A(i._zod,"pattern",()=>i._zod.innerType?._zod?.pattern),A(i._zod,"propValues",()=>i._zod.innerType?._zod?.propValues),A(i._zod,"optin",()=>i._zod.innerType?._zod?.optin??void 0),A(i._zod,"optout",()=>i._zod.innerType?._zod?.optout??void 0),i._zod.parse=(m,h)=>i._zod.innerType._zod.run(m,h)}),kn=Z("$ZodCustom",(i,f)=>{W.init(i,f),C.init(i,f),i._zod.parse=(m,h)=>m,i._zod.check=(m)=>{let h=m.value,_=f.fn(h);if(_ instanceof Promise)return _.then((g)=>So(g,m,h,i));So(_,m,h,i);return}});function So(i,f,m,h){if(!i){let _={code:"custom",input:m,inst:h,path:[...h._zod.def.path??[]],continue:!h._zod.def.abort};if(h._zod.def.params)_.params=h._zod.def.params;f.issues.push(me(_))}}var Zn,Uc=Symbol("ZodOutput"),Mc=Symbol("ZodInput");class Pn{constructor(){this._map=new WeakMap,this._idmap=new Map}add(i,...f){let m=f[0];if(this._map.set(i,m),m&&typeof m==="object"&&"id"in m)this._idmap.set(m.id,i);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(i){let f=this._map.get(i);if(f&&typeof f==="object"&&"id"in f)this._idmap.delete(f.id);return this._map.delete(i),this}get(i){let f=i._zod.parent;if(f){let m={...this.get(f)??{}};delete m.id;let h={...m,...this._map.get(i)};return Object.keys(h).length?h:void 0}return this._map.get(i)}has(i){return this._map.has(i)}}function di(){return new Pn}(Zn=globalThis).__zod_globalRegistry??(Zn.__zod_globalRegistry=di());var he=globalThis.__zod_globalRegistry;function Sn(i,f){return new i({type:"string",...S(f)})}function $r(i,f){return new i({type:"string",format:"email",check:"string_format",abort:!1,...S(f)})}function br(i,f){return new i({type:"string",format:"guid",check:"string_format",abort:!1,...S(f)})}function On(i,f){return new i({type:"string",format:"uuid",check:"string_format",abort:!1,...S(f)})}function En(i,f){return new i({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...S(f)})}function In(i,f){return new i({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...S(f)})}function Tn(i,f){return new i({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...S(f)})}function wr(i,f){return new i({type:"string",format:"url",check:"string_format",abort:!1,...S(f)})}function Nn(i,f){return new i({type:"string",format:"emoji",check:"string_format",abort:!1,...S(f)})}function An(i,f){return new i({type:"string",format:"nanoid",check:"string_format",abort:!1,...S(f)})}function jn(i,f){return new i({type:"string",format:"cuid",check:"string_format",abort:!1,...S(f)})}function Cn(i,f){return new i({type:"string",format:"cuid2",check:"string_format",abort:!1,...S(f)})}function Rn(i,f){return new i({type:"string",format:"ulid",check:"string_format",abort:!1,...S(f)})}function Dn(i,f){return new i({type:"string",format:"xid",check:"string_format",abort:!1,...S(f)})}function Ln(i,f){return new i({type:"string",format:"ksuid",check:"string_format",abort:!1,...S(f)})}function Fn(i,f){return new i({type:"string",format:"ipv4",check:"string_format",abort:!1,...S(f)})}function Un(i,f){return new i({type:"string",format:"ipv6",check:"string_format",abort:!1,...S(f)})}function Mn(i,f){return new i({type:"string",format:"cidrv4",check:"string_format",abort:!1,...S(f)})}function Jn(i,f){return new i({type:"string",format:"cidrv6",check:"string_format",abort:!1,...S(f)})}function Bn(i,f){return new i({type:"string",format:"base64",check:"string_format",abort:!1,...S(f)})}function Vn(i,f){return new i({type:"string",format:"base64url",check:"string_format",abort:!1,...S(f)})}function Wn(i,f){return new i({type:"string",format:"e164",check:"string_format",abort:!1,...S(f)})}function Kn(i,f){return new i({type:"string",format:"jwt",check:"string_format",abort:!1,...S(f)})}function Gn(i,f){return new i({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...S(f)})}function qn(i,f){return new i({type:"string",format:"date",check:"string_format",...S(f)})}function Yn(i,f){return new i({type:"string",format:"time",check:"string_format",precision:null,...S(f)})}function Xn(i,f){return new i({type:"string",format:"duration",check:"string_format",...S(f)})}function Hn(i,f){return new i({type:"number",checks:[],...S(f)})}function $e(i,f){return new i({type:"number",coerce:!0,checks:[],...S(f)})}function Qn(i,f){return new i({type:"number",check:"number_format",abort:!1,format:"safeint",...S(f)})}function es(i,f){return new i({type:"boolean",...S(f)})}function rs(i,f){return new i({type:"null",...S(f)})}function ts(i){return new i({type:"any"})}function os(i){return new i({type:"unknown"})}function ns(i,f){return new i({type:"never",...S(f)})}function Xe(i,f){return new mr({check:"less_than",...S(f),value:i,inclusive:!1})}function Oe(i,f){return new mr({check:"less_than",...S(f),value:i,inclusive:!0})}function He(i,f){return new hr({check:"greater_than",...S(f),value:i,inclusive:!1})}function Te(i,f){return new hr({check:"greater_than",...S(f),value:i,inclusive:!0})}function Qe(i,f){return new io({check:"multiple_of",...S(f),value:i})}function er(i,f){return new uo({check:"max_length",...S(f),maximum:i})}function xe(i,f){return new ao({check:"min_length",...S(f),minimum:i})}function rr(i,f){return new po({check:"length_equals",...S(f),length:i})}function kr(i,f){return new lo({check:"string_format",format:"regex",...S(f),pattern:i})}function Zr(i){return new fo({check:"string_format",format:"lowercase",...S(i)})}function Pr(i){return new mo({check:"string_format",format:"uppercase",...S(i)})}function Sr(i,f){return new ho({check:"string_format",format:"includes",...S(f),includes:i})}function Or(i,f){return new _o({check:"string_format",format:"starts_with",...S(f),prefix:i})}function Er(i,f){return new go({check:"string_format",format:"ends_with",...S(f),suffix:i})}function ie(i){return new xo({check:"overwrite",tx:i})}function Ir(i){return ie((f)=>f.normalize(i))}function Tr(){return ie((i)=>i.trim())}function Nr(){return ie((i)=>i.toLowerCase())}function Ar(){return ie((i)=>i.toUpperCase())}function jr(){return ie((i)=>ft(i))}function ss(i,f,m){return new i({type:"array",element:f,...S(m)})}function is(i,f,m){return new i({type:"custom",check:"custom",fn:f,...S(m)})}function cs(i,f){let m=mi((h)=>(h.addIssue=(_)=>{if(typeof _==="string")h.issues.push(me(_,h.value,m._zod.def));else{let g=_;if(g.fatal)g.continue=!1;g.code??(g.code="custom"),g.input??(g.input=h.value),g.inst??(g.inst=m),g.continue??(g.continue=!m._zod.def.abort),h.issues.push(me(g))}},i(h.value,h)),f);return m}function mi(i,f){let m=new W({check:"custom",...S(f)});return m._zod.check=i,m}function Ae(i){let f=i?.target??"draft-2020-12";if(f==="draft-4")f="draft-04";if(f==="draft-7")f="draft-07";return{processors:i.processors??{},metadataRegistry:i?.metadata??he,target:f,unrepresentable:i?.unrepresentable??"throw",override:i?.override??(()=>{}),io:i?.io??"output",counter:0,seen:new Map,cycles:i?.cycles??"ref",reused:i?.reused??"inline",external:i?.external??void 0}}function D(i,f,m={path:[],schemaPath:[]}){var h;let _=i._zod.def,g=f.seen.get(i);if(g){if(g.count++,m.schemaPath.includes(i))g.cycle=m.path;return g.schema}let z={schema:{},count:1,cycle:void 0,path:m.path};f.seen.set(i,z);let v=i._zod.toJSONSchema?.();if(v)z.schema=v;else{let P={...m,schemaPath:[...m.schemaPath,i],path:m.path};if(i._zod.processJSONSchema)i._zod.processJSONSchema(f,z.schema,P);else{let T=z.schema,E=f.processors[_.type];if(!E)throw Error(`[toJSONSchema]: Non-representable type encountered: ${_.type}`);E(i,f,T,P)}let O=i._zod.parent;if(O){if(!z.ref)z.ref=O;D(O,f,P),f.seen.get(O).isParent=!0}}let b=f.metadataRegistry.get(i);if(b)Object.assign(z.schema,b);if(f.io==="input"&&K(i))delete z.schema.examples,delete z.schema.default;if(f.io==="input"&&"_prefault"in z.schema)(h=z.schema).default??(h.default=z.schema._prefault);return delete z.schema._prefault,f.seen.get(i).schema}function je(i,f){let m=i.seen.get(f);if(!m)throw Error("Unprocessed schema. This is a bug in Zod.");let h=new Map;for(let z of i.seen.entries()){let v=i.metadataRegistry.get(z[0])?.id;if(v){let b=h.get(v);if(b&&b!==z[0])throw Error(`Duplicate schema id "${v}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);h.set(v,z[0])}}let _=(z)=>{let v=i.target==="draft-2020-12"?"$defs":"definitions";if(i.external){let O=i.external.registry.get(z[0])?.id,T=i.external.uri??((j)=>j);if(O)return{ref:T(O)};let E=z[1].defId??z[1].schema.id??`schema${i.counter++}`;return z[1].defId=E,{defId:E,ref:`${T("__shared")}#/${v}/${E}`}}if(z[1]===m)return{ref:"#"};let w=`${"#"}/${v}/`,P=z[1].schema.id??`__schema${i.counter++}`;return{defId:P,ref:w+P}},g=(z)=>{if(z[1].schema.$ref)return;let v=z[1],{ref:b,defId:w}=_(z);if(v.def={...v.schema},w)v.defId=w;let P=v.schema;for(let O in P)delete P[O];P.$ref=b};if(i.cycles==="throw")for(let z of i.seen.entries()){let v=z[1];if(v.cycle)throw Error(`Cycle detected: #/${v.cycle?.join("/")}/<root>
|
|
64
|
+
|
|
65
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let z of i.seen.entries()){let v=z[1];if(f===z[0]){g(z);continue}if(i.external){let w=i.external.registry.get(z[0])?.id;if(f!==z[0]&&w){g(z);continue}}if(i.metadataRegistry.get(z[0])?.id){g(z);continue}if(v.cycle){g(z);continue}if(v.count>1){if(i.reused==="ref"){g(z);continue}}}}function Ce(i,f){let m=i.seen.get(f);if(!m)throw Error("Unprocessed schema. This is a bug in Zod.");let h=(v)=>{let b=i.seen.get(v);if(b.ref===null)return;let w=b.def??b.schema,P={...w},O=b.ref;if(b.ref=null,O){h(O);let E=i.seen.get(O),j=E.schema;if(j.$ref&&(i.target==="draft-07"||i.target==="draft-04"||i.target==="openapi-3.0"))w.allOf=w.allOf??[],w.allOf.push(j);else Object.assign(w,j);if(Object.assign(w,P),v._zod.parent===O)for(let B in w){if(B==="$ref"||B==="allOf")continue;if(!(B in P))delete w[B]}if(j.$ref&&E.def)for(let B in w){if(B==="$ref"||B==="allOf")continue;if(B in E.def&&JSON.stringify(w[B])===JSON.stringify(E.def[B]))delete w[B]}}let T=v._zod.parent;if(T&&T!==O){h(T);let E=i.seen.get(T);if(E?.schema.$ref){if(w.$ref=E.schema.$ref,E.def)for(let j in w){if(j==="$ref"||j==="allOf")continue;if(j in E.def&&JSON.stringify(w[j])===JSON.stringify(E.def[j]))delete w[j]}}}i.override({zodSchema:v,jsonSchema:w,path:b.path??[]})};for(let v of[...i.seen.entries()].reverse())h(v[0]);let _={};if(i.target==="draft-2020-12")_.$schema="https://json-schema.org/draft/2020-12/schema";else if(i.target==="draft-07")_.$schema="http://json-schema.org/draft-07/schema#";else if(i.target==="draft-04")_.$schema="http://json-schema.org/draft-04/schema#";else if(i.target==="openapi-3.0");if(i.external?.uri){let v=i.external.registry.get(f)?.id;if(!v)throw Error("Schema is missing an `id` property");_.$id=i.external.uri(v)}Object.assign(_,m.def??m.schema);let g=i.metadataRegistry.get(f)?.id;if(g!==void 0&&_.id===g)delete _.id;let z=i.external?.defs??{};for(let v of i.seen.entries()){let b=v[1];if(b.def&&b.defId){if(b.def.id===b.defId)delete b.def.id;z[b.defId]=b.def}}if(i.external);else if(Object.keys(z).length>0)if(i.target==="draft-2020-12")_.$defs=z;else _.definitions=z;try{let v=JSON.parse(JSON.stringify(_));return Object.defineProperty(v,"~standard",{value:{...f["~standard"],jsonSchema:{input:Ne(f,"input",i.processors),output:Ne(f,"output",i.processors)}},enumerable:!1,writable:!1}),v}catch(v){throw Error("Error converting schema to JSON.")}}function K(i,f){let m=f??{seen:new Set};if(m.seen.has(i))return!1;m.seen.add(i);let h=i._zod.def;if(h.type==="transform")return!0;if(h.type==="array")return K(h.element,m);if(h.type==="set")return K(h.valueType,m);if(h.type==="lazy")return K(h.getter(),m);if(h.type==="promise"||h.type==="optional"||h.type==="nonoptional"||h.type==="nullable"||h.type==="readonly"||h.type==="default"||h.type==="prefault")return K(h.innerType,m);if(h.type==="intersection")return K(h.left,m)||K(h.right,m);if(h.type==="record"||h.type==="map")return K(h.keyType,m)||K(h.valueType,m);if(h.type==="pipe"){if(i._zod.traits.has("$ZodCodec"))return!0;return K(h.in,m)||K(h.out,m)}if(h.type==="object"){for(let _ in h.shape)if(K(h.shape[_],m))return!0;return!1}if(h.type==="union"){for(let _ of h.options)if(K(_,m))return!0;return!1}if(h.type==="tuple"){for(let _ of h.items)if(K(_,m))return!0;if(h.rest&&K(h.rest,m))return!0;return!1}return!1}var us=(i,f={})=>(m)=>{let h=Ae({...m,processors:f});return D(i,h),je(h,i),Ce(h,i)},Ne=(i,f,m={})=>(h)=>{let{libraryOptions:_,target:g}=h??{},z=Ae({..._??{},target:g,io:f,processors:m});return D(i,z),je(z,i),Ce(z,i)};var hi={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Cr=(i,f,m,h)=>{let _=m;_.type="string";let{minimum:g,maximum:z,format:v,patterns:b,contentEncoding:w}=i._zod.bag;if(typeof g==="number")_.minLength=g;if(typeof z==="number")_.maxLength=z;if(v){if(_.format=hi[v]??v,_.format==="")delete _.format;if(v==="time")delete _.format}if(w)_.contentEncoding=w;if(b&&b.size>0){let P=[...b];if(P.length===1)_.pattern=P[0].source;else if(P.length>1)_.allOf=[...P.map((O)=>({...f.target==="draft-07"||f.target==="draft-04"||f.target==="openapi-3.0"?{type:"string"}:{},pattern:O.source}))]}},Rr=(i,f,m,h)=>{let _=m,{minimum:g,maximum:z,format:v,multipleOf:b,exclusiveMaximum:w,exclusiveMinimum:P}=i._zod.bag;if(typeof v==="string"&&v.includes("int"))_.type="integer";else _.type="number";let O=typeof P==="number"&&P>=(g??Number.NEGATIVE_INFINITY),T=typeof w==="number"&&w<=(z??Number.POSITIVE_INFINITY),E=f.target==="draft-04"||f.target==="openapi-3.0";if(O)if(E)_.minimum=P,_.exclusiveMinimum=!0;else _.exclusiveMinimum=P;else if(typeof g==="number")_.minimum=g;if(T)if(E)_.maximum=w,_.exclusiveMaximum=!0;else _.exclusiveMaximum=w;else if(typeof z==="number")_.maximum=z;if(typeof b==="number")_.multipleOf=b},Dr=(i,f,m,h)=>{m.type="boolean"},ps=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("BigInt cannot be represented in JSON Schema")},ls=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("Symbols cannot be represented in JSON Schema")},Lr=(i,f,m,h)=>{if(f.target==="openapi-3.0")m.type="string",m.nullable=!0,m.enum=[null];else m.type="null"},fs=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("Undefined cannot be represented in JSON Schema")},ds=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("Void cannot be represented in JSON Schema")},Fr=(i,f,m,h)=>{m.not={}},Ur=(i,f,m,h)=>{},Mr=(i,f,m,h)=>{},ms=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("Date cannot be represented in JSON Schema")},Jr=(i,f,m,h)=>{let _=i._zod.def,g=Fe(_.entries);if(g.every((z)=>typeof z==="number"))m.type="number";if(g.every((z)=>typeof z==="string"))m.type="string";m.enum=g},Br=(i,f,m,h)=>{let _=i._zod.def,g=[];for(let z of _.values)if(z===void 0){if(f.unrepresentable==="throw")throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof z==="bigint")if(f.unrepresentable==="throw")throw Error("BigInt literals cannot be represented in JSON Schema");else g.push(Number(z));else g.push(z);if(g.length===0);else if(g.length===1){let z=g[0];if(m.type=z===null?"null":typeof z,f.target==="draft-04"||f.target==="openapi-3.0")m.enum=[z];else m.const=z}else{if(g.every((z)=>typeof z==="number"))m.type="number";if(g.every((z)=>typeof z==="string"))m.type="string";if(g.every((z)=>typeof z==="boolean"))m.type="boolean";if(g.every((z)=>z===null))m.type="null";m.enum=g}},hs=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("NaN cannot be represented in JSON Schema")},_s=(i,f,m,h)=>{let _=m,g=i._zod.pattern;if(!g)throw Error("Pattern not found in template literal");_.type="string",_.pattern=g.source},gs=(i,f,m,h)=>{let _=m,g={type:"string",format:"binary",contentEncoding:"binary"},{minimum:z,maximum:v,mime:b}=i._zod.bag;if(z!==void 0)g.minLength=z;if(v!==void 0)g.maxLength=v;if(b)if(b.length===1)g.contentMediaType=b[0],Object.assign(_,g);else Object.assign(_,g),_.anyOf=b.map((w)=>({contentMediaType:w}));else Object.assign(_,g)},xs=(i,f,m,h)=>{m.type="boolean"},Vr=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("Custom types cannot be represented in JSON Schema")},zs=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("Function types cannot be represented in JSON Schema")},Wr=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("Transforms cannot be represented in JSON Schema")},vs=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("Map cannot be represented in JSON Schema")},ys=(i,f,m,h)=>{if(f.unrepresentable==="throw")throw Error("Set cannot be represented in JSON Schema")},Kr=(i,f,m,h)=>{let _=m,g=i._zod.def,{minimum:z,maximum:v}=i._zod.bag;if(typeof z==="number")_.minItems=z;if(typeof v==="number")_.maxItems=v;_.type="array",_.items=D(g.element,f,{...h,path:[...h.path,"items"]})},Gr=(i,f,m,h)=>{let _=m,g=i._zod.def;_.type="object",_.properties={};let z=g.shape;for(let w in z)_.properties[w]=D(z[w],f,{...h,path:[...h.path,"properties",w]});let v=new Set(Object.keys(z)),b=new Set([...v].filter((w)=>{let P=g.shape[w]._zod;if(f.io==="input")return P.optin===void 0;else return P.optout===void 0}));if(b.size>0)_.required=Array.from(b);if(g.catchall?._zod.def.type==="never")_.additionalProperties=!1;else if(!g.catchall){if(f.io==="output")_.additionalProperties=!1}else if(g.catchall)_.additionalProperties=D(g.catchall,f,{...h,path:[...h.path,"additionalProperties"]})},qr=(i,f,m,h)=>{let _=i._zod.def,g=_.inclusive===!1,z=_.options.map((v,b)=>D(v,f,{...h,path:[...h.path,g?"oneOf":"anyOf",b]}));if(g)m.oneOf=z;else m.anyOf=z},Yr=(i,f,m,h)=>{let _=i._zod.def,g=D(_.left,f,{...h,path:[...h.path,"allOf",0]}),z=D(_.right,f,{...h,path:[...h.path,"allOf",1]}),v=(w)=>("allOf"in w)&&Object.keys(w).length===1,b=[...v(g)?g.allOf:[g],...v(z)?z.allOf:[z]];m.allOf=b},$s=(i,f,m,h)=>{let _=m,g=i._zod.def;_.type="array";let z=f.target==="draft-2020-12"?"prefixItems":"items",v=f.target==="draft-2020-12"?"items":f.target==="openapi-3.0"?"items":"additionalItems",b=g.items.map((T,E)=>D(T,f,{...h,path:[...h.path,z,E]})),w=g.rest?D(g.rest,f,{...h,path:[...h.path,v,...f.target==="openapi-3.0"?[g.items.length]:[]]}):null;if(f.target==="draft-2020-12"){if(_.prefixItems=b,w)_.items=w}else if(f.target==="openapi-3.0"){if(_.items={anyOf:b},w)_.items.anyOf.push(w);if(_.minItems=b.length,!w)_.maxItems=b.length}else if(_.items=b,w)_.additionalItems=w;let{minimum:P,maximum:O}=i._zod.bag;if(typeof P==="number")_.minItems=P;if(typeof O==="number")_.maxItems=O},Xr=(i,f,m,h)=>{let _=m,g=i._zod.def;_.type="object";let z=g.keyType,b=z._zod.bag?.patterns;if(g.mode==="loose"&&b&&b.size>0){let P=D(g.valueType,f,{...h,path:[...h.path,"patternProperties","*"]});_.patternProperties={};for(let O of b)_.patternProperties[O.source]=P}else{if(f.target==="draft-07"||f.target==="draft-2020-12")_.propertyNames=D(g.keyType,f,{...h,path:[...h.path,"propertyNames"]});_.additionalProperties=D(g.valueType,f,{...h,path:[...h.path,"additionalProperties"]})}let w=z._zod.values;if(w){let P=[...w].filter((O)=>typeof O==="string"||typeof O==="number");if(P.length>0)_.required=P}},Hr=(i,f,m,h)=>{let _=i._zod.def,g=D(_.innerType,f,h),z=f.seen.get(i);if(f.target==="openapi-3.0")z.ref=_.innerType,m.nullable=!0;else m.anyOf=[g,{type:"null"}]},Qr=(i,f,m,h)=>{let _=i._zod.def;D(_.innerType,f,h);let g=f.seen.get(i);g.ref=_.innerType},et=(i,f,m,h)=>{let _=i._zod.def;D(_.innerType,f,h);let g=f.seen.get(i);g.ref=_.innerType,m.default=JSON.parse(JSON.stringify(_.defaultValue))},rt=(i,f,m,h)=>{let _=i._zod.def;D(_.innerType,f,h);let g=f.seen.get(i);if(g.ref=_.innerType,f.io==="input")m._prefault=JSON.parse(JSON.stringify(_.defaultValue))},tt=(i,f,m,h)=>{let _=i._zod.def;D(_.innerType,f,h);let g=f.seen.get(i);g.ref=_.innerType;let z;try{z=_.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}m.default=z},ot=(i,f,m,h)=>{let _=i._zod.def,g=_.in._zod.traits.has("$ZodTransform"),z=f.io==="input"?g?_.out:_.in:_.out;D(z,f,h);let v=f.seen.get(i);v.ref=z},nt=(i,f,m,h)=>{let _=i._zod.def;D(_.innerType,f,h);let g=f.seen.get(i);g.ref=_.innerType,m.readOnly=!0},bs=(i,f,m,h)=>{let _=i._zod.def;D(_.innerType,f,h);let g=f.seen.get(i);g.ref=_.innerType},tr=(i,f,m,h)=>{let _=i._zod.def;D(_.innerType,f,h);let g=f.seen.get(i);g.ref=_.innerType},st=(i,f,m,h)=>{let _=i._zod.innerType;D(_,f,h);let g=f.seen.get(i);g.ref=_},as={string:Cr,number:Rr,boolean:Dr,bigint:ps,symbol:ls,null:Lr,undefined:fs,void:ds,never:Fr,any:Ur,unknown:Mr,date:ms,enum:Jr,literal:Br,nan:hs,template_literal:_s,file:gs,success:xs,custom:Vr,function:zs,transform:Wr,map:vs,set:ys,array:Kr,object:Gr,union:qr,intersection:Yr,tuple:$s,record:Xr,nullable:Hr,nonoptional:Qr,default:et,prefault:rt,catch:tt,pipe:ot,readonly:nt,promise:bs,optional:tr,lazy:st};function le(i,f){if("_idmap"in i){let h=i,_=Ae({...f,processors:as}),g={};for(let b of h._idmap.entries()){let[w,P]=b;D(P,_)}let z={},v={registry:h,uri:f?.uri,defs:g};_.external=v;for(let b of h._idmap.entries()){let[w,P]=b;je(_,P),z[w]=Ce(_,P)}if(Object.keys(g).length>0){let b=_.target==="draft-2020-12"?"$defs":"definitions";z.__shared={[b]:g}}return{schemas:z}}let m=Ae({...f,processors:as});return D(i,m),je(m,i),Ce(m,i)}var $i=Z("ZodISODateTime",(i,f)=>{Fo.init(i,f),M.init(i,f)});function N(i){return Gn($i,i)}var bi=Z("ZodISODate",(i,f)=>{Uo.init(i,f),M.init(i,f)});function ue(i){return qn(bi,i)}var wi=Z("ZodISOTime",(i,f)=>{Mo.init(i,f),M.init(i,f)});function ws(i){return Yn(wi,i)}var ki=Z("ZodISODuration",(i,f)=>{Jo.init(i,f),M.init(i,f)});function ks(i){return Xn(ki,i)}var Si=(i,f)=>{Be.init(i,f),i.name="ZodError",Object.defineProperties(i,{format:{value:(m)=>vt(i,m)},flatten:{value:(m)=>zt(i,m)},addIssue:{value:(m)=>{i.issues.push(m),i.message=JSON.stringify(i.issues,ye,2)}},addIssues:{value:(m)=>{i.issues.push(...m),i.message=JSON.stringify(i.issues,ye,2)}},isEmpty:{get(){return i.issues.length===0}}})};var G=Z("ZodError",Si,{Parent:Error});var Zs=Ve(G),Ps=We(G),X=Ze(G),Ss=Pe(G),Os=bt(G),Es=wt(G),Is=kt(G),Ts=Zt(G),Ns=Pt(G),As=St(G),js=Ot(G),Cs=Et(G);var Rs=new WeakMap;function De(i,f,m){let h=Object.getPrototypeOf(i),_=Rs.get(h);if(!_)_=new Set,Rs.set(h,_);if(_.has(f))return;_.add(f);for(let g in m){let z=m[g];Object.defineProperty(h,g,{configurable:!0,enumerable:!1,get(){let v=z.bind(this);return Object.defineProperty(this,g,{configurable:!0,writable:!0,enumerable:!0,value:v}),v},set(v){Object.defineProperty(this,g,{configurable:!0,writable:!0,enumerable:!0,value:v})}})}}var L=Z("ZodType",(i,f)=>(C.init(i,f),Object.assign(i["~standard"],{jsonSchema:{input:Ne(i,"input"),output:Ne(i,"output")}}),i.toJSONSchema=us(i,{}),i.def=f,i.type=f.type,Object.defineProperty(i,"_def",{value:f}),i.parse=(m,h)=>Zs(i,m,h,{callee:i.parse}),i.safeParse=(m,h)=>X(i,m,h),i.parseAsync=async(m,h)=>Ps(i,m,h,{callee:i.parseAsync}),i.safeParseAsync=async(m,h)=>Ss(i,m,h),i.spa=i.safeParseAsync,i.encode=(m,h)=>Os(i,m,h),i.decode=(m,h)=>Es(i,m,h),i.encodeAsync=async(m,h)=>Is(i,m,h),i.decodeAsync=async(m,h)=>Ts(i,m,h),i.safeEncode=(m,h)=>Ns(i,m,h),i.safeDecode=(m,h)=>As(i,m,h),i.safeEncodeAsync=async(m,h)=>js(i,m,h),i.safeDecodeAsync=async(m,h)=>Cs(i,m,h),De(i,"ZodType",{check(...m){let h=this.def;return this.clone(te(h,{checks:[...h.checks??[],...m.map((_)=>typeof _==="function"?{_zod:{check:_,def:{check:"custom"},onattach:[]}}:_)]}),{parent:!0})},with(...m){return this.check(...m)},clone(m,h){return H(this,m,h)},brand(){return this},register(m,h){return m.add(this,h),this},refine(m,h){return this.check(zc(m,h))},superRefine(m,h){return this.check(vc(m,h))},overwrite(m){return this.check(ie(m))},optional(){return u(this)},exactOptional(){return sc(this)},nullable(){return Us(this)},nullish(){return u(Us(this))},nonoptional(m){return lc(this,m)},array(){return n(this)},or(m){return c([this,m])},and(m){return k(this,m)},transform(m){return Ms(this,Gs(m))},default(m){return uc(this,m)},prefault(m){return pc(this,m)},catch(m){return dc(this,m)},pipe(m){return Ms(this,m)},readonly(){return _c(this)},describe(m){let h=this.clone();return he.add(h,{description:m}),h},meta(...m){if(m.length===0)return he.get(this);let h=this.clone();return he.add(h,m[0]),h},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(m){return m(this)}}),Object.defineProperty(i,"description",{get(){return he.get(i)?.description},configurable:!0}),i)),Js=Z("_ZodString",(i,f)=>{Ye.init(i,f),L.init(i,f),i._zod.processJSONSchema=(h,_,g)=>Cr(i,h,_,g);let m=i._zod.bag;i.format=m.format??null,i.minLength=m.minimum??null,i.maxLength=m.maximum??null,De(i,"_ZodString",{regex(...h){return this.check(kr(...h))},includes(...h){return this.check(Sr(...h))},startsWith(...h){return this.check(Or(...h))},endsWith(...h){return this.check(Er(...h))},min(...h){return this.check(xe(...h))},max(...h){return this.check(er(...h))},length(...h){return this.check(rr(...h))},nonempty(...h){return this.check(xe(1,...h))},lowercase(h){return this.check(Zr(h))},uppercase(h){return this.check(Pr(h))},trim(){return this.check(Tr())},normalize(...h){return this.check(Ir(...h))},toLowerCase(){return this.check(Nr())},toUpperCase(){return this.check(Ar())},slugify(){return this.check(jr())}})}),Ei=Z("ZodString",(i,f)=>{Ye.init(i,f),Js.init(i,f),i.email=(m)=>i.check($r(Bs,m)),i.url=(m)=>i.check(wr(Vs,m)),i.jwt=(m)=>i.check(Kn(Vi,m)),i.emoji=(m)=>i.check(Nn(Ii,m)),i.guid=(m)=>i.check(br(Ds,m)),i.uuid=(m)=>i.check(On(nr,m)),i.uuidv4=(m)=>i.check(En(nr,m)),i.uuidv6=(m)=>i.check(In(nr,m)),i.uuidv7=(m)=>i.check(Tn(nr,m)),i.nanoid=(m)=>i.check(An(Ti,m)),i.guid=(m)=>i.check(br(Ds,m)),i.cuid=(m)=>i.check(jn(Ni,m)),i.cuid2=(m)=>i.check(Cn(Ai,m)),i.ulid=(m)=>i.check(Rn(ji,m)),i.base64=(m)=>i.check(Bn(Mi,m)),i.base64url=(m)=>i.check(Vn(Ji,m)),i.xid=(m)=>i.check(Dn(Ci,m)),i.ksuid=(m)=>i.check(Ln(Ri,m)),i.ipv4=(m)=>i.check(Fn(Di,m)),i.ipv6=(m)=>i.check(Un(Li,m)),i.cidrv4=(m)=>i.check(Mn(Fi,m)),i.cidrv6=(m)=>i.check(Jn(Ui,m)),i.e164=(m)=>i.check(Wn(Bi,m)),i.datetime=(m)=>i.check(N(m)),i.date=(m)=>i.check(ue(m)),i.time=(m)=>i.check(ws(m)),i.duration=(m)=>i.check(ks(m))});function e(i){return Sn(Ei,i)}var M=Z("ZodStringFormat",(i,f)=>{F.init(i,f),Js.init(i,f)}),Bs=Z("ZodEmail",(i,f)=>{Io.init(i,f),M.init(i,f)});function ke(i){return $r(Bs,i)}var Ds=Z("ZodGUID",(i,f)=>{Oo.init(i,f),M.init(i,f)});var nr=Z("ZodUUID",(i,f)=>{Eo.init(i,f),M.init(i,f)});var Vs=Z("ZodURL",(i,f)=>{To.init(i,f),M.init(i,f)});function Q(i){return wr(Vs,i)}var Ii=Z("ZodEmoji",(i,f)=>{No.init(i,f),M.init(i,f)});var Ti=Z("ZodNanoID",(i,f)=>{Ao.init(i,f),M.init(i,f)});var Ni=Z("ZodCUID",(i,f)=>{jo.init(i,f),M.init(i,f)});var Ai=Z("ZodCUID2",(i,f)=>{Co.init(i,f),M.init(i,f)});var ji=Z("ZodULID",(i,f)=>{Ro.init(i,f),M.init(i,f)});var Ci=Z("ZodXID",(i,f)=>{Do.init(i,f),M.init(i,f)});var Ri=Z("ZodKSUID",(i,f)=>{Lo.init(i,f),M.init(i,f)});var Di=Z("ZodIPv4",(i,f)=>{Bo.init(i,f),M.init(i,f)});var Li=Z("ZodIPv6",(i,f)=>{Vo.init(i,f),M.init(i,f)});var Fi=Z("ZodCIDRv4",(i,f)=>{Wo.init(i,f),M.init(i,f)});var Ui=Z("ZodCIDRv6",(i,f)=>{Ko.init(i,f),M.init(i,f)});var Mi=Z("ZodBase64",(i,f)=>{qo.init(i,f),M.init(i,f)});var Ji=Z("ZodBase64URL",(i,f)=>{Yo.init(i,f),M.init(i,f)});var Bi=Z("ZodE164",(i,f)=>{Xo.init(i,f),M.init(i,f)});var Vi=Z("ZodJWT",(i,f)=>{Ho.init(i,f),M.init(i,f)});var ee=Z("ZodNumber",(i,f)=>{xr.init(i,f),L.init(i,f),i._zod.processJSONSchema=(h,_,g)=>Rr(i,h,_,g),De(i,"ZodNumber",{gt(h,_){return this.check(He(h,_))},gte(h,_){return this.check(Te(h,_))},min(h,_){return this.check(Te(h,_))},lt(h,_){return this.check(Xe(h,_))},lte(h,_){return this.check(Oe(h,_))},max(h,_){return this.check(Oe(h,_))},int(h){return this.check(Ls(h))},safe(h){return this.check(Ls(h))},positive(h){return this.check(He(0,h))},nonnegative(h){return this.check(Te(0,h))},negative(h){return this.check(Xe(0,h))},nonpositive(h){return this.check(Oe(0,h))},multipleOf(h,_){return this.check(Qe(h,_))},step(h,_){return this.check(Qe(h,_))},finite(){return this}});let m=i._zod.bag;i.minValue=Math.max(m.minimum??Number.NEGATIVE_INFINITY,m.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,i.maxValue=Math.min(m.maximum??Number.POSITIVE_INFINITY,m.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,i.isInt=(m.format??"").includes("int")||Number.isSafeInteger(m.multipleOf??0.5),i.isFinite=!0,i.format=m.format??null});function o(i){return Hn(ee,i)}var Wi=Z("ZodNumberFormat",(i,f)=>{Qo.init(i,f),ee.init(i,f)});function Ls(i){return Qn(Wi,i)}var Ki=Z("ZodBoolean",(i,f)=>{en.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Dr(i,m,h,_)});function a(i){return es(Ki,i)}var Gi=Z("ZodNull",(i,f)=>{rn.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Lr(i,m,h,_)});function I(i){return rs(Gi,i)}var qi=Z("ZodAny",(i,f)=>{tn.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Ur(i,m,h,_)});function Ee(){return ts(qi)}var Yi=Z("ZodUnknown",(i,f)=>{on.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Mr(i,m,h,_)});function l(){return os(Yi)}var Xi=Z("ZodNever",(i,f)=>{nn.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Fr(i,m,h,_)});function Hi(i){return ns(Xi,i)}var Qi=Z("ZodArray",(i,f)=>{sn.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Kr(i,m,h,_),i.element=f.element,De(i,"ZodArray",{min(m,h){return this.check(xe(m,h))},nonempty(m){return this.check(xe(1,m))},max(m,h){return this.check(er(m,h))},length(m,h){return this.check(rr(m,h))},unwrap(){return this.element}})});function n(i,f){return ss(Qi,i,f)}var Ws=Z("ZodObject",(i,f)=>{an.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Gr(i,m,h,_),A(i,"shape",()=>f.shape),De(i,"ZodObject",{keyof(){return p(Object.keys(this._zod.def.shape))},catchall(m){return this.clone({...this._zod.def,catchall:m})},passthrough(){return this.clone({...this._zod.def,catchall:l()})},loose(){return this.clone({...this._zod.def,catchall:l()})},strict(){return this.clone({...this._zod.def,catchall:Hi()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(m){return ti(this,m)},safeExtend(m){return oi(this,m)},merge(m){return ni(this,m)},pick(m){return ei(this,m)},omit(m){return ri(this,m)},partial(...m){return si(qs,this,m[0])},required(...m){return ii(Ys,this,m[0])}})});function t(i,f){let m={type:"object",shape:i??{},...S(f)};return new Ws(m)}function d(i,f){return new Ws({type:"object",shape:i,catchall:l(),...S(f)})}var Ks=Z("ZodUnion",(i,f)=>{zr.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>qr(i,m,h,_),i.options=f.options});function c(i,f){return new Ks({type:"union",options:i,...S(f)})}var ec=Z("ZodDiscriminatedUnion",(i,f)=>{Ks.init(i,f),pn.init(i,f)});function R(i,f,m){return new ec({type:"union",options:f,discriminator:i,...S(m)})}var rc=Z("ZodIntersection",(i,f)=>{ln.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Yr(i,m,h,_)});function k(i,f){return new rc({type:"intersection",left:i,right:f})}var Fs=Z("ZodRecord",(i,f)=>{fn.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Xr(i,m,h,_),i.keyType=f.keyType,i.valueType=f.valueType});function s(i,f,m){if(!f||!f._zod)return new Fs({type:"record",keyType:e(),valueType:i,...S(f)});return new Fs({type:"record",keyType:i,valueType:f,...S(m)})}var it=Z("ZodEnum",(i,f)=>{dn.init(i,f),L.init(i,f),i._zod.processJSONSchema=(h,_,g)=>Jr(i,h,_,g),i.enum=f.entries,i.options=Object.values(f.entries);let m=new Set(Object.keys(f.entries));i.extract=(h,_)=>{let g={};for(let z of h)if(m.has(z))g[z]=f.entries[z];else throw Error(`Key ${z} not found in enum`);return new it({...f,checks:[],...S(_),entries:g})},i.exclude=(h,_)=>{let g={...f.entries};for(let z of h)if(m.has(z))delete g[z];else throw Error(`Key ${z} not found in enum`);return new it({...f,checks:[],...S(_),entries:g})}});function p(i,f){let m=Array.isArray(i)?Object.fromEntries(i.map((h)=>[h,h])):i;return new it({type:"enum",entries:m,...S(f)})}var tc=Z("ZodLiteral",(i,f)=>{mn.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Br(i,m,h,_),i.values=new Set(f.values),Object.defineProperty(i,"value",{get(){if(f.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return f.values[0]}})});function r(i,f){return new tc({type:"literal",values:Array.isArray(i)?i:[i],...S(f)})}var oc=Z("ZodTransform",(i,f)=>{hn.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Wr(i,m,h,_),i._zod.parse=(m,h)=>{if(h.direction==="backward")throw new ve(i.constructor.name);m.addIssue=(g)=>{if(typeof g==="string")m.issues.push(me(g,m.value,f));else{let z=g;if(z.fatal)z.continue=!1;z.code??(z.code="custom"),z.input??(z.input=m.value),z.inst??(z.inst=i),m.issues.push(me(z))}};let _=f.transform(m.value,m);if(_ instanceof Promise)return _.then((g)=>(m.value=g,m.fallback=!0,m));return m.value=_,m.fallback=!0,m}});function Gs(i){return new oc({type:"transform",transform:i})}var qs=Z("ZodOptional",(i,f)=>{vr.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>tr(i,m,h,_),i.unwrap=()=>i._zod.def.innerType});function u(i){return new qs({type:"optional",innerType:i})}var nc=Z("ZodExactOptional",(i,f)=>{_n.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>tr(i,m,h,_),i.unwrap=()=>i._zod.def.innerType});function sc(i){return new nc({type:"optional",innerType:i})}var ic=Z("ZodNullable",(i,f)=>{gn.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Hr(i,m,h,_),i.unwrap=()=>i._zod.def.innerType});function Us(i){return new ic({type:"nullable",innerType:i})}var cc=Z("ZodDefault",(i,f)=>{xn.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>et(i,m,h,_),i.unwrap=()=>i._zod.def.innerType,i.removeDefault=i.unwrap});function uc(i,f){return new cc({type:"default",innerType:i,get defaultValue(){return typeof f==="function"?f():ar(f)}})}var ac=Z("ZodPrefault",(i,f)=>{zn.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>rt(i,m,h,_),i.unwrap=()=>i._zod.def.innerType});function pc(i,f){return new ac({type:"prefault",innerType:i,get defaultValue(){return typeof f==="function"?f():ar(f)}})}var Ys=Z("ZodNonOptional",(i,f)=>{vn.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Qr(i,m,h,_),i.unwrap=()=>i._zod.def.innerType});function lc(i,f){return new Ys({type:"nonoptional",innerType:i,...S(f)})}var fc=Z("ZodCatch",(i,f)=>{yn.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>tt(i,m,h,_),i.unwrap=()=>i._zod.def.innerType,i.removeCatch=i.unwrap});function dc(i,f){return new fc({type:"catch",innerType:i,catchValue:typeof f==="function"?f:()=>f})}var Xs=Z("ZodPipe",(i,f)=>{yr.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>ot(i,m,h,_),i.in=f.in,i.out=f.out});function Ms(i,f){return new Xs({type:"pipe",in:i,out:f})}var mc=Z("ZodPreprocess",(i,f)=>{Xs.init(i,f),$n.init(i,f)}),hc=Z("ZodReadonly",(i,f)=>{bn.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>nt(i,m,h,_),i.unwrap=()=>i._zod.def.innerType});function _c(i){return new hc({type:"readonly",innerType:i})}var gc=Z("ZodLazy",(i,f)=>{wn.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>st(i,m,h,_),i.unwrap=()=>i._zod.def.getter()});function U(i){return new gc({type:"lazy",getter:i})}var xc=Z("ZodCustom",(i,f)=>{kn.init(i,f),L.init(i,f),i._zod.processJSONSchema=(m,h,_)=>Vr(i,m,h,_)});function zc(i,f={}){return is(xc,i,f)}function vc(i,f){return cs(i,f)}function x(i,f){return new mc({type:"pipe",in:Gs(i),out:f})}
|
|
66
|
+
export{we,y,ae,ce,Re,Ie,$e,le,N,ue,X,e,ke,Q,ee,o,a,I,Ee,l,n,t,d,c,R,k,s,p,r,u,U,x};
|