@tryarcanist/cli 0.1.393 → 0.1.395

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.
Files changed (2) hide show
  1. package/dist/index.js +4 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { createRequire as __arcanistCreateRequire } from "node:module";
3
3
  const require = __arcanistCreateRequire(import.meta.url);
4
4
  var Eb=Object.defineProperty;var He=(e,t)=>{for(var r in t)Eb(e,r,{get:t[r],enumerable:!0})};import{Command as gP,Option as hP}from"commander";var em=["idle","running","review_starting","waiting_for_input","finalizing","review_listening","completed","superseded","needs_you","blocked","failed","stopped","archived"];var Zt=["completed","superseded","needs_you","blocked","failed","stopped","archived"],kb=new Set(Zt),IP=new Set(Zt.filter(e=>e!=="completed")),EP=new Set(Zt.filter(e=>e!=="stopped")),kP=Zt.filter(e=>e!=="archived"&&e!=="needs_you"&&e!=="blocked"&&e!=="stopped");function tm(e,t){return kb.has(e)}function nm(e){let t=e.createHelp().visibleGlobalOptions(e).map(im);return{...rm(e),...t.length>0?{globalOptions:t}:{}}}function rm(e){let t=Tb(e);return{path:za(e),description:e.description(),aliases:e.aliases(),arguments:e.registeredArguments.map(r=>({name:r.name(),description:r.description,required:r.required,variadic:r.variadic})),options:e.createHelp().visibleOptions(e).map(im),...t?{notes:t}:{},subcommands:e.commands.map(rm)}}function im(e){return{flags:e.flags,description:e.description,required:e.mandatory,...e.defaultValue===void 0?{}:{defaultValue:e.defaultValue}}}function za(e){let t=[];for(let r=e;r;r=r.parent)t.unshift(r.name());return t.join(" ")}function Tb(e){let t="";return e.emit("afterHelp",{error:!1,command:e,write:r=>t+=r}),t.trim()}import{existsSync as hS,mkdirSync as vS,writeFileSync as _S}from"node:fs";import{basename as yS,join as Em,resolve as bS}from"node:path";var Ab="en-US";function om(e,t){let r=new Intl.DateTimeFormat(Ab,{timeZone:t,month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0,timeZoneName:"short"}).formatToParts(e),o=n=>r.find(i=>i.type===n)?.value??"";return`${o("month")} ${o("day")}, ${o("year")}, ${o("hour")}:${o("minute")} ${o("dayPeriod")} ${o("timeZoneName")}`}function Ee(e,t=""){return(e instanceof Error?e.message:String(e))||t}function Qr(e){return new Promise(t=>setTimeout(t,e))}function am(e,t){return new Promise(r=>{let o=!1,n=()=>{o||(o=!0,clearTimeout(i),t?.removeEventListener("abort",n),r())},i=setTimeout(()=>{o=!0,t?.removeEventListener("abort",n),r()},e);if(t?.aborted){clearTimeout(i),o=!0,r();return}t?.addEventListener("abort",n)})}var Cb=.2,Ob=new Set([408,429,500,502,503,504]);function Nb(e){let{retry:t,baseMs:r,maxMs:o=Number.POSITIVE_INFINITY,jitter:n,random:i=Math.random}=e,a=n[0]+i()*(n[1]-n[0]);return Math.min(o,Math.max(0,Math.round(r*2**Math.max(0,t-1)*a)))}function Db(e,t){let r=t?.includeDefaults!==!1&&Ob.has(e)||t?.includeServerErrors===!0&&e>=500;return t?.remove?.includes(e)?!1:r||t?.add?.includes(e)===!0}var Ua=class extends Error{constructor(t="Provider retry aborted"){super(t),this.name="ProviderRetryAbortError"}};function zb(e){if(!(!e||typeof e!="object"||!("status"in e)))return typeof e.status=="number"?e.status:void 0}function Ub(e){if(!e||typeof e!="object"||!("headers"in e))return;let t=e.headers;if(!(!t||typeof t!="object"||!("get"in t)))return typeof t.get=="function"?t:void 0}function Lb(e){if(e instanceof TypeError||e instanceof Error&&e.name==="TimeoutError")return!0;let t=zb(e);return typeof t=="number"&&Db(t,{add:[409],includeServerErrors:!0})}function jb(e,t=Date.now()){let r=e.get("retry-after-ms");if(r){let a=Number(r);if(Number.isFinite(a)&&a>=0)return a}let o=e.get("retry-after");if(!o)return null;let n=Number(o);if(Number.isFinite(n))return n>=0?n*1e3:null;let i=Date.parse(o);return Number.isNaN(i)?null:Math.max(0,i-t)}function Mb(e){let t=Ub(e);return t?jb(t):null}function sm(e,t){if(!(!e||typeof e!="object"))try{Object.defineProperty(e,"__retryAttempts",{value:t,enumerable:!1,configurable:!0,writable:!0})}catch{}}function Zb(e,t){if(!t)return e;let r=AbortSignal.timeout(t);return e?AbortSignal.any([e,r]):r}async function um(e){if(!Number.isInteger(e.maxAttempts)||e.maxAttempts<1)throw new RangeError("maxAttempts must be at least 1");let t=e.sleep??am,r=e.random??Math.random,o=e.perAttemptTimeoutMs??6e5,n=e.isTransient??Lb,i=e.getRetryAfterMs??Mb,a=e.abortErrorFactory??(()=>new Ua),s=e.now??Date.now,u=e.jitterFactor??Cb,c=[1-u,1+u],l=0,d;for(;l<e.maxAttempts;){if(e.callerSignal?.aborted)throw a(l);if(e.deadlineMs!==void 0&&s()>=e.deadlineMs)throw d!==void 0?d:a(l);l+=1;let f=o>0&&e.deadlineMs!==void 0?Math.min(o,Math.max(1,e.deadlineMs-s())):o,m=Zb(e.callerSignal,f);try{return{value:await e.op(m??new AbortController().signal),attempts:l}}catch(g){if(e.callerSignal?.aborted)throw a(l,g);if(!n(g)||l>=e.maxAttempts)throw sm(g,l),g;let h=Math.max(i(g)??0,Nb({retry:l,baseMs:e.baseMs??250,jitter:c,random:r}));if(sm(g,l),d=g,e.deadlineMs!==void 0&&s()+h>=e.deadlineMs)throw g;try{e.onRetry?.({attempt:l+1,maxAttempts:e.maxAttempts,delayMs:h,error:g})}catch{}if(await t(h,e.callerSignal??new AbortController().signal),e.callerSignal?.aborted)throw a(l)}}throw new Error("Provider retry loop exited without a result")}function et(e){return e.replace(/\/+$/,"")}function cm(e){if(!e||typeof e!="object")return null;let t=e,r=typeof t.code=="string"&&t.code?t.code:null,o=typeof t.message=="string"&&t.message?t.message:null;if(typeof t.error=="string"&&t.error)return{code:r??t.error,message:o??t.error,raw:t.error};if(t.error&&typeof t.error=="object"){let n=t.error,i=typeof n.code=="string"&&n.code?n.code:r,a=typeof n.message=="string"&&n.message?n.message:o;return i||a?{code:i,message:a,raw:t.error}:null}return r||o?{code:r,message:o,raw:e}:null}function La(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let r=t,o={...typeof r.repository=="string"?{repository:r.repository}:{},...typeof r.environmentsUrl=="string"?{environmentsUrl:r.environmentsUrl}:{},...typeof r.billingUrl=="string"?{billingUrl:r.billingUrl}:{}},n=cm(t);return n?typeof n.raw=="string"&&n.raw?{...n.code?{serverCode:n.code}:{},rawError:n.raw,...n.message?{message:n.message}:{},...o}:n.message||n.code?{...n.message?{message:n.message}:{},...n.code?{serverCode:n.code,rawError:n.code}:{},...o}:null:null}catch{return null}}var ke=130,ja=5,y=class extends Error{code;exitCode;hint;requestId;data;constructor(t,r,o={}){super(r),this.name="CliError",this.code=t,this.exitCode=o.exitCode??lm(t),this.hint=o.hint,this.requestId=o.requestId,this.data=o.data}},_t=class extends y{},ze=class extends y{status;body;constructor(t,r,o,n){let i=dm(t),a=La(r);super(i,Bb(t,r,a),{exitCode:Fb(t),hint:Vb(t,n,a),requestId:o,data:a?.serverCode||a?.repository||a?.environmentsUrl||a?.billingUrl?{...a.serverCode?{serverCode:a.serverCode}:{},...a.repository?{repository:a.repository}:{},...a.environmentsUrl?{environmentsUrl:a.environmentsUrl}:{},...a.billingUrl?{billingUrl:a.billingUrl}:{}}:void 0}),this.name="ApiError",this.status=t,this.body=r}};function lm(e){switch(e){case"auth":return 2;case"not_found":return 3;case"conflict":return 4;case"server":return 10;default:return 1}}function dm(e){return e===401||e===403?"auth":e===404?"not_found":e===409?"conflict":e>=500?"server":"user"}function Fb(e){return lm(dm(e))}function Bb(e,t,r=La(t)){return r?.message?r.message:r?.serverCode?r.serverCode:t?`API error ${e}: ${t}`:`API error ${e}`}function Vb(e,t,r){if(e===401)return"Run `arcanist auth login` or set `ARCANIST_TOKEN`.";if(e===403)return"This token is not allowed to do that. `arcanist auth whoami --json` shows its tokenScope and your businessRole: a change needs a write-scope token (mint one in Settings > CLI), and a workspace-wide change also needs the admin role.";if(e===404)return t==="repo"?"Check accessible repositories with `arcanist repos list`.":t==="session"?"List sessions with `arcanist sessions list`.":void 0;if(e===409&&r?.repository){if(r.serverCode==="environment_required")return`Run \`arcanist environments prepare ${r.repository} --wait\`, then retry the review.`;if(r.serverCode==="environment_preparing"||r.serverCode==="environment_needs_attention")return`Run \`arcanist environments status ${r.repository} --wait\` for the latest setup state.`}if(e===409)return"Check the current resource state and retry the command when it is ready.";if(e>=500)return"Retry later or check the control-plane logs."}var Gb="Run `arcanist help <command>` for usage, or `arcanist help --json` for the full command tree.";function qb(e){if(!("code"in e)||typeof e.code!="string"||!e.code.startsWith("commander."))return null;let[t="",r]=e.message.replace(/^error: /,"").split(`
5
- `);return new y("user",t,{hint:r?r.replace(/^\((.*)\)$/,"$1"):Gb})}function pm(e){if(e instanceof y)return e;if(e instanceof Error){let t=qb(e);if(t)return t}return e instanceof Error?new y("user",e.message):new y("user",String(e))}function ei(e){return JSON.stringify({error:{code:e.code,message:e.message,...e.hint?{hint:e.hint}:{},...e.requestId?{requestId:e.requestId}:{},...e.data?{data:e.data}:{}}})}var mm={name:"@tryarcanist/cli",version:"0.1.393",description:"Command-line interface for Arcanist: inspect sessions, prepare Arcanist environments, and trigger reviews",type:"module",bin:{arcanist:"dist/index.js"},engines:{node:">=22"},files:["dist/index.js"],scripts:{build:"tsup",typecheck:"node ../../node_modules/tsrs/bin/tsrs --noEmit",prepublishOnly:"npm --prefix ../.. run guard:cli-bundle"},publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/tryarcanist/arcanist.git",directory:"apps/cli"},homepage:"https://www.tryarcanist.com",license:"MIT",dependencies:{commander:"^12.1.0","playwright-core":"^1.61.1"},devDependencies:{tsup:"^8.0.0",typescript:"^5.9.3"}};var ti=`${mm.version}`;var Hb=`arcanist-cli/${ti}`,Kb=3e4,Jb=1e3,Yb=6e5,ni="ARCANIST_HTTP_TIMEOUT_MS";function Xb(e=process.env){let t=e[ni];if(!t)return Kb;if(!/^\d+$/.test(t))throw new y("user",`${ni} must be a positive integer between 1000 and 600000.`);let r=Number(t);if(r<Jb||r>Yb)throw new y("user",`${ni} must be between 1000 and 600000 milliseconds.`);return r}function Ma(e){return e instanceof DOMException&&e.name==="AbortError"}function Qb(e){let t=e instanceof Error?e.cause:null;return t&&typeof t=="object"&&"code"in t&&typeof t.code=="string"?t.code:null}function Za(e){return new _t("server",`Network timeout after ${e}ms.`,{hint:`Increase ${ni} for slow links, or check the API connection.`})}function eS(e){let t=Xb();if(!e)return{fetchInit:void 0,timeoutMs:t};let{timeoutMs:r,...o}=e;return r===void 0?{fetchInit:o,timeoutMs:t}:!Number.isFinite(r)||r<=0?{fetchInit:o,timeoutMs:1}:{fetchInit:o,timeoutMs:Math.max(1,Math.min(t,r))}}async function Fa(e,t,r,o){let{fetchInit:n,timeoutMs:i}=eS(r),a=new AbortController,s=setTimeout(()=>a.abort(),i);try{let u=new Headers(n?.headers);u.set("Content-Type","application/json"),u.set("User-Agent",Hb),e.token&&u.set("Authorization",`Bearer ${e.token}`);let c=await fetch(`${et(e.apiUrl)}${t}`,{...n,headers:u,signal:a.signal}).catch(l=>{throw Ma(l)?Za(i):new _t("server",`Network error: could not reach ${et(e.apiUrl)} (${Qb(l)??Ee(l)}).`,{hint:"Check the network and `ARCANIST_API_URL` or `--api-url`, then retry."})});if(!c.ok){let l=await c.text().catch(d=>{if(Ma(d))throw Za(i);return""});throw new ze(c.status,l,c.headers.get("x-request-id")??void 0,tS(t))}return await o(c)}catch(u){throw u instanceof y?u:Ma(u)?Za(i):u instanceof TypeError?new _t("server",`The API response could not be read: ${Ee(u)}`):new y("server",`The API response could not be read: ${Ee(u)}`)}finally{clearTimeout(s)}}function tS(e){if(e.startsWith("/api/repos"))return"repo";if(e.startsWith("/api/sessions"))return"session"}async function P(e,t,r){return Fa(e,t,r,o=>o.json())}async function fm(e,t,r){return Fa(e,t,r,o=>o.text())}async function gm(e,t,r){return Fa(e,t,r,async o=>new Uint8Array(await o.arrayBuffer()))}async function Un(e,t){let{value:r}=await um({op:()=>P(e,t),maxAttempts:3,perAttemptTimeoutMs:0,isTransient:o=>o instanceof _t,onRetry:({attempt:o,maxAttempts:n,delayMs:i})=>{process.stderr.write(`Retrying archive GET ${t} (${o}/${n}) in ${i}ms.
5
+ `);return new y("user",t,{hint:r?r.replace(/^\((.*)\)$/,"$1"):Gb})}function pm(e){if(e instanceof y)return e;if(e instanceof Error){let t=qb(e);if(t)return t}return e instanceof Error?new y("user",e.message):new y("user",String(e))}function ei(e){return JSON.stringify({error:{code:e.code,message:e.message,...e.hint?{hint:e.hint}:{},...e.requestId?{requestId:e.requestId}:{},...e.data?{data:e.data}:{}}})}var mm={name:"@tryarcanist/cli",version:"0.1.395",description:"Command-line interface for Arcanist: inspect sessions, prepare Arcanist environments, and trigger reviews",type:"module",bin:{arcanist:"dist/index.js"},engines:{node:">=22"},files:["dist/index.js"],scripts:{build:"tsup",typecheck:"node ../../node_modules/tsrs/bin/tsrs --noEmit",prepublishOnly:"npm --prefix ../.. run guard:cli-bundle"},publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/tryarcanist/arcanist.git",directory:"apps/cli"},homepage:"https://www.tryarcanist.com",license:"MIT",dependencies:{commander:"^12.1.0","playwright-core":"^1.61.1"},devDependencies:{tsup:"^8.0.0",typescript:"^5.9.3"}};var ti=`${mm.version}`;var Hb=`arcanist-cli/${ti}`,Kb=3e4,Jb=1e3,Yb=6e5,ni="ARCANIST_HTTP_TIMEOUT_MS";function Xb(e=process.env){let t=e[ni];if(!t)return Kb;if(!/^\d+$/.test(t))throw new y("user",`${ni} must be a positive integer between 1000 and 600000.`);let r=Number(t);if(r<Jb||r>Yb)throw new y("user",`${ni} must be between 1000 and 600000 milliseconds.`);return r}function Ma(e){return e instanceof DOMException&&e.name==="AbortError"}function Qb(e){let t=e instanceof Error?e.cause:null;return t&&typeof t=="object"&&"code"in t&&typeof t.code=="string"?t.code:null}function Za(e){return new _t("server",`Network timeout after ${e}ms.`,{hint:`Increase ${ni} for slow links, or check the API connection.`})}function eS(e){let t=Xb();if(!e)return{fetchInit:void 0,timeoutMs:t};let{timeoutMs:r,...o}=e;return r===void 0?{fetchInit:o,timeoutMs:t}:!Number.isFinite(r)||r<=0?{fetchInit:o,timeoutMs:1}:{fetchInit:o,timeoutMs:Math.max(1,Math.min(t,r))}}async function Fa(e,t,r,o){let{fetchInit:n,timeoutMs:i}=eS(r),a=new AbortController,s=setTimeout(()=>a.abort(),i);try{let u=new Headers(n?.headers);u.set("Content-Type","application/json"),u.set("User-Agent",Hb),e.token&&u.set("Authorization",`Bearer ${e.token}`);let c=await fetch(`${et(e.apiUrl)}${t}`,{...n,headers:u,signal:a.signal}).catch(l=>{throw Ma(l)?Za(i):new _t("server",`Network error: could not reach ${et(e.apiUrl)} (${Qb(l)??Ee(l)}).`,{hint:"Check the network and `ARCANIST_API_URL` or `--api-url`, then retry."})});if(!c.ok){let l=await c.text().catch(d=>{if(Ma(d))throw Za(i);return""});throw new ze(c.status,l,c.headers.get("x-request-id")??void 0,tS(t))}return await o(c)}catch(u){throw u instanceof y?u:Ma(u)?Za(i):u instanceof TypeError?new _t("server",`The API response could not be read: ${Ee(u)}`):new y("server",`The API response could not be read: ${Ee(u)}`)}finally{clearTimeout(s)}}function tS(e){if(e.startsWith("/api/repos"))return"repo";if(e.startsWith("/api/sessions"))return"session"}async function P(e,t,r){return Fa(e,t,r,o=>o.json())}async function fm(e,t,r){return Fa(e,t,r,o=>o.text())}async function gm(e,t,r){return Fa(e,t,r,async o=>new Uint8Array(await o.arrayBuffer()))}async function Un(e,t){let{value:r}=await um({op:()=>P(e,t),maxAttempts:3,perAttemptTimeoutMs:0,isTransient:o=>o instanceof _t,onRetry:({attempt:o,maxAttempts:n,delayMs:i})=>{process.stderr.write(`Retrying archive GET ${t} (${o}/${n}) in ${i}ms.
6
6
  `)}});return r}function A(e,t={}){return e.replace(/:([A-Za-z]+)/g,(r,o)=>{let n=t[o];if(n===void 0)throw new Error(`apiPath(${e}) is missing the ${o} parameter`);return encodeURIComponent(n)})}import{existsSync as Ln,mkdirSync as nS,readFileSync as Ba,statSync as rS,writeFileSync as iS}from"node:fs";import{homedir as oS}from"node:os";import{dirname as vm,join as yt,resolve as aS}from"node:path";var _m=yt(oS(),".arcanist"),ym=yt(_m,"config.json"),tt=".arcanist-cli.json",sS="https://app.tryarcanist.com";function bm(){try{return JSON.parse(Ba(ym,"utf-8"))}catch{return null}}function uS(e={}){let t=lS(e);if(t)return hm(t);let r=cS(),o=Va(e,r!==null),n=bm(),i=o?.apiUrl??r?.apiUrl??n?.apiUrl,a=o?.token??r?.token??n?.token;if(!i||!a)return null;let s=hm({apiUrl:i,token:a});return r&&!o&&!e.json&&process.stderr.write(`using ${tt} -> ${s.apiUrl}
7
7
  `),s}function Sm(e){let t=ri(e.apiUrl);if(t)throw new y("user",t);nS(_m,{recursive:!0,mode:448}),iS(ym,JSON.stringify({...e,apiUrl:et(e.apiUrl)},null,2)+`
8
8
  `,{mode:384})}function J(e){let t=uS(e);if(!t)throw new y("auth","Not logged in.",{hint:"Run `arcanist auth login` or set `ARCANIST_TOKEN`."});return t}function wm(e){let t=e??process.env.ARCANIST_API_URL??bm()?.apiUrl??sS,r=ri(t);if(r)throw new y("user",r);return et(t)}function cS(e=process.cwd()){let t=dS(e);if(!t)return null;let r=e;for(;;){let o=yt(r,tt);if(Ln(o))return fS(o);if(r===t)return null;let n=vm(r);if(n===r)return null;r=n}}function ri(e){let t;try{t=new URL(e)}catch{return"Invalid URL format"}return t.username||t.password?"API URL must not include embedded credentials. Use --token or ARCANIST_TOKEN to authenticate.":t.protocol!=="https:"&&!xm(t)?"API URL must use HTTPS for non-local hosts":null}function Va(e,t){let r=e.apiUrl??process.env.ARCANIST_API_URL,o=e.token??process.env.ARCANIST_TOKEN;if(!t)return!r&&!o?null:{apiUrl:r,token:o};if(r&&!o||!r&&o)throw new y("user",`${tt} is active; set both ARCANIST_API_URL and ARCANIST_TOKEN, pass both --api-url and --token, or set neither.`);return!r||!o?null:{apiUrl:r,token:o}}function lS(e){let t=e.apiUrl??process.env.ARCANIST_API_URL,r=e.token??process.env.ARCANIST_TOKEN;return!t||!r?null:{apiUrl:t,token:r}}function hm(e){let t=ri(e.apiUrl);if(t)throw new y("user",t);return{apiUrl:et(e.apiUrl),token:e.token}}function dS(e){let t=e;for(;;){if(pS(t))return t;let r=vm(t);if(r===t)return null;t=r}}function pS(e){let t=yt(e,".git");if(!Ln(t))return!1;try{let r=rS(t);if(r.isDirectory())return Ln(yt(t,"HEAD"))&&Ln(yt(t,"config"));if(!r.isFile())return!1;let o=mS(t);return o?Ln(yt(aS(e,o),"HEAD")):!1}catch{return!1}}function mS(e){let t=Ba(e,"utf-8").split(/\r?\n/).find(o=>o.startsWith("gitdir:"));return t&&t.slice(7).trim()||null}function fS(e){let t;try{t=JSON.parse(Ba(e,"utf-8"))}catch{throw new y("user",`${tt} is not valid JSON.`)}if(!t||typeof t!="object")throw new y("user",`${tt} must contain both apiUrl and token.`);let r=t;if(typeof r.apiUrl!="string"||typeof r.token!="string"||!r.apiUrl||!r.token)throw new y("user",`${tt} must contain both apiUrl and token.`);let o;try{o=new URL(r.apiUrl)}catch{throw new y("user",`${tt} apiUrl must be a valid URL.`)}if(!xm(o))throw new y("user",`${tt} apiUrl must be a loopback host.`);let n=ri(r.apiUrl);if(n)throw new y("user",n);return{apiUrl:et(r.apiUrl),token:r.token}}function xm(e){let t=e.hostname.replace(/^\[|\]$/g,"");return t==="localhost"||t==="127.0.0.1"||t==="::1"}function V(e,t={}){let o={...e?.optsWithGlobals?.(),...t};return{...o,noColor:o.noColor===!0||o.color===!1}}function Te(e,t={}){return V(e,t).json===!0}function Ue(e){process.stdout.write(`${JSON.stringify(e)}
@@ -68,7 +68,7 @@ ${u}`:u:"",l=Function,d=`return (input) => {
68
68
  ${u}
69
69
  }`,f;try{f=new l(...a,d)(...s)}catch(m){throw new F(`this schema (generated code failed to evaluate: ${m.message})`)}return t?.debug&&(f.code=c),f.definite=o.definite,f}function D(e,t){for(let[o,n]of e.constants)if(n===t)return o;let r=`c${e.constantCounter++}`;return e.constants.set(r,t),r}function kt(e,t){return e.definite=!1,D(e,t)}function O(e){return`v${e.varCounter++}`}function f$(e,t){let r=e._zod.run({value:t,issues:[]},{});if(r&&typeof r.then=="function")return ve;let o=r;return o.issues.length===0?o.value:ve}function de(e,t,r,o,n=!0){let i=e.content.length,a=t.constants.size,s=t.constantCounter,u=t.varCounter;try{return te(e,t,r,o,n)}catch(c){if(!(c instanceof F)||!c.islandable)throw c;if(e.content.length=i,t.constants.size>a){let l=Array.from(t.constants.keys()).slice(a);for(let d of l)t.constants.delete(d)}return t.constantCounter=s,t.varCounter=u,g$(e,t,r,o)}}function g$(e,t,r,o){t.definite=!1;let n=D(t,r),i=D(t,f$),a=O(t);return e.write(`const ${a} = ${i}(${n}, ${o});`),e.write(`if (${a} === INVALID) return INVALID;`),a}var h$=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function v$(e,t,r,o){let n=r._zod.def.checks;if(!n||n.length===0)return o;let i=o;for(let a of n){let s=a._zod.def;if(s.when&&!h$.has(s.check))throw new F('check with a custom "when" condition');switch(s.check){case"greater_than":_$(e,t,s,i);break;case"less_than":y$(e,t,s,i);break;case"multiple_of":b$(e,t,s,i);break;case"number_format":jg(e,s,i);break;case"min_length":{let u=ot(s.minimum,"min_length"),c=Rc(e,t,i,`${i}.length >= ${u} && ${i}.length < ${s.minimum*2}`);e.write(`if (${c} < ${u}) return INVALID;`);break}case"max_length":{let u=ot(s.maximum,"max_length"),c=Rc(e,t,i,`${i}.length > ${u}`);e.write(`if (${c} > ${u}) return INVALID;`);break}case"length_equals":{let u=ot(s.length,"length_equals"),c=Rc(e,t,i,`${i}.length >= ${u} && ${i}.length <= ${s.length*2}`);e.write(`if (${c} !== ${u}) return INVALID;`);break}case"min_size":e.write(`if (${i}.size < ${ot(s.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${i}.size > ${ot(s.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${i}.size !== ${ot(s.size,"size_equals")}) return INVALID;`);break;case"string_format":i=Mg(e,t,s,i);break;case"custom":i=E$(e,t,a,i);break;case"bigint_format":S$(e,s,i);break;case"mime_type":w$(e,t,s,i);break;case"property":$$(e,t,s,i);break;case"properties":x$(e,t,s,i);break;case"overwrite":{let u=O(t);I$(e,t,a,i,u),i=u;break}default:throw new F(`check type ${s.check}`)}}return i}function Rc(e,t,r,o){let n=D(t,wt),i=O(t);return e.write(`const ${i} = typeof ${r} === "string" && ${o} ? ${n}(${r}) : ${r}.length;`),i}function ot(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new F(`${t} bound of type ${typeof e}`);return`${e}`}function Lg(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new F("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new F("comparison check with Invalid Date bound");return D(e,t)}throw new F(`comparison check bound of type ${typeof t}`)}function _$(e,t,r,o){let n=r.inclusive?"<":"<=";e.write(`if (${o} ${n} ${Lg(t,r.value)}) return INVALID;`)}function y$(e,t,r,o){let n=r.inclusive?">":">=";e.write(`if (${o} ${n} ${Lg(t,r.value)}) return INVALID;`)}function b$(e,t,r,o){if(typeof r.value=="bigint"){if(r.value===BigInt(0))throw new F("multiple_of check with a zero divisor");e.write(`if (${o} % ${r.value}n !== 0n) return INVALID;`)}else{let n=D(t,Mn);e.write(`if (${n}(${o}, ${ot(r.value,"multiple_of")}) !== 0) return INVALID;`)}}function jg(e,t,r){let o=t.format;switch(o){case"safeint":e.write(`if (!Number.isSafeInteger(${r})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${r}) || ${r} < -2147483648 || ${r} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${r}) || ${r} < 0 || ${r} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${r}) || ${r} < -3.4028234663852886e38 || ${r} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${r})) return INVALID;`);break;default:throw new F(`number format ${o}`)}}function S$(e,t,r){let o=t.format;if(o)switch(o){case"int64":e.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break;default:throw new F(`bigint format ${o}`)}}function w$(e,t,r,o){let n=r.mime;if(n&&n.length>0){let i=D(t,new Set(n));e.write(`if (!${i}.has(${o}.type)) return INVALID;`)}}function x$(e,t,r,o){if(r.when)throw new F('check with a custom "when" condition');e.write(`if (${o} == null) return INVALID;`);let n=r.shape;for(let i of Reflect.ownKeys(n)){let a=typeof i=="symbol"?D(t,i):ge(i),s=O(t);e.write(`const ${s} = ${o}[${a}];`),de(e,t,n[i],s,!1)}}function $$(e,t,r,o){let n=`${o}[${JSON.stringify(r.property)}]`;te(e,t,r.schema,n)}function I$(e,t,r,o,n){let i=r._zod.def.tx;if(!i)throw new F("overwrite check without a transform function");if(Tt(i))throw new je("z.compile: async overwrite transforms are not supported");let a=D(t,i);e.write(`const ${n} = ${a}(${o});`)}function Cc(){throw new xe}function Dc(e){this.issues.push(e)}function E$(e,t,r,o){let n=r._zod.def;if(n.fn){if(Tt(n.fn))throw new je("z.compile: async .refine() predicates are not supported");let i=kt(t,n.fn),a=D(t,Cc),s=O(t);return e.write(`const ${s} = ${i}(${o});`),e.write(`if (${s} instanceof Promise) ${a}();`),e.write(`if (!${s}) return INVALID;`),o}if(r._zod.check){if(Tt(r._zod.check))throw new je("z.compile: async .superRefine() / check functions are not supported");let i=r._zod.check,s=kt(t,c=>{let l={value:c,issues:[],addIssue:Dc};return i(l)instanceof Promise&&Cc(),l.issues.length===0?l.value:ve}),u=O(t);return e.write(`const ${u} = ${s}(${o});`),e.write(`if (${u} === INVALID) return INVALID;`),u}throw new F("custom check without a predicate or check function")}var k$=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function Mg(e,t,r,o,n=!0){let i=r.format;if(i==="base64"){let c=D(t,ar);return e.write(`if (!${c}(${o})) return INVALID;`),o}if(i==="base64url"){let c=D(t,Di);return e.write(`if (!${c}(${o})) return INVALID;`),o}if(i==="jwt"){let c=D(t,Li),l=D(t,r.alg??null);return e.write(`if (!${c}(${o}, ${l})) return INVALID;`),o}if(i==="ipv6"){let c=D(t,or);return e.write(`if (!${c}(${o})) return INVALID;`),o}if(i==="cidrv6"){let c=D(t,Oi);return e.write(`if (!${c}(${o})) return INVALID;`),o}if(i==="credit_card"){let c=D(t,zi);return e.write(`if (!${c}(${o})) return INVALID;`),o}if(i==="iban"){let c=D(t,Ui);return e.write(`if (!${c}(${o})) return INVALID;`),o}let a=r;if(i==="url"||i==="httpurl"||a.normalize||a.hostname!==void 0||a.protocol!==void 0){let c=D(t,Pi),l=D(t,r),d=O(t),f=O(t);if(e.write(`const ${d} = ${o}.trim();`),e.write(`const ${f} = ${c}(${d}, ${l});`),e.write(`if (typeof ${f} === "number") return INVALID;`),a.hostname!==void 0){let h=D(t,Ri);e.write(`if (!${h}(${f}, ${l}.hostname)) return INVALID;`)}if(a.protocol!==void 0){let h=D(t,Ci);e.write(`if (!${h}(${f}, ${l}.protocol)) return INVALID;`)}if(!n)return null;let m=O(t),g=a.normalize?`${f}.href`:`${D(t,ir)}(${d})`;return e.write(`const ${m} = ${g};`),m}let s=r.fn;if(s){if(Tt(s))throw new F(`async string format ${i}`);let c=D(t,s);return e.write(`if (!${c}(${o})) return INVALID;`),o}if(k$.has(i)&&r.pattern){let c=D(t,r.pattern);return e.write(`${c}.lastIndex = 0;`),e.write(`if (!${c}.test(${o})) return INVALID;`),o}let u=r.format;switch(u){case"regex":throw new F("regex format without a pattern");case"lowercase":e.write(`if (${o} !== ${o}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${o} !== ${o}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${o}.includes(${ge(r.includes)})) return INVALID;`);break;case"starts_with":{let c=r.prefix;e.write(`if (${o}.slice(0, ${c.length}) !== ${ge(c)}) return INVALID;`);break}case"ends_with":{let c=r.suffix;e.write(`if (${o}.slice(-${c.length}) !== ${ge(c)}) return INVALID;`);break}default:throw new F(`string format ${u}`)}return o}function te(e,t,r,o,n=!0){let i=r._zod.def,a=i.type;if(i.coerce)throw new F(`coercion (z.coerce.${a}())`);let s=n||!!i.checks?.length,u;switch(a){case"string":u=T$(e,t,r,o,s);break;case"number":u=A$(e,r,o);break;case"boolean":u=P$(e,o);break;case"bigint":u=R$(e,r,o);break;case"symbol":u=C$(e,o);break;case"undefined":u=O$(e,o);break;case"null":u=N$(e,o);break;case"any":case"unknown":u=o;break;case"never":e.write("return INVALID;"),u=o;break;case"void":u=D$(e,o);break;case"nan":u=z$(e,o);break;case"date":u=U$(e,o);break;case"object":u=L$(e,t,r,o,s);break;case"optional":u=j$(e,t,r,o,s);break;case"nullable":u=F$(e,t,r,o,s);break;case"array":u=B$(e,t,r,o,s);break;case"literal":u=V$(e,t,r,o);break;case"enum":u=G$(e,t,r,o);break;case"readonly":{let c=Dg(e,t,r,o),l=O(t);e.write(`const ${l} = Object.freeze(${c});`),u=l;break}case"success":Dg(e,t,r,o),u="true";break;case"default":case"prefault":u=q$(e,t,r,o);break;case"nonoptional":u=W$(e,t,r,o);break;case"tuple":u=H$(e,t,r,o);break;case"union":u=K$(e,t,r,o);break;case"intersection":u=X$(e,t,r,o);break;case"record":u=Q$(e,t,r,o);break;case"map":u=tI(e,t,r,o);break;case"set":u=nI(e,t,r,o);break;case"file":u=rI(e,o);break;case"template_literal":u=iI(e,t,r,o);break;case"lazy":u=oI(e,t,r,o);break;case"pipe":u=aI(e,t,r,o);break;case"custom":u=sI(e,t,r,o);break;case"transform":u=lI(e,t,r,o);break;case"catch":u=cI(e,t,r,o);break;default:throw new F(`schema type ${a}`)}return u===null?null:v$(e,t,r,u)}function T$(e,t,r,o,n=!0){e.write(`if (typeof ${o} !== "string") return INVALID;`);let i=r._zod.def;return i.format===void 0?o:Mg(e,t,i,o,n)}function A$(e,t,r){e.write(`if (typeof ${r} !== "number" || !Number.isFinite(${r})) return INVALID;`);let o=t._zod.def;return o.check==="number_format"&&o.format&&jg(e,{format:o.format},r),r}function P$(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function R$(e,t,r){e.write(`if (typeof ${r} !== "bigint") return INVALID;`);let o=t._zod.def;if(o.format)switch(o.format){case"int64":e.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break}return r}function C$(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function O$(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function N$(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function D$(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function z$(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function U$(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function L$(e,t,r,o,n=!0){let i=r._zod.def;e.write(`if (typeof ${o} !== "object" || ${o} === null || Array.isArray(${o})) return INVALID;`);let a=i.shape,s=Object.keys(a),u=Object.getOwnPropertySymbols(a),c=u.length?[...s,...u]:s,l=I=>typeof I=="symbol"?D(t,I):ge(I),d=I=>typeof I=="symbol"?`[${l(I)}]`:ge(I),f=a;if(s.includes("__proto__"))throw new F('object shape key "__proto__"');let m=new Map;for(let I of c){let k=f[I],R=l(I),U=O(t);if(e.write(`const ${U} = ${o}[${R}];`),k._zod.optin!==void 0){let N=O(t);e.write(`let ${N} = (() => {`),e.indented(G=>{let X=de(G,t,k,U);G.write(`return ${X};`)}),e.write("})();"),k._zod.optout==="optional"?(e.write(`if (${N} === INVALID) {`),e.indented(G=>{G.write(`if (${R} in ${o}) return INVALID;`),G.write(`${N} = undefined;`)}),e.write("}")):e.write(`if (${N} === INVALID) return INVALID;`),m.set(I,N)}else{Z$(k)&&e.write(`if (!(${R} in ${o})) return INVALID;`);let N=de(e,t,k,U,n);N!==null&&m.set(I,N)}}let g=i.catchall,h="none";if(g){let I=g._zod.def.type;if(I==="never"){let k=s.map(R=>`k !== ${ge(R)}`).join(" && ")||"true";e.write(`for (const k in ${o}) {`),e.indented(R=>{R.write(`if (${k}) return INVALID;`)}),e.write("}")}else(I==="unknown"||I==="any")&&!g._zod.def.checks?.length?h="passthrough":h="schema"}let b=O(t),$=c.some(I=>Ng(f[I])||Oc(f[I]));if(!n){if(h==="schema"){let I=s.length>0?D(t,new Set(s)):null;e.write(`for (const k in ${o}) {`),e.indented(k=>{k.write('if (k === "__proto__") continue;'),I&&k.write(`if (${I}.has(k)) continue;`);let R=O(t);k.write(`const ${R} = ${o}[k];`),de(k,t,g,R,!1)}),e.write("}")}return null}if($){e.write(`const ${b} = {};`);for(let I of c){let k=l(I),R=m.get(I);Oc(f[I])?e.write(`if (${k} in ${o}) ${b}[${k}] = ${R};`):Ng(f[I])?e.write(`if (${R} !== undefined || ${k} in ${o}) ${b}[${k}] = ${R};`):e.write(`${b}[${k}] = ${R};`)}}else{let I=c.map(k=>`${d(k)}: ${m.get(k)}`).join(", ");e.write(`const ${b} = { ${I} };`)}if(h!=="none"){let I=s.length>0?D(t,new Set(s)):null;e.write(`for (const k in ${o}) {`),e.indented(k=>{if(k.write('if (k === "__proto__") continue;'),I&&k.write(`if (${I}.has(k)) continue;`),h==="passthrough")k.write(`${b}[k] = ${o}[k];`);else{let R=O(t);k.write(`const ${R} = ${o}[k];`);let U=de(k,t,g,R);k.write(`${b}[k] = ${U};`)}}),e.write("}")}return b}function j$(e,t,r,o,n=!0){let i=r._zod.def;if(M$(r))return te(e,t,i.innerType,o,n);if(i.innerType._zod.optin==="defaulted"){let s=O(t),u=O(t);return e.write(`let ${s};`),e.write(`if (${o} === undefined) {`),e.indented(c=>{c.write(`const ${u} = (() => {`),c.indented(l=>{let d=te(l,t,i.innerType,o);l.write(`return ${d};`)}),c.write("})();"),c.write(`if (${u} !== INVALID) ${s} = ${u};`)}),e.write("} else {"),e.indented(c=>{let l=te(c,t,i.innerType,o);c.write(`${s} = ${l};`)}),e.write("}"),s}let a=n?O(t):null;return a&&e.write(`let ${a};`),e.write(`if (${o} !== undefined) {`),e.indented(s=>{let u=te(s,t,i.innerType,o,n);a&&u!==null&&s.write(`${a} = ${u};`)}),e.write("}"),a}function M$(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function Z$(e){return e._zod.optin===void 0&&Et(e)}function Et(e){if(e._zod.def.coerce)return!0;let t=e._zod.def;switch(t.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return t.innerType?Et(t.innerType):!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return t.innerType?Et(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(Et):!0;case"intersection":return!t.left||!t.right?!0:Et(t.left)&&Et(t.right);case"pipe":return t.in?Et(t.in):!0;default:return!0}}function Oc(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function Ng(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&rn(e)}function rn(e){let t=e._zod.def;switch(t.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return t.innerType?rn(t.innerType):!0;case"union":return t.options?t.options.some(rn):!0;case"intersection":return!t.left||!t.right||rn(t.left)||rn(t.right);case"pipe":return t.out?rn(t.out):!0;default:return!0}}function F$(e,t,r,o,n=!0){let i=r._zod.def,a=n?O(t):null;return a&&e.write(`let ${a} = null;`),e.write(`if (${o} !== null) {`),e.indented(s=>{let u=te(s,t,i.innerType,o,n);a&&u!==null&&s.write(`${a} = ${u};`)}),e.write("}"),a}function zc(e,t,r){for(let[o,n]of Wt(t._zod.def.checks))e.write(`if (${r} > ${ot(o,n._zod.def.check)}) return INVALID;`)}function B$(e,t,r,o,n=!0){let i=r._zod.def;e.write(`if (!Array.isArray(${o})) return INVALID;`),zc(e,r,`${o}.length`);let a=n?O(t):null,s=O(t),u=O(t);return a&&e.write(`const ${a} = new Array(${o}.length);`),e.write(`for (let ${s} = 0; ${s} < ${o}.length; ${s}++) {`),e.indented(c=>{c.write(`const ${u} = ${o}[${s}];`);let l=de(c,t,i.element,u,n);a&&l!==null&&c.write(`${a}[${s}] = ${l};`)}),e.write("}"),a}function V$(e,t,r,o){let i=r._zod.def.values;if(i.length!==1){let s=D(t,new Set(i));return e.write(`if (!${s}.has(${o})) return INVALID;`),o}let a=i[0];if(typeof a=="number"&&Number.isNaN(a)){let s=D(t,new Set(i));return e.write(`if (!${s}.has(${o})) return INVALID;`),o}if(typeof a=="string")e.write(`if (${o} !== ${ge(a)}) return INVALID;`);else if(typeof a=="number"||typeof a=="boolean")e.write(`if (${o} !== ${a}) return INVALID;`);else if(a===null)e.write(`if (${o} !== null) return INVALID;`);else if(a===void 0)e.write(`if (${o} !== undefined) return INVALID;`);else if(typeof a=="bigint")e.write(`if (${o} !== ${a}n) return INVALID;`);else throw new F(`literal type ${typeof a}`);return o}function G$(e,t,r,o){let n=r._zod.values;if(!n)throw new F("enum schema without enumerated values");let i=D(t,n);return e.write(`if (!${i}.has(${o})) return INVALID;`),o}function Dg(e,t,r,o){let n=r._zod.def;return te(e,t,n.innerType,o)}function q$(e,t,r,o){let n=r._zod.def,a=Object.getOwnPropertyDescriptor(r._zod.def,"defaultValue")?()=>r._zod.def.defaultValue:void 0;if(r._zod.def.type==="prefault"){if(!a)return te(e,t,n.innerType,o);let u=D(t,a),c=O(t);return e.write(`let ${c} = ${o};`),e.write(`if (${o} === undefined) ${c} = ${u}();`),te(e,t,n.innerType,c)}let s=O(t);if(a){let u=D(t,a),c=D(t,Zn);e.write(`let ${s};`),e.write(`if (${o} === undefined) {`),e.indented(l=>{l.write(`${s} = ${c}(${u}());`)}),e.write("} else {"),e.indented(l=>{let d=te(l,t,n.innerType,o);l.write(`${s} = ${d} === undefined ? ${c}(${u}()) : ${d};`)}),e.write("}")}else e.write(`let ${s};`),e.write(`if (${o} !== undefined) {`),e.indented(u=>{let c=te(u,t,n.innerType,o);u.write(`${s} = ${c};`)}),e.write("}");return s}function W$(e,t,r,o){let n=r._zod.def,i=te(e,t,n.innerType,o),a=O(t);return e.write(`const ${a} = ${i};`),e.write(`if (${a} === undefined) return INVALID;`),a}function H$(e,t,r,o){let n=r._zod.def,i=n.items,a=n.rest;e.write(`if (!Array.isArray(${o})) return INVALID;`);let s=zg(i,"optin"),u=zg(i,"optout");a?e.write(`if (${o}.length < ${s}) return INVALID;`):e.write(`if (${o}.length < ${s} || ${o}.length > ${i.length}) return INVALID;`);let c=O(t);e.write(`const ${c} = [];`);for(let l=0;l<i.length;l++){let d=i[l];if(l>=u)e.write(`if (${c}.length === ${l}) {`),e.indented(f=>{f.write(`if (${l} < ${o}.length) {`),f.indented(m=>{let g=O(t);m.write(`const ${g} = ${o}[${l}];`);let h=de(m,t,d,g);m.write(`${c}[${l}] = ${h};`)}),f.write("} else {"),f.indented(m=>{if(Oc(d)){m.write(`${c}.length = ${l};`);return}let g=O(t),h=O(t);m.write(`const ${g} = undefined;`),m.write(`const ${h} = (() => {`),m.indented(b=>{let $=de(b,t,d,g);b.write(`return ${$};`)}),m.write("})();"),m.write(`if (${h} === INVALID || ${h} === undefined) ${c}.length = ${l};`),m.write(`else ${c}[${l}] = ${h};`)}),f.write("}")}),e.write("}");else{let f=O(t);e.write(`const ${f} = ${o}[${l}];`);let m=de(e,t,d,f);e.write(`${c}[${l}] = ${m};`)}}if(a){let l=O(t),d=O(t);e.write(`for (let ${l} = ${i.length}; ${l} < ${o}.length; ${l}++) {`),e.indented(f=>{f.write(`const ${d} = ${o}[${l}];`);let m=de(f,t,a,d);f.write(`${c}[${l}] = ${m};`)}),e.write("}")}return c}function zg(e,t){for(let r=e.length-1;r>=0;r--)if(!(t==="optin"?e[r]._zod.optin!==void 0:e[r]._zod.optout==="optional"))return r+1;return 0}function K$(e,t,r,o){let n=r._zod.def,i=n.options;if(n.discriminator)return J$(e,t,n,o);if(n.inclusive===!1)throw new F("exclusive unions (z.xor)");if(i.length===0)return e.write("return INVALID;"),o;if(i.length===1)return te(e,t,i[0],o);if(i.every(u=>u._zod.def.type==="literal"&&!u._zod.def.checks?.length)){let u=new Set(i.flatMap(l=>l._zod.def.values)),c=D(t,u);return e.write(`if (!${c}.has(${o})) return INVALID;`),o}let s=O(t);e.write(`let ${s};`);for(let u=0;u<i.length;u++){let c=i[u];u===0?e.write(`${s} = (() => {`):e.write(`if (${s} === INVALID) ${s} = (() => {`),e.indented(l=>{let d=te(l,t,c,o);l.write(`return ${d};`)}),e.write("})();")}return e.write(`if (${s} === INVALID) return INVALID;`),s}function J$(e,t,r,o){if(r.unionFallback)throw new F("discriminated union with unionFallback");if(r.options.length===0)return e.write("return INVALID;"),o;let n=O(t),i=O(t);e.write(`const ${n} = ${o}?.[${ge(r.discriminator)}];`),e.write(`let ${i};`);let a=!0,s=new Set;for(let u of r.options){let c=u._zod.propValues?.[r.discriminator];if(!c||c.size===0)throw new F("discriminated union option without static discriminator values");for(let f of c){if(s.has(f))throw new F(`duplicate discriminator value ${String(f)}`);s.add(f)}let l=Array.from(c,f=>Y$(t,n,f)),d=a?"if":"else if";e.write(`${d} (${l.join(" || ")}) {`),e.indented(f=>{let m=te(f,t,u,o);f.write(`${i} = ${m};`)}),e.write("}"),a=!1}return e.write("else { return INVALID; }"),i}function Y$(e,t,r){if(typeof r=="string")return`${t} === ${ge(r)}`;if(typeof r=="number")return Number.isNaN(r)?`Number.isNaN(${t})`:`${t} === ${r}`;if(typeof r=="boolean")return`${t} === ${r}`;if(r===null)return`${t} === null`;if(r===void 0)return`${t} === undefined`;if(typeof r=="bigint")return`${t} === ${r}n`;if(typeof r=="symbol"){let o=D(e,r);return`${t} === ${o}`}throw new F(`literal discriminator value ${String(r)}`)}function X$(e,t,r,o){let n=r._zod.def;t.definite=!1;let i=de(e,t,n.left,o),a=de(e,t,n.right,o),s=D(t,en),u=O(t);return e.write(`const ${u} = ${s}(${i}, ${a});`),e.write(`if (!${u}.valid) return INVALID;`),`${u}.data`}function Q$(e,t,r,o){let n=r._zod.def,i=D(t,Ce);e.write(`if (!${i}(${o})) return INVALID;`);let a=O(t),s=O(t),u=O(t);e.write(`const ${a} = {};`);let c=n,l=c.partial?void 0:n.keyType._zod.values;if(l){let m=[];for(let h of l){if(!(typeof h=="string"||typeof h=="number"||typeof h=="symbol"))throw new F(`record key value ${String(h)}`);let b=typeof h=="number"?h.toString():h;if(b==="__proto__")throw new F('record key "__proto__"');m.push(b);let $=D(t,h),I=te(e,t,n.keyType,$),k=O(t);e.write(`const ${k} = ${o}[${eI(t,b)}];`);let R=de(e,t,n.valueType,k);e.write(`${a}[${I}] = ${R};`)}let g=D(t,new Set(m));return e.write(`for (const ${s} in ${o}) {`),e.indented(h=>{h.write(`if (${g}.has(${s})) continue;`),c.mode==="loose"?h.write(`if (${s} !== "__proto__") ${a}[${s}] = ${o}[${s}];`):h.write("return INVALID;")}),e.write("}"),a}let d=n.keyType._zod.def;if(!(d.type==="string"&&d.format===void 0&&!d.coerce&&(d.checks?.length??0)===0)){let m=n.mode==="loose",g=no(n.keyType);g.definite===!1&&(t.definite=!1);let h=D(t,g),b=D(t,Ye),$=O(t);return Ug(e,t,o,s,I=>{I.write(`let ${$} = ${h}(${s});`),I.write(`if (${$} === INVALID && typeof ${s} === "string" && ${b}.test(${s})) ${$} = ${h}(Number(${s}));`),m?I.write(`if (${$} === INVALID) { ${a}[${s}] = ${o}[${s}]; continue; }`):I.write(`if (${$} === INVALID) return INVALID;`),I.write(`if (${$} === "__proto__") continue;`);let k=O(t);I.write(`const ${k} = ${o}[${s}];`);let R=de(I,t,n.valueType,k);I.write(`${a}[${$}] = ${R};`)}),a}return Ug(e,t,o,s,m=>{m.write(`const ${u} = ${o}[${s}];`);let g=de(m,t,n.valueType,u);m.write(`${a}[${s}] = ${g};`)},"return INVALID;"),a}function Ug(e,t,r,o,n,i){let a=D(t,Object.prototype.propertyIsEnumerable),s=O(t),u=O(t),c=O(t);e.write(`const ${s} = Object.getOwnPropertySymbols(${r});`),e.write(`const ${u} = Object.getOwnPropertyNames(${r});`),e.write(`for (let ${c} = 0; ${c} < ${u}.length; ${c}++) {`),e.indented(l=>{l.write(`const ${o} = ${u}[${c}];`),l.write(`if (${o} === "__proto__" || !${a}.call(${r}, ${o})) continue;`),n(l)}),e.write("}"),e.write(`for (let ${c} = 0; ${c} < ${s}.length; ${c}++) {`),e.indented(l=>{l.write(`const ${o} = ${s}[${c}];`),l.write(`if (!${a}.call(${r}, ${o})) continue;`),i?l.write(i):n(l)}),e.write("}")}function eI(e,t){return typeof t=="string"?ge(t):D(e,t)}function tI(e,t,r,o){let n=r._zod.def;e.write(`if (!(${o} instanceof Map)) return INVALID;`),zc(e,r,`${o}.size`);let i=O(t),a=O(t),s=O(t);return e.write(`const ${i} = new Map();`),e.write(`for (const [${a}, ${s}] of ${o}) {`),e.indented(u=>{let c=te(u,t,n.keyType,a),l=te(u,t,n.valueType,s);u.write(`${i}.set(${c}, ${l});`)}),e.write("}"),i}function nI(e,t,r,o){let n=r._zod.def;e.write(`if (!(${o} instanceof Set)) return INVALID;`),zc(e,r,`${o}.size`);let i=O(t),a=O(t);return e.write(`const ${i} = new Set();`),e.write(`for (const ${a} of ${o}) {`),e.indented(s=>{let u=te(s,t,n.valueType,a);s.write(`${i}.add(${u});`)}),e.write("}"),i}function rI(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function iI(e,t,r,o){e.write(`if (typeof ${o} !== "string") return INVALID;`);let n=r._zod.pattern;if(n){let i=D(t,n);e.write(`${i}.lastIndex = 0;`),e.write(`if (!${i}.test(${o})) return INVALID;`)}return o}function oI(e,t,r,o){let n=r._zod.def,i=kt(t,n.getter),a=D(t,{parser:null});e.write(`if (!${a}.parser) {`),e.indented(u=>{u.write(`const inner = ${i}();`),u.write(`${a}.parser = function(input) {`),u.indented(c=>{c.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),c.write("return result.issues.length === 0 ? result.value : INVALID;")}),u.write("};")}),e.write("}");let s=O(t);return e.write(`const ${s} = ${a}.parser(${o});`),e.write(`if (${s} === INVALID) return INVALID;`),s}function aI(e,t,r,o){let n=r._zod.def,i=te(e,t,n.in,o);if(n.transform){if(Tt(n.transform))throw new je("z.compile: async transforms in pipes are not supported");let a=n.transform,u=kt(t,l=>{let d={value:l,issues:[],addIssue:Dc},f=a(l,d);return f instanceof Promise?ve:d.issues.length===0?f:ve}),c=O(t);return e.write(`const ${c} = ${u}(${i});`),e.write(`if (${c} === INVALID) return INVALID;`),te(e,t,n.out,c)}else return te(e,t,n.out,i)}function Tt(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function sI(e,t,r,o){let n=r._zod.def;if(n.fn){if(Tt(n.fn))throw new je("z.compile: async custom predicates are not supported");let i=kt(t,n.fn),a=D(t,Cc),s=O(t);e.write(`const ${s} = ${i}(${o});`),e.write(`if (${s} instanceof Promise) ${a}();`),e.write(`if (!${s}) return INVALID;`)}else throw new F("custom schema without a predicate function");return o}function uI(e,t,r){let o=e._zod.run({value:r,issues:[]},{});if(o&&typeof o.then=="function")return ve;let n=o;return n.issues.length===0?n.value:t()}function cI(e,t,r,o){let n=r._zod.def;if(!n.catchValue[si])throw new F("catch with a callback (only a constant catch value compiles)",!1);let i=O(t);e.write(`let ${i} = (() => {`),e.indented(c=>{let l=de(c,t,n.innerType,o);c.write(`return ${l};`)}),e.write("})();");let a=D(t,n.innerType),s=kt(t,n.catchValue),u=D(t,uI);return e.write(`if (${i} === INVALID) {`),e.indented(c=>{c.write(`${i} = ${u}(${a}, ${s}, ${o});`),c.write(`if (${i} === INVALID) return INVALID;`)}),e.write("}"),i}function lI(e,t,r,o){let n=r._zod.def;if(n.transform){if(Tt(n.transform))throw new je("z.compile: async transforms are not supported");let i=n.transform,s=kt(t,c=>{let l={value:c,issues:[],addIssue:Dc},d=i(c,l);return d instanceof Promise?ve:l.issues.length===0?d:ve}),u=O(t);return e.write(`const ${u} = ${s}(${o});`),e.write(`if (${u} === INVALID) return INVALID;`),u}return o}function ro(e){return e.checks&&(e.checks=[...e.checks]),e}function Uc(e,t){return new e(ro({type:"string",...E(t)}))}function Lc(e,t){return new e(ro({type:"string",coerce:!0,...E(t)}))}function io(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...E(t)})}function oo(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...E(t)})}function ao(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...E(t)})}function so(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...E(t)})}function uo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...E(t)})}function co(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...E(t)})}function vr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...E(t)})}function lo(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...E(t)})}function po(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...E(t)})}function mo(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...E(t)})}function fo(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...E(t)})}function go(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...E(t)})}function ho(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...E(t)})}function vo(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...E(t)})}function _o(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...E(t)})}function yo(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...E(t)})}function jc(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...E(t)})}function bo(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...E(t)})}function So(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...E(t)})}function wo(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...E(t)})}function xo(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...E(t)})}function $o(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...E(t)})}function Mc(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...E(t)})}function Zc(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...E(t)})}function Io(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...E(t)})}var Fc={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function _r(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...E(t)})}function yr(e,t){return new e({type:"string",format:"date",check:"string_format",...E(t)})}function br(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...E(t)})}function Sr(e,t){return new e({type:"string",format:"duration",check:"string_format",...E(t)})}function Bc(e,t){return new e(ro({type:"number",checks:[],...E(t)}))}function Vc(e,t){return new e(ro({type:"number",coerce:!0,checks:[],...E(t)}))}function Gc(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...E(t)})}function qc(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...E(t)})}function Wc(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...E(t)})}function Hc(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...E(t)})}function Kc(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...E(t)})}function Jc(e,t){return new e({type:"boolean",...E(t)})}function Yc(e,t){return new e({type:"boolean",coerce:!0,...E(t)})}function Xc(e,t){return new e({type:"bigint",...E(t)})}function Qc(e,t){return new e({type:"bigint",coerce:!0,...E(t)})}function el(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...E(t)})}function tl(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...E(t)})}function nl(e,t){return new e({type:"symbol",...E(t)})}function rl(e,t){return new e({type:"undefined",...E(t)})}function il(e,t){return new e({type:"null",...E(t)})}function ol(e){return new e({type:"any"})}function al(e){return new e({type:"unknown"})}function sl(e,t){return new e({type:"never",...E(t)})}function ul(e,t){return new e({type:"void",...E(t)})}function cl(e,t){return new e({type:"date",...E(t)})}function ll(e,t){return new e({type:"date",coerce:!0,...E(t)})}function dl(e,t){return new e({type:"nan",...E(t)})}function Be(e,t){return new xi({check:"less_than",...E(t),value:e,inclusive:!1})}function Ae(e,t){return new xi({check:"less_than",...E(t),value:e,inclusive:!0})}function Ve(e,t){return new $i({check:"greater_than",...E(t),value:e,inclusive:!1})}function Pe(e,t){return new $i({check:"greater_than",...E(t),value:e,inclusive:!0})}function Eo(e){return Ve(0,e)}function ko(e){return Be(0,e)}function To(e){return Ae(0,e)}function Ao(e){return Pe(0,e)}function at(e,t){return new Ws({check:"multiple_of",...E(t),value:e})}function st(e,t){return new Js({check:"max_size",...E(t),maximum:e})}function Ge(e,t){return new Ys({check:"min_size",...E(t),minimum:e})}function At(e,t){return new Xs({check:"size_equals",...E(t),size:e})}function Pt(e,t){return new Qs({check:"max_length",...E(t),maximum:e})}function Xe(e,t){return new eu({check:"min_length",...E(t),minimum:e})}function Rt(e,t){return new tu({check:"length_equals",...E(t),length:e})}function on(e,t){return new nu({check:"string_format",format:"regex",...E(t),pattern:e})}function an(e){return new ru({check:"string_format",format:"lowercase",...E(e)})}function sn(e){return new iu({check:"string_format",format:"uppercase",...E(e)})}function un(e,t){return new ou({check:"string_format",format:"includes",...E(t),includes:e})}function cn(e,t){return new au({check:"string_format",format:"starts_with",...E(t),prefix:e})}function ln(e,t){return new su({check:"string_format",format:"ends_with",...E(t),suffix:e})}function Po(e,t,r){return new uu({check:"property",property:e,schema:t,...E(r)})}function dn(e,t){return new cu({check:"properties",shape:e,...E(t)})}function pn(e,t){return new lu({check:"mime_type",mime:e,...E(t)})}function Me(e){return new du({check:"overwrite",tx:e})}function mn(e){return Me(t=>t.normalize(e))}function fn(){return Me(e=>e.trim())}function gn(){return Me(e=>e.toLowerCase())}function hn(){return Me(e=>e.toUpperCase())}function vn(){return Me(e=>Ka(e))}function pl(e,t,r){return new e({type:"array",element:t,...E(r)})}function dI(e,t,r){return new e({type:"union",options:t,...E(r)})}function pI(e,t,r){return new e({type:"union",options:t,inclusive:!1,...E(r)})}function mI(e,t,r,o){return new e({type:"union",options:r,discriminator:t,...E(o)})}function fI(e,t,r){return new e({type:"intersection",left:t,right:r})}function gI(e,t,r,o){let n=r instanceof z,i=n?o:r,a=n?r:null;return new e({type:"tuple",items:t,rest:a,...E(i)})}function hI(e,t,r,o){return new e({type:"record",keyType:t,valueType:r,...E(o)})}function vI(e,t,r,o){return new e({type:"map",keyType:t,valueType:r,...E(o)})}function _I(e,t,r){return new e({type:"set",valueType:t,...E(r)})}function yI(e,t,r){let o=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new e({type:"enum",entries:o,...E(r)})}function bI(e,t,r){return new e({type:"enum",entries:t,...E(r)})}function SI(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...E(r)})}function ml(e,t){return new e({type:"file",...E(t)})}function wI(e,t){return new e({type:"transform",transform:t})}function xI(e,t){return new e({type:"optional",innerType:t})}function $I(e,t){return new e({type:"nullable",innerType:t})}function II(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():Zn(r)}})}function EI(e,t,r){return new e({type:"nonoptional",innerType:t,...E(r)})}function kI(e,t){return new e({type:"success",innerType:t})}function TI(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:ts(r)})}function AI(e,t,r){return new e({type:"pipe",in:t,out:r})}function PI(e,t){return new e({type:"readonly",innerType:t})}function RI(e,t,r){return new e({type:"template_literal",parts:t,...E(r)})}function CI(e,t){return new e({type:"lazy",getter:t})}function OI(e,t){return new e({type:"promise",innerType:t})}function fl(e,t,r){let o=E(r);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function gl(e,t,r){return new e({type:"custom",check:"custom",fn:t,...E(r)})}function hl(e,t){let r=Zg(o=>(o.addIssue=n=>{if(typeof n=="string")o.issues.push(Ht(n,o.value,r._zod.def));else{let i=n;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=o.value),i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),o.issues.push(Ht(i))}},e(o.value,o)),t);return r}function Zg(e,t){let r=new Y({check:"custom",...E(t)});return r._zod.check=e,r}function vl(e){let t=new Y({check:"describe"});return t._zod.onattach=[r=>{let o=ue.get(r)??{};ue.add(r,{...o,description:e})}],t._zod.check=()=>{},t}function _l(e){let t=new Y({check:"meta"});return t._zod.onattach=[r=>{let o=ue.get(r)??{};ue.add(r,{...o,...e})}],t._zod.check=()=>{},t}function yl(e,t){let r=E(t),o=r.truthy??["true","1","yes","on","y","enabled"],n=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(o=o.map(m=>typeof m=="string"?m.toLowerCase():m),n=n.map(m=>typeof m=="string"?m.toLowerCase():m));let i=new Set(o),a=new Set(n),s=e.Codec??lr,u=e.Boolean??ur,c=e.String??It,l=new c({type:"string",error:r.error}),d=new u({type:"boolean",error:r.error}),f=new s({type:"pipe",in:l,out:d,transform:((m,g)=>{let h=m;return r.case!=="sensitive"&&(h=h.toLowerCase()),i.has(h)?!0:a.has(h)?!1:(g.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...a],input:g.value,inst:f,continue:!1}),{})}),reverseTransform:((m,g)=>m===!0?o[0]||"true":n[0]||"false"),error:r.error});return f._zod.bag.truthy=o,f._zod.bag.falsy=n,f._zod.bag.case=r.case??"insensitive",f}function Ct(e,t,r,o={}){let n=E(o),i={check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:s=>r.test(s),...n};return r instanceof RegExp&&(i.pattern=r),new e(i)}function wr(e,...t){for(let r of t)for(let o of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,o)&&se(e,o,r[o]);return e}function ut(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??ue,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function ie(e,t,r,o,n){let i=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:o.path,message:n}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw new Error(n);return Object.assign(r,i),!0}function H(e,t,r={path:[],schemaPath:[]}){var o;let n=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,l);else{let f=a.schema,m=t.processors[n.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);m(e,t,f,l)}let d=e._zod.parent;d&&(a.ref||(a.ref=d),H(d,t,l),t.seen.get(d).isParent=!0)}let u=t.metadataRegistry.get(e);return u&&wr(a.schema,u),t.io==="input"&&_e(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&"_prefault"in a.schema&&((o=a.schema).default??(o.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Fg(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ct(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let o=new Map;for(let a of e.seen.entries()){let s=e.metadataRegistry.get(a[0])?.id;if(s){let u=o.get(s);if(u&&u!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(s,a[0])}}let n=a=>{let s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(a[0])?.id,f=e.external.uri??(g=>g);if(d)return{ref:f(d)};let m=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=m,{defId:m,ref:`${f("__shared")}#/${s}/${Fg(m)}`}}let u="#",c=`${u}/${s}/`;if(a[1]===r&&!a[1].schema.id)return{ref:u};let l=a[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:c+Fg(l)}},i=a=>{if(a[1].schema.$ref)return;let s=a[1],{ref:u,defId:c}=n(a);s.def={...s.schema},c&&(s.defId=c);let l=s.schema;for(let d in l)delete l[d];l.$ref=u};if(e.cycles==="throw")for(let a of e.seen.entries()){let s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
70
70
 
71
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let s=a[1];if(t===a[0]){i(a);continue}if(e.external){let c=e.external.registry.get(a[0])?.id;if(t!==a[0]&&c){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(s.cycle){i(a);continue}s.count>1&&e.reused==="ref"&&i(a)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Gg(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let o of t){if(!o||typeof o!="object")return;Gg(o);let n=Object.keys(o);if(n.length!==1||n[0]!=="type")return;let i=o.type;for(let a of Array.isArray(i)?i:[i]){if(typeof a!="string")return;r.includes(a)||r.push(a)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var qg=new Set(["type","properties","required","additionalProperties"]),Bg=["oneOf","anyOf"];function Vg(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function bl(e){let t=[];for(let i of e){if(typeof i!="object"||i.type!=="object")return null;for(let a in i)if(!qg.has(a))return null;t.push(i)}let r={},o=new Set;for(let i of t){for(let a in i.properties){if(Object.prototype.hasOwnProperty.call(r,a))continue;let s=[];for(let c of t){let l=c.properties?.[a]??Vg(c);l!=null&&(s.some(d=>JSON.stringify(d)===JSON.stringify(l))||s.push(l))}let u=s.length===1?s[0]:bl(s)??{allOf:s};se(r,a,u)}for(let a of i.required??[])o.add(a)}let n={type:"object",properties:r};if(o.size&&(n.required=[...o]),t.every(i=>i.additionalProperties===!1))n.additionalProperties=!1;else{let i=[];for(let a of t){let s=Vg(a);s&&!i.some(u=>JSON.stringify(u)===JSON.stringify(s))&&i.push(s)}i.length===1?n.additionalProperties=i[0]:i.length>1&&(n.additionalProperties={allOf:i})}return n}function NI(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let n of qg)if(n in e)return;let r=t.filter(n=>Bg.some(i=>Array.isArray(n[i]))),o=null;if(!r.length)o=bl(t);else{let n=r[0],i=Bg.find(u=>Array.isArray(n[u]));if(Object.keys(n).length!==1)return;let a=t.filter(u=>u!==n),s=n[i].map(u=>bl([...a,u]));if(s.some(u=>!u))return;o={[i]:s}}o&&(delete e.allOf,wr(e,o))}function lt(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=s=>{let u=e.seen.get(s);if(u.ref===null)return;let c=u.def??u.schema,l={...c},d=u.ref;if(u.ref=null,d){o(d);let m=e.seen.get(d),g=m.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(g)):wr(c,g),wr(c,l),s._zod.parent===d)for(let b in c)b==="$ref"||b==="allOf"||b in l||delete c[b];if(g.$ref&&m.def)for(let b in c)b==="$ref"||b==="allOf"||b in m.def&&JSON.stringify(c[b])===JSON.stringify(m.def[b])&&delete c[b]}let f=s._zod.parent;if(f&&f!==d){o(f);let m=e.seen.get(f);if(m?.schema.$ref&&(c.$ref=m.schema.$ref,m.def))for(let g in c)g==="$ref"||g==="allOf"||g in m.def&&JSON.stringify(c[g])===JSON.stringify(m.def[g])&&delete c[g]}e.override({zodSchema:s,jsonSchema:c,path:u.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let s of[...e.seen.entries()].reverse())o(s[0]);if(e.target!=="openapi-3.0")for(let s of e.seen.entries())Gg(s[1].def??s[1].schema);for(let s of e.deferred)s();if(e.intersections.length){let s=new Map;for(let u of e.seen.values())for(let c of[u.schema,u.def]){let l=c?.allOf;if(!Array.isArray(l))continue;let d=s.get(l);d?d.push(c):s.set(l,[c])}for(let u of e.intersections)for(let c of s.get(u)??[])NI(c)}}let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(s)}wr(n,r.defId?r.schema:r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;i!==void 0&&n.id===i&&delete n.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let s of e.seen.entries()){let u=s[1];u.def&&u.defId&&(u.def.id===u.defId&&delete u.def.id,se(a,u.defId,u.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?n.$defs=a:n.definitions=a);try{let s=JSON.parse(JSON.stringify(n));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:_n(t,"input",e.processors),output:_n(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function _e(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return _e(o.element,r);if(o.type==="set")return _e(o.valueType,r);if(o.type==="lazy")return _e(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault"||o.type==="catch")return _e(o.innerType,r);if(o.type==="intersection")return _e(o.left,r)||_e(o.right,r);if(o.type==="record"||o.type==="map")return _e(o.keyType,r)||_e(o.valueType,r);if(o.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:_e(o.in,r)||_e(o.out,r);if(o.type==="object"){for(let n in o.shape)if(_e(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if(_e(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if(_e(n,r))return!0;return!!(o.rest&&_e(o.rest,r))}return!1}var Sl=(e,t={})=>r=>{let o=ut({...r,processors:t});return H(e,o),ct(o,e),lt(o,e)},_n=(e,t,r={})=>o=>{let{libraryOptions:n,target:i}=o??{},a=ut({...n??{},target:i,io:t,processors:r});return H(e,a),ct(a,e),lt(a,e)};var yn=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},bn=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},Wg=(e,t)=>{yn(e,"minimum",t),bn(e,"maximum",t)},Yg=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Xg=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Qg=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},eh=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Hg=(e,t)=>yn(e,"minimum",t.minimum),Kg=(e,t)=>bn(e,"maximum",t.maximum),Jg=e=>(t,r)=>{eh(t,r.format);let[o,n]=e[r.format];yn(t,"minimum",o),bn(t,"maximum",n)},DI={greater_than:(e,t)=>yn(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>bn(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Yg(e,t.value),number_format:Jg(Bn),bigint_format:Jg(Vn),min_length:Hg,max_length:Kg,length_equals:(e,t)=>Wg(e,t.length),min_size:Hg,max_size:Kg,size_equals:(e,t)=>Wg(e,t.size),string_format:(e,t)=>{eh(e,t.format),t.pattern&&Xg(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Qg(e,t.mime)};function oe(e){let t={},r=e._zod.def,o=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let i of o)DI[i._zod.def.check]?.(t,i._zod.def);let n=e._zod.bag;n.minimum!==void 0&&yn(t,"minimum",n.minimum),n.exclusiveMinimum!==void 0&&yn(t,"exclusiveMinimum",n.exclusiveMinimum),n.maximum!==void 0&&bn(t,"maximum",n.maximum),n.exclusiveMaximum!==void 0&&bn(t,"exclusiveMaximum",n.exclusiveMaximum),n.multipleOf!==void 0&&Yg(t,n.multipleOf),n.format!==void 0&&(t.format??(t.format=n.format),n.format.includes("int")&&(t.isInt=!0)),n.mime&&Qg(t,n.mime);for(let i of n.patterns??[])Xg(t,i);return t}var zI={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},UI=new Map([[Ni,ks],[sr,Ts]]),th=e=>UI.get(e)??e,$l=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:i,maximum:a,format:s,patterns:u,contentEncoding:c,laxFormat:l}=oe(e);if(typeof i=="number"&&(n.minLength=i),typeof a=="number"&&(n.maxLength=a),s&&(n.format=zI[s]??s,n.format===""&&delete n.format,(s==="time"||l)&&delete n.format),c&&(n.contentEncoding=c),u&&u.size>0){let d=[...u].map(th);d.length===1?n.pattern=d[0].source:d.length>1&&(n.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Il=(e,t,r,o)=>{let n=r,{minimum:i,maximum:a,multipleOf:s,exclusiveMaximum:u,exclusiveMinimum:c,isInt:l}=oe(e);n.type=l?"integer":"number";let d=typeof c=="number"&&c>=(i??Number.NEGATIVE_INFINITY),f=typeof u=="number"&&u<=(a??Number.POSITIVE_INFINITY),m=t.target==="draft-04"||t.target==="openapi-3.0";if(d?m?(n.minimum=c,n.exclusiveMinimum=!0):n.exclusiveMinimum=c:typeof i=="number"&&(n.minimum=i),f?m?(n.maximum=u,n.exclusiveMaximum=!0):n.exclusiveMaximum=u:typeof a=="number"&&(n.maximum=a),s){let g=new Set;for(let $ of s)Number.isFinite($)&&$!==0?g.add(Math.abs($)):ie(e,t,n,o,`A multipleOf divisor of ${$} cannot be represented in JSON Schema`);let[h,...b]=g;h!==void 0&&(n.multipleOf=h),b.length&&(n.allOf=[...n.allOf??[],...b.map($=>({multipleOf:$}))])}},El=(e,t,r,o)=>{r.type="boolean"},kl=(e,t,r,o)=>{ie(e,t,r,o,"BigInt cannot be represented in JSON Schema")},Tl=(e,t,r,o)=>{ie(e,t,r,o,"Symbols cannot be represented in JSON Schema")},Al=(e,t,r,o)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},Pl=(e,t,r,o)=>{ie(e,t,r,o,"Undefined cannot be represented in JSON Schema")},Rl=(e,t,r,o)=>{ie(e,t,r,o,"Void cannot be represented in JSON Schema")},Cl=(e,t,r,o)=>{r.not={}},Ol=(e,t,r,o)=>{},Nl=(e,t,r,o)=>{},Dl=(e,t,r,o)=>{ie(e,t,r,o,"Date cannot be represented in JSON Schema")},zl=(e,t,r,o)=>{let n=e._zod.def,i=Bt(n.entries);if(i.length===0){r.not={};return}i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),r.enum=i},Ul=(e,t,r,o)=>{let n=e._zod.def;if(n.values.length===0){r.not={};return}let i=[];for(let a of n.values)if(a===void 0){if(ie(e,t,r,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(ie(e,t,r,o,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){let a=i[0];r.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[a]:r.const=a}else i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),i.every(a=>typeof a=="boolean")&&(r.type="boolean"),i.every(a=>a===null)&&(r.type="null"),r.enum=i},Ll=(e,t,r,o)=>{ie(e,t,r,o,"NaN cannot be represented in JSON Schema")},jl=(e,t,r,o)=>{let n=r,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},Ml=(e,t,r,o)=>{let n=r;n.type="string",n.format="binary",n.contentEncoding="binary";let{minimum:i,maximum:a,mime:s}=oe(e);i!==void 0&&(n.minLength=i),a!==void 0&&(n.maxLength=a),s&&(s.length===0?n.not={}:s.length===1?n.contentMediaType=s[0]:n.anyOf=s.map(u=>({contentMediaType:u})))},Zl=(e,t,r,o)=>{r.type="boolean"},Fl=(e,t,r,o)=>{ie(e,t,r,o,"Custom types cannot be represented in JSON Schema")},Bl=(e,t,r,o)=>{ie(e,t,r,o,"Function types cannot be represented in JSON Schema")},Vl=(e,t,r,o)=>{ie(e,t,r,o,"Transforms cannot be represented in JSON Schema")},Gl=(e,t,r,o)=>{ie(e,t,r,o,"Map cannot be represented in JSON Schema")},ql=(e,t,r,o)=>{ie(e,t,r,o,"Set cannot be represented in JSON Schema")},Wl=(e,t,r,o)=>{let n=r,i=e._zod.def,{minimum:a,maximum:s}=oe(e);typeof a=="number"&&(n.minItems=a),typeof s=="number"&&(n.maxItems=s),n.type="array",n.items=H(i.element,t,{...o,path:[...o.path,"items"]})};function xr(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?xr(t.out):t.type==="catch"?xr(t.innerType):e._zod.optin}var Hl=(e,t,r,o)=>{let n=r,i=e._zod.def,a=i.shape;if(Object.getOwnPropertySymbols(a).length&&ie(e,t,n,o,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(let c in a)se(n.properties,c,H(a[c],t,{...o,path:[...o.path,"properties",c]}));let u=[];for(let c of Object.keys(a)){let l=i.shape[c];(t.io==="input"?xr(l)===void 0:l._zod.optout===void 0)&&u.push(c)}u.length>0&&(n.required=u),i.catchall?._zod.def.type==="never"?n.additionalProperties=!1:i.catchall?i.catchall&&(n.additionalProperties=H(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},Co=(e,t,r,o)=>{let n=e._zod.def,i=n.inclusive===!1,a=n.options.map((s,u)=>H(s,t,{...o,path:[...o.path,i?"oneOf":"anyOf",u]}));i?r.oneOf=a:r.anyOf=a},Kl=(e,t,r,o)=>{let n=e._zod.def,i=H(n.left,t,{...o,path:[...o.path,"allOf",0]}),a=H(n.right,t,{...o,path:[...o.path,"allOf",1]}),s=c=>"allOf"in c&&Object.keys(c).length===1,u=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]];r.allOf=u,t.intersections.push(u)},Jl=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",u=i.items.map((h,b)=>H(h,t,{...o,path:[...o.path,a,b]})),c=i.rest?H(i.rest,t,{...o,path:[...o.path,s,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null,l=i.items.length;for(;l>0;){let h=i.items[l-1];if(!(t.io==="input"?xr(h)!==void 0:h._zod.optout==="optional"))break;l--}let d=i.items.length,f=!i.rest;t.target==="draft-2020-12"?(n.prefixItems=u,f?n.items=!1:c&&(n.items=c),l>0&&(n.minItems=l),f&&(n.maxItems=d)):t.target==="openapi-3.0"?(n.items={anyOf:u},c&&n.items.anyOf.push(c),l>0&&(n.minItems=l),f&&(n.maxItems=d)):(n.items=u,f?n.additionalItems=!1:c&&(n.additionalItems=c),l>0&&(n.minItems=l),f&&(n.maxItems=d));let{minimum:m,maximum:g}=oe(e);typeof m=="number"&&(n.minItems=m),typeof g=="number"&&(n.maxItems=g)};function wl(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let g=e.get(t)?.def;if(!g)return t;let h=wl(e,g,r);return h===g?t:h}for(let g of["anyOf","oneOf"]){let h=t[g];if(!Array.isArray(h))continue;let b=h.map($=>wl(e,$,r));b.some(($,I)=>$!==h[I])&&(t={...t,[g]:b})}let o=Array.isArray(t.type)?t.type:[t.type],n=!o.includes("string")&&o.some(g=>g==="number"||g==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!n&&!i?.some(g=>typeof g=="number"))return t;let{minimum:a,maximum:s,exclusiveMinimum:u,exclusiveMaximum:c,multipleOf:l,format:d,id:f,...m}=t;return m.enum?m.enum=m.enum.map(g=>typeof g=="number"?String(g):g):typeof m.const=="number"&&(m.const=String(m.const)),n&&(m.type="string",i||(m.pattern=(o.includes("number")?Ye:er).source)),m}var xl=new WeakMap;function LI(e){let t=new Map;for(let o of e.seen.values())o.def&&!t.has(o.schema)&&t.set(o.schema,o);let r=new Map;for(let o of xl.get(e)??[]){let n=e.seen.get(o),i=(n?.def??n?.schema)?.propertyNames;if(!i||i===!0||r.has(i))continue;let a=wl(t,i,new Set);a!==i&&r.set(i,a)}if(r.size)for(let o of e.seen.values())for(let n of[o.schema,o.def]){let i=n&&r.get(n.propertyNames);i&&(n.propertyNames=i)}}var Yl=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object";let a=i.keyType,s=oe(a).patterns;if(i.mode==="loose"&&s&&s.size>0){let l=H(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});n.patternProperties={};for(let d of s)se(n.patternProperties,th(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){n.propertyNames=H(i.keyType,t,{...o,path:[...o.path,"propertyNames"]});let l=xl.get(t);l||(l=[],xl.set(t,l),t.deferred.push(()=>LI(t))),l.push(e)}n.additionalProperties=H(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let u=a._zod.values,c=t.io==="input"&&xr(i.valueType)!==void 0;if(u&&!i.partial&&!c){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(n.required=l.map(String))}},Xl=(e,t,r,o)=>{let n=e._zod.def,i=H(n.innerType,t,o),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=n.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},Ql=(e,t,r,o)=>{let n=e._zod.def;H(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},ed=Symbol();function nh(e,t,r,o,n){let i=!1,a=JSON.stringify(e,(s,u)=>typeof u!="bigint"?u:(i=!0,null));return i?(ie(t,r,o,n,"BigInt defaults cannot be represented in JSON Schema"),ed):JSON.parse(a)}var td=(e,t,r,o)=>{let n=e._zod.def;H(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let a=nh(n.defaultValue,e,t,r,o);a!==ed&&(r.default=a)},nd=(e,t,r,o)=>{let n=e._zod.def;H(n.innerType,t,o);let i=t.seen.get(e);if(i.ref=n.innerType,t.io!=="input")return;let a=nh(n.defaultValue,e,t,r,o);a!==ed&&(r._prefault=a)},rd=(e,t,r,o)=>{let n=e._zod.def;H(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let a;try{a=n.catchValue(void 0)}catch{ie(e,t,r,o,"Dynamic catch values are not supported in JSON Schema");return}r.default=a},id=(e,t,r,o)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?i?n.out:n.in:n.out;H(a,t,o);let s=t.seen.get(e);s.ref=a},od=(e,t,r,o)=>{let n=e._zod.def;H(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0},ad=(e,t,r,o)=>{let n=e._zod.def;H(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},Oo=(e,t,r,o)=>{let n=e._zod.def;H(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},sd=(e,t,r,o)=>{let n=e._zod.innerType;H(n,t,o);let i=t.seen.get(e);i.ref=n},Ro={string:$l,number:Il,boolean:El,bigint:kl,symbol:Tl,null:Al,undefined:Pl,void:Rl,never:Cl,any:Ol,unknown:Nl,date:Dl,enum:zl,literal:Ul,nan:Ll,template_literal:jl,file:Ml,success:Zl,custom:Fl,function:Bl,transform:Vl,map:Gl,set:ql,array:Wl,object:Hl,union:Co,intersection:Kl,tuple:Jl,record:Yl,nullable:Xl,nonoptional:Ql,default:td,prefault:nd,catch:rd,pipe:id,readonly:od,promise:ad,optional:Oo,lazy:sd};function No(e,t){if("_idmap"in e){let o=e,n=ut({...t,processors:Ro}),i={};for(let u of o._idmap.entries()){let[c,l]=u;H(l,n)}let a={},s={registry:o,uri:t?.uri,defs:i};n.external=s;for(let u of o._idmap.entries()){let[c,l]=u;ct(n,l),se(a,c,lt(n,l))}if(Object.keys(i).length>0){let u=n.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[u]:i}}return{schemas:a}}let r=ut({...t,processors:Ro});return H(e,r),ct(r,e),lt(r,e)}var Do=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=ut({processors:Ro,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return H(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,ct(this.ctx,t);let o=lt(this.ctx,t),{"~standard":n,...i}=o;return i}};var rh={};var Tn={};He(Tn,{ZodAny:()=>Ad,ZodArray:()=>Od,ZodBase64:()=>ea,ZodBase64URL:()=>ta,ZodBigInt:()=>En,ZodBigIntFormat:()=>ia,ZodBoolean:()=>In,ZodCIDRv4:()=>Xo,ZodCIDRv6:()=>Qo,ZodCUID:()=>Go,ZodCUID2:()=>qo,ZodCatch:()=>ep,ZodCodec:()=>Or,ZodCreditCard:()=>Sd,ZodCustom:()=>Nr,ZodCustomStringFormat:()=>zt,ZodDate:()=>kr,ZodDefault:()=>Hd,ZodDiscriminatedUnion:()=>Dd,ZodE164:()=>na,ZodEmail:()=>Zo,ZodEmoji:()=>Bo,ZodEnum:()=>wn,ZodExactOptional:()=>ua,ZodFile:()=>Vd,ZodFunction:()=>lp,ZodGUID:()=>Fo,ZodIBAN:()=>wd,ZodIPv4:()=>Jo,ZodIPv6:()=>Yo,ZodISODate:()=>pt,ZodISODateTime:()=>dt,ZodISODuration:()=>ft,ZodISOTime:()=>mt,ZodInstanceOf:()=>mp,ZodIntersection:()=>zd,ZodJWT:()=>ra,ZodKSUID:()=>Ko,ZodLazy:()=>sp,ZodLiteral:()=>Bd,ZodMAC:()=>bd,ZodMap:()=>Zd,ZodNaN:()=>np,ZodNanoID:()=>Vo,ZodNever:()=>Rd,ZodNonOptional:()=>ca,ZodNull:()=>kd,ZodNullable:()=>Wd,ZodNumber:()=>$n,ZodNumberFormat:()=>Ut,ZodObject:()=>Ar,ZodOptional:()=>Rr,ZodPipe:()=>Cr,ZodPrefault:()=>Jd,ZodPreprocess:()=>rp,ZodPromise:()=>cp,ZodReadonly:()=>ip,ZodRecord:()=>Sn,ZodSet:()=>Fd,ZodString:()=>xn,ZodStringFormat:()=>K,ZodSuccess:()=>Qd,ZodSymbol:()=>Id,ZodTemplateLiteral:()=>ap,ZodTransform:()=>Gd,ZodTuple:()=>Ld,ZodType:()=>M,ZodULID:()=>Wo,ZodURL:()=>Er,ZodUUID:()=>qe,ZodUndefined:()=>Ed,ZodUnion:()=>Pr,ZodUnknown:()=>Pd,ZodVoid:()=>Cd,ZodXID:()=>Ho,ZodXor:()=>Nd,_ZodString:()=>Mo,_default:()=>Kd,_function:()=>gv,any:()=>qh,array:()=>Tr,base64:()=>Eh,base64url:()=>kh,bigint:()=>Zh,boolean:()=>$d,catch:()=>tp,check:()=>hv,cidrv4:()=>$h,cidrv6:()=>Ih,codec:()=>dv,creditCard:()=>Ah,cuid:()=>hh,cuid2:()=>vh,currencyCode:()=>Dh,custom:()=>vv,date:()=>Hh,describe:()=>_v,discriminatedUnion:()=>ev,e164:()=>Th,email:()=>ah,emoji:()=>fh,enum:()=>aa,exactOptional:()=>qd,file:()=>sv,float32:()=>Uh,float64:()=>Lh,function:()=>gv,guid:()=>sh,hash:()=>zh,hex:()=>Nh,hostname:()=>Oh,httpUrl:()=>mh,iban:()=>Ph,instanceof:()=>bv,int:()=>Lo,int32:()=>jh,int64:()=>Fh,intersection:()=>Ud,invertCodec:()=>pv,ipv4:()=>Sh,ipv6:()=>xh,json:()=>wv,jwt:()=>Rh,keyof:()=>Kh,ksuid:()=>bh,lazy:()=>up,literal:()=>av,looseObject:()=>Xh,looseRecord:()=>nv,mac:()=>wh,map:()=>rv,meta:()=>yv,nan:()=>lv,nanoid:()=>gh,nativeEnum:()=>ov,never:()=>oa,nonoptional:()=>Xd,null:()=>Td,nullable:()=>Ir,nullish:()=>uv,number:()=>xd,object:()=>Jh,optional:()=>Nt,partialRecord:()=>tv,pipe:()=>jo,prefault:()=>Yd,preprocess:()=>xv,promise:()=>fv,readonly:()=>op,record:()=>Md,refine:()=>dp,set:()=>iv,strictObject:()=>Yh,string:()=>$r,stringFormat:()=>Ch,stringbool:()=>Sv,success:()=>cv,superRefine:()=>pp,symbol:()=>Vh,templateLiteral:()=>mv,transform:()=>sa,tuple:()=>jd,uint32:()=>Mh,uint64:()=>Bh,ulid:()=>_h,undefined:()=>Gh,union:()=>kn,unknown:()=>Ot,url:()=>ph,uuid:()=>uh,uuidv4:()=>ch,uuidv6:()=>lh,uuidv7:()=>dh,void:()=>Wh,xid:()=>yh,xor:()=>Qh});var zo={};He(zo,{endsWith:()=>ln,gt:()=>Ve,gte:()=>Pe,includes:()=>un,length:()=>Rt,lowercase:()=>an,lt:()=>Be,lte:()=>Ae,maxLength:()=>Pt,maxSize:()=>st,mime:()=>pn,minLength:()=>Xe,minSize:()=>Ge,multipleOf:()=>at,negative:()=>ko,nonnegative:()=>Ao,nonpositive:()=>To,normalize:()=>mn,overwrite:()=>Me,positive:()=>Eo,properties:()=>dn,property:()=>Po,regex:()=>on,size:()=>At,slugify:()=>vn,startsWith:()=>cn,toLowerCase:()=>gn,toUpperCase:()=>hn,trim:()=>fn,uppercase:()=>sn});var ih=new WeakSet([Object.prototype,Error.prototype]);function Uo(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let o=r(this);return Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0})}})}var oh=(e,t)=>{ss.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);ih.has(r)||(ih.add(r),Uo(r,"format",o=>n=>Jn(o,n)),Uo(r,"flatten",o=>n=>Kn(o,n)),Uo(r,"addIssue",o=>n=>{o.issues.push(n),o.message=JSON.stringify(o.issues,Vt,2)}),Uo(r,"addIssues",o=>n=>{o.issues.push(...n),o.message=JSON.stringify(o.issues,Vt,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},MI=v("ZodError",oh),Ie=v("ZodError",oh,void 0,{Parent:Error});var ud=Kt(Ie),cd=Jt(Ie),ld=Yt(Ie),dd=Xt(Ie),pd=di(Ie),md=pi(Ie),fd=mi(Ie),gd=fi(Ie),hd=gi(Ie),vd=hi(Ie),_d=vi(Ie),yd=_i(Ie);function FI(){ae.localeError||ne(Ji())}function Dt(){ae.memoizer||ne({memoizer:fr()})}var M=v("ZodType",(e,t)=>(FI(),z.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(S.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return q(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(dp(e,t))},superRefine(e,t){return this.check(pp(e,t))},overwrite(e){return this.check(Me(e))},optional(){return Nt(this)},exactOptional(){return qd(this)},nullable(){return Ir(this)},nullish(){return Nt(Ir(this))},nonoptional(e){return Xd(this,e)},array(){return Tr(this)},or(e){return kn([this,e])},and(e){return Ud(this,e)},transform(e){return jo(this,sa(e))},default(e){return Kd(this,e)},prefault(e){return Yd(this,e)},catch(e){return tp(this,e)},pipe(e){return jo(this,e)},readonly(){return op(this)},describe(e){let t=this.clone();return ue.add(t,{description:e}),t},meta(...e){if(e.length===0)return ue.get(this);let t=this.clone();return ue.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return S.hide(this,"~standard",{...Ai(this),jsonSchema:{input:_n(this,"input"),output:_n(this,"output")}})},set"~standard"(e){S.own(this,"~standard",e)},parse:function e(t,r){return ud(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await cd(this,t,r,{callee:e})},safeParse(e,t){return ld(this,e,t)},async safeParseAsync(e,t){return dd(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){S.own(this,"spa",e)},validate(e,t){return Yn(this,e,t)},validateAsync(e,t){return Xn(this,e,t)},encode:function e(t,r){return pd(this,t,r,{callee:e})},decode:function e(t,r){return md(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await fd(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await gd(this,t,r,{callee:e})},safeEncode(e,t){return hd(this,e,t)},safeDecode(e,t){return vd(this,e,t)},async safeEncodeAsync(e,t){return _d(this,e,t)},async safeDecodeAsync(e,t){return yd(this,e,t)},toJSONSchema(e){return Sl(this,{})(e)},get description(){return ue.get(this)?.description},get _def(){return this._zod.def}}),Mo=v("_ZodString",(e,t)=>{It.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>$l(e,r,o,n)},S.derived({format:e=>oe(e).format??null,minLength:e=>oe(e).minimum??null,maxLength:e=>oe(e).maximum??null},{regex(...e){return this.check(on(...e))},includes(...e){return this.check(un(...e))},startsWith(...e){return this.check(cn(...e))},endsWith(...e){return this.check(ln(...e))},min(...e){return this.check(Xe(...e))},max(...e){return this.check(Pt(...e))},length(...e){return this.check(Rt(...e))},nonempty(...e){return this.check(Xe(1,...e))},lowercase(e){return this.check(an(e))},uppercase(e){return this.check(sn(e))},trim(){return this.check(fn())},normalize(...e){return this.check(mn(...e))},toLowerCase(){return this.check(gn())},toUpperCase(){return this.check(hn())},slugify(){return this.check(vn())}})),xn=v("ZodString",(e,t)=>{It.init(e,t),Mo.init(e,t)},{email(e){return this.check(io(Zo,e))},url(e){return this.check(vr(Er,e))},jwt(e){return this.check(Io(ra,e))},emoji(e){return this.check(lo(Bo,e))},guid(e){return this.check(oo(Fo,e))},uuid(e){return this.check(ao(qe,e))},uuidv4(e){return this.check(so(qe,e))},uuidv6(e){return this.check(uo(qe,e))},uuidv7(e){return this.check(co(qe,e))},nanoid(e){return this.check(po(Vo,e))},cuid(e){return this.check(mo(Go,e))},cuid2(e){return this.check(fo(qo,e))},ulid(e){return this.check(go(Wo,e))},base64(e){return this.check(wo(ea,e))},base64url(e){return this.check(xo(ta,e))},xid(e){return this.check(ho(Ho,e))},ksuid(e){return this.check(vo(Ko,e))},ipv4(e){return this.check(_o(Jo,e))},ipv6(e){return this.check(yo(Yo,e))},cidrv4(e){return this.check(bo(Xo,e))},cidrv6(e){return this.check(So(Qo,e))},e164(e){return this.check($o(na,e))},datetime(e){return this.check(_r(dt,e))},date(e){return this.check(yr(pt,e))},time(e){return this.check(br(mt,e))},duration(e){return this.check(Sr(ft,e))}});function $r(e){return Uc(xn,e)}var K=v("ZodStringFormat",(e,t)=>{W.init(e,t),Mo.init(e,t)}),dt=v("ZodISODateTime",(e,t)=>{ku.init(e,t),K.init(e,t)}),pt=v("ZodISODate",(e,t)=>{Tu.init(e,t),K.init(e,t)}),mt=v("ZodISOTime",(e,t)=>{Au.init(e,t),K.init(e,t)}),ft=v("ZodISODuration",(e,t)=>{Pu.init(e,t),K.init(e,t)}),Zo=v("ZodEmail",(e,t)=>{hu.init(e,t),K.init(e,t)});function ah(e){return io(Zo,e)}var Fo=v("ZodGUID",(e,t)=>{fu.init(e,t),K.init(e,t)});function sh(e){return oo(Fo,e)}var qe=v("ZodUUID",(e,t)=>{gu.init(e,t),K.init(e,t)});function uh(e){return ao(qe,e)}function ch(e){return so(qe,e)}function lh(e){return uo(qe,e)}function dh(e){return co(qe,e)}var Er=v("ZodURL",(e,t)=>{yu.init(e,t),K.init(e,t)});function ph(e){return vr(Er,e)}function mh(e){return vr(Er,{protocol:Qn,hostname:Ps,...S.normalizeParams(e)})}var Bo=v("ZodEmoji",(e,t)=>{bu.init(e,t),K.init(e,t)});function fh(e){return lo(Bo,e)}var Vo=v("ZodNanoID",(e,t)=>{Su.init(e,t),K.init(e,t)});function gh(e){return po(Vo,e)}var Go=v("ZodCUID",(e,t)=>{wu.init(e,t),K.init(e,t)});function hh(e){return mo(Go,e)}var qo=v("ZodCUID2",(e,t)=>{xu.init(e,t),K.init(e,t)});function vh(e){return fo(qo,e)}var Wo=v("ZodULID",(e,t)=>{$u.init(e,t),K.init(e,t)});function _h(e){return go(Wo,e)}var Ho=v("ZodXID",(e,t)=>{Iu.init(e,t),K.init(e,t)});function yh(e){return ho(Ho,e)}var Ko=v("ZodKSUID",(e,t)=>{Eu.init(e,t),K.init(e,t)});function bh(e){return vo(Ko,e)}var Jo=v("ZodIPv4",(e,t)=>{Ru.init(e,t),K.init(e,t)});function Sh(e){return _o(Jo,e)}var bd=v("ZodMAC",(e,t)=>{Ou.init(e,t),K.init(e,t)});function wh(e){return jc(bd,e)}var Yo=v("ZodIPv6",(e,t)=>{Cu.init(e,t),K.init(e,t)});function xh(e){return yo(Yo,e)}var Xo=v("ZodCIDRv4",(e,t)=>{Nu.init(e,t),K.init(e,t)});function $h(e){return bo(Xo,e)}var Qo=v("ZodCIDRv6",(e,t)=>{Du.init(e,t),K.init(e,t)});function Ih(e){return So(Qo,e)}var ea=v("ZodBase64",(e,t)=>{zu.init(e,t),K.init(e,t)});function Eh(e){return wo(ea,e)}var ta=v("ZodBase64URL",(e,t)=>{Uu.init(e,t),K.init(e,t)});function kh(e){return xo(ta,e)}var na=v("ZodE164",(e,t)=>{Lu.init(e,t),K.init(e,t)});function Th(e){return $o(na,e)}var Sd=v("ZodCreditCard",(e,t)=>{ju.init(e,t),K.init(e,t)});function Ah(e){return Mc(Sd,e)}var wd=v("ZodIBAN",(e,t)=>{Mu.init(e,t),K.init(e,t)});function Ph(e){return Zc(wd,e)}var ra=v("ZodJWT",(e,t)=>{Zu.init(e,t),K.init(e,t)});function Rh(e){return Io(ra,e)}var zt=v("ZodCustomStringFormat",(e,t)=>{Fu.init(e,t),K.init(e,t)});function Ch(e,t,r={}){return Ct(zt,e,t,r)}function Oh(e){return Ct(zt,"hostname",As,e)}function Nh(e){return Ct(zt,"hex",Vs,e)}function Dh(e){return Ct(zt,"currency_code",Cs,e)}function zh(e,t){let r=t?.enc??"hex",o=`${e}_${r}`,n=Ne[o];if(!n)throw new Error(`Unrecognized hash format: ${o}`);return Ct(zt,o,n,t)}var $n=v("ZodNumber",(e,t)=>{ji.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Il(e,r,o,n),e.isFinite=!0},S.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=oe(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=oe(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=oe(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>oe(e).format??null},{gt(e,t){return this.check(Ve(e,t))},gte(e,t){return this.check(Pe(e,t))},min(e,t){return this.check(Pe(e,t))},lt(e,t){return this.check(Be(e,t))},lte(e,t){return this.check(Ae(e,t))},max(e,t){return this.check(Ae(e,t))},int(e){return this.check(Lo(e))},safe(e){return this.check(Lo(e))},positive(e){return this.check(Ve(0,e))},nonnegative(e){return this.check(Pe(0,e))},negative(e){return this.check(Be(0,e))},nonpositive(e){return this.check(Ae(0,e))},multipleOf(e,t){return this.check(at(e,t))},step(e,t){return this.check(at(e,t))},finite(){return this}}));function xd(e){return Bc($n,e)}var Ut=v("ZodNumberFormat",(e,t)=>{Bu.init(e,t),$n.init(e,t)});function Lo(e){return Gc(Ut,e)}function Uh(e){return qc(Ut,e)}function Lh(e){return Wc(Ut,e)}function jh(e){return Hc(Ut,e)}function Mh(e){return Kc(Ut,e)}var In=v("ZodBoolean",(e,t)=>{ur.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>El(e,r,o,n)});function $d(e){return Jc(In,e)}var En=v("ZodBigInt",(e,t)=>{Mi.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>kl(e,r,o,n)},S.derived({minValue:e=>oe(e).minimum??null,maxValue:e=>oe(e).maximum??null,format:e=>oe(e).format??null},{gte(e,t){return this.check(Pe(e,t))},min(e,t){return this.check(Pe(e,t))},gt(e,t){return this.check(Ve(e,t))},lt(e,t){return this.check(Be(e,t))},lte(e,t){return this.check(Ae(e,t))},max(e,t){return this.check(Ae(e,t))},positive(e){return this.check(Ve(BigInt(0),e))},negative(e){return this.check(Be(BigInt(0),e))},nonpositive(e){return this.check(Ae(BigInt(0),e))},nonnegative(e){return this.check(Pe(BigInt(0),e))},multipleOf(e,t){return this.check(at(e,t))}}));function Zh(e){return Xc(En,e)}var ia=v("ZodBigIntFormat",(e,t)=>{Vu.init(e,t),En.init(e,t)});function Fh(e){return el(ia,e)}function Bh(e){return tl(ia,e)}var Id=v("ZodSymbol",(e,t)=>{Gu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Tl(e,r,o,n)});function Vh(e){return nl(Id,e)}var Ed=v("ZodUndefined",(e,t)=>{qu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Pl(e,r,o,n)});function Gh(e){return rl(Ed,e)}var kd=v("ZodNull",(e,t)=>{Wu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Al(e,r,o,n)});function Td(e){return il(kd,e)}var Ad=v("ZodAny",(e,t)=>{Hu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ol(e,r,o,n)});function qh(){return ol(Ad)}var Pd=v("ZodUnknown",(e,t)=>{Ku.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Nl(e,r,o,n)});function Ot(){return al(Pd)}var Rd=v("ZodNever",(e,t)=>{Ju.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Cl(e,r,o,n)});function oa(e){return sl(Rd,e)}var Cd=v("ZodVoid",(e,t)=>{Yu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Rl(e,r,o,n)});function Wh(e){return ul(Cd,e)}var kr=v("ZodDate",(e,t)=>{Xu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Dl(e,r,o,n),e.min=(r,o)=>e.check(Pe(r,o)),e.max=(r,o)=>e.check(Ae(r,o))},S.derived({minDate:e=>{let{minimum:t}=oe(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=oe(e);return t?new Date(t):null}},{}));function Hh(e){return cl(kr,e)}var Od=v("ZodArray",(e,t)=>{Dt(),ec.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Wl(e,r,o,n),e.element=t.element},{min(e,t){return this.check(Xe(e,t))},nonempty(e){return this.check(Xe(1,e))},max(e,t){return this.check(Pt(e,t))},length(e,t){return this.check(Rt(e,t))},unwrap(){return this.element}});function Tr(e,t){return pl(Od,e,t)}function Kh(e){let t=e._zod.def.shape;return aa(Object.keys(t))}var Ar=v("ZodObject",(e,t)=>{Dt(),tc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Hl(e,r,o,n),S.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return aa(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(S.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(S.mergeDefs(this._zod.def,{catchall:Ot()}))},loose(){return this.clone(S.mergeDefs(this._zod.def,{catchall:Ot()}))},strict(){return this.clone(S.mergeDefs(this._zod.def,{catchall:oa()}))},strip(){return this.clone(S.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return S.extend(this,e)},safeExtend(e){return S.safeExtend(this,e)},merge(e){return S.merge(this,e)},pick(e){return S.pick(this,e)},omit(e){return S.omit(this,e)},partial(...e){return S.partial(Rr,this,e[0])},exactPartial(...e){return S.partial(ua,this,e[0],"exactPartial")},required(...e){return S.required(ca,this,e[0])}});function Jh(e,t){let r={type:"object",shape:e??{},...S.normalizeParams(t)};return new Ar(r)}function Yh(e,t){return new Ar({type:"object",shape:e,catchall:oa(),...S.normalizeParams(t)})}function Xh(e,t){return new Ar({type:"object",shape:e,catchall:Ot(),...S.normalizeParams(t)})}var Pr=v("ZodUnion",(e,t)=>{cr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Co(e,r,o,n),e.options=t.options});function kn(e,t){return new Pr({type:"union",options:e,...S.normalizeParams(t)})}var Nd=v("ZodXor",(e,t)=>{Pr.init(e,t),nc.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Co(e,r,o,n),e.options=t.options});function Qh(e,t){return new Nd({type:"union",options:e,inclusive:!1,...S.normalizeParams(t)})}var Dd=v("ZodDiscriminatedUnion",(e,t)=>{Pr.init(e,t),ic.init(e,t)});function ev(e,t,r){return new Dd({type:"union",options:t,discriminator:e,...S.normalizeParams(r)})}var zd=v("ZodIntersection",(e,t)=>{oc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Kl(e,r,o,n)});function Ud(e,t){return new zd({type:"intersection",left:e,right:t})}var Ld=v("ZodTuple",(e,t)=>{Dt(),Zi.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Jl(e,r,o,n)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new Rr({type:"optional",innerType:t}))})}});function jd(e,t,r){let o=t instanceof z,n=o?r:t,i=o?t:null;return new Ld({type:"tuple",items:e,rest:i,...S.normalizeParams(n)})}var Sn=v("ZodRecord",(e,t)=>{Dt(),ac.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Yl(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});function Md(e,t,r){return!t||!t._zod?new Sn({type:"record",keyType:$r(),valueType:e,...S.normalizeParams(t)}):new Sn({type:"record",keyType:e,valueType:t,...S.normalizeParams(r)})}function tv(e,t,r){return new Sn({type:"record",keyType:e,valueType:t,...S.normalizeParams(r),partial:!0})}function nv(e,t,r){return new Sn({type:"record",keyType:e,valueType:t,mode:"loose",...S.normalizeParams(r)})}var Zd=v("ZodMap",(e,t)=>{Dt(),sc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Gl(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Ge(...r)),e.nonempty=r=>e.check(Ge(1,r)),e.max=(...r)=>e.check(st(...r)),e.size=(...r)=>e.check(At(...r))});function rv(e,t,r){return new Zd({type:"map",keyType:e,valueType:t,...S.normalizeParams(r)})}var Fd=v("ZodSet",(e,t)=>{Dt(),uc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ql(e,r,o,n),e.min=(...r)=>e.check(Ge(...r)),e.nonempty=r=>e.check(Ge(1,r)),e.max=(...r)=>e.check(st(...r)),e.size=(...r)=>e.check(At(...r))});function iv(e,t){return new Fd({type:"set",valueType:e,...S.normalizeParams(t)})}var wn=v("ZodEnum",(e,t)=>{cc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(o,n,i)=>zl(e,o,n,i),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let i={};for(let a of o)if(r.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new wn({...t,checks:[],...S.normalizeParams(n),entries:i})},e.exclude=(o,n)=>{let i={...t.entries};for(let a of o)if(r.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new wn({...t,checks:[],...S.normalizeParams(n),entries:i})}});function aa(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new wn({type:"enum",entries:r,...S.normalizeParams(t)})}function ov(e,t){return new wn({type:"enum",entries:e,...S.normalizeParams(t)})}var Bd=v("ZodLiteral",(e,t)=>{lc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ul(e,r,o,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function av(e,t){return new Bd({type:"literal",values:Array.isArray(e)?e:[e],...S.normalizeParams(t)})}var Vd=v("ZodFile",(e,t)=>{dc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ml(e,r,o,n),e.min=(r,o)=>e.check(Ge(r,o)),e.max=(r,o)=>e.check(st(r,o)),e.mime=(r,o)=>e.check(pn(Array.isArray(r)?r:[r],o))});function sv(e){return ml(Vd,e)}var Gd=v("ZodTransform",(e,t)=>{Dt(),pc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Vl(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new it(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(S.issue(i,r.value,t));else{let a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=r.value),a.inst??(a.inst=e),r.issues.push(S.issue(a))}};let n=t.transform(r.value,r);return n instanceof Promise?n.then(i=>(r.value=i,r)):(r.value=n,r)}});function sa(e){return new Gd({type:"transform",transform:e})}var Rr=v("ZodOptional",(e,t)=>{Fi.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Oo(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Nt(e){return new Rr({type:"optional",innerType:e})}var ua=v("ZodExactOptional",(e,t)=>{mc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Oo(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function qd(e){return new ua({type:"optional",innerType:e})}var Wd=v("ZodNullable",(e,t)=>{fc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Xl(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Ir(e){return new Wd({type:"nullable",innerType:e})}function uv(e){return Nt(Ir(e))}var Hd=v("ZodDefault",(e,t)=>{gc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>td(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Kd(e,t){return new Hd({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():S.shallowClone(t)}})}var Jd=v("ZodPrefault",(e,t)=>{hc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>nd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Yd(e,t){return new Jd({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():S.shallowClone(t)}})}var ca=v("ZodNonOptional",(e,t)=>{vc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ql(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Xd(e,t){return new ca({type:"nonoptional",innerType:e,...S.normalizeParams(t)})}var Qd=v("ZodSuccess",(e,t)=>{_c.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Zl(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function cv(e){return new Qd({type:"success",innerType:e})}var ep=v("ZodCatch",(e,t)=>{yc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>rd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function tp(e,t){return new ep({type:"catch",innerType:e,catchValue:typeof t=="function"?t:S.constantCatch(t)})}var np=v("ZodNaN",(e,t)=>{bc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ll(e,r,o,n)});function lv(e){return dl(np,e)}var Cr=v("ZodPipe",(e,t)=>{Bi.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>id(e,r,o,n),e.in=t.in,e.out=t.out});function jo(e,t){return new Cr({type:"pipe",in:e,out:t})}var Or=v("ZodCodec",(e,t)=>{Cr.init(e,t),lr.init(e,t)});function dv(e,t,r){return new Or({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function pv(e){let t=e._zod.def;return new Or({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var rp=v("ZodPreprocess",(e,t)=>{Cr.init(e,t),Sc.init(e,t)}),ip=v("ZodReadonly",(e,t)=>{wc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>od(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function op(e){return new ip({type:"readonly",innerType:e})}var ap=v("ZodTemplateLiteral",(e,t)=>{xc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>jl(e,r,o,n)});function mv(e,t){return new ap({type:"template_literal",parts:e,...S.normalizeParams(t)})}var sp=v("ZodLazy",(e,t)=>{dr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>sd(e,r,o,n),e.unwrap=()=>e._zod.def.getter()});function up(e){return new sp({type:"lazy",getter:e})}var cp=v("ZodPromise",(e,t)=>{Ic.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ad(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function fv(e){return new cp({type:"promise",innerType:e})}var lp=v("ZodFunction",(e,t)=>{$c.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Bl(e,r,o,n)});function gv(e){return new lp({type:"function",input:Array.isArray(e?.input)?jd(e?.input):e?.input??Tr(Ot()),output:e?.output??Ot()})}var Nr=v("ZodCustom",(e,t)=>{Ec.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Fl(e,r,o,n)});function hv(e){let t=new Y({check:"custom"});return t._zod.check=e,t}function vv(e,t){return fl(Nr,e??(()=>!0),t)}function dp(e,t={}){return gl(Nr,e,t)}function pp(e,t){return hl(e,t)}var _v=vl,yv=_l,mp=v("ZodInstanceOf",(e,t)=>{Nr.init(e,t)},{properties(e,t){return this.check(dn(e,t))}});function bv(e,t={}){let r=new mp({type:"custom",check:"custom",fn:o=>o instanceof e,abort:!0,...S.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=o=>{o.value instanceof e||o.issues.push({code:"invalid_type",expected:e.name,input:o.value,inst:r,path:[...r._zod.def.path??[]]})},r}var Sv=(...e)=>yl({Codec:Or,Boolean:In,String:xn},...e);function wv(e){let t=up(()=>kn([$r(e),xd(),$d(),Td(),Tr(t),Md($r(),t)]));return t}function xv(e,t){return new rp({type:"pipe",in:sa(e),out:t})}var BI={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function VI(e){ne({customError:e})}function GI(){return ne().customError}var fp;fp||(fp={});var Dr={};He(Dr,{ZodISODate:()=>pt,ZodISODateTime:()=>dt,ZodISODuration:()=>ft,ZodISOTime:()=>mt,date:()=>WI,datetime:()=>qI,duration:()=>KI,time:()=>HI});function qI(e){return _r(dt,e)}function WI(e){return yr(pt,e)}function HI(e){return br(mt,e)}function KI(e){return Sr(ft,e)}var T={...Tn,...zo,iso:Dr},JI=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function YI(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function $v(e,t){return e.map((r,o)=>o<t?r:r.optional())}function XI(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function QI(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let o=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===o){let n=r[1]===void 0?void 0:XI(r[1]);if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function eE(e,t){return T.transform(o=>o).check(o=>{let n=o.value;if(typeof n!="object"||n===null||Array.isArray(n))return;let i=Object.getOwnPropertyNames(n);if(t.minProperties!==void 0&&i.length<t.minProperties&&o.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:n,inst:e,continue:!0}),t.maxProperties!==void 0&&i.length>t.maxProperties&&o.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:n,inst:e,continue:!0}),t.keySchema)for(let a of i){let s=t.keySchema.safeParse(a);s.success||o.issues.push({code:"invalid_key",origin:"record",issues:s.error.issues,input:a,path:[a],continue:!0})}}).pipe(e)}function gp(e,t){if(e===null)return"z";let r=typeof e;if(r!=="object"){if(r==="number"&&Number.isNaN(e))return null;let o=String(e);return`${r[0]}${o.length}:${o}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let i=[];for(let a of e){let s=gp(a,t);if(s===null)return null;i.push(s)}return`a${i.length}:[${i.join(",")}]`}let o=Object.keys(e).sort(),n=[];for(let i of o){let a=gp(e[i],t);if(a===null)return null;n.push(`${i.length}:${i}=${a}`)}return`o${n.length}:{${n.join(",")}}`}finally{t.delete(e)}}var tE=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),nE=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function zr(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(zr):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,r])=>tE.has(t)?zr(r):!nE.has(t)||typeof r!="object"||r===null?!1:Object.values(r).some(zr))}function Iv(e){return e===1?"element":"elements"}function rE(e,t){return T.transform(o=>o).check(o=>{let n=o.value;if(Array.isArray(n)){if(t.uniqueItems===!0){let i=new Map;for(let a=0;a<n.length;a++){let s=gp(n[a],new Set);if(s===null)continue;let u=i.get(s);if(u===void 0){i.set(s,a);continue}o.issues.push({code:"custom",message:`Array items must be unique: element at index ${a} duplicates the one at index ${u}`,input:n,path:[a],continue:!0})}}if(t.containsSchema){let i=t.minContains??1,a=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY,s=0;for(let u of n)if(t.containsSchema.safeParse(u).success&&++s>=a)break;s<i&&o.issues.push({code:"custom",message:`Array must contain at least ${i} matching ${Iv(i)}; found ${s}`,input:n,continue:!0}),t.maxContains!==void 0&&s>t.maxContains&&o.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${Iv(t.maxContains)}`,input:n,continue:!0})}}}).pipe(e)}function Ev(e,t){if(e!==!1)return e===void 0||e===!0?T.any():ye(e,t)}var iE=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function kv(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return T.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return T.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let i=QI(n,t),a=ye(i,t);return t.refs.set(n,a),t.processing.delete(n),a}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return T.null();if(n.length===0)return T.never();if(n.length===1)return T.literal(n[0]);if(n.every(a=>typeof a=="string"))return T.enum(n);let i=n.map(a=>T.literal(a));return i.length<2?i[0]:T.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return T.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map(i=>{let a={...e,type:i};return kv(a,t)});return n.length===0?T.never():n.length===1?n[0]:T.union(n)}if(!r)return T.any();let o;switch(r){case"string":{let n=T.string();if(e.format){let i=e.format;i==="email"?n=n.check(T.email()):i==="uri"||i==="uri-reference"?n=n.check(T.url()):i==="uuid"||i==="guid"?n=n.check(T.uuid()):i==="date-time"?n=n.check(T.iso.datetime({offset:!0})):i==="date"?n=n.check(T.iso.date()):i==="time"?n=n.check(T.regex(iE)):i==="duration"?n=n.check(T.iso.duration()):i==="hostname"?n=n.check(T.hostname()):i==="ipv4"?n=n.check(T.ipv4()):i==="ipv6"?n=n.check(T.ipv6()):i==="mac"?n=n.check(T.mac()):i==="cidr"?n=n.check(T.cidrv4()):i==="cidr-v6"?n=n.check(T.cidrv6()):i==="base64"?n=n.check(T.base64()):i==="base64url"?n=n.check(T.base64url()):i==="e164"?n=n.check(T.e164()):i==="credit_card"?n=n.check(T.creditCard()):i==="iban"?n=n.check(T.iban()):i==="jwt"?n=n.check(T.jwt()):i==="emoji"?n=n.check(T.emoji()):i==="nanoid"?n=n.check(T.nanoid()):i==="cuid"?n=n.check(T.cuid()):i==="cuid2"?n=n.check(T.cuid2()):i==="ulid"?n=n.check(T.ulid()):i==="xid"?n=n.check(T.xid()):i==="ksuid"&&(n=n.check(T.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),o=n;break}case"number":case"integer":{let n=r==="integer"?T.number().int():T.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),o=n;break}case"boolean":{o=T.boolean();break}case"null":{o=T.null();break}case"object":{let n={},i=e.properties||{},a=new Set(e.required||[]),s=typeof e.additionalProperties=="object"?ye(e.additionalProperties,t):void 0;for(let[d,f]of Object.entries(i)){let m=ye(f,t);se(n,d,a.has(d)?m:m.optional())}if(e.patternProperties){let d=e.patternProperties,f=Object.keys(d),m=[];for(let h of f){let b=ye(d[h],t),$=T.string().regex(new RegExp(h));m.push(T.looseRecord($,b))}let g=[];if(Object.keys(n).length>0&&g.push(T.object(n).passthrough()),g.push(...m),g.length===0)o=T.object({}).passthrough();else if(g.length===1)o=g[0];else{let h=T.intersection(g[0],g[1]);for(let b=2;b<g.length;b++)h=T.intersection(h,g[b]);o=h}if(e.additionalProperties===!1){let h=Object.keys(n),b=f.map(I=>new RegExp(I)),$=o;o=o.check(I=>{if(!Ce(I.value))return;let k=[];for(let R of Object.keys(I.value))h.includes(R)||b.some(U=>U.test(R))||k.push(R);k.length&&I.issues.push({code:"unrecognized_keys",keys:k,input:I.value,inst:$})})}}else{let d=T.object(n);e.additionalProperties===!1?o=d.strict():s?o=d.catchall(s):o=d.passthrough()}let u=e.propertyNames!==void 0&&e.propertyNames!==!0,c=typeof e.minProperties=="number"?e.minProperties:void 0,l=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(u||c!==void 0||l!==void 0){let d;if(u){let f=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;d=ye(f,t)}o=eE(o,{keySchema:d,minProperties:c,maxProperties:l})}break}case"array":{let n=e.prefixItems,i=e.items;if(n&&Array.isArray(n)){let a=typeof e.minItems=="number"?e.minItems:0,s=n.map(d=>ye(d,t)),u=$v(s,a),c=Array.isArray(i)?void 0:Ev(i,t),l=T.tuple(u);o=c?l.rest(c):l,typeof e.minItems=="number"&&(o=o.check(T.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(T.maxLength(e.maxItems)))}else if(Array.isArray(i)){let a=typeof e.minItems=="number"?e.minItems:0,s=i.map(d=>ye(d,t)),u=$v(s,a),c=Ev(e.additionalItems,t),l=T.tuple(u);o=c?l.rest(c):l,typeof e.minItems=="number"&&(o=o.check(T.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(T.maxLength(e.maxItems)))}else if(i!==void 0){let a=ye(i,t),s=T.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),o=s}else o=T.array(T.any());(e.uniqueItems===!0||e.contains!==void 0)&&(o=rE(o,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?ye(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${r}`)}return o}function ye(e,t){if(typeof e=="boolean")return e?T.any():T.never();let r=kv(e,t),o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(c=>ye(c,t)),u=T.union(s);r=o?T.intersection(r,u):u}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(c=>ye(c,t)),u=T.xor(s);r=o?T.intersection(r,u):u}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=o?r:T.any();else{let s=o?r:ye(e.allOf[0],t),u=o?0:1;for(let c=u;c<e.allOf.length;c++)s=T.intersection(s,ye(e.allOf[c],t));r=s}e.nullable===!0&&t.version==="openapi-3.0"&&(r=T.nullable(r)),e.readOnly===!0&&(r=T.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let n={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of i)s in e&&(n[s]=e[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in e&&(n[s]=e[s]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!zr(e.propertyNames)&&(n.propertyNames=e.propertyNames);for(let s of["minProperties","maxProperties"])e[s]!==void 0&&(n[s]=e[s])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!zr(e.contains)&&(n.contains=e.contains);for(let s of["uniqueItems","minContains","maxContains"])e[s]!==void 0&&(n[s]=e[s])}for(let s of Object.keys(e))JI.has(s)||se(n,s,e[s]);return Object.keys(n).length>0&&t.registry.add(r,n),e.description&&(r=r.describe(e.description)),r}function Tv(e,t){if(typeof e=="boolean")return e?T.any():T.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let o=YI(r,t?.defaultTarget),n=r.$defs||r.definitions||{},i={version:o,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??ue};return ye(r,i)}var Av=Symbol("z.visit/resolving");function Ur(e,t){let r=typeof t=="function"?t:(a,s)=>{let u=t[a._zod.def.type];return u?u(a,s):a},o=new Map;function n(a){let s=o.get(a);if(s===Av)return new dr({type:"lazy",getter:()=>o.get(a)});if(s!==void 0)return s;o.set(a,Av);let u=i(a),c=r(u,u!==a);return o.set(a,c),c}function i(a){let s=a._zod.def,u=s.type;switch(u){case"object":{let c=s.shape,l=Object.keys(c),d=!1,f={};for(let g of l){let h=n(c[g]);h!==c[g]&&(d=!0),f[g]=h}let m=s.catchall;return s.catchall&&(m=n(s.catchall),m!==s.catchall&&(d=!0)),d?q(a,{...s,shape:f,catchall:m}):a}case"array":{let c=n(s.element);return c===s.element?a:q(a,{...s,element:c})}case"tuple":{let c=s.items,l=!1,d=[];for(let m of c){let g=n(m);g!==m&&(l=!0),d.push(g)}let f=s.rest;return s.rest&&(f=n(s.rest),f!==s.rest&&(l=!0)),l?q(a,{...s,items:d,rest:f}):a}case"record":case"map":{let c=n(s.keyType),l=n(s.valueType);return c===s.keyType&&l===s.valueType?a:q(a,{...s,keyType:c,valueType:l})}case"set":{let c=n(s.valueType);return c===s.valueType?a:q(a,{...s,valueType:c})}case"union":{let c=s.options,l=!1,d=[];for(let f of c){let m=n(f);m!==f&&(l=!0),d.push(m)}return l?q(a,{...s,options:d}):a}case"intersection":{let c=n(s.left),l=n(s.right);return c===s.left&&l===s.right?a:q(a,{...s,left:c,right:l})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let c=n(s.innerType);return c===s.innerType?a:q(a,{...s,innerType:c})}case"pipe":{let c=n(s.in),l=n(s.out);return c===s.in&&l===s.out?a:q(a,{...s,in:c,out:l})}case"function":{let c=n(s.input),l=n(s.output);return c===s.input&&l===s.output?a:q(a,{...s,input:c,output:l})}case"lazy":{let c=s.getter,{_cachedInner:l,...d}=s;return q(a,{...d,getter:()=>n(c())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return a;default:return a}}return n(e)}function Pv(e){return Ur(e,{object:t=>t.partial(),union:t=>{let r=t._zod.def;return r.discriminator===void 0?t:kn(r.options)}})}function oE(e,t){if(!t?.length)return e;let r=e._zod.def;return q(e,Le(r,{checks:[...r.checks??[],...t]}),{parent:!0})}function Rv(e){return oE(e.out,e.checks)}function aE(e){return e.in._zod.traits.has("$ZodTransform")?Rv(e):e.in}function Cv(e){return Ur(e,{pipe:t=>aE(t._zod.def),default:(t,r)=>r?Nt(t._zod.def.innerType):t,catch:(t,r)=>r?t._zod.def.innerType:t})}function Ov(e){return Ur(e,{pipe:t=>Rv(t._zod.def),prefault:(t,r)=>r?t._zod.def.innerType:t})}var hp={};He(hp,{bigint:()=>lE,boolean:()=>cE,date:()=>dE,number:()=>uE,string:()=>sE});function sE(e){return Lc(xn,e)}function uE(e){return Vc($n,e)}function cE(e){return Yc(In,e)}function lE(e){return Qc(En,e)}function dE(e){return ll(kr,e)}var Lt={ALWAYS:"always",USER:"user",BUSINESS:"business"},vp={OAUTH:"oauth",API_KEY:"api-key",INTERNAL:"internal"},Nv={github:{displayName:"GitHub",description:"Repository access, pull requests, and authentication",toggleable:!1,credentialScopes:[Lt.ALWAYS],personalSettingsSection:null,lifecycleSupport:"instrumented"},slack:{displayName:"Slack",description:"Business workspace bot install for admin-managed Slack integrations",toggleable:!0,credentialScopes:[Lt.USER],personalSettingsSection:null,lifecycleSupport:"instrumented"},openai:{displayName:"OpenAI",description:"Model access via OpenAI API keys",toggleable:!0,credentialScopes:[Lt.BUSINESS,Lt.USER],personalSettingsSection:vp.API_KEY,lifecycleSupport:"instrumented",customerFacing:!1},codex_subscription:{displayName:"Codex subscription",description:"Internal Codex subscription auth",toggleable:!0,credentialScopes:[Lt.USER],personalSettingsSection:vp.INTERNAL,lifecycleSupport:"instrumented",customerFacing:!1},anthropic:{displayName:"Anthropic",description:"Historical Anthropic credentials for platform structured output",toggleable:!0,credentialScopes:[Lt.BUSINESS,Lt.USER],personalSettingsSection:vp.API_KEY,lifecycleSupport:"instrumented",customerFacing:!1}};var Dv={VALIDATED:"validated",SAVED_UNVERIFIED:"saved_unverified",INVALID:"invalid"},zv={NONE:"none",CREDENTIALS_MISSING:"credentials_missing",CREDENTIALS_PRESENT:"credentials_present",CREDENTIALS_INVALID:"credentials_invalid",INTEGRATION_DISABLED:"integration_disabled",BUSINESS_MANAGED:"business_managed",NETWORK_VALIDATION_SKIPPED:"network_validation_skipped",GITHUB_LOGGED_IN:"github_logged_in",GITHUB_NOT_LOGGED_IN:"github_not_logged_in",GITHUB_BUSINESS_AUTHORIZED:"github_business_authorized",GITHUB_BUSINESS_NOT_AUTHORIZED:"github_business_not_authorized",GITHUB_APP_INSTALLED:"github_app_installed",GITHUB_APP_NOT_INSTALLED:"github_app_not_installed",GITHUB_APP_INSTALL_PENDING_WEBHOOK_SYNC:"github_app_install_pending_webhook_sync",GITHUB_APP_SUSPENDED:"github_app_suspended",GITHUB_REPO_NOT_SELECTED:"github_repo_not_selected",GITHUB_REPO_ACCESS_VERIFIED:"github_repo_access_verified",GITHUB_REPO_ACCESS_DENIED:"github_repo_access_denied",GITHUB_REPO_ACCESS_CHECK_FAILED:"github_repo_access_check_failed",OAUTH_CONNECTED:"oauth_connected",OAUTH_NOT_CONNECTED:"oauth_not_connected",OAUTH_TOKEN_EXPIRED:"oauth_token_expired",OAUTH_NO_REFRESH_TOKEN:"oauth_no_refresh_token",DB_LOOKUP_FAILED:"db_lookup_failed"};var dD={github_login:{title:Nv.github.displayName,owner:"user",required:!0},github_business_authorized:{title:"GitHub Business Access",owner:"admin",required:!0},github_app_installed:{title:"GitHub App",owner:"user",required:!0},github_repo_access:{title:"Repository Access",owner:"user",required:!0}};var pE=Object.values(Dv),mE=Object.values(zv),_p=p.object({isSet:p.boolean(),lastValidatedAt:p.number().nullable().default(null),lastValidationStatus:p.enum(pE).nullable().default(null),lastValidationReasonCode:p.enum(mE).nullable().default(null)}),Uv=p.object({eligible:p.boolean(),credential:_p});import{spawn as fE}from"node:child_process";import{rmSync as gE}from"node:fs";import{mkdtemp as hE,rm as vE}from"node:fs/promises";import{tmpdir as _E}from"node:os";import{join as yE}from"node:path";function Lv(e){return new Promise((t,r)=>{let o=fE(e.binPath,e.args,{stdio:"inherit",env:{...process.env,...e.env}});o.on("error",n=>{if(n.code==="ENOENT"){r(new y("user",`Could not find the \`${e.binPath}\` executable.`,{hint:e.missingBinaryHint}));return}r(new y("user",`Failed to launch \`${e.binPath} ${e.args.join(" ")}\`: ${n.message}`))}),o.on("close",n=>{if(n===0){t();return}r(new y("user",`\`${e.binPath} ${e.args.join(" ")}\` exited with code ${n??"unknown"}.`,{hint:`Complete the ${e.displayName} login, then re-run \`${e.retryCommand}\`.`}))})})}async function jv(e,t){let r,o=()=>{if(r)try{gE(r,{recursive:!0,force:!0})}catch{}process.exit(ke)};process.on("SIGINT",o);try{return r=await hE(yE(_E(),e)),await t(r)}finally{try{r&&await vE(r,{recursive:!0,force:!0}).catch(()=>{})}finally{process.off("SIGINT",o)}}}var wE=A("/api/settings/codex-subscription"),xE=A("/api/settings/codex-subscription/auth-json"),$E=A("/api/settings/codex-subscription/enabled");function Mv(e){return e.isSet?e.lastValidationStatus==="invalid"?"Expired. Run `arcanist codex login` to reconnect. `arcanist codex use off` falls back to your OpenAI key.":e.lastValidationStatus==="validated"?"Verified with OpenAI.":"Saved, but not verified with OpenAI yet.":null}function Zv(e,t){let r=e.safeParse(t);if(!r.success)throw new y("server","The Arcanist API returned an invalid Codex subscription response.");return r.data}function IE(e){return e?.trim()||process.env.ARCANIST_CODEX_BIN?.trim()||"codex"}function EE(e,t){return Lv({displayName:"Codex",binPath:e,args:["login","--device-auth"],env:{CODEX_HOME:t},missingBinaryHint:"Install the Codex CLI, or point at it with --codex-path <path> or ARCANIST_CODEX_BIN.",retryCommand:"arcanist codex login"})}async function Fv(e,t){return P(e,$E,{method:"PUT",body:JSON.stringify({enabled:t})})}async function Bv(e,t){let{config:r}=Q(t,e),o=IE(e.codexPath),n=await jv("arcanist-codex-",async u=>{await EE(o,u);let c;try{c=await bE(SE(u,"auth.json"),"utf8")}catch{throw new y("user","Codex login completed but no auth.json was written.",{hint:"Verify `codex login --device-auth` succeeds on its own, then re-run `arcanist codex login`."})}if(!c.trim())throw new y("user","Codex login produced an empty auth.json.");return c}),i=Zv(_p,await P(r,xE,{method:"PUT",body:JSON.stringify({authJson:n})})),a=!1,s;try{await Fv(r,!0),a=!0}catch(u){s=u instanceof Error?u.message:String(u)}C(t,e,{...i,useCodexSubscription:a},u=>{console.log(a?"Codex subscription auth saved and activated for OpenAI sessions.":"Codex subscription auth saved.");let c=Mv(u);c&&console.log(`Status: ${c}`),a||(console.log(`Could not activate it automatically${s?` (${s})`:""}.`),console.log("Run `arcanist codex use on` to start using it."))})}async function Vv(e,t,r){let o=e.trim().toLowerCase();if(o!=="on"&&o!=="off")throw new y("user","Usage: arcanist codex use <on|off>");let n=o==="on",{config:i}=Q(r,t),a=await Fv(i,n);C(r,t,a,()=>console.log(a.useCodexSubscription?"Codex subscription auth is now used for OpenAI sessions.":"Codex subscription auth is no longer used for OpenAI sessions."))}async function Gv(e,t){let{config:r}=Q(t,e),o=Zv(Uv,await P(r,wE));C(t,e,o,n=>{console.log(`Eligible: ${n.eligible?"yes":"no"}`),console.log(`Auth.json saved: ${n.credential.isSet?"yes":"no"}`);let i=Mv(n.credential);i&&console.log(`Status: ${i}`)})}function qv(e){if(!e)return"no switch";let t=e.phase==="pausing"?` target_seq=${e.target_seq??"none"} drained_seq=${e.drained_seq??"none"}`:"";return`${e.phase}(${e.source}\u2192${e.target}) generation ${e.generation}${t}`}function kE(e){let t=Number(e);if(!Number.isSafeInteger(t)||t<0)throw new y("user",`Not a change-log seq: ${e}`);return t}var la=class{static register(t){let r=t.command("engine-switch").description("Read or move the serving database engine (Arcanist operators only)");r.command("status").description("Show which engine serves and whether a pause is in progress").action(async(n,i)=>{let a=J(V(i,n)),s=await P(a,A("/api/internal/engine-switch"));C(i,n,s,()=>process.stdout.write(`${s.engine}: ${qv(s.switch)}
71
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let s=a[1];if(t===a[0]){i(a);continue}if(e.external){let c=e.external.registry.get(a[0])?.id;if(t!==a[0]&&c){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(s.cycle){i(a);continue}s.count>1&&e.reused==="ref"&&i(a)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Gg(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let o of t){if(!o||typeof o!="object")return;Gg(o);let n=Object.keys(o);if(n.length!==1||n[0]!=="type")return;let i=o.type;for(let a of Array.isArray(i)?i:[i]){if(typeof a!="string")return;r.includes(a)||r.push(a)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var qg=new Set(["type","properties","required","additionalProperties"]),Bg=["oneOf","anyOf"];function Vg(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function bl(e){let t=[];for(let i of e){if(typeof i!="object"||i.type!=="object")return null;for(let a in i)if(!qg.has(a))return null;t.push(i)}let r={},o=new Set;for(let i of t){for(let a in i.properties){if(Object.prototype.hasOwnProperty.call(r,a))continue;let s=[];for(let c of t){let l=c.properties?.[a]??Vg(c);l!=null&&(s.some(d=>JSON.stringify(d)===JSON.stringify(l))||s.push(l))}let u=s.length===1?s[0]:bl(s)??{allOf:s};se(r,a,u)}for(let a of i.required??[])o.add(a)}let n={type:"object",properties:r};if(o.size&&(n.required=[...o]),t.every(i=>i.additionalProperties===!1))n.additionalProperties=!1;else{let i=[];for(let a of t){let s=Vg(a);s&&!i.some(u=>JSON.stringify(u)===JSON.stringify(s))&&i.push(s)}i.length===1?n.additionalProperties=i[0]:i.length>1&&(n.additionalProperties={allOf:i})}return n}function NI(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let n of qg)if(n in e)return;let r=t.filter(n=>Bg.some(i=>Array.isArray(n[i]))),o=null;if(!r.length)o=bl(t);else{let n=r[0],i=Bg.find(u=>Array.isArray(n[u]));if(Object.keys(n).length!==1)return;let a=t.filter(u=>u!==n),s=n[i].map(u=>bl([...a,u]));if(s.some(u=>!u))return;o={[i]:s}}o&&(delete e.allOf,wr(e,o))}function lt(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=s=>{let u=e.seen.get(s);if(u.ref===null)return;let c=u.def??u.schema,l={...c},d=u.ref;if(u.ref=null,d){o(d);let m=e.seen.get(d),g=m.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(g)):wr(c,g),wr(c,l),s._zod.parent===d)for(let b in c)b==="$ref"||b==="allOf"||b in l||delete c[b];if(g.$ref&&m.def)for(let b in c)b==="$ref"||b==="allOf"||b in m.def&&JSON.stringify(c[b])===JSON.stringify(m.def[b])&&delete c[b]}let f=s._zod.parent;if(f&&f!==d){o(f);let m=e.seen.get(f);if(m?.schema.$ref&&(c.$ref=m.schema.$ref,m.def))for(let g in c)g==="$ref"||g==="allOf"||g in m.def&&JSON.stringify(c[g])===JSON.stringify(m.def[g])&&delete c[g]}e.override({zodSchema:s,jsonSchema:c,path:u.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let s of[...e.seen.entries()].reverse())o(s[0]);if(e.target!=="openapi-3.0")for(let s of e.seen.entries())Gg(s[1].def??s[1].schema);for(let s of e.deferred)s();if(e.intersections.length){let s=new Map;for(let u of e.seen.values())for(let c of[u.schema,u.def]){let l=c?.allOf;if(!Array.isArray(l))continue;let d=s.get(l);d?d.push(c):s.set(l,[c])}for(let u of e.intersections)for(let c of s.get(u)??[])NI(c)}}let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(s)}wr(n,r.defId?r.schema:r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;i!==void 0&&n.id===i&&delete n.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let s of e.seen.entries()){let u=s[1];u.def&&u.defId&&(u.def.id===u.defId&&delete u.def.id,se(a,u.defId,u.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?n.$defs=a:n.definitions=a);try{let s=JSON.parse(JSON.stringify(n));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:_n(t,"input",e.processors),output:_n(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function _e(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return _e(o.element,r);if(o.type==="set")return _e(o.valueType,r);if(o.type==="lazy")return _e(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault"||o.type==="catch")return _e(o.innerType,r);if(o.type==="intersection")return _e(o.left,r)||_e(o.right,r);if(o.type==="record"||o.type==="map")return _e(o.keyType,r)||_e(o.valueType,r);if(o.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:_e(o.in,r)||_e(o.out,r);if(o.type==="object"){for(let n in o.shape)if(_e(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if(_e(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if(_e(n,r))return!0;return!!(o.rest&&_e(o.rest,r))}return!1}var Sl=(e,t={})=>r=>{let o=ut({...r,processors:t});return H(e,o),ct(o,e),lt(o,e)},_n=(e,t,r={})=>o=>{let{libraryOptions:n,target:i}=o??{},a=ut({...n??{},target:i,io:t,processors:r});return H(e,a),ct(a,e),lt(a,e)};var yn=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},bn=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},Wg=(e,t)=>{yn(e,"minimum",t),bn(e,"maximum",t)},Yg=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Xg=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Qg=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},eh=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Hg=(e,t)=>yn(e,"minimum",t.minimum),Kg=(e,t)=>bn(e,"maximum",t.maximum),Jg=e=>(t,r)=>{eh(t,r.format);let[o,n]=e[r.format];yn(t,"minimum",o),bn(t,"maximum",n)},DI={greater_than:(e,t)=>yn(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>bn(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Yg(e,t.value),number_format:Jg(Bn),bigint_format:Jg(Vn),min_length:Hg,max_length:Kg,length_equals:(e,t)=>Wg(e,t.length),min_size:Hg,max_size:Kg,size_equals:(e,t)=>Wg(e,t.size),string_format:(e,t)=>{eh(e,t.format),t.pattern&&Xg(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Qg(e,t.mime)};function oe(e){let t={},r=e._zod.def,o=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let i of o)DI[i._zod.def.check]?.(t,i._zod.def);let n=e._zod.bag;n.minimum!==void 0&&yn(t,"minimum",n.minimum),n.exclusiveMinimum!==void 0&&yn(t,"exclusiveMinimum",n.exclusiveMinimum),n.maximum!==void 0&&bn(t,"maximum",n.maximum),n.exclusiveMaximum!==void 0&&bn(t,"exclusiveMaximum",n.exclusiveMaximum),n.multipleOf!==void 0&&Yg(t,n.multipleOf),n.format!==void 0&&(t.format??(t.format=n.format),n.format.includes("int")&&(t.isInt=!0)),n.mime&&Qg(t,n.mime);for(let i of n.patterns??[])Xg(t,i);return t}var zI={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},UI=new Map([[Ni,ks],[sr,Ts]]),th=e=>UI.get(e)??e,$l=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:i,maximum:a,format:s,patterns:u,contentEncoding:c,laxFormat:l}=oe(e);if(typeof i=="number"&&(n.minLength=i),typeof a=="number"&&(n.maxLength=a),s&&(n.format=zI[s]??s,n.format===""&&delete n.format,(s==="time"||l)&&delete n.format),c&&(n.contentEncoding=c),u&&u.size>0){let d=[...u].map(th);d.length===1?n.pattern=d[0].source:d.length>1&&(n.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Il=(e,t,r,o)=>{let n=r,{minimum:i,maximum:a,multipleOf:s,exclusiveMaximum:u,exclusiveMinimum:c,isInt:l}=oe(e);n.type=l?"integer":"number";let d=typeof c=="number"&&c>=(i??Number.NEGATIVE_INFINITY),f=typeof u=="number"&&u<=(a??Number.POSITIVE_INFINITY),m=t.target==="draft-04"||t.target==="openapi-3.0";if(d?m?(n.minimum=c,n.exclusiveMinimum=!0):n.exclusiveMinimum=c:typeof i=="number"&&(n.minimum=i),f?m?(n.maximum=u,n.exclusiveMaximum=!0):n.exclusiveMaximum=u:typeof a=="number"&&(n.maximum=a),s){let g=new Set;for(let $ of s)Number.isFinite($)&&$!==0?g.add(Math.abs($)):ie(e,t,n,o,`A multipleOf divisor of ${$} cannot be represented in JSON Schema`);let[h,...b]=g;h!==void 0&&(n.multipleOf=h),b.length&&(n.allOf=[...n.allOf??[],...b.map($=>({multipleOf:$}))])}},El=(e,t,r,o)=>{r.type="boolean"},kl=(e,t,r,o)=>{ie(e,t,r,o,"BigInt cannot be represented in JSON Schema")},Tl=(e,t,r,o)=>{ie(e,t,r,o,"Symbols cannot be represented in JSON Schema")},Al=(e,t,r,o)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},Pl=(e,t,r,o)=>{ie(e,t,r,o,"Undefined cannot be represented in JSON Schema")},Rl=(e,t,r,o)=>{ie(e,t,r,o,"Void cannot be represented in JSON Schema")},Cl=(e,t,r,o)=>{r.not={}},Ol=(e,t,r,o)=>{},Nl=(e,t,r,o)=>{},Dl=(e,t,r,o)=>{ie(e,t,r,o,"Date cannot be represented in JSON Schema")},zl=(e,t,r,o)=>{let n=e._zod.def,i=Bt(n.entries);if(i.length===0){r.not={};return}i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),r.enum=i},Ul=(e,t,r,o)=>{let n=e._zod.def;if(n.values.length===0){r.not={};return}let i=[];for(let a of n.values)if(a===void 0){if(ie(e,t,r,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(ie(e,t,r,o,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){let a=i[0];r.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[a]:r.const=a}else i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),i.every(a=>typeof a=="boolean")&&(r.type="boolean"),i.every(a=>a===null)&&(r.type="null"),r.enum=i},Ll=(e,t,r,o)=>{ie(e,t,r,o,"NaN cannot be represented in JSON Schema")},jl=(e,t,r,o)=>{let n=r,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},Ml=(e,t,r,o)=>{let n=r;n.type="string",n.format="binary",n.contentEncoding="binary";let{minimum:i,maximum:a,mime:s}=oe(e);i!==void 0&&(n.minLength=i),a!==void 0&&(n.maxLength=a),s&&(s.length===0?n.not={}:s.length===1?n.contentMediaType=s[0]:n.anyOf=s.map(u=>({contentMediaType:u})))},Zl=(e,t,r,o)=>{r.type="boolean"},Fl=(e,t,r,o)=>{ie(e,t,r,o,"Custom types cannot be represented in JSON Schema")},Bl=(e,t,r,o)=>{ie(e,t,r,o,"Function types cannot be represented in JSON Schema")},Vl=(e,t,r,o)=>{ie(e,t,r,o,"Transforms cannot be represented in JSON Schema")},Gl=(e,t,r,o)=>{ie(e,t,r,o,"Map cannot be represented in JSON Schema")},ql=(e,t,r,o)=>{ie(e,t,r,o,"Set cannot be represented in JSON Schema")},Wl=(e,t,r,o)=>{let n=r,i=e._zod.def,{minimum:a,maximum:s}=oe(e);typeof a=="number"&&(n.minItems=a),typeof s=="number"&&(n.maxItems=s),n.type="array",n.items=H(i.element,t,{...o,path:[...o.path,"items"]})};function xr(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?xr(t.out):t.type==="catch"?xr(t.innerType):e._zod.optin}var Hl=(e,t,r,o)=>{let n=r,i=e._zod.def,a=i.shape;if(Object.getOwnPropertySymbols(a).length&&ie(e,t,n,o,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(let c in a)se(n.properties,c,H(a[c],t,{...o,path:[...o.path,"properties",c]}));let u=[];for(let c of Object.keys(a)){let l=i.shape[c];(t.io==="input"?xr(l)===void 0:l._zod.optout===void 0)&&u.push(c)}u.length>0&&(n.required=u),i.catchall?._zod.def.type==="never"?n.additionalProperties=!1:i.catchall?i.catchall&&(n.additionalProperties=H(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},Co=(e,t,r,o)=>{let n=e._zod.def,i=n.inclusive===!1,a=n.options.map((s,u)=>H(s,t,{...o,path:[...o.path,i?"oneOf":"anyOf",u]}));i?r.oneOf=a:r.anyOf=a},Kl=(e,t,r,o)=>{let n=e._zod.def,i=H(n.left,t,{...o,path:[...o.path,"allOf",0]}),a=H(n.right,t,{...o,path:[...o.path,"allOf",1]}),s=c=>"allOf"in c&&Object.keys(c).length===1,u=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]];r.allOf=u,t.intersections.push(u)},Jl=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",u=i.items.map((h,b)=>H(h,t,{...o,path:[...o.path,a,b]})),c=i.rest?H(i.rest,t,{...o,path:[...o.path,s,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null,l=i.items.length;for(;l>0;){let h=i.items[l-1];if(!(t.io==="input"?xr(h)!==void 0:h._zod.optout==="optional"))break;l--}let d=i.items.length,f=!i.rest;t.target==="draft-2020-12"?(n.prefixItems=u,f?n.items=!1:c&&(n.items=c),l>0&&(n.minItems=l),f&&(n.maxItems=d)):t.target==="openapi-3.0"?(n.items={anyOf:u},c&&n.items.anyOf.push(c),l>0&&(n.minItems=l),f&&(n.maxItems=d)):(n.items=u,f?n.additionalItems=!1:c&&(n.additionalItems=c),l>0&&(n.minItems=l),f&&(n.maxItems=d));let{minimum:m,maximum:g}=oe(e);typeof m=="number"&&(n.minItems=m),typeof g=="number"&&(n.maxItems=g)};function wl(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let g=e.get(t)?.def;if(!g)return t;let h=wl(e,g,r);return h===g?t:h}for(let g of["anyOf","oneOf"]){let h=t[g];if(!Array.isArray(h))continue;let b=h.map($=>wl(e,$,r));b.some(($,I)=>$!==h[I])&&(t={...t,[g]:b})}let o=Array.isArray(t.type)?t.type:[t.type],n=!o.includes("string")&&o.some(g=>g==="number"||g==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!n&&!i?.some(g=>typeof g=="number"))return t;let{minimum:a,maximum:s,exclusiveMinimum:u,exclusiveMaximum:c,multipleOf:l,format:d,id:f,...m}=t;return m.enum?m.enum=m.enum.map(g=>typeof g=="number"?String(g):g):typeof m.const=="number"&&(m.const=String(m.const)),n&&(m.type="string",i||(m.pattern=(o.includes("number")?Ye:er).source)),m}var xl=new WeakMap;function LI(e){let t=new Map;for(let o of e.seen.values())o.def&&!t.has(o.schema)&&t.set(o.schema,o);let r=new Map;for(let o of xl.get(e)??[]){let n=e.seen.get(o),i=(n?.def??n?.schema)?.propertyNames;if(!i||i===!0||r.has(i))continue;let a=wl(t,i,new Set);a!==i&&r.set(i,a)}if(r.size)for(let o of e.seen.values())for(let n of[o.schema,o.def]){let i=n&&r.get(n.propertyNames);i&&(n.propertyNames=i)}}var Yl=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object";let a=i.keyType,s=oe(a).patterns;if(i.mode==="loose"&&s&&s.size>0){let l=H(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});n.patternProperties={};for(let d of s)se(n.patternProperties,th(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){n.propertyNames=H(i.keyType,t,{...o,path:[...o.path,"propertyNames"]});let l=xl.get(t);l||(l=[],xl.set(t,l),t.deferred.push(()=>LI(t))),l.push(e)}n.additionalProperties=H(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let u=a._zod.values,c=t.io==="input"&&xr(i.valueType)!==void 0;if(u&&!i.partial&&!c){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(n.required=l.map(String))}},Xl=(e,t,r,o)=>{let n=e._zod.def,i=H(n.innerType,t,o),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=n.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},Ql=(e,t,r,o)=>{let n=e._zod.def;H(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},ed=Symbol();function nh(e,t,r,o,n){let i=!1,a=JSON.stringify(e,(s,u)=>typeof u!="bigint"?u:(i=!0,null));return i?(ie(t,r,o,n,"BigInt defaults cannot be represented in JSON Schema"),ed):JSON.parse(a)}var td=(e,t,r,o)=>{let n=e._zod.def;H(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let a=nh(n.defaultValue,e,t,r,o);a!==ed&&(r.default=a)},nd=(e,t,r,o)=>{let n=e._zod.def;H(n.innerType,t,o);let i=t.seen.get(e);if(i.ref=n.innerType,t.io!=="input")return;let a=nh(n.defaultValue,e,t,r,o);a!==ed&&(r._prefault=a)},rd=(e,t,r,o)=>{let n=e._zod.def;H(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let a;try{a=n.catchValue(void 0)}catch{ie(e,t,r,o,"Dynamic catch values are not supported in JSON Schema");return}r.default=a},id=(e,t,r,o)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?i?n.out:n.in:n.out;H(a,t,o);let s=t.seen.get(e);s.ref=a},od=(e,t,r,o)=>{let n=e._zod.def;H(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0},ad=(e,t,r,o)=>{let n=e._zod.def;H(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},Oo=(e,t,r,o)=>{let n=e._zod.def;H(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},sd=(e,t,r,o)=>{let n=e._zod.innerType;H(n,t,o);let i=t.seen.get(e);i.ref=n},Ro={string:$l,number:Il,boolean:El,bigint:kl,symbol:Tl,null:Al,undefined:Pl,void:Rl,never:Cl,any:Ol,unknown:Nl,date:Dl,enum:zl,literal:Ul,nan:Ll,template_literal:jl,file:Ml,success:Zl,custom:Fl,function:Bl,transform:Vl,map:Gl,set:ql,array:Wl,object:Hl,union:Co,intersection:Kl,tuple:Jl,record:Yl,nullable:Xl,nonoptional:Ql,default:td,prefault:nd,catch:rd,pipe:id,readonly:od,promise:ad,optional:Oo,lazy:sd};function No(e,t){if("_idmap"in e){let o=e,n=ut({...t,processors:Ro}),i={};for(let u of o._idmap.entries()){let[c,l]=u;H(l,n)}let a={},s={registry:o,uri:t?.uri,defs:i};n.external=s;for(let u of o._idmap.entries()){let[c,l]=u;ct(n,l),se(a,c,lt(n,l))}if(Object.keys(i).length>0){let u=n.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[u]:i}}return{schemas:a}}let r=ut({...t,processors:Ro});return H(e,r),ct(r,e),lt(r,e)}var Do=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=ut({processors:Ro,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return H(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,ct(this.ctx,t);let o=lt(this.ctx,t),{"~standard":n,...i}=o;return i}};var rh={};var Tn={};He(Tn,{ZodAny:()=>Ad,ZodArray:()=>Od,ZodBase64:()=>ea,ZodBase64URL:()=>ta,ZodBigInt:()=>En,ZodBigIntFormat:()=>ia,ZodBoolean:()=>In,ZodCIDRv4:()=>Xo,ZodCIDRv6:()=>Qo,ZodCUID:()=>Go,ZodCUID2:()=>qo,ZodCatch:()=>ep,ZodCodec:()=>Or,ZodCreditCard:()=>Sd,ZodCustom:()=>Nr,ZodCustomStringFormat:()=>zt,ZodDate:()=>kr,ZodDefault:()=>Hd,ZodDiscriminatedUnion:()=>Dd,ZodE164:()=>na,ZodEmail:()=>Zo,ZodEmoji:()=>Bo,ZodEnum:()=>wn,ZodExactOptional:()=>ua,ZodFile:()=>Vd,ZodFunction:()=>lp,ZodGUID:()=>Fo,ZodIBAN:()=>wd,ZodIPv4:()=>Jo,ZodIPv6:()=>Yo,ZodISODate:()=>pt,ZodISODateTime:()=>dt,ZodISODuration:()=>ft,ZodISOTime:()=>mt,ZodInstanceOf:()=>mp,ZodIntersection:()=>zd,ZodJWT:()=>ra,ZodKSUID:()=>Ko,ZodLazy:()=>sp,ZodLiteral:()=>Bd,ZodMAC:()=>bd,ZodMap:()=>Zd,ZodNaN:()=>np,ZodNanoID:()=>Vo,ZodNever:()=>Rd,ZodNonOptional:()=>ca,ZodNull:()=>kd,ZodNullable:()=>Wd,ZodNumber:()=>$n,ZodNumberFormat:()=>Ut,ZodObject:()=>Ar,ZodOptional:()=>Rr,ZodPipe:()=>Cr,ZodPrefault:()=>Jd,ZodPreprocess:()=>rp,ZodPromise:()=>cp,ZodReadonly:()=>ip,ZodRecord:()=>Sn,ZodSet:()=>Fd,ZodString:()=>xn,ZodStringFormat:()=>K,ZodSuccess:()=>Qd,ZodSymbol:()=>Id,ZodTemplateLiteral:()=>ap,ZodTransform:()=>Gd,ZodTuple:()=>Ld,ZodType:()=>M,ZodULID:()=>Wo,ZodURL:()=>Er,ZodUUID:()=>qe,ZodUndefined:()=>Ed,ZodUnion:()=>Pr,ZodUnknown:()=>Pd,ZodVoid:()=>Cd,ZodXID:()=>Ho,ZodXor:()=>Nd,_ZodString:()=>Mo,_default:()=>Kd,_function:()=>gv,any:()=>qh,array:()=>Tr,base64:()=>Eh,base64url:()=>kh,bigint:()=>Zh,boolean:()=>$d,catch:()=>tp,check:()=>hv,cidrv4:()=>$h,cidrv6:()=>Ih,codec:()=>dv,creditCard:()=>Ah,cuid:()=>hh,cuid2:()=>vh,currencyCode:()=>Dh,custom:()=>vv,date:()=>Hh,describe:()=>_v,discriminatedUnion:()=>ev,e164:()=>Th,email:()=>ah,emoji:()=>fh,enum:()=>aa,exactOptional:()=>qd,file:()=>sv,float32:()=>Uh,float64:()=>Lh,function:()=>gv,guid:()=>sh,hash:()=>zh,hex:()=>Nh,hostname:()=>Oh,httpUrl:()=>mh,iban:()=>Ph,instanceof:()=>bv,int:()=>Lo,int32:()=>jh,int64:()=>Fh,intersection:()=>Ud,invertCodec:()=>pv,ipv4:()=>Sh,ipv6:()=>xh,json:()=>wv,jwt:()=>Rh,keyof:()=>Kh,ksuid:()=>bh,lazy:()=>up,literal:()=>av,looseObject:()=>Xh,looseRecord:()=>nv,mac:()=>wh,map:()=>rv,meta:()=>yv,nan:()=>lv,nanoid:()=>gh,nativeEnum:()=>ov,never:()=>oa,nonoptional:()=>Xd,null:()=>Td,nullable:()=>Ir,nullish:()=>uv,number:()=>xd,object:()=>Jh,optional:()=>Nt,partialRecord:()=>tv,pipe:()=>jo,prefault:()=>Yd,preprocess:()=>xv,promise:()=>fv,readonly:()=>op,record:()=>Md,refine:()=>dp,set:()=>iv,strictObject:()=>Yh,string:()=>$r,stringFormat:()=>Ch,stringbool:()=>Sv,success:()=>cv,superRefine:()=>pp,symbol:()=>Vh,templateLiteral:()=>mv,transform:()=>sa,tuple:()=>jd,uint32:()=>Mh,uint64:()=>Bh,ulid:()=>_h,undefined:()=>Gh,union:()=>kn,unknown:()=>Ot,url:()=>ph,uuid:()=>uh,uuidv4:()=>ch,uuidv6:()=>lh,uuidv7:()=>dh,void:()=>Wh,xid:()=>yh,xor:()=>Qh});var zo={};He(zo,{endsWith:()=>ln,gt:()=>Ve,gte:()=>Pe,includes:()=>un,length:()=>Rt,lowercase:()=>an,lt:()=>Be,lte:()=>Ae,maxLength:()=>Pt,maxSize:()=>st,mime:()=>pn,minLength:()=>Xe,minSize:()=>Ge,multipleOf:()=>at,negative:()=>ko,nonnegative:()=>Ao,nonpositive:()=>To,normalize:()=>mn,overwrite:()=>Me,positive:()=>Eo,properties:()=>dn,property:()=>Po,regex:()=>on,size:()=>At,slugify:()=>vn,startsWith:()=>cn,toLowerCase:()=>gn,toUpperCase:()=>hn,trim:()=>fn,uppercase:()=>sn});var ih=new WeakSet([Object.prototype,Error.prototype]);function Uo(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let o=r(this);return Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0})}})}var oh=(e,t)=>{ss.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);ih.has(r)||(ih.add(r),Uo(r,"format",o=>n=>Jn(o,n)),Uo(r,"flatten",o=>n=>Kn(o,n)),Uo(r,"addIssue",o=>n=>{o.issues.push(n),o.message=JSON.stringify(o.issues,Vt,2)}),Uo(r,"addIssues",o=>n=>{o.issues.push(...n),o.message=JSON.stringify(o.issues,Vt,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},MI=v("ZodError",oh),Ie=v("ZodError",oh,void 0,{Parent:Error});var ud=Kt(Ie),cd=Jt(Ie),ld=Yt(Ie),dd=Xt(Ie),pd=di(Ie),md=pi(Ie),fd=mi(Ie),gd=fi(Ie),hd=gi(Ie),vd=hi(Ie),_d=vi(Ie),yd=_i(Ie);function FI(){ae.localeError||ne(Ji())}function Dt(){ae.memoizer||ne({memoizer:fr()})}var M=v("ZodType",(e,t)=>(FI(),z.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(S.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return q(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(dp(e,t))},superRefine(e,t){return this.check(pp(e,t))},overwrite(e){return this.check(Me(e))},optional(){return Nt(this)},exactOptional(){return qd(this)},nullable(){return Ir(this)},nullish(){return Nt(Ir(this))},nonoptional(e){return Xd(this,e)},array(){return Tr(this)},or(e){return kn([this,e])},and(e){return Ud(this,e)},transform(e){return jo(this,sa(e))},default(e){return Kd(this,e)},prefault(e){return Yd(this,e)},catch(e){return tp(this,e)},pipe(e){return jo(this,e)},readonly(){return op(this)},describe(e){let t=this.clone();return ue.add(t,{description:e}),t},meta(...e){if(e.length===0)return ue.get(this);let t=this.clone();return ue.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return S.hide(this,"~standard",{...Ai(this),jsonSchema:{input:_n(this,"input"),output:_n(this,"output")}})},set"~standard"(e){S.own(this,"~standard",e)},parse:function e(t,r){return ud(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await cd(this,t,r,{callee:e})},safeParse(e,t){return ld(this,e,t)},async safeParseAsync(e,t){return dd(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){S.own(this,"spa",e)},validate(e,t){return Yn(this,e,t)},validateAsync(e,t){return Xn(this,e,t)},encode:function e(t,r){return pd(this,t,r,{callee:e})},decode:function e(t,r){return md(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await fd(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await gd(this,t,r,{callee:e})},safeEncode(e,t){return hd(this,e,t)},safeDecode(e,t){return vd(this,e,t)},async safeEncodeAsync(e,t){return _d(this,e,t)},async safeDecodeAsync(e,t){return yd(this,e,t)},toJSONSchema(e){return Sl(this,{})(e)},get description(){return ue.get(this)?.description},get _def(){return this._zod.def}}),Mo=v("_ZodString",(e,t)=>{It.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>$l(e,r,o,n)},S.derived({format:e=>oe(e).format??null,minLength:e=>oe(e).minimum??null,maxLength:e=>oe(e).maximum??null},{regex(...e){return this.check(on(...e))},includes(...e){return this.check(un(...e))},startsWith(...e){return this.check(cn(...e))},endsWith(...e){return this.check(ln(...e))},min(...e){return this.check(Xe(...e))},max(...e){return this.check(Pt(...e))},length(...e){return this.check(Rt(...e))},nonempty(...e){return this.check(Xe(1,...e))},lowercase(e){return this.check(an(e))},uppercase(e){return this.check(sn(e))},trim(){return this.check(fn())},normalize(...e){return this.check(mn(...e))},toLowerCase(){return this.check(gn())},toUpperCase(){return this.check(hn())},slugify(){return this.check(vn())}})),xn=v("ZodString",(e,t)=>{It.init(e,t),Mo.init(e,t)},{email(e){return this.check(io(Zo,e))},url(e){return this.check(vr(Er,e))},jwt(e){return this.check(Io(ra,e))},emoji(e){return this.check(lo(Bo,e))},guid(e){return this.check(oo(Fo,e))},uuid(e){return this.check(ao(qe,e))},uuidv4(e){return this.check(so(qe,e))},uuidv6(e){return this.check(uo(qe,e))},uuidv7(e){return this.check(co(qe,e))},nanoid(e){return this.check(po(Vo,e))},cuid(e){return this.check(mo(Go,e))},cuid2(e){return this.check(fo(qo,e))},ulid(e){return this.check(go(Wo,e))},base64(e){return this.check(wo(ea,e))},base64url(e){return this.check(xo(ta,e))},xid(e){return this.check(ho(Ho,e))},ksuid(e){return this.check(vo(Ko,e))},ipv4(e){return this.check(_o(Jo,e))},ipv6(e){return this.check(yo(Yo,e))},cidrv4(e){return this.check(bo(Xo,e))},cidrv6(e){return this.check(So(Qo,e))},e164(e){return this.check($o(na,e))},datetime(e){return this.check(_r(dt,e))},date(e){return this.check(yr(pt,e))},time(e){return this.check(br(mt,e))},duration(e){return this.check(Sr(ft,e))}});function $r(e){return Uc(xn,e)}var K=v("ZodStringFormat",(e,t)=>{W.init(e,t),Mo.init(e,t)}),dt=v("ZodISODateTime",(e,t)=>{ku.init(e,t),K.init(e,t)}),pt=v("ZodISODate",(e,t)=>{Tu.init(e,t),K.init(e,t)}),mt=v("ZodISOTime",(e,t)=>{Au.init(e,t),K.init(e,t)}),ft=v("ZodISODuration",(e,t)=>{Pu.init(e,t),K.init(e,t)}),Zo=v("ZodEmail",(e,t)=>{hu.init(e,t),K.init(e,t)});function ah(e){return io(Zo,e)}var Fo=v("ZodGUID",(e,t)=>{fu.init(e,t),K.init(e,t)});function sh(e){return oo(Fo,e)}var qe=v("ZodUUID",(e,t)=>{gu.init(e,t),K.init(e,t)});function uh(e){return ao(qe,e)}function ch(e){return so(qe,e)}function lh(e){return uo(qe,e)}function dh(e){return co(qe,e)}var Er=v("ZodURL",(e,t)=>{yu.init(e,t),K.init(e,t)});function ph(e){return vr(Er,e)}function mh(e){return vr(Er,{protocol:Qn,hostname:Ps,...S.normalizeParams(e)})}var Bo=v("ZodEmoji",(e,t)=>{bu.init(e,t),K.init(e,t)});function fh(e){return lo(Bo,e)}var Vo=v("ZodNanoID",(e,t)=>{Su.init(e,t),K.init(e,t)});function gh(e){return po(Vo,e)}var Go=v("ZodCUID",(e,t)=>{wu.init(e,t),K.init(e,t)});function hh(e){return mo(Go,e)}var qo=v("ZodCUID2",(e,t)=>{xu.init(e,t),K.init(e,t)});function vh(e){return fo(qo,e)}var Wo=v("ZodULID",(e,t)=>{$u.init(e,t),K.init(e,t)});function _h(e){return go(Wo,e)}var Ho=v("ZodXID",(e,t)=>{Iu.init(e,t),K.init(e,t)});function yh(e){return ho(Ho,e)}var Ko=v("ZodKSUID",(e,t)=>{Eu.init(e,t),K.init(e,t)});function bh(e){return vo(Ko,e)}var Jo=v("ZodIPv4",(e,t)=>{Ru.init(e,t),K.init(e,t)});function Sh(e){return _o(Jo,e)}var bd=v("ZodMAC",(e,t)=>{Ou.init(e,t),K.init(e,t)});function wh(e){return jc(bd,e)}var Yo=v("ZodIPv6",(e,t)=>{Cu.init(e,t),K.init(e,t)});function xh(e){return yo(Yo,e)}var Xo=v("ZodCIDRv4",(e,t)=>{Nu.init(e,t),K.init(e,t)});function $h(e){return bo(Xo,e)}var Qo=v("ZodCIDRv6",(e,t)=>{Du.init(e,t),K.init(e,t)});function Ih(e){return So(Qo,e)}var ea=v("ZodBase64",(e,t)=>{zu.init(e,t),K.init(e,t)});function Eh(e){return wo(ea,e)}var ta=v("ZodBase64URL",(e,t)=>{Uu.init(e,t),K.init(e,t)});function kh(e){return xo(ta,e)}var na=v("ZodE164",(e,t)=>{Lu.init(e,t),K.init(e,t)});function Th(e){return $o(na,e)}var Sd=v("ZodCreditCard",(e,t)=>{ju.init(e,t),K.init(e,t)});function Ah(e){return Mc(Sd,e)}var wd=v("ZodIBAN",(e,t)=>{Mu.init(e,t),K.init(e,t)});function Ph(e){return Zc(wd,e)}var ra=v("ZodJWT",(e,t)=>{Zu.init(e,t),K.init(e,t)});function Rh(e){return Io(ra,e)}var zt=v("ZodCustomStringFormat",(e,t)=>{Fu.init(e,t),K.init(e,t)});function Ch(e,t,r={}){return Ct(zt,e,t,r)}function Oh(e){return Ct(zt,"hostname",As,e)}function Nh(e){return Ct(zt,"hex",Vs,e)}function Dh(e){return Ct(zt,"currency_code",Cs,e)}function zh(e,t){let r=t?.enc??"hex",o=`${e}_${r}`,n=Ne[o];if(!n)throw new Error(`Unrecognized hash format: ${o}`);return Ct(zt,o,n,t)}var $n=v("ZodNumber",(e,t)=>{ji.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Il(e,r,o,n),e.isFinite=!0},S.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=oe(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=oe(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=oe(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>oe(e).format??null},{gt(e,t){return this.check(Ve(e,t))},gte(e,t){return this.check(Pe(e,t))},min(e,t){return this.check(Pe(e,t))},lt(e,t){return this.check(Be(e,t))},lte(e,t){return this.check(Ae(e,t))},max(e,t){return this.check(Ae(e,t))},int(e){return this.check(Lo(e))},safe(e){return this.check(Lo(e))},positive(e){return this.check(Ve(0,e))},nonnegative(e){return this.check(Pe(0,e))},negative(e){return this.check(Be(0,e))},nonpositive(e){return this.check(Ae(0,e))},multipleOf(e,t){return this.check(at(e,t))},step(e,t){return this.check(at(e,t))},finite(){return this}}));function xd(e){return Bc($n,e)}var Ut=v("ZodNumberFormat",(e,t)=>{Bu.init(e,t),$n.init(e,t)});function Lo(e){return Gc(Ut,e)}function Uh(e){return qc(Ut,e)}function Lh(e){return Wc(Ut,e)}function jh(e){return Hc(Ut,e)}function Mh(e){return Kc(Ut,e)}var In=v("ZodBoolean",(e,t)=>{ur.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>El(e,r,o,n)});function $d(e){return Jc(In,e)}var En=v("ZodBigInt",(e,t)=>{Mi.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>kl(e,r,o,n)},S.derived({minValue:e=>oe(e).minimum??null,maxValue:e=>oe(e).maximum??null,format:e=>oe(e).format??null},{gte(e,t){return this.check(Pe(e,t))},min(e,t){return this.check(Pe(e,t))},gt(e,t){return this.check(Ve(e,t))},lt(e,t){return this.check(Be(e,t))},lte(e,t){return this.check(Ae(e,t))},max(e,t){return this.check(Ae(e,t))},positive(e){return this.check(Ve(BigInt(0),e))},negative(e){return this.check(Be(BigInt(0),e))},nonpositive(e){return this.check(Ae(BigInt(0),e))},nonnegative(e){return this.check(Pe(BigInt(0),e))},multipleOf(e,t){return this.check(at(e,t))}}));function Zh(e){return Xc(En,e)}var ia=v("ZodBigIntFormat",(e,t)=>{Vu.init(e,t),En.init(e,t)});function Fh(e){return el(ia,e)}function Bh(e){return tl(ia,e)}var Id=v("ZodSymbol",(e,t)=>{Gu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Tl(e,r,o,n)});function Vh(e){return nl(Id,e)}var Ed=v("ZodUndefined",(e,t)=>{qu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Pl(e,r,o,n)});function Gh(e){return rl(Ed,e)}var kd=v("ZodNull",(e,t)=>{Wu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Al(e,r,o,n)});function Td(e){return il(kd,e)}var Ad=v("ZodAny",(e,t)=>{Hu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ol(e,r,o,n)});function qh(){return ol(Ad)}var Pd=v("ZodUnknown",(e,t)=>{Ku.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Nl(e,r,o,n)});function Ot(){return al(Pd)}var Rd=v("ZodNever",(e,t)=>{Ju.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Cl(e,r,o,n)});function oa(e){return sl(Rd,e)}var Cd=v("ZodVoid",(e,t)=>{Yu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Rl(e,r,o,n)});function Wh(e){return ul(Cd,e)}var kr=v("ZodDate",(e,t)=>{Xu.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Dl(e,r,o,n),e.min=(r,o)=>e.check(Pe(r,o)),e.max=(r,o)=>e.check(Ae(r,o))},S.derived({minDate:e=>{let{minimum:t}=oe(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=oe(e);return t?new Date(t):null}},{}));function Hh(e){return cl(kr,e)}var Od=v("ZodArray",(e,t)=>{Dt(),ec.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Wl(e,r,o,n),e.element=t.element},{min(e,t){return this.check(Xe(e,t))},nonempty(e){return this.check(Xe(1,e))},max(e,t){return this.check(Pt(e,t))},length(e,t){return this.check(Rt(e,t))},unwrap(){return this.element}});function Tr(e,t){return pl(Od,e,t)}function Kh(e){let t=e._zod.def.shape;return aa(Object.keys(t))}var Ar=v("ZodObject",(e,t)=>{Dt(),tc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Hl(e,r,o,n),S.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return aa(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(S.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(S.mergeDefs(this._zod.def,{catchall:Ot()}))},loose(){return this.clone(S.mergeDefs(this._zod.def,{catchall:Ot()}))},strict(){return this.clone(S.mergeDefs(this._zod.def,{catchall:oa()}))},strip(){return this.clone(S.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return S.extend(this,e)},safeExtend(e){return S.safeExtend(this,e)},merge(e){return S.merge(this,e)},pick(e){return S.pick(this,e)},omit(e){return S.omit(this,e)},partial(...e){return S.partial(Rr,this,e[0])},exactPartial(...e){return S.partial(ua,this,e[0],"exactPartial")},required(...e){return S.required(ca,this,e[0])}});function Jh(e,t){let r={type:"object",shape:e??{},...S.normalizeParams(t)};return new Ar(r)}function Yh(e,t){return new Ar({type:"object",shape:e,catchall:oa(),...S.normalizeParams(t)})}function Xh(e,t){return new Ar({type:"object",shape:e,catchall:Ot(),...S.normalizeParams(t)})}var Pr=v("ZodUnion",(e,t)=>{cr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Co(e,r,o,n),e.options=t.options});function kn(e,t){return new Pr({type:"union",options:e,...S.normalizeParams(t)})}var Nd=v("ZodXor",(e,t)=>{Pr.init(e,t),nc.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Co(e,r,o,n),e.options=t.options});function Qh(e,t){return new Nd({type:"union",options:e,inclusive:!1,...S.normalizeParams(t)})}var Dd=v("ZodDiscriminatedUnion",(e,t)=>{Pr.init(e,t),ic.init(e,t)});function ev(e,t,r){return new Dd({type:"union",options:t,discriminator:e,...S.normalizeParams(r)})}var zd=v("ZodIntersection",(e,t)=>{oc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Kl(e,r,o,n)});function Ud(e,t){return new zd({type:"intersection",left:e,right:t})}var Ld=v("ZodTuple",(e,t)=>{Dt(),Zi.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Jl(e,r,o,n)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new Rr({type:"optional",innerType:t}))})}});function jd(e,t,r){let o=t instanceof z,n=o?r:t,i=o?t:null;return new Ld({type:"tuple",items:e,rest:i,...S.normalizeParams(n)})}var Sn=v("ZodRecord",(e,t)=>{Dt(),ac.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Yl(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});function Md(e,t,r){return!t||!t._zod?new Sn({type:"record",keyType:$r(),valueType:e,...S.normalizeParams(t)}):new Sn({type:"record",keyType:e,valueType:t,...S.normalizeParams(r)})}function tv(e,t,r){return new Sn({type:"record",keyType:e,valueType:t,...S.normalizeParams(r),partial:!0})}function nv(e,t,r){return new Sn({type:"record",keyType:e,valueType:t,mode:"loose",...S.normalizeParams(r)})}var Zd=v("ZodMap",(e,t)=>{Dt(),sc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Gl(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Ge(...r)),e.nonempty=r=>e.check(Ge(1,r)),e.max=(...r)=>e.check(st(...r)),e.size=(...r)=>e.check(At(...r))});function rv(e,t,r){return new Zd({type:"map",keyType:e,valueType:t,...S.normalizeParams(r)})}var Fd=v("ZodSet",(e,t)=>{Dt(),uc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ql(e,r,o,n),e.min=(...r)=>e.check(Ge(...r)),e.nonempty=r=>e.check(Ge(1,r)),e.max=(...r)=>e.check(st(...r)),e.size=(...r)=>e.check(At(...r))});function iv(e,t){return new Fd({type:"set",valueType:e,...S.normalizeParams(t)})}var wn=v("ZodEnum",(e,t)=>{cc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(o,n,i)=>zl(e,o,n,i),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let i={};for(let a of o)if(r.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new wn({...t,checks:[],...S.normalizeParams(n),entries:i})},e.exclude=(o,n)=>{let i={...t.entries};for(let a of o)if(r.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new wn({...t,checks:[],...S.normalizeParams(n),entries:i})}});function aa(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new wn({type:"enum",entries:r,...S.normalizeParams(t)})}function ov(e,t){return new wn({type:"enum",entries:e,...S.normalizeParams(t)})}var Bd=v("ZodLiteral",(e,t)=>{lc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ul(e,r,o,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function av(e,t){return new Bd({type:"literal",values:Array.isArray(e)?e:[e],...S.normalizeParams(t)})}var Vd=v("ZodFile",(e,t)=>{dc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ml(e,r,o,n),e.min=(r,o)=>e.check(Ge(r,o)),e.max=(r,o)=>e.check(st(r,o)),e.mime=(r,o)=>e.check(pn(Array.isArray(r)?r:[r],o))});function sv(e){return ml(Vd,e)}var Gd=v("ZodTransform",(e,t)=>{Dt(),pc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Vl(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new it(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(S.issue(i,r.value,t));else{let a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=r.value),a.inst??(a.inst=e),r.issues.push(S.issue(a))}};let n=t.transform(r.value,r);return n instanceof Promise?n.then(i=>(r.value=i,r)):(r.value=n,r)}});function sa(e){return new Gd({type:"transform",transform:e})}var Rr=v("ZodOptional",(e,t)=>{Fi.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Oo(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Nt(e){return new Rr({type:"optional",innerType:e})}var ua=v("ZodExactOptional",(e,t)=>{mc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Oo(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function qd(e){return new ua({type:"optional",innerType:e})}var Wd=v("ZodNullable",(e,t)=>{fc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Xl(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Ir(e){return new Wd({type:"nullable",innerType:e})}function uv(e){return Nt(Ir(e))}var Hd=v("ZodDefault",(e,t)=>{gc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>td(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Kd(e,t){return new Hd({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():S.shallowClone(t)}})}var Jd=v("ZodPrefault",(e,t)=>{hc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>nd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Yd(e,t){return new Jd({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():S.shallowClone(t)}})}var ca=v("ZodNonOptional",(e,t)=>{vc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ql(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Xd(e,t){return new ca({type:"nonoptional",innerType:e,...S.normalizeParams(t)})}var Qd=v("ZodSuccess",(e,t)=>{_c.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Zl(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function cv(e){return new Qd({type:"success",innerType:e})}var ep=v("ZodCatch",(e,t)=>{yc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>rd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function tp(e,t){return new ep({type:"catch",innerType:e,catchValue:typeof t=="function"?t:S.constantCatch(t)})}var np=v("ZodNaN",(e,t)=>{bc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ll(e,r,o,n)});function lv(e){return dl(np,e)}var Cr=v("ZodPipe",(e,t)=>{Bi.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>id(e,r,o,n),e.in=t.in,e.out=t.out});function jo(e,t){return new Cr({type:"pipe",in:e,out:t})}var Or=v("ZodCodec",(e,t)=>{Cr.init(e,t),lr.init(e,t)});function dv(e,t,r){return new Or({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function pv(e){let t=e._zod.def;return new Or({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var rp=v("ZodPreprocess",(e,t)=>{Cr.init(e,t),Sc.init(e,t)}),ip=v("ZodReadonly",(e,t)=>{wc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>od(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function op(e){return new ip({type:"readonly",innerType:e})}var ap=v("ZodTemplateLiteral",(e,t)=>{xc.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>jl(e,r,o,n)});function mv(e,t){return new ap({type:"template_literal",parts:e,...S.normalizeParams(t)})}var sp=v("ZodLazy",(e,t)=>{dr.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>sd(e,r,o,n),e.unwrap=()=>e._zod.def.getter()});function up(e){return new sp({type:"lazy",getter:e})}var cp=v("ZodPromise",(e,t)=>{Ic.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ad(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function fv(e){return new cp({type:"promise",innerType:e})}var lp=v("ZodFunction",(e,t)=>{$c.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Bl(e,r,o,n)});function gv(e){return new lp({type:"function",input:Array.isArray(e?.input)?jd(e?.input):e?.input??Tr(Ot()),output:e?.output??Ot()})}var Nr=v("ZodCustom",(e,t)=>{Ec.init(e,t),M.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Fl(e,r,o,n)});function hv(e){let t=new Y({check:"custom"});return t._zod.check=e,t}function vv(e,t){return fl(Nr,e??(()=>!0),t)}function dp(e,t={}){return gl(Nr,e,t)}function pp(e,t){return hl(e,t)}var _v=vl,yv=_l,mp=v("ZodInstanceOf",(e,t)=>{Nr.init(e,t)},{properties(e,t){return this.check(dn(e,t))}});function bv(e,t={}){let r=new mp({type:"custom",check:"custom",fn:o=>o instanceof e,abort:!0,...S.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=o=>{o.value instanceof e||o.issues.push({code:"invalid_type",expected:e.name,input:o.value,inst:r,path:[...r._zod.def.path??[]]})},r}var Sv=(...e)=>yl({Codec:Or,Boolean:In,String:xn},...e);function wv(e){let t=up(()=>kn([$r(e),xd(),$d(),Td(),Tr(t),Md($r(),t)]));return t}function xv(e,t){return new rp({type:"pipe",in:sa(e),out:t})}var BI={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function VI(e){ne({customError:e})}function GI(){return ne().customError}var fp;fp||(fp={});var Dr={};He(Dr,{ZodISODate:()=>pt,ZodISODateTime:()=>dt,ZodISODuration:()=>ft,ZodISOTime:()=>mt,date:()=>WI,datetime:()=>qI,duration:()=>KI,time:()=>HI});function qI(e){return _r(dt,e)}function WI(e){return yr(pt,e)}function HI(e){return br(mt,e)}function KI(e){return Sr(ft,e)}var T={...Tn,...zo,iso:Dr},JI=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function YI(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function $v(e,t){return e.map((r,o)=>o<t?r:r.optional())}function XI(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function QI(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let o=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===o){let n=r[1]===void 0?void 0:XI(r[1]);if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function eE(e,t){return T.transform(o=>o).check(o=>{let n=o.value;if(typeof n!="object"||n===null||Array.isArray(n))return;let i=Object.getOwnPropertyNames(n);if(t.minProperties!==void 0&&i.length<t.minProperties&&o.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:n,inst:e,continue:!0}),t.maxProperties!==void 0&&i.length>t.maxProperties&&o.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:n,inst:e,continue:!0}),t.keySchema)for(let a of i){let s=t.keySchema.safeParse(a);s.success||o.issues.push({code:"invalid_key",origin:"record",issues:s.error.issues,input:a,path:[a],continue:!0})}}).pipe(e)}function gp(e,t){if(e===null)return"z";let r=typeof e;if(r!=="object"){if(r==="number"&&Number.isNaN(e))return null;let o=String(e);return`${r[0]}${o.length}:${o}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let i=[];for(let a of e){let s=gp(a,t);if(s===null)return null;i.push(s)}return`a${i.length}:[${i.join(",")}]`}let o=Object.keys(e).sort(),n=[];for(let i of o){let a=gp(e[i],t);if(a===null)return null;n.push(`${i.length}:${i}=${a}`)}return`o${n.length}:{${n.join(",")}}`}finally{t.delete(e)}}var tE=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),nE=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function zr(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(zr):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,r])=>tE.has(t)?zr(r):!nE.has(t)||typeof r!="object"||r===null?!1:Object.values(r).some(zr))}function Iv(e){return e===1?"element":"elements"}function rE(e,t){return T.transform(o=>o).check(o=>{let n=o.value;if(Array.isArray(n)){if(t.uniqueItems===!0){let i=new Map;for(let a=0;a<n.length;a++){let s=gp(n[a],new Set);if(s===null)continue;let u=i.get(s);if(u===void 0){i.set(s,a);continue}o.issues.push({code:"custom",message:`Array items must be unique: element at index ${a} duplicates the one at index ${u}`,input:n,path:[a],continue:!0})}}if(t.containsSchema){let i=t.minContains??1,a=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY,s=0;for(let u of n)if(t.containsSchema.safeParse(u).success&&++s>=a)break;s<i&&o.issues.push({code:"custom",message:`Array must contain at least ${i} matching ${Iv(i)}; found ${s}`,input:n,continue:!0}),t.maxContains!==void 0&&s>t.maxContains&&o.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${Iv(t.maxContains)}`,input:n,continue:!0})}}}).pipe(e)}function Ev(e,t){if(e!==!1)return e===void 0||e===!0?T.any():ye(e,t)}var iE=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function kv(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return T.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return T.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let i=QI(n,t),a=ye(i,t);return t.refs.set(n,a),t.processing.delete(n),a}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return T.null();if(n.length===0)return T.never();if(n.length===1)return T.literal(n[0]);if(n.every(a=>typeof a=="string"))return T.enum(n);let i=n.map(a=>T.literal(a));return i.length<2?i[0]:T.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return T.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map(i=>{let a={...e,type:i};return kv(a,t)});return n.length===0?T.never():n.length===1?n[0]:T.union(n)}if(!r)return T.any();let o;switch(r){case"string":{let n=T.string();if(e.format){let i=e.format;i==="email"?n=n.check(T.email()):i==="uri"||i==="uri-reference"?n=n.check(T.url()):i==="uuid"||i==="guid"?n=n.check(T.uuid()):i==="date-time"?n=n.check(T.iso.datetime({offset:!0})):i==="date"?n=n.check(T.iso.date()):i==="time"?n=n.check(T.regex(iE)):i==="duration"?n=n.check(T.iso.duration()):i==="hostname"?n=n.check(T.hostname()):i==="ipv4"?n=n.check(T.ipv4()):i==="ipv6"?n=n.check(T.ipv6()):i==="mac"?n=n.check(T.mac()):i==="cidr"?n=n.check(T.cidrv4()):i==="cidr-v6"?n=n.check(T.cidrv6()):i==="base64"?n=n.check(T.base64()):i==="base64url"?n=n.check(T.base64url()):i==="e164"?n=n.check(T.e164()):i==="credit_card"?n=n.check(T.creditCard()):i==="iban"?n=n.check(T.iban()):i==="jwt"?n=n.check(T.jwt()):i==="emoji"?n=n.check(T.emoji()):i==="nanoid"?n=n.check(T.nanoid()):i==="cuid"?n=n.check(T.cuid()):i==="cuid2"?n=n.check(T.cuid2()):i==="ulid"?n=n.check(T.ulid()):i==="xid"?n=n.check(T.xid()):i==="ksuid"&&(n=n.check(T.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),o=n;break}case"number":case"integer":{let n=r==="integer"?T.number().int():T.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),o=n;break}case"boolean":{o=T.boolean();break}case"null":{o=T.null();break}case"object":{let n={},i=e.properties||{},a=new Set(e.required||[]),s=typeof e.additionalProperties=="object"?ye(e.additionalProperties,t):void 0;for(let[d,f]of Object.entries(i)){let m=ye(f,t);se(n,d,a.has(d)?m:m.optional())}if(e.patternProperties){let d=e.patternProperties,f=Object.keys(d),m=[];for(let h of f){let b=ye(d[h],t),$=T.string().regex(new RegExp(h));m.push(T.looseRecord($,b))}let g=[];if(Object.keys(n).length>0&&g.push(T.object(n).passthrough()),g.push(...m),g.length===0)o=T.object({}).passthrough();else if(g.length===1)o=g[0];else{let h=T.intersection(g[0],g[1]);for(let b=2;b<g.length;b++)h=T.intersection(h,g[b]);o=h}if(e.additionalProperties===!1){let h=Object.keys(n),b=f.map(I=>new RegExp(I)),$=o;o=o.check(I=>{if(!Ce(I.value))return;let k=[];for(let R of Object.keys(I.value))h.includes(R)||b.some(U=>U.test(R))||k.push(R);k.length&&I.issues.push({code:"unrecognized_keys",keys:k,input:I.value,inst:$})})}}else{let d=T.object(n);e.additionalProperties===!1?o=d.strict():s?o=d.catchall(s):o=d.passthrough()}let u=e.propertyNames!==void 0&&e.propertyNames!==!0,c=typeof e.minProperties=="number"?e.minProperties:void 0,l=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(u||c!==void 0||l!==void 0){let d;if(u){let f=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;d=ye(f,t)}o=eE(o,{keySchema:d,minProperties:c,maxProperties:l})}break}case"array":{let n=e.prefixItems,i=e.items;if(n&&Array.isArray(n)){let a=typeof e.minItems=="number"?e.minItems:0,s=n.map(d=>ye(d,t)),u=$v(s,a),c=Array.isArray(i)?void 0:Ev(i,t),l=T.tuple(u);o=c?l.rest(c):l,typeof e.minItems=="number"&&(o=o.check(T.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(T.maxLength(e.maxItems)))}else if(Array.isArray(i)){let a=typeof e.minItems=="number"?e.minItems:0,s=i.map(d=>ye(d,t)),u=$v(s,a),c=Ev(e.additionalItems,t),l=T.tuple(u);o=c?l.rest(c):l,typeof e.minItems=="number"&&(o=o.check(T.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(T.maxLength(e.maxItems)))}else if(i!==void 0){let a=ye(i,t),s=T.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),o=s}else o=T.array(T.any());(e.uniqueItems===!0||e.contains!==void 0)&&(o=rE(o,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?ye(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${r}`)}return o}function ye(e,t){if(typeof e=="boolean")return e?T.any():T.never();let r=kv(e,t),o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(c=>ye(c,t)),u=T.union(s);r=o?T.intersection(r,u):u}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(c=>ye(c,t)),u=T.xor(s);r=o?T.intersection(r,u):u}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=o?r:T.any();else{let s=o?r:ye(e.allOf[0],t),u=o?0:1;for(let c=u;c<e.allOf.length;c++)s=T.intersection(s,ye(e.allOf[c],t));r=s}e.nullable===!0&&t.version==="openapi-3.0"&&(r=T.nullable(r)),e.readOnly===!0&&(r=T.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let n={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of i)s in e&&(n[s]=e[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in e&&(n[s]=e[s]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!zr(e.propertyNames)&&(n.propertyNames=e.propertyNames);for(let s of["minProperties","maxProperties"])e[s]!==void 0&&(n[s]=e[s])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!zr(e.contains)&&(n.contains=e.contains);for(let s of["uniqueItems","minContains","maxContains"])e[s]!==void 0&&(n[s]=e[s])}for(let s of Object.keys(e))JI.has(s)||se(n,s,e[s]);return Object.keys(n).length>0&&t.registry.add(r,n),e.description&&(r=r.describe(e.description)),r}function Tv(e,t){if(typeof e=="boolean")return e?T.any():T.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let o=YI(r,t?.defaultTarget),n=r.$defs||r.definitions||{},i={version:o,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??ue};return ye(r,i)}var Av=Symbol("z.visit/resolving");function Ur(e,t){let r=typeof t=="function"?t:(a,s)=>{let u=t[a._zod.def.type];return u?u(a,s):a},o=new Map;function n(a){let s=o.get(a);if(s===Av)return new dr({type:"lazy",getter:()=>o.get(a)});if(s!==void 0)return s;o.set(a,Av);let u=i(a),c=r(u,u!==a);return o.set(a,c),c}function i(a){let s=a._zod.def,u=s.type;switch(u){case"object":{let c=s.shape,l=Object.keys(c),d=!1,f={};for(let g of l){let h=n(c[g]);h!==c[g]&&(d=!0),f[g]=h}let m=s.catchall;return s.catchall&&(m=n(s.catchall),m!==s.catchall&&(d=!0)),d?q(a,{...s,shape:f,catchall:m}):a}case"array":{let c=n(s.element);return c===s.element?a:q(a,{...s,element:c})}case"tuple":{let c=s.items,l=!1,d=[];for(let m of c){let g=n(m);g!==m&&(l=!0),d.push(g)}let f=s.rest;return s.rest&&(f=n(s.rest),f!==s.rest&&(l=!0)),l?q(a,{...s,items:d,rest:f}):a}case"record":case"map":{let c=n(s.keyType),l=n(s.valueType);return c===s.keyType&&l===s.valueType?a:q(a,{...s,keyType:c,valueType:l})}case"set":{let c=n(s.valueType);return c===s.valueType?a:q(a,{...s,valueType:c})}case"union":{let c=s.options,l=!1,d=[];for(let f of c){let m=n(f);m!==f&&(l=!0),d.push(m)}return l?q(a,{...s,options:d}):a}case"intersection":{let c=n(s.left),l=n(s.right);return c===s.left&&l===s.right?a:q(a,{...s,left:c,right:l})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let c=n(s.innerType);return c===s.innerType?a:q(a,{...s,innerType:c})}case"pipe":{let c=n(s.in),l=n(s.out);return c===s.in&&l===s.out?a:q(a,{...s,in:c,out:l})}case"function":{let c=n(s.input),l=n(s.output);return c===s.input&&l===s.output?a:q(a,{...s,input:c,output:l})}case"lazy":{let c=s.getter,{_cachedInner:l,...d}=s;return q(a,{...d,getter:()=>n(c())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return a;default:return a}}return n(e)}function Pv(e){return Ur(e,{object:t=>t.partial(),union:t=>{let r=t._zod.def;return r.discriminator===void 0?t:kn(r.options)}})}function oE(e,t){if(!t?.length)return e;let r=e._zod.def;return q(e,Le(r,{checks:[...r.checks??[],...t]}),{parent:!0})}function Rv(e){return oE(e.out,e.checks)}function aE(e){return e.in._zod.traits.has("$ZodTransform")?Rv(e):e.in}function Cv(e){return Ur(e,{pipe:t=>aE(t._zod.def),default:(t,r)=>r?Nt(t._zod.def.innerType):t,catch:(t,r)=>r?t._zod.def.innerType:t})}function Ov(e){return Ur(e,{pipe:t=>Rv(t._zod.def),prefault:(t,r)=>r?t._zod.def.innerType:t})}var hp={};He(hp,{bigint:()=>lE,boolean:()=>cE,date:()=>dE,number:()=>uE,string:()=>sE});function sE(e){return Lc(xn,e)}function uE(e){return Vc($n,e)}function cE(e){return Yc(In,e)}function lE(e){return Qc(En,e)}function dE(e){return ll(kr,e)}var Lt={ALWAYS:"always",USER:"user",BUSINESS:"business"},vp={OAUTH:"oauth",API_KEY:"api-key",INTERNAL:"internal"},Nv={github:{displayName:"GitHub",description:"Repository access, pull requests, and authentication",toggleable:!1,credentialScopes:[Lt.ALWAYS],personalSettingsSection:null,lifecycleSupport:"instrumented"},slack:{displayName:"Slack",description:"Business workspace bot install for admin-managed Slack integrations",toggleable:!0,credentialScopes:[Lt.USER],personalSettingsSection:null,lifecycleSupport:"instrumented"},openai:{displayName:"OpenAI",description:"Model access via OpenAI API keys",toggleable:!0,credentialScopes:[Lt.BUSINESS,Lt.USER],personalSettingsSection:vp.API_KEY,lifecycleSupport:"instrumented",customerFacing:!1},codex_subscription:{displayName:"Codex subscription",description:"Internal Codex subscription auth",toggleable:!0,credentialScopes:[Lt.USER],personalSettingsSection:vp.INTERNAL,lifecycleSupport:"instrumented",customerFacing:!1},anthropic:{displayName:"Anthropic",description:"Historical Anthropic credentials for platform structured output",toggleable:!0,credentialScopes:[Lt.BUSINESS,Lt.USER],personalSettingsSection:vp.API_KEY,lifecycleSupport:"instrumented",customerFacing:!1}};var Dv={VALIDATED:"validated",SAVED_UNVERIFIED:"saved_unverified",INVALID:"invalid"},zv={NONE:"none",CREDENTIALS_MISSING:"credentials_missing",CREDENTIALS_PRESENT:"credentials_present",CREDENTIALS_INVALID:"credentials_invalid",INTEGRATION_DISABLED:"integration_disabled",BUSINESS_MANAGED:"business_managed",NETWORK_VALIDATION_SKIPPED:"network_validation_skipped",GITHUB_LOGGED_IN:"github_logged_in",GITHUB_NOT_LOGGED_IN:"github_not_logged_in",GITHUB_BUSINESS_AUTHORIZED:"github_business_authorized",GITHUB_BUSINESS_NOT_AUTHORIZED:"github_business_not_authorized",GITHUB_APP_INSTALLED:"github_app_installed",GITHUB_APP_NOT_INSTALLED:"github_app_not_installed",GITHUB_APP_INSTALL_PENDING_WEBHOOK_SYNC:"github_app_install_pending_webhook_sync",GITHUB_APP_SUSPENDED:"github_app_suspended",GITHUB_REPO_NOT_SELECTED:"github_repo_not_selected",GITHUB_REPO_ACCESS_VERIFIED:"github_repo_access_verified",GITHUB_REPO_ACCESS_DENIED:"github_repo_access_denied",GITHUB_REPO_ACCESS_CHECK_FAILED:"github_repo_access_check_failed",OAUTH_CONNECTED:"oauth_connected",OAUTH_NOT_CONNECTED:"oauth_not_connected",OAUTH_TOKEN_EXPIRED:"oauth_token_expired",OAUTH_NO_REFRESH_TOKEN:"oauth_no_refresh_token",DB_LOOKUP_FAILED:"db_lookup_failed"};var dD={github_login:{title:Nv.github.displayName,owner:"user",required:!0},github_business_authorized:{title:"GitHub Business Access",owner:"admin",required:!0},github_app_installed:{title:"GitHub App",owner:"user",required:!0},github_repo_access:{title:"Repository Access",owner:"user",required:!0}};var pE=Object.values(Dv),mE=Object.values(zv),_p=p.object({isSet:p.boolean(),lastValidatedAt:p.number().nullable().default(null),lastValidationStatus:p.enum(pE).nullable().default(null),lastValidationReasonCode:p.enum(mE).nullable().default(null)}),Uv=p.object({eligible:p.boolean(),credential:_p});import{spawn as fE}from"node:child_process";import{rmSync as gE}from"node:fs";import{mkdtemp as hE,rm as vE}from"node:fs/promises";import{tmpdir as _E}from"node:os";import{join as yE}from"node:path";function Lv(e){return new Promise((t,r)=>{let o=fE(e.binPath,e.args,{stdio:"inherit",env:{...process.env,...e.env}});o.on("error",n=>{if(n.code==="ENOENT"){r(new y("user",`Could not find the \`${e.binPath}\` executable.`,{hint:e.missingBinaryHint}));return}r(new y("user",`Failed to launch \`${e.binPath} ${e.args.join(" ")}\`: ${n.message}`))}),o.on("close",n=>{if(n===0){t();return}r(new y("user",`\`${e.binPath} ${e.args.join(" ")}\` exited with code ${n??"unknown"}.`,{hint:`Complete the ${e.displayName} login, then re-run \`${e.retryCommand}\`.`}))})})}async function jv(e,t){let r,o=()=>{if(r)try{gE(r,{recursive:!0,force:!0})}catch{}process.exit(ke)};process.on("SIGINT",o);try{return r=await hE(yE(_E(),e)),await t(r)}finally{try{r&&await vE(r,{recursive:!0,force:!0}).catch(()=>{})}finally{process.off("SIGINT",o)}}}var wE=A("/api/settings/codex-subscription"),xE=A("/api/settings/codex-subscription/auth-json"),$E=A("/api/settings/codex-subscription/enabled");function Mv(e){return e.isSet?e.lastValidationStatus==="invalid"?"Expired. Run `arcanist codex login` to reconnect. `arcanist codex use off` falls back to your OpenAI key.":e.lastValidationStatus==="validated"?"Verified with OpenAI.":"Saved, but not verified with OpenAI yet.":null}function Zv(e,t){let r=e.safeParse(t);if(!r.success)throw new y("server","The Arcanist API returned an invalid Codex subscription response.");return r.data}function IE(e){return e?.trim()||process.env.ARCANIST_CODEX_BIN?.trim()||"codex"}function EE(e,t){return Lv({displayName:"Codex",binPath:e,args:["login","--device-auth"],env:{CODEX_HOME:t},missingBinaryHint:"Install the Codex CLI, or point at it with --codex-path <path> or ARCANIST_CODEX_BIN.",retryCommand:"arcanist codex login"})}async function Fv(e,t){return P(e,$E,{method:"PUT",body:JSON.stringify({enabled:t})})}async function Bv(e,t){let{config:r}=Q(t,e),o=IE(e.codexPath),n=await jv("arcanist-codex-",async u=>{await EE(o,u);let c;try{c=await bE(SE(u,"auth.json"),"utf8")}catch{throw new y("user","Codex login completed but no auth.json was written.",{hint:"Verify `codex login --device-auth` succeeds on its own, then re-run `arcanist codex login`."})}if(!c.trim())throw new y("user","Codex login produced an empty auth.json.");return c}),i=Zv(_p,await P(r,xE,{method:"PUT",body:JSON.stringify({authJson:n})})),a=!1,s;try{await Fv(r,!0),a=!0}catch(u){s=u instanceof Error?u.message:String(u)}C(t,e,{...i,useCodexSubscription:a},u=>{console.log(a?"Codex subscription auth saved and activated for OpenAI sessions.":"Codex subscription auth saved.");let c=Mv(u);c&&console.log(`Status: ${c}`),a||(console.log(`Could not activate it automatically${s?` (${s})`:""}.`),console.log("Run `arcanist codex use on` to start using it."))})}async function Vv(e,t,r){let o=e.trim().toLowerCase();if(o!=="on"&&o!=="off")throw new y("user","Usage: arcanist codex use <on|off>");let n=o==="on",{config:i}=Q(r,t),a=await Fv(i,n);C(r,t,a,()=>console.log(a.useCodexSubscription?"Codex subscription auth is now used for OpenAI sessions.":"Codex subscription auth is no longer used for OpenAI sessions."))}async function Gv(e,t){let{config:r}=Q(t,e),o=Zv(Uv,await P(r,wE));C(t,e,o,n=>{console.log(`Eligible: ${n.eligible?"yes":"no"}`),console.log(`Auth.json saved: ${n.credential.isSet?"yes":"no"}`);let i=Mv(n.credential);i&&console.log(`Status: ${i}`)})}function qv(e){if(!e)return"no switch";let t=e.phase==="pausing"?` target_seq=${e.target_seq??"none"} drained_seq=${e.drained_seq??"none"}`:"",r=e.phase==="steady"&&e.webhooks_parked?" webhooks=parked until the replay drains":"";return`${e.phase}(${e.source}\u2192${e.target}) generation ${e.generation}${t}${r}`}function kE(e){let t=Number(e);if(!Number.isSafeInteger(t)||t<0)throw new y("user",`Not a change-log seq: ${e}`);return t}var la=class{static register(t){let r=t.command("engine-switch").description("Read or move the serving database engine (Arcanist operators only)");r.command("status").description("Show which engine serves and whether a pause is in progress").action(async(n,i)=>{let a=J(V(i,n)),s=await P(a,A("/api/internal/engine-switch"));C(i,n,s,()=>process.stdout.write(`${s.engine}: ${qv(s.switch)}
72
72
  `))});let o=[["pause","Pause writes and point the switch at the target engine",["<target>","d1 or postgres"]],["target","Post the change-log seq the replayer must drain before commit",["<seq>","d1_change_log seq"]],["drained","Post the seq the replayer drained, when the loop cannot post it itself",["<seq>","drained seq"]],["commit","Serve the target engine; accepted only once the replayer drained the target seq"],["abort","Resume writes on the source engine with no drain"]];for(let[n,i,a]of o){let s=r.command(n).description(i);a&&s.argument(a[0],a[1]),s.action(async(...u)=>{let c=u.at(-1),l=u.at(-2),d=a?String(u[0]):void 0,f=n==="pause"?{action:n,target:d}:n==="target"||n==="drained"?{action:n,seq:kE(d)}:{action:n};if(n==="pause"&&d!=="d1"&&d!=="postgres")throw new y("user",`Target must be d1 or postgres, not ${d}`);let m=J(V(c,l)),g=await P(m,A("/api/internal/engine-switch"),{method:"POST",body:JSON.stringify(f)});C(c,l,g,()=>process.stdout.write(`${g.changed?"moved to":"already"} ${qv(g.state)}
73
73
  `))})}}};function L(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}var TE=1024*1024,gt=class extends Error{constructor(r,o){super(o);this.code=r;this.name="BrowserStateValidationError"}code},AE=new Set(["localhost","127.0.0.1","[::1]","::1"]),PE=new Set(["Strict","Lax","None"]);function Lr(e){return new gt("invalid_shape",e)}function RE(e){return!(!L(e)||typeof e.name!="string"||typeof e.value!="string"||typeof e.domain!="string"||typeof e.path!="string"||e.expires!==void 0&&!(typeof e.expires=="number"&&Number.isFinite(e.expires))||e.httpOnly!==void 0&&typeof e.httpOnly!="boolean"||e.secure!==void 0&&typeof e.secure!="boolean"||e.sameSite!==void 0&&!PE.has(e.sameSite))}function CE(e){if(typeof e!="string")return!1;let t;try{t=new URL(e)}catch{return!1}return t.origin!=="null"&&t.origin===e}function OE(e){return L(e)&&typeof e.name=="string"&&typeof e.value=="string"}function Wv(e){let t=new TextEncoder().encode(e).byteLength;if(t>TE)throw new gt("too_large",`Browser state is ${t} bytes; the limit is 1 MiB.`);let r;try{r=JSON.parse(e)}catch{throw new gt("invalid_json","Browser state is not valid JSON.")}if(!L(r)||!Array.isArray(r.cookies)||!Array.isArray(r.origins))throw Lr("Browser state must be a Playwright storage state with cookies[] and origins[].");let o=[];r.cookies.forEach((i,a)=>{if(!RE(i))throw Lr(`Browser state cookies[${a}] is not a Playwright cookie: name, value, domain, and path must be strings; expires a finite number; httpOnly and secure booleans; sameSite one of Strict, Lax, None.`);o.push(i)});let n=[];if(r.origins.forEach((i,a)=>{if(!L(i)||!Array.isArray(i.localStorage))throw Lr(`Browser state origins[${a}] must carry an origin string and a localStorage[] array.`);if(!CE(i.origin))throw Lr(`Browser state origins[${a}].origin must be a URL origin such as https://app.example.com with no path, query, or fragment.`);let s=[];i.localStorage.forEach((u,c)=>{if(!OE(u))throw Lr(`Browser state origins[${a}].localStorage[${c}] must be a record with string name and value.`);s.push({name:u.name,value:u.value})}),n.push({origin:i.origin,localStorage:s})}),o.length===0&&n.every(i=>i.localStorage.length===0))throw new gt("empty","Browser state is empty; nothing was captured. Did you log in?");return{state:{cookies:o,origins:n},bytes:t}}function Hv(e){return{cookieDomainCount:new Set(e.cookies.map(t=>t.domain.replace(/^\./,"").toLowerCase())).size,storageOriginCount:e.origins.filter(t=>t.localStorage.length>0).length}}function yp(e){return AE.has(e.replace(/^\./,"").toLowerCase())}function Kv(e){return`http://localhost:${e}`}function Jv(e,t){let r=new URL(t),o=new Map;for(let n of e.origins){let i;try{i=new URL(n.origin).hostname}catch{i=""}let a=yp(i)?r.origin:n.origin,s=o.get(a);s||(s=new Map,o.set(a,s));for(let u of n.localStorage)s.delete(u.name),s.set(u.name,u.value)}return{cookies:e.cookies.map(n=>yp(n.domain)?{...n,domain:r.hostname,secure:!1}:n),origins:[...o].map(([n,i])=>({origin:n,localStorage:[...i].map(([a,s])=>({name:a,value:s}))}))}}function Yv(e){let t=new Set;for(let r of e){let o;try{o=new URL(r)}catch{continue}o.protocol!=="http:"&&o.protocol!=="https:"||yp(o.hostname)||t.add(o.hostname.toLowerCase())}return[...t].sort()}import{mkdtempSync as NE,rmSync as DE}from"node:fs";import{tmpdir as zE}from"node:os";import{join as UE}from"node:path";var LE="The browser window was closed before Enter was pressed. Run the command again, log in, then press Enter here before closing the window.";function jE(e){try{let{origin:t}=new URL(e);if(t&&t!=="null")return j(t)}catch{}return"the start page"}async function ME(e){let{chromium:t}=await import("playwright-core"),r={headless:!1,viewport:null,handleSIGINT:!1,args:["--no-first-run","--no-default-browser-check"]};try{return await t.launchPersistentContext(e,{...r,channel:"chrome"})}catch{try{return await t.launchPersistentContext(e,r)}catch{throw new y("user","No browser found for the login window.",{hint:"Install Google Chrome, or run `npx playwright install chromium` and try again."})}}}async function Xv(e){let t,r,o=[],n=new AbortController,i=async()=>{let s=r;r=void 0,await s?.close().catch(()=>{}),t&&(DE(t,{recursive:!0,force:!0}),t=void 0)},a=()=>{i().finally(()=>process.exit(ke))};process.once("SIGINT",a);try{t=NE(UE(zE(),"arcanist-login-"));let s=await ME(t);r=s;let u=g=>{g.on("framenavigated",h=>{h===g.mainFrame()&&o.push(h.url())})};for(let g of s.pages())u(g);s.on("page",u);let c=s.pages()[0]??await s.newPage(),l=!1,d=new Promise((g,h)=>{s.once("close",()=>{l=!0,h(new y("user",LE))})});d.catch(()=>{});let f=await Promise.race([d,c.goto(e.startUrl).then(()=>!0,()=>!1)]);l&&await d,f||e.onStatus?.(`Could not open ${jE(e.startUrl)}; the window is open, navigate to your app yourself.`),await Promise.race([d,e.waitForDone(n.signal)]);let m=await s.storageState();return{rawState:JSON.stringify(m),navigations:o}}finally{n.abort(),process.off("SIGINT",a),await i()}}var ZE=/^[A-Za-z0-9_.][A-Za-z0-9_.-]*$/;function Qv(e){return typeof e!="string"||!e||e.length>100||e==="."||e===".."?!1:ZE.test(e)}function FE(e,t){return Qv(e)&&Qv(t)?{owner:e,repo:t}:null}function da(e){let t=e.match(/^([a-zA-Z0-9_.-]+)\/([a-zA-Z0-9_.-]+)$/)??e.match(/^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?$/)??e.match(/^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/);return t?FE(t[1],t[2]):null}import{execFileSync as e_}from"node:child_process";function jr(e,t={}){try{return e_("git",e,{encoding:"utf8",stdio:[t.input===void 0?"ignore":"pipe","pipe","pipe"],...t.cwd?{cwd:t.cwd}:{},...t.input===void 0?{}:{input:t.input},...t.maxBuffer?{maxBuffer:t.maxBuffer}:{}})}catch(r){throw new y("user",`git ${e.join(" ")} failed: ${Ee(r)}`)}}function t_(e,t={}){let r;try{r=e_("git",e,{stdio:["ignore","pipe","pipe"],...t.cwd?{cwd:t.cwd}:{},...t.maxBuffer?{maxBuffer:t.maxBuffer}:{}})}catch(o){throw new y("user",`git ${e.join(" ")} failed: ${Ee(o)}`)}try{return new TextDecoder("utf-8",{fatal:!0}).decode(r)}catch{throw new y("user","A changed file has a file name that is not valid UTF-8, so it cannot be reviewed.",{hint:"Rename the file, commit, then run the review again."})}}function Mr(e,t={}){return jr(e,t).trim()}function n_(e="repo"){let t=`Pass the ${e} as owner/name.`,r;try{r=Mr(["remote","get-url","origin"])}catch{throw new y("user","This directory has no git `origin` remote to read the repository from.",{hint:t})}let o=da(r);if(!o)throw new y("user","origin remote must point at a GitHub repository",{hint:t});return{owner:o.owner,repo:o.repo}}function BE(e,t="repo"){let r=da(e);if(!r)throw new y("user",`${t} must be owner/name or a GitHub URL`);return{owner:r.owner,repo:r.repo.replace(/\.git$/,"")}}function pa(e,t="repo"){return e===void 0?n_(t):BE(e,t)}var VE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function r_(e){return(await P(e,A("/api/environments"))).data.environments}function i_(e,t){return e.find(r=>r.scope==="team"&&r.repoOwner.toLowerCase()===t.owner.toLowerCase()&&r.repoName.toLowerCase()===t.repo.toLowerCase())}async function o_(e,t){return i_(await r_(e),t)??null}async function Zr(e,t){let r=await r_(e);if(t&&VE.test(t)){let i=r.find(a=>a.id===t);if(!i)throw new y("user",`No environment with id ${t}.`);return i}let o=pa(t,"environment"),n=i_(r,o);if(!n)throw new y("user",`No team environment for ${o.owner}/${o.repo}.`,{hint:"Run `arcanist environments status` first."});return n}import{createInterface as GE}from"node:readline/promises";async function ma(e,t={}){if(!process.stdin.isTTY||!process.stderr.isTTY)throw new y("user","An interactive terminal is required here. Re-run with the matching flag in non-interactive environments.");let{signal:r}=t;if(r?.aborted)throw new y("user","Cancelled.");let o=GE({input:process.stdin,output:process.stderr}),n=()=>o.close();r?.addEventListener("abort",n,{once:!0});try{return await new Promise((i,a)=>{o.once("SIGINT",()=>a(new y("user","Cancelled.",{exitCode:ke}))),o.once("close",()=>a(new y("user","Cancelled."))),o.question(e).then(s=>i(s.trim()),a)})}finally{r?.removeEventListener("abort",n),o.close()}}function qE(e){let t=e.provisioningConfig?.sandbox?.appRuntime,r=t?.url?.hostPort;if(!t||!r)throw new y("user",`Environment "${j(e.name)}" has no app runtime, so there is nothing to log into.`,{hint:"Configure the app runtime on the Environment page first."});let o=Kv(r),n=t.url?.path??"/";return{origin:o,startUrl:`${o}${n.startsWith("/")?n:`/${n}`}`,appRuntime:t}}function WE(e,t){let r;try{r=Wv(e)}catch(n){if(n instanceof gt){let i=n.code==="empty"?"Log into your app in the browser window before pressing Enter.":n.code==="too_large"?"Log out of sites you do not need for this app and try again.":void 0;throw new y("user",n.message,i?{hint:i}:{})}throw n}let o=Jv(r.state,t);return{normalized:o,counts:Hv(o),bytes:r.bytes}}function HE(){if(!(process.stdin.isTTY&&process.stderr.isTTY))throw new y("user","environments login needs an interactive terminal to wait for you to finish logging in.",{hint:"Run it from a terminal (add --yes --validate-path <path> to skip the other prompts), or use --clear to remove a saved login."})}function a_(e){if(!(e.startsWith("/")&&!e.startsWith("//")))throw new y("user","validatePath must be an app-relative path like /dashboard.",{hint:"Pass a path on your own app, not a full URL."})}function be(e){console.error(e)}async function KE(e,t){if(e.length===0||t.networkPolicy===!1)return[];be("These provider hosts will be added to the environment's trusted domains so the sandbox can follow the login redirect:");for(let o of e)be(` ${o}`);if(t.yes)return e;let r=(await ma("Add them? [Y/n] ")).toLowerCase();return r===""||r==="y"||r==="yes"?e:[]}async function JE(e,t,r){let n=(await P(e,A("/api/environments/:id",{id:t}))).data,i=n.provisioningConfig?.sandbox?.appRuntime??{};if(i.auth?.validatePath===r)return!1;let a={...n.provisioningConfig,sandbox:{...n.provisioningConfig?.sandbox,appRuntime:{...i,auth:{...i.auth,validatePath:r}}}};return await P(e,A("/api/environments/:id",{id:n.id}),{method:"PUT",body:JSON.stringify({name:n.name,description:n.description,provisioningKind:n.provisioningKind,provisioningConfig:a,cache:n.cache,repos:n.repos,networkPolicy:n.networkPolicy,...n.reviewConfig!==void 0?{reviewConfig:n.reviewConfig}:{}})}),!0}async function s_(e,t={},r){let{config:o}=Q(r,t);t.clear||(HE(),t.validatePath&&a_(t.validatePath));let n=await Zr(o,e),i=j(n.name),a=A("/api/environments/:id/browser-state",{id:n.id});if(t.clear){let k=await P(o,a,{method:"DELETE"});C(r,t,{environmentId:n.id,deleted:k.data.deleted},({deleted:R})=>console.log(R?`Browser login removed from "${i}".`:`"${i}" had no browser login.`));return}let{origin:s,startUrl:u,appRuntime:c}=qE(n);be(`Environment: ${i} (${j(n.id)})`),be(`Sandbox app origin: ${s}`),be(""),be("Opening a fresh Chrome window. Log into your app and every provider it uses (Auth0, Google, ...)"),be("using dedicated TEST accounts only. Do not use personal, admin, or billing accounts."),be(`If your app is running locally, open it at ${s} so the saved login matches the sandbox.`),be("Press Enter here when you are done. Keep the window open until you press Enter.");let l=await Xv({startUrl:t.url??u,waitForDone:async k=>{await ma("",{signal:k})},onStatus:be}),{normalized:d,counts:f,bytes:m}=WE(l.rawState,s),g=Yv(l.navigations);be(""),be(`Captured browser state: ${f.cookieDomainCount} cookie domains, ${f.storageOriginCount} storage origins, ${Math.round(m/1024)} KB`);let h=await KE(g,t),b=await P(o,a,{method:"PUT",body:JSON.stringify({state:JSON.stringify(d),providerHosts:h})}),$=t.validatePath??c.auth?.validatePath;$||(be(""),be("This environment has no auth.validatePath. Enter a page only a signed-in user can see, so Arcanist can verify the login on every session:"),$=await ma("> ")||void 0),$&&$!==c.auth?.validatePath&&(a_($),await JE(o,n.id,$)&&be("Environment rebuild scheduled (the app runtime profile changed)."));let{networkPolicy:I}=b.data;C(r,t,{environmentId:n.id,version:b.data.browserState.version,counts:f,providerHosts:h,networkPolicy:I,validatePath:$??null},()=>{console.log(`Saved. Environment "${i}" now has browser login v${b.data.browserState.version}.`),I.added.length>0&&console.log(`Trusted domains added: ${I.added.map(j).join(", ")}`),I.rejected.length>0&&console.log(`Not added (fix on the Environment page): ${I.rejected.map(j).join(", ")}`),I.skipped&&console.log("Network policy is full access; nothing to add."),g.length>0&&h.length===0&&console.log("Provider hosts were not added; verification reports unavailable until they are on the trusted domains."),$||console.log("No validatePath saved; Arcanist cannot verify this login until one is set on the Environment page or with --validate-path.")})}import{readFile as lk,writeFile as dk}from"node:fs/promises";var u_=p.object({id:p.string().regex(/^[a-z0-9-]+(?:\/[a-z0-9-]+)*$/).max(120),scope:p.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/)}).strict(),c_=p.array(u_).max(8).superRefine((e,t)=>{let r=e.map(({id:o,scope:n})=>`${o}:${n}`);new Set(r).size!==r.length&&t.addIssue({code:"custom",message:"Duplicate fixture binding"})}),wz=p.object({id:p.string(),scope:p.string(),version:p.number().int().positive(),description:p.string().max(2e3),coverage:p.array(p.string().max(2e3)).max(40),limitations:p.array(p.string().max(2e3)).max(40),status:p.enum(["ready","absent","incomplete"]),missing:p.array(p.string().max(500)).max(200),parameters:p.record(p.string(),p.unknown()),outputs:p.record(p.string(),p.unknown())}).strict(),xz=u_.extend({version:p.number().int().positive(),status:p.literal("instructions"),path:p.string().min(1).max(2e3),instructions:p.string().min(1).max(24e3)}).strict();function bp(e){return new TextEncoder().encode(e).byteLength}var l_=128*1024,d_=512*1024,p_=64,m_=p.string().max(240).regex(/^[a-zA-Z0-9_-][a-zA-Z0-9_.-]*(\/[a-zA-Z0-9_-][a-zA-Z0-9_.-]*)*$/,"Use a relative file path such as db/restore.py; absolute paths and dot segments are not allowed"),f_=p.string().refine(e=>bp(e)<=l_&&!e.includes("\0"),`File contents must be text without null bytes, at most ${l_} UTF-8 bytes`),Tz=p.record(m_,f_.nullable()),Sp=p.record(m_,f_).superRefine((e,t)=>{let r=Object.keys(e);(r.length>p_||Object.values(e).reduce((o,n)=>o+bp(n),0)>d_)&&t.addIssue({code:"custom",message:`Save at most ${p_} helper files totaling ${d_} UTF-8 bytes`});for(let o of r){let n=o.split("/");for(let i=1;i<n.length;i++)Object.prototype.hasOwnProperty.call(e,n.slice(0,i).join("/"))&&t.addIssue({code:"custom",message:`File ${o} has a parent that is also a file`})}});var fa=/^[A-Za-z_][A-Za-z0-9_]*$/;var YE=12,XE=10;var QE=p.object({name:p.string().regex(fa).max(128),description:p.string().trim().min(1).max(300),values:p.array(p.string().min(1).max(200)).min(2).max(XE).describe("Public non-secret setting values. Sent to QA models and shown in GitHub results.").optional()}).strict(),g_=p.array(QE).max(YE);var Fr={Compose:"compose",Command:"command"};var h_=8,ek=64,__=/^\/workspace\/(?!\.+$)(?!.*\.\.)[A-Za-z0-9._-]+$/,tk=p.object({repoOwner:p.string().trim().min(1,"repoOwner is required"),repoName:p.string().trim().min(1,"repoName is required"),sandboxPath:p.string().regex(__,"sandboxPath must be a single path segment under /workspace").optional()}).strict();function nk(e){return e.sandboxPath??`/workspace/${e.repoName}`}var Vz=p.array(tk).min(1,"at least one repo is required").max(h_,`at most ${h_} repos are allowed`).superRefine((e,t)=>{if(e.length===0)return;let r=e[0].repoOwner.toLowerCase();e[0].sandboxPath!==void 0&&t.addIssue({code:"custom",path:[0,"sandboxPath"],message:`the primary repo is always cloned to /workspace/${e[0].repoName}`});let o=new Set,n=new Set;e.forEach((i,a)=>{i.repoOwner.toLowerCase()!==r&&t.addIssue({code:"custom",path:[a,"repoOwner"],message:"all repos must share the primary repo's owner"});let s=`${i.repoOwner}/${i.repoName}`.toLowerCase();o.has(s)&&t.addIssue({code:"custom",path:[a],message:`duplicate repo ${i.repoOwner}/${i.repoName}`}),o.add(s);let u=nk(i);if(!__.test(u)){t.addIssue({code:"custom",path:[a],message:`repo name ${i.repoName} needs an explicit sandboxPath`});return}n.has(u)&&t.addIssue({code:"custom",path:[a],message:`sandbox path ${u} is already taken`}),n.add(u)})}),v_=p.object({name:p.string(),envVar:p.string(),source:p.enum(["business_openai_key","business_anthropic_key"]).optional()}),Br=p.record(p.string().regex(fa,"must be a POSIX-style environment variable name"),p.string()),y_=p.object({type:p.enum([Fr.Compose]),files:p.array(p.string()).optional(),service:p.string().optional(),profiles:p.array(p.string()).optional()}).strict(),wp=p.object({fixtures:c_.optional(),cwd:p.string().optional(),bootScript:p.string().max(65536).describe("Optional bash bringup script. When set it overrides the entry: arcanist-app start runs it on the sandbox host from cwd with runtimeVariables plus HOST and PORT, and waits on ready.path. The app must listen on url.hostPort. Leave unset to boot from the entry.").optional(),kind:p.string().optional(),runner:p.string().optional(),entry:y_.optional(),url:p.object({hostPort:p.number().int().optional(),path:p.string().optional()}).strict().optional(),portMapping:p.object({containerPort:p.number().int().optional()}).strict().optional(),additionalPorts:p.array(p.object({service:p.string().optional(),hostPort:p.number().int().optional(),containerPort:p.number().int().optional()}).strict()).optional(),runtimeVariables:Br.optional(),composeEnv:Br.optional(),generatedComposeEnv:p.record(p.string(),p.union([p.object({type:p.literal("alphanumeric"),length:p.number().int()}).strict(),p.object({type:p.literal("hex"),bytes:p.number().int()}).strict()])).optional(),env:Br.optional(),ready:p.object({path:p.string().optional(),nonEmptyPath:p.string().optional(),timeoutSeconds:p.number().int().optional()}).strict().optional(),open:p.object({path:p.string().optional()}).strict().optional(),renderedPathPrefixes:p.array(p.string().max(512)).max(ek).describe("Repo-relative directories the booted app is built from. When set, a review boots the app only when the diff touches a non-test file under one of them; when unset, the file-extension heuristic decides.").optional(),auth:p.object({command:p.string().optional(),validatePath:p.string().optional(),browserStateEnvVar:p.string().optional(),credentials:p.array(v_).optional()}).strict().optional(),e2e:p.object({testCommand:p.string(),seedCommand:p.string().optional(),resetCommand:p.string().optional(),credentials:p.array(v_).optional()}).strict().optional(),qaSwitches:g_.describe("Runtime variables QA may switch, each with the only values it may take (default true/false). A QA run restarts the app with the chosen values so a flag-gated change can be tested on and off.").optional()}).strict(),rk="dockerfile",ik=p.union([p.object({type:p.literal(Fr.Command),command:p.string().optional()}).passthrough(),p.object({type:p.literal(rk),context:p.string().optional(),dockerfile:p.string().optional(),service:p.string().optional()}).passthrough()]),b_=wp.extend({entry:p.union([y_,ik]).optional()}),ok=/^[a-z][a-z0-9-]*$/;var S_=p.object({id:p.string().trim().min(1).regex(ok),description:p.string().trim().min(1),config:wp}).strict(),ak=S_.extend({config:b_}),sk=p.array(S_).superRefine((e,t)=>{new Set(e.map(r=>r.id)).size!==e.length&&t.addIssue({code:"custom",message:"App runtime names must be unique"})}),Gz=p.object({sandbox:p.object({appRuntime:wp.optional(),appRuntimes:sk.optional(),helperFiles:Sp.optional(),runtimeVariables:Br.optional()}).strict().refine(e=>e.appRuntime===void 0||e.appRuntimes===void 0,{message:"Supply appRuntimes or legacy appRuntime, not both"}).optional()}).strict(),qz=p.object({sandbox:p.object({appRuntime:b_.optional(),appRuntimes:p.array(ak).optional(),helperFiles:Sp.optional(),runtimeVariables:Br.optional()}).strict().optional()}).strict();function xp(e){if(!e)return null;let t=e.entry;if(t===void 0||t.type===Fr.Compose)return e;let{entry:r,...o}=e,n=t.type===Fr.Command?t.command?.trim():void 0,i=e.bootScript?.trim()?e.bootScript:n||e.bootScript;return{...o,...i!==void 0?{bootScript:i}:{}}}var ga=1,uk=["name","description","provisioningKind","provisioningConfig","helperFiles","cache","networkPolicy"];function ck(e){let t=e?.sandbox;if(!t)return e;let{appRuntime:r,appRuntimes:o,...n}=t;return{...e,sandbox:{...n,...r?{appRuntime:xp(r)}:{},...o?{appRuntimes:o.map(i=>({...i,config:xp(i.config)}))}:{}}}}function ha(e){let{status:t,setupScript:r,maintenanceScript:o,smokeTestScript:n,dependencies:i,cpuCount:a,memoryMB:s}=e.cache;return{name:e.name,description:e.description,provisioningKind:e.provisioningKind,provisioningConfig:ck(e.provisioningConfig),...e.helperFiles!==void 0?{helperFiles:e.helperFiles}:{},cache:{status:t,setupScript:r,maintenanceScript:o,smokeTestScript:n,dependencies:i,cpuCount:a,memoryMB:s},networkPolicy:e.networkPolicy}}function w_(e){return JSON.stringify(e,(t,r)=>r&&typeof r=="object"&&!Array.isArray(r)?Object.fromEntries(Object.entries(r).sort(([o],[n])=>o.localeCompare(n))):r)}function x_(e,t){let r={...ha(e),repos:e.repos},o={...t.environment,repos:t.repos};return[...uk,"repos"].filter(n=>w_(r[n]??null)!==w_(o[n]??null))}function $_(e,t){let r=ha(e).helperFiles??{},o=t.environment.helperFiles??{},i=[...new Set([...Object.keys(r),...Object.keys(o)])].filter(a=>(r[a]??null)!==(o[a]??null)).sort();return i.length>0?i:void 0}async function I_(e,t){return(await P(e,A("/api/environments/:id",{id:t}))).data}function pk(e,t){let r;try{r=JSON.parse(e)}catch{throw new y("user",`${t} is not valid JSON.`)}let o=r;if(!o||o.version!==ga||!o.environment||typeof o.environment.name!="string"||!o.environment.cache||!Array.isArray(o.repos)||o.repos.length===0)throw new y("user",`${t} is not an Environment export (version ${ga}).`,{hint:"Write one with `arcanist environments export owner/repo -o <file>`."});return o}async function E_(e,t={},r){let{config:o}=Q(r,t),n=await Zr(o,e),i=await I_(o,n.id),a={version:ga,exportedFrom:{apiUrl:o.apiUrl,environmentId:i.id,configurationGeneration:i.cache.configurationGeneration,exportedAt:new Date().toISOString()},repos:i.repos,environment:ha(i)},s=`${JSON.stringify(a,null,2)}
74
74
  `;if(t.output){await dk(t.output,s,"utf8"),C(r,t,{environmentId:i.id,name:i.name,configurationGeneration:i.cache.configurationGeneration,path:t.output},u=>{console.log(`Exported "${j(u.name)}" (generation ${u.configurationGeneration}) to ${u.path}`)});return}process.stdout.write(s)}async function mk(e,t,r,o){let n=t.repos[0],i=`${n.repoOwner}/${n.repoName}`,{name:a}=t.environment;if(r.dryRun){C(o,r,{environmentId:null,name:a,created:!1,applied:!1},u=>{console.log(`Would create "${j(u.name)}" for ${i} (dry run; nothing was sent).`)});return}let s=await P(e,A("/api/environments"),{method:"POST",body:JSON.stringify({...t.environment,repos:t.repos,scope:"team"})});C(o,r,{environmentId:s.data.id,name:s.data.name,created:!0,applied:!0,configurationGeneration:{after:s.data.cache.configurationGeneration},buildScheduled:s.data.cache.status==="enabled"},u=>{console.log(`Created "${j(u.name)}" for ${i} (${u.environmentId}).`),u.buildScheduled&&console.log("A build is scheduled; watch it with `arcanist environments status --wait`.")})}async function k_(e,t,r={},o){let n=pk(await lk(e,"utf8"),e),{config:i}=Q(o,r),a=n.repos[0],s=t===void 0?await o_(i,{owner:a.repoOwner,repo:a.repoName}):await Zr(i,t);if(!s){if(!r.create)throw new y("user",`No team environment for ${a.repoOwner}/${a.repoName}.`,{hint:"Pass --create to create it from this file."});await mk(i,n,r,o);return}let u=await I_(i,s.id),c=u.repos[0]??{repoOwner:u.repoOwner,repoName:u.repoName};if(c.repoOwner.toLowerCase()!==a.repoOwner.toLowerCase()||c.repoName.toLowerCase()!==a.repoName.toLowerCase())throw new y("user",`${e} was exported for ${a.repoOwner}/${a.repoName}, but the target environment's primary repository is ${c.repoOwner}/${c.repoName}.`,{hint:"An Environment's primary repository cannot change; export from a matching repository."});let l=x_(u,n),d=$_(u,n),f={environmentId:u.id,name:u.name,changedFields:l,...d?{driftedHelperFilePaths:d}:{},configurationGeneration:{before:u.cache.configurationGeneration}};if(r.dryRun&&l.length>0&&await P(i,`${A("/api/environments/:id",{id:u.id})}?dryRun=1`,{method:"PUT",body:JSON.stringify({...n.environment,repos:n.repos})}),r.dryRun||l.length===0){C(o,r,{...f,applied:!1},h=>{console.log(h.changedFields.length===0?`"${j(h.name)}" already matches ${e}; nothing to apply.`:`Would change ${h.changedFields.join(", ")} on "${j(h.name)}" (dry run).`)});return}let m=await P(i,A("/api/environments/:id",{id:u.id}),{method:"PUT",body:JSON.stringify({...n.environment,repos:n.repos})}),g=m.data.cache.configurationGeneration;C(o,r,{...f,applied:!0,configurationGeneration:{before:u.cache.configurationGeneration,after:g},rebuildScheduled:g!==u.cache.configurationGeneration&&m.data.cache.status==="enabled"},h=>{console.log(`Applied ${h.changedFields.join(", ")} to "${j(h.name)}" (generation ${h.configurationGeneration.before} -> ${h.configurationGeneration.after}).`),h.rebuildScheduled&&console.log("A rebuild is scheduled; watch it with `arcanist environments status --wait`.")})}var va=class{static register(t){for(let r of["soft-delete","restore"])t.command(r).description(`${r==="restore"?"Restore":"Hide"} an environment while retaining its records (operator only)`).argument("<environment-id>","Exact environment UUID").requiredOption("--business-id <id>","Workspace owning the environment").requiredOption("--reason <text>","Audit reason").option("--confirm","Confirm the visibility change").action(async(o,n,i)=>{if(!n.confirm)throw new y("user","Pass --confirm to change environment visibility.");if(!n.reason.trim())throw new y("user","An audit reason is required.");let a=J(V(i,n)),s=await P(a,A("/api/admin/console/businesses/:businessId/environments/:id/visibility",{businessId:n.businessId,id:o}),{method:"PATCH",body:JSON.stringify({deleted:r==="soft-delete",reason:n.reason})});C(i,n,s,()=>process.stdout.write(`Environment ${o} ${r==="restore"?"restored":"soft-deleted"}.
@@ -172,10 +172,10 @@ written to your default ~/.codex.
172
172
  Examples:
173
173
  arcanist codex login
174
174
  arcanist codex login --codex-path /usr/local/bin/codex
175
- `).action((e,t)=>Bv(e,t));Qp.command("use <state>").description("Turn using your saved Codex subscription auth for OpenAI sessions on or off (state: on|off)").action((e,t,r)=>Vv(e,t,r));Qp.command("status").description("Show Codex subscription availability and whether auth is saved").action((e,t)=>Gv(e,t));var Nn=le.command("sessions").description("Session commands"),Dn=le.command("reviews").description("Read review results and manage QA recovery probes");Dn.command("recovery-probe").description("Arm, inspect, or clear finite faults on your disposable QA review").argument("<request-id>","Admitted QA review request ID").option("--fault <fault>","planner-receipt, scouts-receipt, generation-retries, or publication-effects").option("--clear","Remove the fault control after evidence capture").addHelpText("after",`
175
+ `).action((e,t)=>Bv(e,t));Qp.command("use <state>").description("Turn using your saved Codex subscription auth for OpenAI sessions on or off (state: on|off)").action((e,t,r)=>Vv(e,t,r));Qp.command("status").description("Show Codex subscription availability and whether auth is saved").action((e,t)=>Gv(e,t));var Nn=le.command("sessions").description("Session commands"),Dn=le.command("reviews").description("Read review results and manage QA recovery probes");Dn.command("recovery-probe").description("Arm, inspect, or clear finite faults on your disposable QA review").argument("<request-id>","Admitted QA review request ID").option("--fault <fault>","planner-receipt, scouts-receipt, generation-retries, generation-exhaustion, or publication-effects").option("--clear","Remove the fault control after evidence capture").addHelpText("after",`
176
176
  QA only. Requires your first active review of an open [TESTING] PR on a prod-qa branch in tryarcanist/arcanist.
177
177
  No fault flag reads receipts. Receipt faults fail once after a durable stage write.
178
- Generation and publication faults fail one more attempt than the existing retry limit, then stop.
178
+ Generation-retries fails one attempt fewer than the generation limit so the next attempt recovers; generation-exhaustion fails every attempt in the limit so the request blocks. Publication faults fail one more attempt than the existing retry limit, then stop.
179
179
  This command does not start a review, replace a sandbox, or prove recovery by itself.
180
180
  Save the receipts and verify the final request/head publication before --clear and fixture cleanup.
181
181
  `).action((e,t,r)=>fy(e,t,r));Dn.command("export-traces").description("Export production planner archives, question links, and checksums (internal)").requiredOption("--spans <file>","Archived span JSONL for the export window").option("--eval-dir <directory>","Optional private eval checkout for local holdout filtering; otherwise the consumer owns the split").requiredOption("--out <directory>","New output directory").action((e,t)=>wb(e,t));Dn.command("compare").description("Compare automatic QA Arcanist and Macroscope latency on the same trigger and head (Arcanist members only)").argument("<pr-url>","Internal GitHub PR URL").requiredOption("--head <sha>","Exact reviewed head SHA").action((e,t,r)=>ly(e,t,r));Dn.command("traces").description("List full planner trace parts or download observed events (Arcanist members only)").argument("<session-id>","Review session ID").argument("[trace-id]","Trace ID from fullTraceId metadata or the index").option("--out <file.jsonl>","Create a private JSONL file; fails if the file exists or the archive is incomplete").action((e,t,r,o)=>my(e,t,r,o));Dn.command("get").description("Read a PR request result and lifecycle snapshot without a new review").argument("<request-id>","PR review request ID, not a local review request ID").addHelpText("after",`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryarcanist/cli",
3
- "version": "0.1.393",
3
+ "version": "0.1.395",
4
4
  "description": "Command-line interface for Arcanist: inspect sessions, prepare Arcanist environments, and trigger reviews",
5
5
  "type": "module",
6
6
  "bin": {