omo-ai 5.1.12 → 5.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/lib/child-process.js +2 -2
- package/bin/lib/daemon-adopt.js +125 -0
- package/bin/lib/daemon-args.js +2 -32
- package/bin/lib/daemon-operations.js +10 -2
- package/bin/lib/daemon-status.js +21 -2
- package/bin/lib/daemon.js +32 -33
- package/bin/lib/host-status.js +59 -0
- package/bin/lib/launcher.js +31 -8
- package/bin/lib/provider-map.json +1 -1
- package/bin/lib/thread-args.js +54 -0
- package/bin/lib/thread-output.js +40 -0
- package/bin/lib/thread.js +257 -0
- package/package.json +2 -2
- package/plugin/CHANGELOG.md +48 -0
- package/plugin/extensions/gateway-store-worker.mjs +2 -0
- package/plugin/extensions/memory-run-supervisor.mjs +1 -1
- package/plugin/extensions/omo-computer-use.js +1 -1
- package/plugin/extensions/omo-init-deep-advisor.js +1 -1
- package/plugin/extensions/omo-member.js +1 -1
- package/plugin/extensions/omo-task.js +2 -2
- package/plugin/extensions/omo.js +2 -2
- package/plugin/package.json +1 -1
- package/plugin/runtime/agent-toolkit-sdk/sdk.js +2 -2
- package/plugin/runtime/ast-grep-mcp/manifest.json +1 -1
- package/plugin/runtime/rollback-migrate.js +1 -1
- package/plugin/runtime/thread-sdk/sdk.js +2 -0
- package/plugin/scripts/install.mjs +2 -0
- package/plugin/skills/browser/runtime/omowright/manifest.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// omo:
|
|
1
|
+
// omo:V9j-yx6S6AwkMmXva7PKiG7pu5aws_ZkVfgVMrzIdYc:ProvlAjIupHz7t0sNOVl1ahnmlhkaklUqo-YGYF86Ek
|
|
2
2
|
import{readFileSync as e}from"node:fs";import{mkdirSync as t,readdirSync as n,readFileSync as r,renameSync as i,rmSync as o,statSync as a}from"node:fs";import{join as s}from"node:path";var u=["complete","partial","unavailable"],l=["reported","unavailable","invalid"],c=["monotonic","wall_clock","unavailable"],d=["pending","running","completed","error","cancelled","interrupted","lost"],f=["resident","evicted","disposed","persisted_only","rpc_detached"],p=["category","explicit","agent"],h=["foreground","background","promoted"],m=["child-process","host-session"],_=["daemon_unavailable","handoff_parked","host_draining","host_incompatible","idle_evicted","own_host_unreachable","store_index_unavailable"],v=/^st_[0-9a-f]{8}$/;function y(e){if(!function(e){return v.test(e)}(e))throw Error("Invalid task id; expected st_[0-9a-f]{8}");return e}var g=new Set(["completed","error","cancelled","interrupted","lost"]),b=new Set(["evict","dispose","persist_only","detach_rpc","mark_resident"]);function w(e,t){let n=function(e,t){switch(e.type){case"start":return"running";case"complete":return"completed";case"fail":return"error";case"cancel":return"cancelled";case"interrupt":return"interrupted";case"lose":return"lost";case"evict":case"dispose":case"persist_only":case"detach_rpc":case"mark_resident":return t;default:return z(e)}}(t,e.status),r=b.has(t.type);if(g.has(e.status)&&!r)return{applied:!1,record:e,audit:{type:"late_transition_ignored",attempted_status:n,current_status:e.status}};if(!function(e,t){switch(t.type){case"start":return"pending"===e;case"cancel":return"running"===e||"pending"===e;case"complete":case"fail":case"interrupt":return"running"===e;case"lose":return!1;case"evict":case"dispose":case"persist_only":case"detach_rpc":case"mark_resident":return!0;default:return z(t)}}(e.status,t))return{applied:!1,record:e,audit:{type:"invalid_transition_ignored",attempted_status:n,current_status:e.status}};let i=function(e,t){switch(e.type){case"evict":return"evicted";case"dispose":return"disposed";case"persist_only":return"persisted_only";case"detach_rpc":return"rpc_detached";case"mark_resident":return"resident";case"start":case"complete":case"fail":case"cancel":case"interrupt":case"lose":return t;default:return z(e)}}(t,e.residency_state),o=function(e,t){switch(t.type){case"start":return{...e,started_at:t.timestamp,...void 0===t.pid?{}:{pid:t.pid},...void 0===t.child_session_id?{}:{child_session_id:t.child_session_id}};case"complete":return{...e,final_response:t.final_response,...k(t.run_stats)};case"fail":{let{failure_kind:n,failure_reason:r,...i}=e;return{...i,error_message:t.error_message,...void 0===t.failure_kind?{}:{failure_kind:t.failure_kind},...void 0===t.failure_reason?{}:{failure_reason:t.failure_reason},...!0===t.killed?{killed:!0}:{},...k(t.run_stats)}}case"lose":return{...e,error_message:t.error_message};case"cancel":case"interrupt":return{...e,...void 0===t.error_message?{}:{error_message:t.error_message},...k(t.run_stats)};case"persist_only":{let{host_pid:t,pid:n,...r}=e;return r}case"detach_rpc":{let{host_pid:t,...n}=e;return n}case"evict":case"dispose":case"mark_resident":return e;default:return z(t)}}(e,t),a=g.has(n)&&!g.has(e.status),s={...o,status:n,residency_state:i,updated_at:t.timestamp,...a?{terminal_at:t.timestamp}:{}};return{applied:!0,record:s,audit:{type:"transition_applied",status:s.status,residency_state:s.residency_state}}}function k(e){return void 0===e?{}:{run_stats:e}}function z(e){throw Error(`Unexpected task transition: ${JSON.stringify(e)}`)}var $=new Set(["model_not_in_child_profile","catalog_probe_timed_out","catalog_probe_failed","protocol","capability","engine_mismatch","engine_refused","win32","runtime","host_unreachable","ensure_failed","ensure_timed_out","shard_socket_too_long","shard_alt_root_unsafe","legacy_host","host_incompatible","store_index_unavailable","own_host_unreachable","shard_identity_missing","host_busy","launch_spec_insecure","open_timed_out","session_path_in_use","session_reservation_limit","invalid_path","open_failed","invalid_session_context","invalid_session_kind","invalid_launch_profile","invalid_session_id","session_id_in_use","host_memory_pressure","host_draining"]),E=new Set(["child-prompt-failed","child-turn-failed","session-create-failed","depth-exceeded","model_unavailable","tools_unavailable","session_unavailable","host_unavailable"]);import{closeSync as O,mkdirSync as S,openSync as x,writeSync as j}from"node:fs";import{join as I}from"node:path";var N=/token|password|secret|authorization|api[_-]?key/i;function T(e){if(Array.isArray(e))return e.map(e=>T(e));if(!function(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}(e))return e;let t={};for(let[n,r]of Object.entries(e))t[n]=N.test(n)?"[REDACTED]":T(r);return t}function P(e,t){return I(e,"logs",`${t}.jsonl`)}function A(e,t,n,r){S(I(e,"logs"),{recursive:!0});let i=P(e,t),o=`${JSON.stringify({type:n.type,payload:T(n.payload)})}\n`;return j(function(e,t){let n=t.get(e);if(void 0!==n)return t.delete(e),t.set(e,n),n;let r=x(e,"a");if(t.set(e,r),t.size>16){let e=t.entries().next().value;t.delete(e[0]),O(e[1])}return r}(i,r),o),i}import{existsSync as Z,readFileSync as R,renameSync as F,rmSync as D,writeFileSync as M}from"node:fs";import{randomUUID as C}from"node:crypto";import{closeSync as J,linkSync as U,mkdirSync as L,openSync as q,readFileSync as B,renameSync as W,rmSync as V,statSync as K,utimesSync as G,writeSync as X}from"node:fs";import{dirname as Y}from"node:path";import{readFileSync as H}from"node:fs";import{createRequire as Q}from"node:module";import{hostname as ee}from"node:os";var te="unavailable";var ne,re=function(e,t){let n,r=0,i=1e3;return()=>{if(void 0!==n)return n;let o=t();if(o<r)return te;let a=e();return null!==a?(n=a,a):(r=o+i,i=Math.min(2*i,6e4),te)}}(()=>ae(process.pid),Date.now);function ie(e){let t=e.split("\n"),[n,r,i,o,a]=t;if(void 0!==n&&/^[1-9]\d*$/.test(n)&&void 0!==r&&/^\d+$/.test(r)&&void 0!==i&&0!==i.length){if(4===t.length&&""===t[3])return{pid:Number(n),startIdentity:te,hostname:void 0,token:i};if(void 0!==o&&0!==o.length&&void 0!==a&&0!==a.length)return{pid:Number(n),startIdentity:o,hostname:a,token:i}}}function oe(e){if(void 0!==e.hostname&&e.hostname!==ee())return!1;let t=function(e){try{return process.kill(e,0),"alive"}catch(e){let t=e instanceof Error&&"code"in e?e.code:void 0;return"ESRCH"===t?"dead":"EPERM"===t?"alive":"unknown"}}(e.pid);if("dead"===t)return!0;if("unknown"===t||e.startIdentity===te)return!1;let n=ae(e.pid);return null!==n&&function(e,t){let n=e=>e.slice(0,Math.max(0,e.indexOf(":"))),r=n(e);return r.length>0&&r===n(t)&&e!==t}(e.startIdentity,n)}function ae(e){if(!Number.isSafeInteger(e)||e<=0)return null;switch(process.platform){case"linux":return function(e){try{let t=H(`/proc/${e}/stat`,"utf8"),n=t.slice(t.lastIndexOf(")")+2).trim().split(/\s+/)[19];return void 0===n?null:`linux-proc-start-ticks:${n}`}catch{return null}}(e);case"darwin":return function(e){if(void 0===ue){let e=se();try{let t=e?.dlopen("/usr/lib/libSystem.B.dylib",{proc_pidinfo:{args:["i32","i32","u64","ptr","i32"],returns:"i32"}});ue=void 0===t?null:(e,n)=>Number(t.symbols.proc_pidinfo(e,le,0n,n,ce))}catch{ue=null}}if(null===ue)return null;let t=new Uint8Array(ce);if(ue(e,t)!==ce)return null;let n=new DataView(t.buffer).getBigUint64(de,!0);return n>0n?`proc-start-epoch:${n}`:null}(e);case"win32":return function(e){if(void 0===fe)try{fe=se()?.dlopen("kernel32.dll",{OpenProcess:{args:["u32","i32","u32"],returns:"ptr"},GetProcessTimes:{args:["ptr","ptr","ptr","ptr","ptr"],returns:"i32"},CloseHandle:{args:["ptr"],returns:"i32"}}).symbols??null}catch{fe=null}if(null===fe)return null;let t=fe.OpenProcess(pe,0,e);if(null===t||0===t||0n===t)return null;try{let e=new BigUint64Array(1),n=fe.GetProcessTimes(t,e,new BigUint64Array(1),new BigUint64Array(1),new BigUint64Array(1)),r=e[0]??0n;return 0===n||0n===r?null:`win32-creation-filetime:${r}`}finally{fe.CloseHandle(t)}}(e);default:return null}}function se(){if(void 0!==ne)return ne;try{ne=void 0===process.versions.bun?null:Q(import.meta.url)("bun:ffi")}catch{ne=null}return ne}var ue,le=3,ce=136,de=120;var fe,pe=4096;var he,me="delete-pending",_e=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));function ve(e,t,n={}){let r=`${e}.lock`;L(Y(r),{recursive:!0});let i=function(e,t){let n=ge(e,t);for(;;){let t=be(e);if("retry"!==t){if("acquired"in t)return t.acquired;n(t.held),Atomics.wait(_e,0,0,10)}}}(r,n.holderWaitMs??1e3);try{return t()}finally{Ee(r,i)}}async function ye(e,t,n={}){let r=`${e}.lock`;L(Y(r),{recursive:!0});let i=await async function(e,t){let n=ge(e,t);for(;;){let t=be(e);if("retry"!==t){if("acquired"in t)return t.acquired;n(t.held),await new Promise(e=>setTimeout(e,10))}}}(r,n.holderWaitMs??1e3),o=setInterval(()=>function(e){let t=new Date;try{G(e,t,t)}catch(e){xe(e,"ENOENT")||console.error("Task record lock heartbeat failed",e)}}(r),2500);o.unref();try{return await t()}finally{clearInterval(o),Ee(r,i)}}function ge(e,t){let n,r=0;return i=>{let o=Date.now();if(i!==n)return n=i,void(r=o);if(o-r>=t)throw Error(`Timed out acquiring task record lock: ${e} (${function(e){if(e===me)return"a delete-pending lock file";let t=ie(e.split(":").slice(2).join(":"));return void 0===t?"a lock with no parseable owner":`held by pid ${t.pid}`}(i)} for ${o-r}ms)`)}}function be(e){let t=C();return we(e,t)?{acquired:t}:function(e){let t=ze(e);if(void 0===t)return"retry";if(t===me)return{held:me};let n={held:`${t.dev}:${t.ino}:${t.body}`};if(!ke(t))return n;let r=`${e}.recovery`,i=C();if(!(we(r,i)||function(e){let t=ze(e);if(void 0===t)return!0;if(t===me||!ke(t))return!1;let n=`${e}.reaping-${C()}`;try{W(e,n)}catch(e){if(xe(e,"ENOENT"))return!0;if(Se(e))return!1;throw e}let r=ze(n),i=void 0===r||r===me||$e(r,t);if(!i)try{U(n,e)}catch(e){if(!xe(e,"EEXIST"))throw e}return V(n,{force:!0}),i}(r)&&we(r,i)))return n;try{he?.("recovery_held",e);let o=ze(e);return o===me?{held:me}:void 0!==o&&$e(o,t)?(he?.("judged_unchanged",e),Oe(r)!==i?n:function(e){for(let t=1;;t+=1)try{return V(e,{force:!0}),!0}catch(e){if(!xe(e,"EPERM")&&!xe(e,"EBUSY"))throw e;if(3===t)return!1;Atomics.wait(_e,0,0,25)}}(e)?"retry":n):"retry"}finally{Ee(r,i)}}(e)}function we(e,t){let n;try{n=q(e,"wx")}catch(t){if(xe(t,"EEXIST"))return!1;if(Se(t)&&function(e){try{return K(e),!0}catch(e){return Se(e)}}(e))return!1;throw t}try{X(n,function(e){return`${process.pid}\n${Date.now()}\n${e}\n${re()}\n${ee()}\n`}(t))}finally{J(n)}return!0}function ke(e){let t=ie(e.body);return void 0===t?Date.now()-e.mtimeMs>5e3:oe(t)}function ze(e){try{let t=K(e);return{dev:t.dev,ino:t.ino,mtimeMs:t.mtimeMs,body:B(e,"utf8")}}catch(e){if(xe(e,"ENOENT"))return;if(Se(e))return me;throw e}}function $e(e,t){return e.dev===t.dev&&e.ino===t.ino&&e.mtimeMs===t.mtimeMs&&e.body===t.body}function Ee(e,t){Oe(e)===t&&V(e,{force:!0})}function Oe(e){try{return B(e,"utf8").split("\n")[2]}catch(e){if(xe(e,"ENOENT"))return;throw e}}function Se(e){return"win32"===process.platform&&["EBUSY","EPERM","EACCES"].some(t=>xe(e,t))}function xe(e,t){return e instanceof Error&&"code"in e&&e.code===t}function je(e){return`${e}.owner`}function Ie(e){return`${je(e)}.tmp`}function Ne(e,t){M(Ie(e),JSON.stringify(t)),F(Ie(e),je(e))}function Te(e){D(je(e),{force:!0}),D(Ie(e),{force:!0})}function Pe(e){let t,n=je(e);if(!Z(n))return;try{t=JSON.parse(R(n,"utf8"))}catch(e){if(e instanceof SyntaxError)return;throw e}if("object"!=typeof t||null===t)return;let{pid:r,token:i}=t;return"number"==typeof r&&"string"==typeof i?{pid:r,token:i}:void 0}function Ae(e,t){return void 0!==e&&void 0!==t&&e.pid===t.pid&&e.token===t.token}function Ze(e,t){let n=e[t];if("string"!=typeof n)throw Error(`${t} is not a string`);return n}function Re(e,t){let n=e[t];if("number"!=typeof n)throw Error(`${t} is not a number`);return n}function Fe(e,t){let n=e[t];if(void 0!==n){if("string"!=typeof n)throw Error(`${t} is not a string`);return n}}function De(e,t){let n=e[t];if(void 0!==n){if("number"!=typeof n)throw Error(`${t} is not a number`);return n}}function Me(e,t){let n=e[t];if(void 0!==n){if("boolean"!=typeof n)throw Error(`${t} is not a boolean`);return n}}function Ce(e,t){let n=e[t];if(void 0!==n){if(!Array.isArray(n)||!n.every(e=>"string"==typeof e))throw Error(`${t} is not a string array`);return n}}function Je(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Ue(e){let t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function Le(e,t="|"){return e.map(e=>dt(e)).join(t)}function qe(e,t){return"bigint"==typeof t?t.toString():t}class Be{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return void 0!==e&&(this._value=e(),this._getter=void 0),this._value}}function We(e){return new Be(e)}function Ve(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Ke(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ge(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function Xe(e){return Ge(e._zod.def)??e._zod.def.shape}function Ye(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Ke(this,t,e),e},enumerable:!0,configurable:!0})}function He(e,t,n){t in e?Ke(e,t,n):e[t]=n}function Qe(e,t,n,r){let i=Xe(t);for(let o of n){let n=Object.getOwnPropertyDescriptor(i,o);n.enumerable&&(n.get?Ye(e,o,()=>{let e=t._zod.def.shape[o];return r?r(e,o):e}):He(e,o,r?r(n.value,o):n.value))}}function et(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function tt(e){return JSON.stringify(e)}var nt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function rt(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var it=We(()=>{if(Lt.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function ot(e){if(!1===rt(e))return!1;let t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;let n=t.prototype;return!1!==rt(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function at(e){return ot(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var st=new Set(["string","number","symbol"]);function ut(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lt(e,t,n){let r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function ct(e){let t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}function dt(e){return"bigint"==typeof e?e.toString()+"n":"string"==typeof e?`"${e}"`:`${e}`}var ft={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},pt={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function ht(e,t){let n=Xe(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function mt(e,t){let n={};return Qe(n,e,Reflect.ownKeys(Xe(e))),function(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Ye(e,n,()=>t[n]):He(e,n,r.value))}}(n,t),n}function _t(e,t,n,r="partial"){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let o=n?new Set(ht(t,n)):void 0,a={};return Qe(a,t,Reflect.ownKeys(Xe(t)),e&&((t,n)=>o&&!o.has(n)?t:new e({type:"optional",innerType:t}))),lt(t,et(t._zod.def,{shape:a,checks:[]}))}function vt(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function yt(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!1===e.issues[n]?.continue)return!0;return!1}function gt(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function bt(e){return"string"==typeof e?e:e?.message}function wt(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function kt(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has("$ZodType")&&(i.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let o=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,a=e.message?e.message:bt(e.inst?._zod.def?.error?.(e))??bt(o?.(e))??bt(t?.error?.(e))??bt(n.customError?.(e))??bt(n.localeError?.(e))??"Invalid input",s={};for(let t of Object.keys(e))"inst"!==t&&"schema"!==t&&"continue"!==t&&"input"!==t&&"__proto__"!==t&&(s[t]=e[t]);return s.path??(s.path=[]),s.message=a,t?.reportInput&&(s.input=e.input),s}var zt=/[\uD800-\uDBFF]/;function $t(e){let t=e.length;if(!zt.test(e))return t;let n=t;for(let r=0;r<t-1;r++)55296==(64512&e.charCodeAt(r))&&56320==(64512&e.charCodeAt(r+1))&&(n--,r++);return n}function Et(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function Ot(...e){let[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}function St(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function xt(e,t,n){return St(e,t,n,!1)}function jt(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return St(this,n,r(this))},set(e){St(this,n,e)}})}return t}function It(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return null==this?n:St(this,t,n.bind(this))},set(e){St(this,t,e)}})}var Nt,Tt=!1,Pt={configurable:!0,get(){Tt=!0}};function At(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&Nt!==e._zod?Nt=void 0:(Nt=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Pt);let e=Tt;Tt=!1;try{let r=n(this);return Tt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Tt=Tt||e,r}catch(n){throw delete this[t],Tt=Tt||e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function Zt(e,t,n,r){let i=function(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var Rt;function Ft(e){let t=()=>e;return t["~constantCatch"]=!0,t}var Dt={value:void 0,enumerable:!1},Mt="captureStackTrace"in Error?Error:null;function Ct(e,t,n,r){function i(e){this.def=e,this.constr=c,this.traits=new Set}i.prototype={};let o=n,a=o&&new WeakSet;function s(n,r){if(n._zod){if(n._zod.traits.has(e))return}else{Dt.value=new i(r);try{Object.defineProperty(n,"_zod",Dt)}finally{Dt.value=void 0}}if(n._zod.traits.add(e),t(n,r),a){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;a.has(i)||(a.add(i),function(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):It(e,n,r.value)}}(i,o))}let s=c.prototype;for(let e in s)Object.prototype.hasOwnProperty.call(s,e)&&(e in n||(n[e]=s[e].bind(n)))}let u=r?.Parent??Object;class l extends u{}function c(e){let t=r?.Parent?function(e){let t=Mt;if(t){let n=t.stackTraceLimit;if("number"==typeof n){try{t.stackTraceLimit=0}catch{return Mt=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}(l):this;s(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(l,"name",{value:e}),Object.defineProperty(c,"init",{value:s}),Object.defineProperty(c,Symbol.hasInstance,{value:t=>!!(r?.Parent&&t instanceof r.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(c,"name",{value:e}),c}class Jt extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ut extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(Rt=globalThis).__zod_globalConfig??(Rt.__zod_globalConfig={});var Lt=globalThis.__zod_globalConfig;function qt(e){return e&&Object.assign(Lt,e),Lt}var Bt={get:function(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,qe,2)),e.message},set:function(e){this._zod.message=e},enumerable:!0,configurable:!0},Wt={value:void 0,enumerable:!1},Vt=new WeakSet([Object.prototype,Error.prototype]),Kt=(e,t)=>{e.name="$ZodError",Wt.value=t,Object.defineProperty(e,"issues",Wt),Wt.value=void 0,Object.defineProperty(e,"message",Bt);let n=Object.getPrototypeOf(e);Vt.has(n)||(Vt.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},Gt=Ct("$ZodError",Kt);Ct("$ZodError",Kt,void 0,{Parent:Error});function Xt(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||("__proto__"===t?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Yt(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Ht=e=>{let t=(n,r,i,o)=>{let a=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},a);if(s instanceof Promise)throw new Jt;if(s.issues.length){let n=new(o?.Err??e)(s.issues.map(e=>kt(e,a,qt())));throw nt(n,o?.callee??t),n}return s.value};return t},Qt=e=>{let t=async(n,r,i,o)=>{let a=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},a);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new(o?.Err??e)(s.issues.map(e=>kt(e,a,qt())));throw nt(n,o?.callee??t),n}return s.value};return t},en=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new Jt;return o.issues.length?tn(e,o.issues,i):{success:!0,data:o.value}};function tn(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>kt(e,n,qt()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var nn=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?tn(e,o.issues,i):{success:!0,data:o.value}},rn=Symbol.for("zod.compile.invalid"),on=Symbol.for("zod.compile.fallback"),an=(e,t,n)=>{let r=e._zod.bag.validator;if(void 0!==r){if(r(t)!==rn)return!0;if(!0===r.definite&&void 0===n)return!1}return function(e,t,n){let r,i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun;o?(i[on]=!0,r=o({value:t,issues:[]},i)):r=e._zod.run({value:t,issues:[]},i);if(r instanceof Promise)throw new Jt;return 0===r.issues.length}(e,t,n)};var sn=/^[cC][0-9a-z]{6,}$/,un=/^[0-9a-z]+$/,ln=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,cn=/^[0-9a-vA-V]{20}$/,dn=/^[A-Za-z0-9]{27}$/,fn=/^[a-zA-Z0-9_-]{21}$/;var pn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,hn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,mn=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,_n=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var vn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,yn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,gn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,bn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,wn=/^https?$/,kn=/^\+[1-9]\d{6,14}$/,zn="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";var $n=new RegExp(`^${zn}$`);function En(e){return"number"==typeof e.precision?-1===e.precision?"(?:[01]\\d|2[0-3]):[0-5]\\d":0===e.precision?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}var On=/^[\s\S]{0,}$/,Sn=/^-?\d+$/,xn=/^-?\d+(?:\.\d+)?$/,jn=/^(?:true|false)$/i,In=/^[^A-Z]*$/,Nn=/^[^a-z]*$/,Tn=Ct("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Pn=e=>{let t=e.value;return!(n=t,null==n||void 0===t.length);var n},An={number:"number",bigint:"bigint",object:"date"},Zn=Ct("$ZodCheckLessThan",(e,t)=>{Tn.init(e,t);let n=An[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:An[typeof r.value]??n,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Rn=Ct("$ZodCheckGreaterThan",(e,t)=>{Tn.init(e,t);let n=An[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:An[typeof r.value]??n,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Fn=Ct("$ZodCheckMultipleOf",(e,t)=>{Tn.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?t.value===BigInt(0)||n.value%t.value!==BigInt(0):0!==function(e,t){let n=e/t,r=Math.round(n),i=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}(n.value,t.value))&&n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Dn=Ct("$ZodCheckNumberFormat",(e,t)=>{Tn.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),r=n?"int":"number",[i,o]=ft[t.format];e._zod.check=a=>{let s=a.value;if(n){if(!Number.isInteger(s))return void a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}))}s<i&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>o&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),Mn=Ct("$ZodCheckMaxLength",(e,t)=>{var n;Tn.init(e,t),(n=e._zod.def).when??(n.when=Pn),e._zod.check=n=>{let r=n.value,i=r.length;if(("string"==typeof r&&i>t.maximum?$t(r):i)<=t.maximum)return;let o=Et(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Cn=Ct("$ZodCheckMinLength",(e,t)=>{var n;Tn.init(e,t),(n=e._zod.def).when??(n.when=Pn),e._zod.check=n=>{let r=n.value,i=r.length;if(("string"==typeof r&&i>=t.minimum&&i<2*t.minimum?$t(r):i)>=t.minimum)return;let o=Et(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Jn=Ct("$ZodCheckLengthEquals",(e,t)=>{var n;Tn.init(e,t),(n=e._zod.def).when??(n.when=Pn),e._zod.check=n=>{let r=n.value,i=r.length,o="string"==typeof r&&i>=t.length&&i<=2*t.length?$t(r):i;if(o===t.length)return;let a=Et(r),s=o>t.length;n.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Un=Ct("$ZodCheckStringFormat",(e,t)=>{var n,r;Tn.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Ln=Ct("$ZodCheckRegex",(e,t)=>{Un.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),qn=Ct("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=In),Un.init(e,t)}),Bn=Ct("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Nn),Un.init(e,t)}),Wn=Ct("$ZodCheckIncludes",(e,t)=>{Tn.init(e,t);let n=ut(t.includes),r=new RegExp("number"==typeof t.position?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Vn=Ct("$ZodCheckStartsWith",(e,t)=>{Tn.init(e,t);let n=new RegExp(`^${ut(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Kn=Ct("$ZodCheckEndsWith",(e,t)=>{Tn.init(e,t);let n=new RegExp(`.*${ut(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Gn=Ct("$ZodCheckOverwrite",(e,t)=>{Tn.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class Xn{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{this.indent-=1}}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});let t=e.split("\n").filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[""];return new e(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {\n${t.join("\n")}\n};`)(...Object.values(this.closed))}}var Yn={major:4,minor:6,patch:5},Hn=Ct("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Yn;let r=e._zod.def.checks,i=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(0===i.length)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i,o=vt(t);for(let a of n){if(a._zod.def.when){if(yt(t))continue;if(!a._zod.def.when(t))continue}else if(o)continue;let n=t.issues.length,s=a._zod.check(t);if(s instanceof Promise&&!1===r?.async)throw new Jt;if(i||s instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(wt(t.issues,n,e),o||(o=vt(t,n)))});else{if(t.issues.length===n)continue;wt(t.issues,n,e),o||(o=vt(t,n))}}return i?i.then(()=>t):t},n=(n,r,o)=>{if(vt(n))return n.aborted=!0,n;let a=t(r,i,o);if(a instanceof Promise){if(!1===o.async)throw new Jt;return a.then(t=>e._zod.parse(t,o))}return e._zod.parse(a,o)};e._zod.run=(r,o)=>{if(o.skipChecks)return e._zod.parse(r,o);if("backward"===o.direction){let t=e._zod.parse({value:r.value,issues:[]},{...o,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,o)):n(t,r,o)}let a=e._zod.parse(r,o);if(a instanceof Promise){if(!1===o.async)throw new Jt;return a.then(e=>t(e,i,o))}return t(a,i,o)}}},{get"~standard"(){return xt(this,"~standard",er(this))},set"~standard"(e){St(this,"~standard",e)}}),Qn=(e,t)=>e.issues.length?{issues:e.issues.map(e=>kt(e,t,qt()))}:{value:e.value};function er(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Qn(r,n)}catch(e){}return async function(e,t){let n={async:!0};return Qn(await e._zod.run({value:t,issues:[]},n),n)}(e,t)},vendor:"zod",version:1}}var tr=Ct("$ZodString",(e,t)=>{Hn.init(e,t),e._zod.pattern=t.pattern??On,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),nr=Ct("$ZodStringFormat",(e,t)=>{Un.init(e,t),tr.init(e,t)}),rr=Ct("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=hn),nr.init(e,t)}),ir=Ct("$ZodUUID",(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=mn(e))}else t.pattern??(t.pattern=mn());nr.init(e,t)}),or=Ct("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=_n),nr.init(e,t)});function ar(e){try{return typeof URL<"u"&&"function"==typeof URL.canParse?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function sr(e,t){return"normalize"in t||"hostname"in t||"protocol"in t?function(e,t){if(!t.normalize&&t.protocol?.source===wn.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<"u"){let t=URL;if("function"==typeof t.parse)return t.parse(e)??2}return new URL(e)}catch{return 2}}(e,t):ar(e)||2}var ur=/[\t\n\r]/g;function lr(e){return e.replace(ur,"")}var cr=Ct("$ZodURL",(e,t)=>{nr.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=sr(r,t);return 1===i?void n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort}):2===i?void n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort}):!0===i?void(n.value=lr(r)):(t.hostname&&!function(e,t){return t.lastIndex=0,t.test(e.hostname)}(i,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!function(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}(i,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),void(n.value=t.normalize?i.href:lr(r)))}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),dr=Ct("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$","u")),nr.init(e,t)}),fr=Ct("$ZodNanoID",(e,t)=>{if(void 0!==t.length&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);var n;t.pattern??(t.pattern=void 0===t.length?fn:(n=t.length,new RegExp(`^[a-zA-Z0-9_-]{${n}}$`))),nr.init(e,t)}),pr=Ct("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=sn),nr.init(e,t)}),hr=Ct("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=un),nr.init(e,t)}),mr=Ct("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ln),nr.init(e,t)}),_r=Ct("$ZodXID",(e,t)=>{t.pattern??(t.pattern=cn),nr.init(e,t)}),vr=Ct("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=dn),nr.init(e,t)}),yr=Ct("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${En({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${En({precision:e.precision})}`:n;return new RegExp(`^${zn}T(?:${r})$`)}(t)),nr.init(e,t)}),gr=Ct("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=$n),nr.init(e,t)}),br=Ct("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${En(t)}$`)),nr.init(e,t)}),wr=Ct("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=pn),nr.init(e,t)}),kr=Ct("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=vn),nr.init(e,t)}),zr=/^[0-9a-fA-F:.]+$/;function $r(e){return!!zr.test(e)&&ar(`http://[${e}]`)}var Er=Ct("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=yn),nr.init(e,t),e._zod.check=n=>{$r(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),Or=Ct("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=gn),nr.init(e,t)});var Sr=Ct("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=bn),nr.init(e,t),e._zod.check=n=>{(function(e){let t=e.split("/");if(2!==t.length)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`===r&&!(i<0||i>128)&&$r(n)})(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function xr(e){if(""===e)return!0;if(/\s/.test(e))return!1;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var jr=/^[0-9a-zA-Z+/]*={0,2}$/,Ir=Ct("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=jr),nr.init(e,t),e._zod.check=n=>{xr(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Nr=/^[A-Za-z0-9_-]*$/;var Tr=Ct("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Nr),nr.init(e,t),e._zod.check=n=>{(function(e){if(!Nr.test(e))return!1;let t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return xr(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Pr=Ct("$ZodE164",(e,t)=>{t.pattern??(t.pattern=kn),nr.init(e,t)});var Ar=Ct("$ZodJWT",(e,t)=>{nr.init(e,t),e._zod.check=n=>{(function(e,t=null){try{let n=e.split(".");if(3!==n.length)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!("typ"in i&&"JWT"!==i?.typ||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Zr=Ct("$ZodNumber",(e,t)=>{Hn.init(e,t),e._zod.pattern=xn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(e){}let i=n.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return n;let o="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),Rr=Ct("$ZodNumberFormat",(e,t)=>{Dn.init(e,t),Zr.init(e,t)}),Fr=Ct("$ZodBoolean",(e,t)=>{Hn.init(e,t),e._zod.pattern=jn,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(e){}let i=n.value;return"boolean"==typeof i||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),Dr=Ct("$ZodUnknown",(e,t)=>{Hn.init(e,t),e._zod.parse=e=>e}),Mr=Ct("$ZodNever",(e,t)=>{Hn.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function Cr(e,t,n){e.issues.length&&t.issues.push(...gt(n,e.issues)),t.value[n]=e.value}var Jr=Ct("$ZodArray",(e,t)=>{Hn.init(e,t);let n=Lt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=n?n.alloc(e,r,Array(o.length),i):Array(o.length);let a=[],s=i?.abortEarly;for(let e=0;e<o.length;e++){let n=o[e],u=t.element._zod.run({value:n,issues:[]},i);if(u instanceof Promise)a.push(u.then(t=>Cr(t,r,e)));else if(Cr(u,r,e),s&&0!==u.issues.length&&vt(u))break}return a.length?Promise.all(a).then(()=>r):r}});function Ur(e,t,n,r,i,o){let a=n in r,s="optional"===o;if(a||!s||"optional"!==i){if(e.issues.length){if(void 0!==i&&s&&!a)return;t.issues.push(...gt(n,e.issues))}a||void 0!==i?void 0===e.value?(a||"defaulted"===i&&!s)&&(t.value[n]=void 0):t.value[n]=e.value:e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]})}}var Lr=[];function qr(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Lr,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let o=(a=e.shape,Object.keys(a).filter(e=>void 0!==a[e]._zod.optin&&"optional"===a[e]._zod.optout));var a;return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function Br(e,t,n,r,i,o,a){let s=[],u=i.keySet,l=i.catchall._zod,c=l.def.type,{optin:d,optout:f}=l,p=0;for(let i in t){if(a&&n.issues.length!==p){if(vt(n,p))break;p=n.issues.length}if(u.has(i))continue;if("__proto__"===i){"never"===c&&s.push(i);continue}if("never"===c){s.push(i);continue}let o=l.run({value:t[i],issues:[]},r);o instanceof Promise?e.push(o.then(e=>Ur(e,n,i,t,d,f))):Ur(o,n,i,t,d,f)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:o,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var Wr=Ct("$ZodObject",(e,t)=>{Hn.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=We(()=>qr(t));At(e,"propValues",e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||Ke(n,e,new Set);for(let t of r.values)n[e].add(t);void 0!==r.optin&&n[e].add(void 0)}}return n});let o,a=rt,s=t.catchall,u=Lt.memoizer;u?.attach(e),e._zod.parse=(t,n)=>{o??(o=i.value);let r=t.value;if(!a(r))return t.issues.push({expected:"object",code:"invalid_type",input:r,inst:e}),t;t.value=u?u.alloc(e,t,{},n):{};let l=[],c=o.shape,d=n?.abortEarly,f=t.issues.length;for(let e of o.allKeys){if(d&&t.issues.length!==f){if(vt(t,f))break;f=t.issues.length}if("__proto__"===e)continue;let i=c[e],o=i._zod.optin,a=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>Ur(n,t,e,r,o,a))):Ur(s,t,e,r,o,a)}return s?Br(l,r,t,n,i.value,e,!0===d):l.length?Promise.all(l).then(()=>t):t}}),Vr=Ct("$ZodObjectJIT",(e,t)=>{Wr.init(e,t);let n,r,i=e._zod.parse,o=We(()=>qr(t)),a=Lt.memoizer,s=rt,u=!Lt.jitless,l=u&&it.value,c=t.catchall;e._zod.parse=(d,f)=>{r??(r=o.value);let p=d.value;return s(p)?u&&l&&!1===f?.async&&!0!==f.jitless?(n||(n=(t=>{let n=o.value,r=n.symbolKeys,i=new Xn(["payload","ctx"],{shape:t,inst:e,memo:a,syms:r}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,u=(e,t)=>`\n let ${e}_ab = false;\n for (let i = 0; i < ${e}.issues.length; i++) {\n const iss = ${e}.issues[i];\n iss.path = iss.path ? [${t}, ...iss.path] : [${t}];\n payload.issues.push(iss);\n if (iss.continue !== true) ${e}_ab = true;\n }\n if (${e}_ab && ctx && ctx.abortEarly) {\n payload.value = newResult;\n return payload;\n }`;i.write("const input = payload.value;");let l=Object.create(null),c=0;for(let e of n.allKeys)l[e]="key_"+c++;i.write(a?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let e of n.allKeys){if("__proto__"===e)continue;let n=l[e],o="symbol"==typeof e?`syms[${r.indexOf(e)}]`:tt(e),a=`${o} in input`,c=t[e],d=c?._zod?.optin,f=void 0!==d,p="optional"===c?._zod?.optout;if(i.write(`const ${n} = ${s(o)};`),f&&p){let e="optional"===d?`${n}_present`:`${n}.value !== undefined || ${n}_present`;i.write(`\n const ${n}_present = ${a};\n if (!${n}.issues.length || ${n}_present) {\n if (${n}.issues.length) {${u(n,o)}\n }\n\n if (${e}) {\n newResult[${o}] = ${n}.value;\n }\n }\n\n `)}else f?(i.write(`\n if (${n}.issues.length) {${u(n,o)}\n }\n `),"defaulted"===d?i.write(`newResult[${o}] = ${n}.value;`):i.write(`\n if (${n}.value !== undefined || ${a}) {\n newResult[${o}] = ${n}.value;\n }\n `)):i.write(`\n const ${n}_present = ${a};\n if (${n}.issues.length) {${u(n,o)}\n }\n if (!${n}_present && !${n}.issues.length) {\n payload.issues.push({\n code: "invalid_type",\n expected: "nonoptional",\n input: undefined,\n path: [${o}]\n });\n if (ctx && ctx.abortEarly) {\n payload.value = newResult;\n return payload;\n }\n }\n\n if (${n}_present) {\n newResult[${o}] = ${n}.value;\n }\n\n `)}return i.write("payload.value = newResult;"),i.write("return payload;"),i.compile()})(t.shape)),d=n(d,f),c?Br([],p,d,f,r,e,!0===f?.abortEarly):d):i(d,f):(d.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),d)}});function Kr(e,t,n,r){for(let n of e)if(0===n.issues.length)return t.value=n.value,t;let i=e.filter(e=>!vt(e));return 1===i.length?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>kt(e,r,qt())))}),t)}var Gr=Ct("$ZodUnion",(e,t)=>{Hn.init(e,t),At(e,"optin",e=>e.def.options.some(e=>"defaulted"===e._zod.optin)?"defaulted":e.def.options.some(e=>void 0!==e._zod.optin)?"optional":void 0),At(e,"optout",e=>e.def.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),At(e,"values",e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),At(e,"pattern",e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return new RegExp(`^(${t.map(e=>Ve(e.source)).join("|")})$`)}});let n=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let o=!1,a=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)a.push(t),o=!0;else{if(0===t.issues.length)return t;a.push(t)}}return o?Promise.all(a).then(t=>Kr(t,r,e,i)):Kr(a,r,e,i)}}),Xr=Ct("$ZodIntersection",(e,t)=>{Hn.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),o=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||o instanceof Promise?Promise.all([i,o]).then(([t,n])=>Hr(e,t,n)):Hr(e,i,o)}});function Yr(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(ot(e)&&ot(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),i={...e,...t};Object.prototype.hasOwnProperty.call(i,"__proto__")&&delete i.__proto__;for(let n of r){if("__proto__"===n)continue;let r=Yr(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=Yr(e[r],t[r]);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Hr(e,t,n){let r,i=new Map,o=new Map,a=(e,t)=>{let n;if("unrecognized_keys"!==e.code||e.path?.length){if("invalid_key"!==e.code||"record"!==e.origin||1!==e.path?.length)return!1;{let t=String(e.path[0]);o.has(t)||o.set(t,e),n=[t]}}else r??(r=e),n=e.keys;for(let e of n)i.has(e)||i.set(e,{}),i.get(e)[t]=!0;return!0};for(let n of t.issues)a(n,"l")||e.issues.push(n);for(let t of n.issues)a(t,"r")||e.issues.push(t);let s=[...i].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=r?s.filter(e=>r.keys.includes(e)):[];t.length&&e.issues.push({...r,keys:t});for(let n of s)!t.includes(n)&&o.has(n)&&e.issues.push(o.get(n))}let u=Yr(t.value,n.value);if(!u.valid){if(vt(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}var Qr=Ct("$ZodRecord",(e,t)=>{Hn.init(e,t);let n=Lt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let o=r.value;if(!ot(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;let a=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let u,l=new Set;for(let n of s)if("string"==typeof n||"number"==typeof n||"symbol"==typeof n){if(l.add("number"==typeof n?n.toString():n),"__proto__"===n)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(s.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:s.issues.map(e=>kt(e,i,qt())),input:n,path:[n],inst:e});continue}let u=s.value;if("__proto__"===u)continue;let c=t.valueType._zod.run({value:o[n],issues:[]},i);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&r.issues.push(...gt(n,e.issues)),r.value[u]=e.value})):(c.issues.length&&r.issues.push(...gt(n,c.issues)),r.value[u]=c.value)}for(let e in o)if(!l.has(e))if("loose"===t.mode){if("__proto__"===e)continue;r.value[e]=o[e]}else u=u??[],u.push(e);u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:u,continue:!0})}else{let u;r.value=n?n.alloc(e,r,{},i):{};for(let n of Reflect.ownKeys(o)){if("__proto__"===n)continue;if(!Object.prototype.propertyIsEnumerable.call(o,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error("Async schemas not supported in object keys currently");if("string"==typeof n&&xn.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error("Async schemas not supported in object keys currently");0===e.issues.length&&(l=e)}if(l.issues.length){"loose"===t.mode?r.value[n]=o[n]:s?(u=u??[],u.push(n)):r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(e=>kt(e,i,qt())),input:n,path:[n],inst:e});continue}let c=l.value;if("__proto__"===c)continue;let d=t.valueType._zod.run({value:o[n],issues:[]},i);d instanceof Promise?a.push(d.then(e=>{e.issues.length&&r.issues.push(...gt(n,e.issues)),r.value[c]=e.value})):(d.issues.length&&r.issues.push(...gt(n,d.issues)),r.value[c]=d.value)}u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:u,continue:!0})}return a.length?Promise.all(a).then(()=>r):r}}),ei=Ct("$ZodEnum",(e,t)=>{Hn.init(e,t);let n=Ue(t.entries),r=new Set(n);e._zod.values=r,At(e,"pattern",e=>{let t=Ue(e.def.entries).filter(e=>st.has(typeof e));return new RegExp(t.length?`^(${t.map(e=>ut(e.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(t,i)=>{let o=t.value;return r.has(o)||t.issues.push({code:"invalid_value",values:n,input:o,inst:e}),t}}),ti=Ct("$ZodLiteral",(e,t)=>{Hn.init(e,t);let n=new Set(t.values);e._zod.values=n,At(e,"pattern",e=>{let t=e.def.values;return new RegExp(t.length?`^(${t.map(e=>"string"==typeof e?ut(e):e?ut(e.toString()):String(e)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,i)=>{let o=r.value;return n.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}}),ni=Ct("$ZodTransform",(e,t)=>{Hn.init(e,t),e._zod.optin="optional",Lt.memoizer?.guard(e),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new Ut(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Jt;return n.value=i,n}});function ri(e,t){return e.value=t.issues.length?void 0:t.value,e}var ii=Ct("$ZodOptional",(e,t)=>{Hn.init(e,t),At(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),e._zod.optout="optional",At(e,"values",e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),At(e,"pattern",e=>{let t=e.def.innerType._zod.pattern;return t?new RegExp(`^(${Ve(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(void 0===e.value){if("defaulted"!==t.innerType._zod.optin)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>ri(e,t)):ri(e,r)}return t.innerType._zod.run(e,n)}}),oi=Ct("$ZodExactOptional",(e,t)=>{ii.init(e,t),At(e,"values",e=>e.def.innerType._zod.values),At(e,"pattern",e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),ai=Ct("$ZodNullable",(e,t)=>{Hn.init(e,t),At(e,"optin",e=>e.def.innerType._zod.optin),At(e,"optout",e=>e.def.innerType._zod.optout),At(e,"pattern",e=>{let t=e.def.innerType._zod.pattern;return t?new RegExp(`^(${Ve(t.source)}|null)$`):void 0}),At(e,"values",e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),si=Ct("$ZodDefault",(e,t)=>{Hn.init(e,t),e._zod.optin="defaulted",At(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>ui(e,t)):ui(r,t)}});function ui(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}var li=Ct("$ZodPrefault",(e,t)=>{Hn.init(e,t),e._zod.optin="defaulted",At(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),ci=Ct("$ZodNonOptional",(e,t)=>{Hn.init(e,t),At(e,"values",e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>di(t,e)):di(i,e)}});function di(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function fi(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>kt(e,r,qt()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var pi=Ct("$ZodCatch",(e,t)=>{Hn.init(e,t),At(e,"optin",e=>"defaulted"===e.def.innerType._zod.optin?"defaulted":"optional"),At(e,"optout",e=>e.def.innerType._zod.optout),At(e,"values",e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>fi(e,r,t,n)):fi(e,r,t,n)}}),hi=Ct("$ZodPipe",(e,t)=>{Hn.init(e,t),At(e,"values",e=>e.def.in._zod.values),At(e,"optin",e=>e.def.in._zod.optin),At(e,"optout",e=>e.def.out._zod.optout),At(e,"propValues",e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>mi(e,t.in,n)):mi(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>mi(e,t.out,n)):mi(r,t.out,n)}});function mi(e,t,n){return e.issues.some(e=>"unrecognized_keys"!==e.code)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var _i=Ct("$ZodReadonly",(e,t)=>{Hn.init(e,t),At(e,"propValues",e=>e.def.innerType._zod.propValues),At(e,"values",e=>e.def.innerType._zod.values),At(e,"optin",e=>e.def.innerType?._zod?.optin),At(e,"optout",e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(vi):vi(r)}});function vi(e){return e.memo||(e.value=Object.freeze(e.value)),e}var yi=Ct("$ZodCustom",(e,t)=>{Tn.init(e,t),Hn.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>gi(t,n,r,e));gi(i,n,r,e)}});function gi(e,t,n,r){if(!e){let e={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Ot(e))}}class bi extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}var wi="~memo",ki=[];function zi(e){return null!==e&&"object"==typeof e}function $i(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var Ei=new WeakMap;function Oi(e,t,n){let r=Ei.get(e);if(void 0!==r)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,o=e=>{if(2!==i&&e?._zod){let r=Oi(e,t,n);r>i&&(i=r)}},a=e=>{e>i&&(i=e)},s=e._zod.def;switch(s.type){case"object":{let e=Ge(s);a(e?((e,r)=>{let i=0;for(let o of Reflect.ownKeys(e)){let a=Object.getOwnPropertyDescriptor(e,o);if(r&&!a.enumerable)continue;let s=a.get?1:a.value?._zod?Oi(a.value,t,n):0;s>i&&(i=s)}return i})(e,!0):1),o(s.catchall);break}case"array":o(s.element);break;case"tuple":for(let e of s.items)o(e);o(s.rest);break;case"record":case"map":o(s.keyType),o(s.valueType);break;case"set":o(s.valueType);break;case"union":for(let e of s.options)o(e);break;case"intersection":o(s.left),o(s.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(s.innerType);break;case"pipe":o(s.in),o(s.out);break;case"function":o(s.input),o(s.output);break;case"lazy":{let r=s._cachedInner??(n?e._zod.innerType:void 0);a(r?Oi(r,t,!1):1);break}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":break;default:for(let e in s){let t=Object.getOwnPropertyDescriptor(s,e);if(!t||t.get)continue;let n=t.value;if(n&&"object"==typeof n)if(n._zod)o(n);else if(Array.isArray(n))for(let e of n)o(e)}}return t.delete(e),function(e,t){1!==t&&Ei.set(e,2===t);return t}(e,i)}var Si,xi=[],ji={alloc(e,t,n){let r=Si;if(!r)return n;Si=void 0;let i={value:n,issues:null};return r.set(t.value,i),xi.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if("backward"!==n.direction&&function(e,t){let n=e[wi]?.backEdges;return void 0!==n&&zi(t)&&n.has(t)}(n,e.value))throw new bi;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r,i,o=!1;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,a=(s,u)=>{if(void 0===n){let r=Oi(e,new Set,!1);if(0===r)return e._zod.parse=t,e._zod.run===a&&(e._zod.run=t),t(s,u);2===r||o?n=!0:o=!0}let l=s.value;if(!zi(l))return t(s,u);let c,d=u[wi];d||(d={buckets:new WeakMap,backEdges:void 0},u[wi]=d),r===u?c=i:(c=function(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}(d,e),r=u,i=c);let f=c.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...$i(f.issues)):(s.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(f.value)),s;Si=c;let p=xi.length,h=t(s,u);Si=void 0;let m=xi.length>p?xi.pop():void 0;return h instanceof Promise?h.then(e=>(m&&(m.issues=e.issues.length?$i(e.issues):ki),e)):(m&&(m.issues=h.issues.length?$i(h.issues):ki),h)};e._zod.parse=a,e._zod.run===t&&(e._zod.run=a)})}};var Ii,Ni=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(t){return e[t]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function i(e,t){return"number"!==e||"number"!=typeof t||Number.isFinite(t)?r[e]??e:String(t)}return e=>{switch(e.code){case"invalid_type":return`Invalid input: expected ${i(e.expected)}, received ${i(function(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(null===e)return"null";if(Array.isArray(e))return"array";let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&"constructor"in t&&t.constructor)return t.constructor.name}}return t}(e.input),e.input)}`;case"invalid_value":return 1===e.values.length?`Invalid input: expected ${dt(e.values[0])}`:`Invalid option: expected one of ${Le(e.values,"|")}`;case"too_big":{let n=e.exact?"exactly ":e.inclusive?"<=":"<",r=t(e.origin);return r?`Too big: expected ${e.origin??"value"} to have ${n}${e.maximum.toString()} ${r.unit??"elements"}`:`Too big: expected ${e.origin??"value"} to be ${n}${e.maximum.toString()}`}case"too_small":{let n=e.exact?"exactly ":e.inclusive?">=":">",r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case"invalid_format":{let t=e;return"starts_with"===t.format?`Invalid string: must start with "${t.prefix}"`:"ends_with"===t.format?`Invalid string: must end with "${t.suffix}"`:"includes"===t.format?`Invalid string: must include "${t.includes}"`:"regex"===t.format?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${e.divisor}`;case"unrecognized_keys":return`Unrecognized key${e.keys.length>1?"s":""}: ${Le(e.keys,", ")}`;case"invalid_key":return`Invalid key in ${e.origin}`;case"invalid_union":return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(" | ")}`:!1===e.inclusive?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${e.origin}`;default:return"Invalid input"}}};class Ti{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&"object"==typeof n&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}(Ii=globalThis).__zod_globalRegistry??(Ii.__zod_globalRegistry=new Ti);var Pi=globalThis.__zod_globalRegistry;function Ai(e){return e.checks&&(e.checks=[...e.checks]),e}function Zi(e,t){return new Zn({check:"less_than",...ct(t),value:e,inclusive:!1})}function Ri(e,t){return new Zn({check:"less_than",...ct(t),value:e,inclusive:!0})}function Fi(e,t){return new Rn({check:"greater_than",...ct(t),value:e,inclusive:!1})}function Di(e,t){return new Rn({check:"greater_than",...ct(t),value:e,inclusive:!0})}function Mi(e,t){return new Fn({check:"multiple_of",...ct(t),value:e})}function Ci(e,t){return new Mn({check:"max_length",...ct(t),maximum:e})}function Ji(e,t){return new Cn({check:"min_length",...ct(t),minimum:e})}function Ui(e,t){return new Jn({check:"length_equals",...ct(t),length:e})}function Li(e){return new Gn({check:"overwrite",tx:e})}function qi(e,t){let n=function(e,t){let n=new Tn({check:"custom",...ct(t)});return n._zod.check=e,n}(t=>(t.addIssue=e=>{if("string"==typeof e)t.issues.push(Ot(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),"input"in r||(r.input=t.value),r.inst??(r.inst=n),r.continue??(r.continue=!n._zod.def.abort),t.issues.push(Ot(r))}},e(t.value,t)),t);return n}function Bi(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Ke(e,t,n[t]);return e}function Wi(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Pi,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 Vi(e,t,n,r,i){let o="function"==typeof t.unrepresentable?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if("any"===o)return!1;if(void 0===o||"throw"===o)throw Error(i);return Object.assign(n,o),!0}function Ki(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;let a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,r);else{let n=a.schema,o=t.processors[i.type];if(!o)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);o(e,t,n,r)}let o=e._zod.parent;o&&(a.ref||(a.ref=o),Ki(o,t,r),t.seen.get(o).isParent=!0)}let u=t.metadataRegistry.get(e);return u&&Bi(a.schema,u),"input"===t.io&&io(e)&&(delete a.schema.examples,delete a.schema.default),"input"===t.io&&"_prefault"in a.schema&&((r=a.schema).default??(r.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Gi(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Xi(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{if(t[1].schema.$ref)return;let r=t[1],{ref:i,defId:o}=(t=>{let r="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let o=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=o,{defId:o,ref:`${i("__shared")}#/${r}/${Gi(o)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:"#"};let o=t[1].schema.id??"__schema"+e.counter++;return{defId:o,ref:i+Gi(o)}})(t);r.def={...r.schema},o&&(r.defId=o);let a=r.schema;for(let e in a)delete a[e];a.$ref=i};if("throw"===e.cycles)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t!==n[0]){if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){i(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&"ref"===e.reused)&&i(n)}else i(n)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Yi(e){let t=e.anyOf;if(!Array.isArray(t)||0===t.length||void 0!==e.type)return;let n=[];for(let e of t){if(!e||"object"!=typeof e)return;Yi(e);let t=Object.keys(e);if(1!==t.length||"type"!==t[0])return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if("string"!=typeof e)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=1===n.length?n[0]:n}var Hi=new Set(["type","properties","required","additionalProperties"]),Qi=["oneOf","anyOf"];function eo(e){let t=e.additionalProperties;return void 0===t||!1===t||"object"!=typeof t||null===t?null:Object.keys(t).length?t:null}function to(e){let t=[];for(let n of e){if("object"!=typeof n||"object"!==n.type)return null;for(let e in n)if(!Hi.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??eo(n);null!=t&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Ke(n,r,1===e.length?e[0]:to(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:"object",properties:n};if(r.size&&(i.required=[...r]),t.every(e=>!1===e.additionalProperties))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=eo(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}1===e.length?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function no(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Hi)if(t in e)return;let n=t.filter(e=>Qi.some(t=>Array.isArray(e[t]))),r=null;if(n.length){let e=n[0],i=Qi.find(t=>Array.isArray(e[t]));if(1!==Object.keys(e).length)return;let o=t.filter(t=>t!==e),a=e[i].map(e=>to([...o,e]));if(a.some(e=>!e))return;r={[i]:a}}else r=to(t);r&&(delete e.allOf,Bi(e,r))}function ro(e,t){let n=e.seen.get(t);if(!n)throw Error("Unprocessed schema. This is a bug in Zod.");let r=t=>{let n=e.seen.get(t);if(null===n.ref)return;let i=n.def??n.schema,o={...i},a=n.ref;if(n.ref=null,a){r(a);let n=e.seen.get(a),s=n.schema;if(!s.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Bi(i,s):(i.allOf=i.allOf??[],i.allOf.push(s)),Bi(i,o),t._zod.parent===a)for(let e in i)"$ref"!==e&&"allOf"!==e&&(e in o||delete i[e]);if(s.$ref&&n.def)for(let e in i)"$ref"!==e&&"allOf"!==e&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==a){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if("openapi-3.0"!==e.target)for(let t of e.seen.entries())Yi(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])no(e)}}let i={};if("draft-2020-12"===e.target?i.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?i.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?i.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Bi(i,n.defId?n.schema:n.def??n.schema);let o=e.metadataRegistry.get(t)?.id;void 0!==o&&i.id===o&&delete i.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Ke(a,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&("draft-2020-12"===e.target?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t["~standard"],jsonSchema:{input:oo(t,"input",e.processors),output:oo(t,"output",e.processors)}},enumerable:!1,writable:!1}),n}catch(e){throw Error("Error converting schema to JSON.")}}function io(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if("transform"===r.type)return!0;if("array"===r.type)return io(r.element,n);if("set"===r.type)return io(r.valueType,n);if("lazy"===r.type)return io(r.getter(),n);if("promise"===r.type||"optional"===r.type||"nonoptional"===r.type||"nullable"===r.type||"readonly"===r.type||"default"===r.type||"prefault"===r.type||"catch"===r.type)return io(r.innerType,n);if("intersection"===r.type)return io(r.left,n)||io(r.right,n);if("record"===r.type||"map"===r.type)return io(r.keyType,n)||io(r.valueType,n);if("pipe"===r.type)return!!e._zod.traits.has("$ZodCodec")||(io(r.in,n)||io(r.out,n));if("object"===r.type){for(let e in r.shape)if(io(r.shape[e],n))return!0;return!1}if("union"===r.type){for(let e of r.options)if(io(e,n))return!0;return!1}if("tuple"===r.type){for(let e of r.items)if(io(e,n))return!0;return!(!r.rest||!io(r.rest,n))}return!1}var oo=(e,t,n={})=>r=>{let{libraryOptions:i,target:o}=r??{},a=Wi({...i??{},target:o,io:t,processors:n});return Ki(e,a),Xi(a,e),ro(a,e)},ao=(e,t,n)=>{(void 0===e[t]||n>e[t])&&(e[t]=n)},so=(e,t,n)=>{(void 0===e[t]||n<e[t])&&(e[t]=n)},uo=(e,t)=>{ao(e,"minimum",t),so(e,"maximum",t)},lo=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},co=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},fo=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},po=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},ho=(e,t)=>ao(e,"minimum",t.minimum),mo=(e,t)=>so(e,"maximum",t.maximum),_o=e=>(t,n)=>{po(t,n.format);let[r,i]=e[n.format];ao(t,"minimum",r),so(t,"maximum",i)},vo={greater_than:(e,t)=>ao(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>so(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>lo(e,t.value),number_format:_o(ft),bigint_format:_o(pt),min_length:ho,max_length:mo,length_equals:(e,t)=>uo(e,t.length),min_size:ho,max_size:mo,size_equals:(e,t)=>uo(e,t.size),string_format:(e,t)=>{po(e,t.format),t.pattern&&co(e,t.pattern),"base64"!==t.format&&"base64url"!==t.format||(e.contentEncoding=t.format),(t.local||-1===t.precision)&&(e.laxFormat=!0)},mime_type:(e,t)=>fo(e,t.mime)};function yo(e){let t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let e of r)vo[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;void 0!==i.minimum&&ao(t,"minimum",i.minimum),void 0!==i.exclusiveMinimum&&ao(t,"exclusiveMinimum",i.exclusiveMinimum),void 0!==i.maximum&&so(t,"maximum",i.maximum),void 0!==i.exclusiveMaximum&&so(t,"exclusiveMaximum",i.exclusiveMaximum),void 0!==i.multipleOf&&lo(t,i.multipleOf),void 0!==i.format&&(t.format??(t.format=i.format),i.format.includes("int")&&(t.isInt=!0)),i.mime&&fo(t,i.mime);for(let e of i.patterns??[])co(t,e);return t}var go={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},bo=new Map([[jr,/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/],[Nr,/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/]]),wo=e=>bo.get(e)??e;function ko(e){let t=e._zod.def;return"pipe"===t.type&&t.in._zod.traits.has("$ZodTransform")?ko(t.out):"catch"===t.type?ko(t.innerType):e._zod.optin}function zo(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=zo(e,r,n);return i===r?t:i}for(let r of["anyOf","oneOf"]){let i=t[r];if(!Array.isArray(i))continue;let o=i.map(t=>zo(e,t,n));o.some((e,t)=>e!==i[t])&&(t={...t,[r]:o})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes("string")&&r.some(e=>"number"===e||"integer"===e),o=t.enum??(void 0!==t.const?[t.const]:void 0);if(!i&&!o?.some(e=>"number"==typeof e))return t;let{minimum:a,maximum:s,exclusiveMinimum:u,exclusiveMaximum:l,multipleOf:c,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>"number"==typeof e?String(e):e):"number"==typeof p.const&&(p.const=String(p.const)),i?(p.type="string",o||(p.pattern=(r.includes("number")?xn:Sn).source),p):p}var $o=new WeakMap;var Eo=(e,t,n,r)=>{let i=n,o=e._zod.def;i.type="object";let a=o.keyType,s=yo(a).patterns;if("loose"===o.mode&&s&&s.size>0){let e=Ki(o.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(let t of s)Ke(i.patternProperties,wo(t).source,e)}else{if("draft-07"===t.target||"draft-2020-12"===t.target){i.propertyNames=Ki(o.keyType,t,{...r,path:[...r.path,"propertyNames"]});let n=$o.get(t);n||(n=[],$o.set(t,n),t.deferred.push(()=>function(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of $o.get(e)??[]){let i=e.seen.get(r),o=(i?.def??i?.schema)?.propertyNames;if(!o||!0===o||n.has(o))continue;let a=zo(t,o,new Set);a!==o&&n.set(o,a)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}(t))),n.push(e)}i.additionalProperties=Ki(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}let u=a._zod.values,l="input"===t.io&&void 0!==ko(o.valueType);if(u&&!o.partial&&!l){let e=[...u].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(i.required=e.map(String))}},Oo=Symbol();function So(e,t,n,r,i){let o=!1,a=JSON.stringify(e,(e,t)=>"bigint"!=typeof t?t:(o=!0,null));return o?(Vi(t,n,r,i,"BigInt defaults cannot be represented in JSON Schema"),Oo):JSON.parse(a)}var xo=(e,t,n,r)=>{let i=e._zod.def;Ki(i.innerType,t,r),t.seen.get(e).ref=i.innerType},jo=new WeakSet([Object.prototype,Error.prototype]);function Io(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var No,To=Ct("ZodError",(e,t)=>{Gt.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);jo.has(n)||(jo.add(n),Io(n,"format",e=>t=>function(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let o of e.issues)if("invalid_union"===o.code&&o.errors.length)o.errors.map(e=>r({issues:e},[...i,...o.path]));else if("invalid_key"===o.code)r({issues:o.issues},[...i,...o.path]);else if("invalid_element"===o.code)r({issues:o.issues},[...i,...o.path]);else{let e=[...i,...o.path];if(0===e.length)n._errors.push(t(o));else{let r=n,i=0;for(;i<e.length;){let n=e[i],a=i===e.length-1;if("_errors"===n){a&&r._errors.push(t(o)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];a&&s._errors.push(t(o)),r=s,i++}}}};return r(e),n}(e,t)),Io(n,"flatten",e=>t=>function(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Xt(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}(e,t)),Io(n,"addIssue",e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,qe,2)}),Io(n,"addIssues",e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,qe,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return 0===this.issues.length}}))},void 0,{Parent:Error}),Po=Ht(To),Ao=Qt(To),Zo=en(To),Ro=nn(To),Fo=(e=>{let t=Ht(e),n=(e,r,i,o)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return t(e,r,a,Yt(n,o))};return n})(To),Do=(e=>{let t=Ht(e),n=(e,r,i,o)=>t(e,r,i,Yt(n,o));return n})(To),Mo=(e=>{let t=Qt(e),n=async(e,r,i,o)=>{let a=i?{...i,direction:"backward"}:{direction:"backward"};return await t(e,r,a,Yt(n,o))};return n})(To),Co=(e=>{let t=Qt(e),n=async(e,r,i,o)=>await t(e,r,i,Yt(n,o));return n})(To),Jo=(No=To,(e,t,n)=>{let r=n?{...n,direction:"backward"}:{direction:"backward"};return en(No)(e,t,r)}),Uo=(e=>(t,n,r)=>en(e)(t,n,r))(To),Lo=(e=>async(t,n,r)=>{let i=r?{...r,direction:"backward"}:{direction:"backward"};return nn(e)(t,n,i)})(To),qo=(e=>async(t,n,r)=>nn(e)(t,n,r))(To);function Bo(){Lt.localeError||qt({localeError:Ni()})}function Wo(){Lt.memoizer||qt({memoizer:ji})}var Vo=Ct("ZodType",(e,t)=>(Bo(),Hn.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(et(t,{checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return lt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...ct(n)})}(ts,e,t)}(e,t))},superRefine(e,t){return this.check(function(e,t){return qi(e,t)}(e,t))},overwrite(e){return this.check(Li(e))},optional(){return qa(this)},exactOptional(){return new Ba({type:"optional",innerType:this})},nullable(){return Va(this)},nullish(){return qa(Va(this))},nonoptional(e){return function(e,t){return new Xa({type:"nonoptional",innerType:e,...ct(t)})}(this,e)},array(){return function(e,t,n){return new e({type:"array",element:t,...ct(n)})}(Na,this,e);var e},or(e){return Za([this,e])},and(e){return new Ra({type:"intersection",left:this,right:e})},transform(e){return Qa(this,new Ua({type:"transform",transform:e}))},default(e){return t=e,new Ka({type:"default",innerType:this,get defaultValue(){return"function"==typeof t?t():at(t)}});var t},prefault(e){return t=e,new Ga({type:"prefault",innerType:this,get defaultValue(){return"function"==typeof t?t():at(t)}});var t},catch(e){return new Ya({type:"catch",innerType:this,catchValue:"function"==typeof(t=e)?t:Ft(t)});var t},pipe(e){return Qa(this,e)},readonly(){return new es({type:"readonly",innerType:this})},describe(e){let t=this.clone();return Pi.add(t,{description:e}),t},meta(...e){if(0===e.length)return Pi.get(this);let t=this.clone();return Pi.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return 0===t.length?e(this):e(this,...t)},get"~standard"(){return xt(this,"~standard",{...er(this),jsonSchema:{input:oo(this,"input"),output:oo(this,"output")}})},set"~standard"(e){St(this,"~standard",e)},parse:function e(t,n){return Po(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Ao(this,t,n,{callee:e})},safeParse(e,t){return Zo(this,e,t)},async safeParseAsync(e,t){return Ro(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){St(this,"spa",e)},validate(e,t){return an(this,e,t)},validateAsync(e,t){return(async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),0===i.issues.length})(this,e,t)},encode:function e(t,n){return Fo(this,t,n,{callee:e})},decode:function e(t,n){return Do(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Mo(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Co(this,t,n,{callee:e})},safeEncode(e,t){return Jo(this,e,t)},safeDecode(e,t){return Uo(this,e,t)},async safeEncodeAsync(e,t){return Lo(this,e,t)},async safeDecodeAsync(e,t){return qo(this,e,t)},toJSONSchema(e){return((e,t={})=>n=>{let r=Wi({...n,processors:t});return Ki(e,r),Xi(r,e),ro(r,e)})(this,{})(e)},get description(){return Pi.get(this)?.description},get _def(){return this._zod.def}}),Ko=Ct("_ZodString",(e,t)=>{tr.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{let r=n;r.type="string";let{minimum:i,maximum:o,format:a,patterns:s,contentEncoding:u,laxFormat:l}=yo(e);if("number"==typeof i&&(r.minLength=i),"number"==typeof o&&(r.maxLength=o),a&&(r.format=go[a]??a,""===r.format&&delete r.format,("time"===a||l)&&delete r.format),u&&(r.contentEncoding=u),s&&s.size>0){let e=[...s].map(wo);1===e.length?r.pattern=e[0].source:e.length>1&&(r.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,n)},jt({format:e=>yo(e).format??null,minLength:e=>yo(e).minimum??null,maxLength:e=>yo(e).maximum??null},{regex(...e){return this.check(function(e,t){return new Ln({check:"string_format",format:"regex",...ct(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new Wn({check:"string_format",format:"includes",...ct(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new Vn({check:"string_format",format:"starts_with",...ct(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new Kn({check:"string_format",format:"ends_with",...ct(t),suffix:e})}(...e))},min(...e){return this.check(Ji(...e))},max(...e){return this.check(Ci(...e))},length(...e){return this.check(Ui(...e))},nonempty(...e){return this.check(Ji(1,...e))},lowercase(e){return this.check(function(e){return new qn({check:"string_format",format:"lowercase",...ct(e)})}(e))},uppercase(e){return this.check(function(e){return new Bn({check:"string_format",format:"uppercase",...ct(e)})}(e))},trim(){return this.check(Li(e=>e.trim()))},normalize(...e){return this.check(function(e){return Li(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(Li(e=>e.toLowerCase()))},toUpperCase(){return this.check(Li(e=>e.toUpperCase()))},slugify(){return this.check(Li(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}})),Go=Ct("ZodString",(e,t)=>{tr.init(e,t),Ko.init(e,t)},{email(e){return this.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...ct(t)})}(na,e))},url(e){return this.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...ct(t)})}(oa,e))},jwt(e){return this.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...ct(t)})}(ba,e))},emoji(e){return this.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...ct(t)})}(aa,e))},guid(e){return this.check(function(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ct(t)})}(ra,e))},uuid(e){return this.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...ct(t)})}(ia,e))},uuidv4(e){return this.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ct(t)})}(ia,e))},uuidv6(e){return this.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ct(t)})}(ia,e))},uuidv7(e){return this.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ct(t)})}(ia,e))},nanoid(e){return this.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...ct(t)})}(sa,e))},cuid(e){return this.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...ct(t)})}(ua,e))},cuid2(e){return this.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...ct(t)})}(la,e))},ulid(e){return this.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...ct(t)})}(ca,e))},base64(e){return this.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...ct(t)})}(va,e))},base64url(e){return this.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...ct(t)})}(ya,e))},xid(e){return this.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...ct(t)})}(da,e))},ksuid(e){return this.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...ct(t)})}(fa,e))},ipv4(e){return this.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...ct(t)})}(pa,e))},ipv6(e){return this.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...ct(t)})}(ha,e))},cidrv4(e){return this.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ct(t)})}(ma,e))},cidrv6(e){return this.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ct(t)})}(_a,e))},e164(e){return this.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...ct(t)})}(ga,e))},datetime(e){return this.check(function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ct(t)})}(Ho,e))},date(e){return this.check(function(e,t){return new e({type:"string",format:"date",check:"string_format",...ct(t)})}(Qo,e))},time(e){return this.check(function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...ct(t)})}(ea,e))},duration(e){return this.check(function(e,t){return new e({type:"string",format:"duration",check:"string_format",...ct(t)})}(ta,e))}});function Xo(e){return function(e,t){return new e(Ai({type:"string",...ct(t)}))}(Go,e)}var Yo=Ct("ZodStringFormat",(e,t)=>{nr.init(e,t),Ko.init(e,t)}),Ho=Ct("ZodISODateTime",(e,t)=>{yr.init(e,t),Yo.init(e,t)}),Qo=Ct("ZodISODate",(e,t)=>{gr.init(e,t),Yo.init(e,t)}),ea=Ct("ZodISOTime",(e,t)=>{br.init(e,t),Yo.init(e,t)}),ta=Ct("ZodISODuration",(e,t)=>{wr.init(e,t),Yo.init(e,t)}),na=Ct("ZodEmail",(e,t)=>{or.init(e,t),Yo.init(e,t)}),ra=Ct("ZodGUID",(e,t)=>{rr.init(e,t),Yo.init(e,t)}),ia=Ct("ZodUUID",(e,t)=>{ir.init(e,t),Yo.init(e,t)}),oa=Ct("ZodURL",(e,t)=>{cr.init(e,t),Yo.init(e,t)}),aa=Ct("ZodEmoji",(e,t)=>{dr.init(e,t),Yo.init(e,t)}),sa=Ct("ZodNanoID",(e,t)=>{fr.init(e,t),Yo.init(e,t)}),ua=Ct("ZodCUID",(e,t)=>{pr.init(e,t),Yo.init(e,t)}),la=Ct("ZodCUID2",(e,t)=>{hr.init(e,t),Yo.init(e,t)}),ca=Ct("ZodULID",(e,t)=>{mr.init(e,t),Yo.init(e,t)}),da=Ct("ZodXID",(e,t)=>{_r.init(e,t),Yo.init(e,t)}),fa=Ct("ZodKSUID",(e,t)=>{vr.init(e,t),Yo.init(e,t)}),pa=Ct("ZodIPv4",(e,t)=>{kr.init(e,t),Yo.init(e,t)}),ha=Ct("ZodIPv6",(e,t)=>{Er.init(e,t),Yo.init(e,t)}),ma=Ct("ZodCIDRv4",(e,t)=>{Or.init(e,t),Yo.init(e,t)}),_a=Ct("ZodCIDRv6",(e,t)=>{Sr.init(e,t),Yo.init(e,t)}),va=Ct("ZodBase64",(e,t)=>{Ir.init(e,t),Yo.init(e,t)}),ya=Ct("ZodBase64URL",(e,t)=>{Tr.init(e,t),Yo.init(e,t)}),ga=Ct("ZodE164",(e,t)=>{Pr.init(e,t),Yo.init(e,t)}),ba=Ct("ZodJWT",(e,t)=>{Ar.init(e,t),Yo.init(e,t)}),wa=Ct("ZodNumber",(e,t)=>{Zr.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=n,{minimum:o,maximum:a,multipleOf:s,exclusiveMaximum:u,exclusiveMinimum:l,isInt:c}=yo(e);i.type=c?"integer":"number";let d="number"==typeof l&&l>=(o??Number.NEGATIVE_INFINITY),f="number"==typeof u&&u<=(a??Number.POSITIVE_INFINITY),p="draft-04"===t.target||"openapi-3.0"===t.target;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:"number"==typeof o&&(i.minimum=o),f?p?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u:"number"==typeof a&&(i.maximum=a),s){let n=new Set;for(let o of s)Number.isFinite(o)&&0!==o?n.add(Math.abs(o)):Vi(e,t,i,r,`A multipleOf divisor of ${o} cannot be represented in JSON Schema`);let[o,...a]=n;void 0!==o&&(i.multipleOf=o),a.length&&(i.allOf=[...i.allOf??[],...a.map(e=>({multipleOf:e}))])}})(e,t,n,r),e.isFinite=!0},jt({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=yo(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=yo(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:n}=yo(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>yo(e).format??null},{gt(e,t){return this.check(Fi(e,t))},gte(e,t){return this.check(Di(e,t))},min(e,t){return this.check(Di(e,t))},lt(e,t){return this.check(Zi(e,t))},lte(e,t){return this.check(Ri(e,t))},max(e,t){return this.check(Ri(e,t))},int(e){return this.check($a(e))},safe(e){return this.check($a(e))},positive(e){return this.check(Fi(0,e))},nonnegative(e){return this.check(Di(0,e))},negative(e){return this.check(Zi(0,e))},nonpositive(e){return this.check(Ri(0,e))},multipleOf(e,t){return this.check(Mi(e,t))},step(e,t){return this.check(Mi(e,t))},finite(){return this}}));function ka(e){return function(e,t){return new e(Ai({type:"number",checks:[],...ct(t)}))}(wa,e)}var za=Ct("ZodNumberFormat",(e,t)=>{Rr.init(e,t),wa.init(e,t)});function $a(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...ct(t)})}(za,e)}var Ea=Ct("ZodBoolean",(e,t)=>{Fr.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.type="boolean"})(0,0,t)});function Oa(e){return function(e,t){return new e({type:"boolean",...ct(t)})}(Ea,e)}var Sa=Ct("ZodUnknown",(e,t)=>{Dr.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>{}});function xa(){return new Sa({type:"unknown"})}var ja=Ct("ZodNever",(e,t)=>{Mr.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(e,t,n)=>((e,t,n)=>{n.not={}})(0,0,t)});function Ia(e){return function(e,t){return new e({type:"never",...ct(t)})}(ja,e)}var Na=Ct("ZodArray",(e,t)=>{Wo(),Jr.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=n,o=e._zod.def,{minimum:a,maximum:s}=yo(e);"number"==typeof a&&(i.minItems=a),"number"==typeof s&&(i.maxItems=s),i.type="array",i.items=Ki(o.element,t,{...r,path:[...r.path,"items"]})})(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Ji(e,t))},nonempty(e){return this.check(Ji(1,e))},max(e,t){return this.check(Ci(e,t))},length(e,t){return this.check(Ui(e,t))},unwrap(){return this.element}});var Ta=Ct("ZodObject",(e,t)=>{Wo(),Vr.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=n,o=e._zod.def,a=o.shape;if(Object.getOwnPropertySymbols(a).length&&Vi(e,t,i,r,"Symbol keys cannot be represented in JSON Schema"))return;i.type="object",i.properties={};for(let e in a)Ke(i.properties,e,Ki(a[e],t,{...r,path:[...r.path,"properties",e]}));let s=[];for(let e of Object.keys(a)){let n=o.shape[e];("input"===t.io?void 0===ko(n):void 0===n._zod.optout)&&s.push(e)}s.length>0&&(i.required=s),"never"===o.catchall?._zod.def.type?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=Ki(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):"output"===t.io&&(i.additionalProperties=!1)})(e,t,n,r),Zt(e,"shape",e=>e._zod.def.shape,!1)},{keyof(){return Ca(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(et(this._zod.def,{catchall:e}))},passthrough(){return this.clone(et(this._zod.def,{catchall:xa()}))},loose(){return this.clone(et(this._zod.def,{catchall:xa()}))},strict(){return this.clone(et(this._zod.def,{catchall:Ia()}))},strip(){return this.clone(et(this._zod.def,{catchall:void 0}))},extend(e){return function(e,t){if(!ot(t))throw Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let n=Xe(e);for(let e of Reflect.ownKeys(t))if(void 0!==Object.getOwnPropertyDescriptor(n,e))throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return lt(e,et(e._zod.def,{shape:mt(e,t)}))}(this,e)},safeExtend(e){return function(e,t){if(!ot(t))throw Error("Invalid input to safeExtend: expected a plain object");return lt(e,et(e._zod.def,{shape:mt(e,t)}))}(this,e)},merge(e){return function(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};return Qe(n,e,Reflect.ownKeys(Xe(e))),Qe(n,t,Reflect.ownKeys(Xe(t))),lt(e,et(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}(this,e)},pick(e){return function(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let i={};return Qe(i,e,ht(e,t)),lt(e,et(n,{shape:i,checks:[]}))}(this,e)},omit(e){return function(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let i=new Set(ht(e,t)),o={};return Qe(o,e,Reflect.ownKeys(Xe(e)).filter(e=>!i.has(e))),lt(e,et(n,{shape:o,checks:[]}))}(this,e)},partial(...e){return _t(La,this,e[0])},exactPartial(...e){return _t(Ba,this,e[0],"exactPartial")},required(...e){return function(e,t,n){let r=n?new Set(ht(t,n)):void 0,i={};return Qe(i,t,Reflect.ownKeys(Xe(t)),(t,n)=>r&&!r.has(n)?t:new e({type:"nonoptional",innerType:t})),lt(t,et(t._zod.def,{shape:i}))}(Xa,this,e[0])}});function Pa(e,t){let n={type:"object",shape:e??{},...ct(t)};return new Ta(n)}var Aa=Ct("ZodUnion",(e,t)=>{Gr.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def,o=!1===i.inclusive,a=i.options.map((e,n)=>Ki(e,t,{...r,path:[...r.path,o?"oneOf":"anyOf",n]}));o?n.oneOf=a:n.anyOf=a})(e,t,n,r),e.options=t.options});function Za(e,t){return new Aa({type:"union",options:e,...ct(t)})}var Ra=Ct("ZodIntersection",(e,t)=>{Xr.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def,o=Ki(i.left,t,{...r,path:[...r.path,"allOf",0]}),a=Ki(i.right,t,{...r,path:[...r.path,"allOf",1]}),s=e=>"allOf"in e&&1===Object.keys(e).length,u=[...s(o)?o.allOf:[o],...s(a)?a.allOf:[a]];n.allOf=u,t.intersections.push(u)})(e,t,n,r)});var Fa=Ct("ZodRecord",(e,t)=>{Wo(),Qr.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Eo(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Da(e,t,n){return t&&t._zod?new Fa({type:"record",keyType:e,valueType:t,...ct(n)}):new Fa({type:"record",keyType:Xo(),valueType:e,...ct(t)})}var Ma=Ct("ZodEnum",(e,t)=>{ei.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n)=>{let r=Ue(e._zod.def.entries);0!==r.length?(r.every(e=>"number"==typeof e)&&(n.type="number"),r.every(e=>"string"==typeof e)&&(n.type="string"),n.enum=r):n.not={}})(e,0,n),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e){if(!n.has(r))throw Error(`Key ${r} not found in enum`);i[r]=t.entries[r]}return new Ma({...t,checks:[],...ct(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e){if(!n.has(t))throw Error(`Key ${t} not found in enum`);delete i[t]}return new Ma({...t,checks:[],...ct(r),entries:i})}});function Ca(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new Ma({type:"enum",entries:n,...ct(t)})}var Ja=Ct("ZodLiteral",(e,t)=>{ti.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def;if(0===i.values.length)return void(n.not={});let o=[];for(let a of i.values)if(void 0===a){if(Vi(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if("bigint"==typeof a){if(Vi(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(a))}else o.push(a);if(0===o.length);else if(1===o.length){let e=o[0];n.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?n.enum=[e]:n.const=e}else o.every(e=>"number"==typeof e)&&(n.type="number"),o.every(e=>"string"==typeof e)&&(n.type="string"),o.every(e=>"boolean"==typeof e)&&(n.type="boolean"),o.every(e=>null===e)&&(n.type="null"),n.enum=o})(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});var Ua=Ct("ZodTransform",(e,t)=>{Wo(),ni.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{Vi(e,t,n,r,"Transforms cannot be represented in JSON Schema")})(e,t,n,r),e._zod.parse=(n,r)=>{if("backward"===r.direction)throw new Ut(e.constructor.name);n.addIssue=r=>{if("string"==typeof r)n.issues.push(Ot(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),"input"in t||(t.input=n.value),t.inst??(t.inst=e),n.issues.push(Ot(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});var La=Ct("ZodOptional",(e,t)=>{ii.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});function qa(e){return new La({type:"optional",innerType:e})}var Ba=Ct("ZodExactOptional",(e,t)=>{oi.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xo(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Wa=Ct("ZodNullable",(e,t)=>{ai.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def,o=Ki(i.innerType,t,r),a=t.seen.get(e);"openapi-3.0"===t.target?(a.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Va(e){return new Wa({type:"nullable",innerType:e})}var Ka=Ct("ZodDefault",(e,t)=>{si.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def;Ki(i.innerType,t,r),t.seen.get(e).ref=i.innerType;let o=So(i.defaultValue,e,t,n,r);o!==Oo&&(n.default=o)})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});var Ga=Ct("ZodPrefault",(e,t)=>{li.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def;if(Ki(i.innerType,t,r),t.seen.get(e).ref=i.innerType,"input"!==t.io)return;let o=So(i.defaultValue,e,t,n,r);o!==Oo&&(n._prefault=o)})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});var Xa=Ct("ZodNonOptional",(e,t)=>{ci.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def;Ki(i.innerType,t,r),t.seen.get(e).ref=i.innerType})(e,t,0,r),e.unwrap=()=>e._zod.def.innerType});var Ya=Ct("ZodCatch",(e,t)=>{pi.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i,o=e._zod.def;Ki(o.innerType,t,r),t.seen.get(e).ref=o.innerType;try{i=o.catchValue(void 0)}catch{return void Vi(e,t,n,r,"Dynamic catch values are not supported in JSON Schema")}n.default=i})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});var Ha=Ct("ZodPipe",(e,t)=>{hi.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def,o=i.in._zod.traits.has("$ZodTransform"),a="input"===t.io?o?i.out:i.in:i.out;Ki(a,t,r),t.seen.get(e).ref=a})(e,t,0,r),e.in=t.in,e.out=t.out});function Qa(e,t){return new Ha({type:"pipe",in:e,out:t})}var es=Ct("ZodReadonly",(e,t)=>{_i.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{let i=e._zod.def;Ki(i.innerType,t,r),t.seen.get(e).ref=i.innerType,n.readOnly=!0})(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});var ts=Ct("ZodCustom",(e,t)=>{yi.init(e,t),Vo.init(e,t),e._zod.processJSONSchema=(t,n,r)=>((e,t,n,r)=>{Vi(e,t,n,r,"Custom types cannot be represented in JSON Schema")})(e,t,n,r)});var ns,rs,is=Za([ka().int().nonnegative(),(ns="unlimited",new Ja({type:"literal",values:Array.isArray(ns)?ns:[ns],...ct(rs)}))]),os=Pa({min_ms:ka().int().positive().default(5e3),default_ms:ka().int().positive().default(6e4),max_ms:ka().int().positive().default(6e5)}).strict(),as=Pa({max_members:ka().int().min(1).max(8).default(8),max_parallel_members:ka().int().min(1).max(8).default(4),max_wall_clock_minutes:ka().int().positive().default(120)}).strict(),ss=Pa({unavailable_categories:Oa().default(!0)}).strict(),us=Ca(["auto","apfs","btrfs","zfs","reflink","overlayfs","block-clone","rcopy"]),ls=Pa({enabled:Oa().default(!1),backend:us.default("auto"),apply:Oa().default(!0),merge:Ca(["patch","branch"]).default("patch"),commits:Ca(["generic","ai"]).default("generic")}).strict(),cs=ls.parse({}),ds=Pa({enabled:Oa().optional(),backend:us.optional(),apply:Oa().optional(),merge:Ca(["patch","branch"]).optional(),commits:Ca(["generic","ai"]).optional()}).strict(),fs=Pa({max_nodes_per_run:ka().int().positive().default(64),max_runs_per_session:ka().int().positive().default(16),subscriber_ring:ka().int().positive().default(1e3),heartbeat_ms:ka().int().positive().default(15e3),history_default_limit:ka().int().positive().default(256),history_max_limit:ka().int().positive().default(1e3),retention_days:ka().int().positive().default(7),max_prompt_bytes:ka().int().positive().default(262144)}).strict(),ps=(Pa({isolation:ls.default(cs),default_execution_mode:Ca(["auto","in-process","process"]).default("auto"),process_runner:Ca(["host","child-process"]).default("host"),host_engine_policy:Ca(["upgrade","fallback"]).default("upgrade"),host_idle_exit_ms:ka().int().positive().optional(),host_shard_prewarm:Ca(["off","first-turn","session-start"]).default("first-turn"),default_concurrency:ka().int().nonnegative().default(5),global_concurrency:ka().int().nonnegative().default(8),provider_concurrency:Da(Xo(),ka().int().nonnegative()).optional(),model_concurrency:Da(Xo(),ka().int().nonnegative()).optional(),max_depth:ka().int().nonnegative().default(1),residency_max_children:is.default("unlimited"),resident_idle_timeout_ms:ka().int().positive().max(Number.MAX_SAFE_INTEGER).default(9e5),ttl_ms:ka().int().positive().default(864e5),state_dir:Xo().optional(),reattach_on_reconcile:Oa().optional(),resume_children:Oa().default(!0),warnings:ss.default({unavailable_categories:!0}),wait:os.default({min_ms:5e3,default_ms:6e4,max_ms:6e5}),team:as.default({max_members:8,max_parallel_members:4,max_wall_clock_minutes:120}),dag:fs.optional()}).strict(),Pa({max_nodes_per_run:ka().int().positive().optional(),max_runs_per_session:ka().int().positive().optional(),subscriber_ring:ka().int().positive().optional(),heartbeat_ms:ka().int().positive().optional(),history_default_limit:ka().int().positive().optional(),history_max_limit:ka().int().positive().optional(),retention_days:ka().int().positive().optional(),max_prompt_bytes:ka().int().positive().optional()}).strict()),hs=Pa({min_ms:ka().int().positive().optional(),default_ms:ka().int().positive().optional(),max_ms:ka().int().positive().optional()}).strict(),ms=Pa({max_members:ka().int().min(1).max(8).optional(),max_parallel_members:ka().int().min(1).max(8).optional(),max_wall_clock_minutes:ka().int().positive().optional()}).strict(),_s=Pa({unavailable_categories:Oa().optional()}).strict();Pa({isolation:ds.optional(),default_execution_mode:Ca(["auto","in-process","process"]).optional(),process_runner:Ca(["host","child-process"]).optional(),host_engine_policy:Ca(["upgrade","fallback"]).optional(),host_idle_exit_ms:ka().int().positive().optional(),host_shard_prewarm:Ca(["off","first-turn","session-start"]).optional(),default_concurrency:ka().int().nonnegative().optional(),global_concurrency:ka().int().nonnegative().optional(),provider_concurrency:Da(Xo(),ka().int().nonnegative()).optional(),model_concurrency:Da(Xo(),ka().int().nonnegative()).optional(),max_depth:ka().int().nonnegative().optional(),residency_max_children:is.optional(),resident_idle_timeout_ms:ka().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),ttl_ms:ka().int().positive().optional(),state_dir:Xo().optional(),reattach_on_reconcile:Oa().optional(),resume_children:Oa().optional(),warnings:_s.optional(),wait:hs.optional(),team:ms.optional(),dag:ps.optional()}).strict();function vs(e){if(!Je(e))throw Error("isolation is not an object");let t=Ze(e,"mode");if("patch"!==t&&"branch"!==t)throw Error("isolation.mode must be patch or branch");let n=Me(e,"apply");if(void 0===n)throw Error("isolation.apply is required");let r=Me(e,"fell_back");return{backend:us.parse(e.backend),...void 0===r?{}:{fell_back:r},merged_dir:Ze(e,"merged_dir"),base_dir:Ze(e,"base_dir"),mode:t,apply:n}}function ys(e,t,n){let r=e[t];if(void 0!==r){if("string"!=typeof r)throw Error(`${t} is not a string`);if(!n.includes(r))throw Error(`${t} has an invalid value: ${r}`);return r}}function gs(e){let t=e.host_session;if(void 0===t)return;if(!Je(t))throw Error("host_session is not an object");let n=Ze(t,"socket"),r=Ze(t,"routing_id"),i=Ze(t,"session_path"),o=Ze(t,"instance_id"),a=De(t,"daemon_pid");return{socket:n,routing_id:r,session_path:i,instance_id:o,...void 0===a?{}:{daemon_pid:a}}}function bs(e,t="resolved_model"){let n=e[t];if(void 0!==n){if(!Je(n))throw Error(`${t} is not an object`);return zs(n)}}function ws(e,t){let n=e[t];if(void 0!==n){if(!Array.isArray(n))throw Error(`${t} is not an array`);return n.map((e,n)=>{if(!Je(e))throw Error(`${t}[${n}] is not an object`);return zs(e)})}}function ks(e){let t=e.notification;if(!Je(t))throw Error("notification is not an object");let n=De(t,"notification_failed_epoch"),r=De(t,"liveness_notified_epoch");return{run_epoch:Re(t,"run_epoch"),notified_epoch:Re(t,"notified_epoch"),...void 0===n?{}:{notification_failed_epoch:n},...void 0===r?{}:{liveness_notified_epoch:r}}}function zs(e){let t=Fe(e,"variant"),n=Fe(e,"reasoning_effort"),r=Fe(e,"reasoning");return{provider:Ze(e,"provider"),model_id:Ze(e,"model_id"),display:Ze(e,"display"),source:$s(e),...void 0===t?{}:{variant:t},...void 0===n?{}:{reasoning_effort:n},...void 0===r?{}:{reasoning:r}}}function $s(e){let t=Ze(e,"source");switch(t){case"category":case"explicit":case"agent":return t;default:throw Error(`resolved_model.source must be ${p.join(" or ")}`)}}function Es(e){let t=e.failure_kind;if(void 0!==t){if("string"!=typeof t)throw Error("failure_kind is not a string");if(!function(e){return"string"==typeof e&&E.has(e)}(t))throw Error("failure_kind has an invalid value");return t}}function Os(e){let t=e.failure_reason;if(void 0!==t){if("string"!=typeof t)throw Error("failure_reason is not a string");if(!function(e){return"string"==typeof e&&$.has(e)}(t))throw Error("failure_reason has an invalid value");return t}}function Ss(e){if(!Je(e))throw Error("run_stats is not an object");let t=De(e,"failed_turns"),n=De(e,"output_tokens"),r=De(e,"input_tokens"),i=De(e,"cache_read_tokens"),o=De(e,"cache_write_tokens"),a=De(e,"total_tokens"),s=De(e,"generation_ms"),d=De(e,"tokens_per_second"),f=De(e,"cost_usd"),p=De(e,"cache_hit_rate_last"),h=De(e,"cache_hit_rate_run"),m=De(e,"cache_hit_rate"),_=h??m,v=function(e){let t=Fe(e,"token_status");if(void 0===t)return;switch(t){case"complete":case"partial":case"unavailable":return t;default:throw Error(`run_stats.token_status must be one of ${u.join(", ")}`)}}(e),y=function(e){let t=Fe(e,"cost_status");if(void 0===t)return;switch(t){case"reported":case"unavailable":case"invalid":return t;default:throw Error(`run_stats.cost_status must be one of ${l.join(", ")}`)}}(e),g=function(e){let t=Fe(e,"duration_status");if(void 0===t)return;switch(t){case"monotonic":case"wall_clock":case"unavailable":return t;default:throw Error(`run_stats.duration_status must be one of ${c.join(", ")}`)}}(e);return{runtime_ms:Re(e,"runtime_ms"),turns:Re(e,"turns"),...void 0===t?{}:{failed_turns:t},tool_calls:Re(e,"tool_calls"),...void 0===n?{}:{output_tokens:n},...void 0===r?{}:{input_tokens:r},...void 0===i?{}:{cache_read_tokens:i},...void 0===o?{}:{cache_write_tokens:o},...void 0===a?{}:{total_tokens:a},...void 0===s?{}:{generation_ms:s},...void 0===d?{}:{tokens_per_second:d},...void 0===f?{}:{cost_usd:f},...void 0===p?{}:{cache_hit_rate_last:p},...void 0===_?{}:{cache_hit_rate_run:_},...void 0===v?{}:{token_status:v},...void 0===y?{}:{cost_status:y},...void 0===g?{}:{duration_status:g}}}var xs=new Set(["completed","error","cancelled","interrupted","lost"]);function js(e,t,n){if(!Je(e))throw Error(`JSON record at ${t} is not an object`);let r=function(e){let t=Ze(e,"status");switch(t){case"pending":case"running":case"completed":case"error":case"cancelled":case"interrupted":case"lost":return t;default:throw Error(`Invalid task status [REDACTED]; expected one of ${d.join(", ")}`)}}(e),i=Ze(e,"updated_at"),o=Fe(e,"name"),a=Fe(e,"task_summary"),s=Fe(e,"description"),u=Fe(e,"agent_type"),l=Fe(e,"category"),c=Fe(e,"team_run_id"),f=Fe(e,"team_name"),p=Fe(e,"team_member_name"),v=Fe(e,"team_role");if(void 0!==v&&"member"!==v)throw Error("team_role must be member");let g=Ce(e,"tool_allow"),b=Ce(e,"tool_deny"),w=De(e,"pid"),k=De(e,"host_pid"),z=Fe(e,"child_session_id"),$=Fe(e,"final_response"),E=function(e){let t=e.isolation;if(void 0===t)return;let n=vs(t);if(!Je(t))throw Error("isolation is not an object");let r=t.merge_result;if(void 0===r)return n;if(!Je(r))throw Error("isolation.merge_result is not an object");let i=Ze(r,"kind");if("applied"!==i&&"already-applied"!==i&&"not-applied"!==i&&"branch-merged"!==i&&"branch-merge-failed"!==i&&"no-changes"!==i&&"retained"!==i)throw Error("isolation.merge_result.kind is invalid");let o=Me(r,"changesApplied");if(void 0===o)throw Error("isolation.merge_result.changesApplied is required");let a=De(r,"duration_ms"),s=Fe(r,"patchPath"),u=Fe(r,"error"),l=Fe(r,"reason"),c=Fe(r,"summaryPath"),d=De(r,"filesChanged"),f=Ce(r,"nestedPatchPaths"),p=Fe(r,"branchName"),h=Me(r,"partial"),m=Fe(r,"conflict"),_=Fe(r,"manualCommand"),v={kind:i,changesApplied:o,...void 0===a?{}:{duration_ms:a},...void 0===s?{}:{patchPath:s},...void 0===u?{}:{error:u},...void 0===l?{}:{reason:l},...void 0===c?{}:{summaryPath:c},...void 0===d?{}:{filesChanged:d},...void 0===f?{}:{nestedPatchPaths:f},...void 0===p?{}:{branchName:p},...void 0===h?{}:{partial:h},...void 0===m?{}:{conflict:m},...void 0===_?{}:{manualCommand:_}};return{...n,merge_result:v}}(e),O=Fe(e,"error_message"),S=Fe(e,"started_at"),x=Fe(e,"terminal_at"),j=Me(e,"killed"),I=Me(e,"notify_on_terminal")??!1,N=bs(e,"requested_model"),T=ws(e,"fallback_models"),P=ws(e,"fallback_attempts"),A=bs(e,"resolved_model"),Z=function(e){let t=e.spawn_spec;if(void 0!==t){if(!Je(t))throw Error("spawn_spec is not an object");if(1===t.version){let e=Ze(t,"cwd"),n=Ze(t,"prompt"),r=Fe(t,"instructions"),i=Ce(t,"member_scoped_tool_names"),o=void 0===t.isolation?void 0:vs(t.isolation);return{version:1,...void 0===o?{}:{isolation:o},cwd:e,prompt:n,...void 0===r?{}:{instructions:r},...void 0===i?{}:{member_scoped_tool_names:i}}}return{cwd:Ze(t,"cwd")}}}(e),R=function(e){let t=e.owner;if(void 0!==t){if(!Je(t))throw Error("owner is not an object");if("dag"!==Ze(t,"kind"))throw Error("owner.kind is not dag");return{kind:"dag",runId:Ze(t,"runId"),nodeId:Ze(t,"nodeId"),fingerprint:Ze(t,"fingerprint")}}}(e),F=function(e,t,n){let r=e.pending_steering;if(void 0===r)return;if(!Array.isArray(r))throw Error("pending_steering is not an array");let i=[];for(let e=0;e<r.length;e++){let o=r[e];if(!Je(o)){n?.push(`pending_steering[${e}] at ${t}: entry is not an object, dropped`);continue}let{id:a,message:s,deliver_as:u}=o;if("string"!=typeof a){n?.push(`pending_steering[${e}] at ${t}: entry missing string id, dropped`);continue}if("string"!=typeof s){n?.push(`pending_steering[${e}] at ${t}: entry missing string message, dropped`);continue}if("steer"!==u&&"followUp"!==u){n?.push(`pending_steering[${e}] at ${t}: entry has invalid deliver_as, dropped`);continue}let l=o.workpool;if(void 0!==l){if(!Je(l)||"string"!=typeof l.pool_id||!/^wp_[0-9a-f]{32}$/.test(l.pool_id)||"string"!=typeof l.item_id||l.item_id!==a||!/^wi_[0-9a-f]{32}$/.test(a)||"string"!=typeof l.key||0===l.key.trim().length||"number"!=typeof l.generation||!Number.isSafeInteger(l.generation)||l.generation<1||"number"!=typeof l.run_epoch||!Number.isSafeInteger(l.run_epoch)||l.run_epoch<0){n?.push(`pending_steering[${e}] at ${t}: invalid workpool correlation, dropped`);continue}i.push({id:a,message:s,deliver_as:u,workpool:{pool_id:l.pool_id,item_id:l.item_id,key:l.key,generation:l.generation,run_epoch:l.run_epoch}})}else i.push({id:a,message:s,deliver_as:u})}return i}(e,t,n),D=void 0===e.run_stats?void 0:Ss(e.run_stats),M=De(e,"task_seq"),C=De(e,"config_generation"),J=function(e){let t=Fe(e,"background_mode");if(void 0===t)return;switch(t){case"foreground":case"background":case"promoted":return t;default:throw Error(`background_mode must be one of ${h.join(", ")}`)}}(e),U=function(e){let t=e.revive_delivery_uncertain;if(void 0===t)return;if(!Je(t))throw Error("revive_delivery_uncertain is not an object");return{run_epoch:Re(t,"run_epoch"),message_sha256:Ze(t,"message_sha256")}}(e),L=De(e,"resumed_run_epoch"),q=function(e){let t=e.start_queued;if(void 0===t)return;if(!Je(t))throw Error("start_queued is not an object");return{model:Ze(t,"model"),queued_at:Ze(t,"queued_at"),queue_position:Re(t,"queue_position")}}(e),B=function(e){return ys(e,"runner_kind",m)}(e),W=function(e){return ys(e,"suspension_reason",_)}(e),V=Es(e),K=Os(e),G=gs(e);!function(e,t){if(void 0!==t&&"host-session"!==e)throw Error("host_session present but runner_kind is not 'host-session'")}(B,G);let X=De(e,"fallback_handoff_epoch"),Y=function(e){let t=e.fallback_closing_child;if(void 0===t)return;if(!Je(t))throw Error("fallback_closing_child is not an object");let n=De(t,"pid"),r=gs(t);return{...void 0===n?{}:{pid:n},...void 0===r?{}:{host_session:r}}}(e),H=Fe(e,"residency_claim"),Q=function(e){let t=e.cancel_requested;if(void 0===t)return;if(!Je(t))throw Error("cancel_requested is not an object");let n=Fe(t,"reason");return{requested_at:Ze(t,"requested_at"),...void 0===n?{}:{reason:n}}}(e);return{task_id:y(Ze(e,"task_id")),status:r,residency_state:Is(e),parent_session_id:Ze(e,"parent_session_id"),root_session_id:Ze(e,"root_session_id"),depth:Re(e,"depth"),execution_mode:Ze(e,"execution_mode"),model:Ze(e,"model"),notify_on_terminal:I,created_at:Ze(e,"created_at"),updated_at:i,notification:ks(e),...void 0===S?{}:{started_at:S},...void 0!==x||xs.has(r)?{terminal_at:x??i}:{},...void 0===o?{}:{name:o},...void 0===a?{}:{task_summary:a},...void 0===s?{}:{description:s},...void 0===u?{}:{agent_type:u},...void 0===l?{}:{category:l},...void 0===c?{}:{team_run_id:c},...void 0===f?{}:{team_name:f},...void 0===p?{}:{team_member_name:p},...void 0===v?{}:{team_role:v},...void 0===g?{}:{tool_allow:g},...void 0===b?{}:{tool_deny:b},...void 0===N?{}:{requested_model:N},...void 0===T?{}:{fallback_models:T},...void 0===P?{}:{fallback_attempts:P},...void 0===A?{}:{resolved_model:A},...void 0===Z?{}:{spawn_spec:Z},...void 0===R?{}:{owner:R},...void 0!==F&&F.length>0?{pending_steering:F}:{},...void 0===w?{}:{pid:w},...void 0===k?{}:{host_pid:k},...void 0===z?{}:{child_session_id:z},...void 0===$?{}:{final_response:$},...void 0===E?{}:{isolation:E},...void 0===O?{}:{error_message:O},...void 0===V?{}:{failure_kind:V},...void 0===K?{}:{failure_reason:K},...void 0===j?{}:{killed:j},...void 0===D?{}:{run_stats:D},...void 0===M?{}:{task_seq:M},...void 0===C?{}:{config_generation:C},...void 0===J?{}:{background_mode:J},...void 0===U?{}:{revive_delivery_uncertain:U},...void 0===L?{}:{resumed_run_epoch:L},...void 0===q?{}:{start_queued:q},...void 0===W?{}:{suspension_reason:W},...void 0===B?{}:{runner_kind:B},...void 0===G?{}:{host_session:G},...void 0===X?{}:{fallback_handoff_epoch:X},...void 0===Y?{}:{fallback_closing_child:Y},...void 0===H?{}:{residency_claim:H},...void 0===Q?{}:{cancel_requested:Q}}}function Is(e){let t=Ze(e,"residency_state");switch(t){case"resident":case"evicted":case"disposed":case"persisted_only":case"rpc_detached":return t;default:throw Error(`Invalid residency state [REDACTED]; expected one of ${f.join(", ")}`)}}import{randomBytes as Ns}from"node:crypto";import{mkdirSync as Ts,renameSync as Ps,rmSync as As,writeFileSync as Zs}from"node:fs";import{dirname as Rs}from"node:path";var Fs=new Set(["EPERM","EBUSY","EACCES"]),Ds=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));class Ms extends Error{taskId;path;constructor(e){super(`Task record already exists: ${e.taskId}`),this.name="TaskRecordCollisionError",this.taskId=e.taskId,this.path=e.path}}function Cs(e,t,n,r){Ts(Rs(e),{recursive:!0});let i=JSON.stringify(t);if("create"===n)try{return void Zs(e,i,{encoding:"utf8",flag:"wx"})}catch(n){if(n instanceof Error&&"code"in n&&"EEXIST"===n.code)throw new Ms({taskId:y(t.task_id),path:e});throw n}!function(e,t,n=process.platform){Ts(Rs(e),{recursive:!0});let r=`${e}.${process.pid}.${Ns(4).toString("hex")}.tmp`;try{Zs(r,t,"utf8"),function(e,t,n){for(let r=0;;r+=1)try{return void Ps(e,t)}catch(e){if("win32"!==n||r>=8||!Js(e))throw e;Atomics.wait(Ds,0,0,5)}}(r,e,n)}finally{As(r,{force:!0})}}(e,i,r)}function Js(e){return e instanceof Error&&"code"in e&&"string"==typeof e.code&&Fs.has(e.code)}import{createHash as Us}from"node:crypto";import{existsSync as Ls,lstatSync as qs,readdirSync as Bs,realpathSync as Ws,writeFileSync as Vs}from"node:fs";import{homedir as Ks}from"node:os";import{basename as Gs,join as Xs,resolve as Ys}from"node:path";var Hs=["OMO_CODING_AGENT_DIR","SENPI_CODING_AGENT_DIR","PI_CODING_AGENT_DIR"];function Qs(e){try{if(!qs(e).isDirectory())return!0}catch(e){return!(e instanceof Error&&"code"in e)||"ENOENT"!==e.code&&"ENOTDIR"!==e.code}return eu(e)}function eu(e){try{return Bs(e,{withFileTypes:!0}).some(t=>!(t.isDirectory()&&!t.name.includes("."))||eu(Xs(e,t.name)))}catch(e){return!(e instanceof Error&&"code"in e)||"ENOENT"!==e.code&&"ENOTDIR"!==e.code}}function tu(e){try{Vs(Xs(e,".in-project"),"",{flag:"wx"})}catch{}}function nu(e){let t=function(e){let t=Ys(e);try{return Ws.native(t)}catch(e){if(e instanceof Error&&"code"in e&&("ENOENT"===e.code||"ENOTDIR"===e.code))return t;throw e}}(e),n=Us("sha256").update(t).digest("hex").slice(0,12);return`${Gs(t).replace(/[^\p{L}\p{N}._-]/gu,"_")||"root"}-${n}`}function ru(e,t,n={}){let{env:r=process.env,exists:i=Ls,hasRecords:o=Qs,markAdopted:a=tu}=n,s=Xs(Ys(e),".omo",t);return i(s)&&o(s)?(a(s),s):Xs(function(e){for(let t of Hs){let n=e[t]?.trim();if(n)return Ys(n)}return Xs(e.HOME??e.USERPROFILE??Ks(),".omo","agent")}(r),"projects",nu(e),t)}function iu(e,n={}){let r=function(e){return e.task?.state_dir??ru(e.project_dir,"senpi-task")}(e),u=n.platform??process.platform,l=new Map,c=new Map;function d(e){let t=[],n=uu(e,t);if(null===n)return;let r=a(e);l.set(e,{record:n,mtimeMs:r.mtimeMs,size:r.size,warnings:t})}return{stateDir:r,save(e){let t=cu(r,y(e.task_id));Cs(t,e,"create",u),d(t)},replace(e){let t=y(e.task_id),n=cu(r,t);ve(n,()=>{Cs(n,e,"replace",u),d(n)})},mutate(e,t){let n=y(e),i=cu(r,n);return ve(i,()=>{let e=uu(i);if(null===e)return null;let n=t(e);return n!==e&&Cs(i,n,"replace",u),d(i),n})},load:e=>su(cu(r,y(e)),l),list:()=>function(e,t){let n=s(e,"tasks"),r=[],i=[],o=new Set;for(let e of au(n).filter(e=>e.endsWith(".json")).toSorted()){let a=s(n,e);o.add(a);try{let e=su(a,t);if(null!==e){r.push(e);let n=t.get(a);if(void 0!==n)for(let e of n.warnings)i.push({type:"parse_warning",path:a,message:e})}}catch(e){if(!(e instanceof Error))throw e;i.push({type:"parse_error",path:a,message:e.message})}}for(let e of t.keys())!o.has(e)&&e.startsWith(n)&&t.delete(e);return{records:r,diagnostics:i}}(r,l),appendEvent:(e,t)=>A(r,y(e),t,c),transition(e,t){let n=y(e),i=cu(r,n);return ve(i,()=>{let o=uu(i);if(null===o)throw Error(`Task record not found: ${e}`);let a=w(o,t);return A(r,n,{type:a.audit.type,payload:a.audit},c),a.applied&&Cs(i,a.record,"replace",u),d(i),a})},remove(e){let t=y(e);ve(cu(r,t),()=>ou(r,t,l,c))},tombstoneIfExpired(e,n,o){let a=y(e),u=cu(r,a);return t(s(r,"tasks"),{recursive:!0}),ve(u,()=>{let e=uu(u);return null===e?{kind:"missing"}:n(e)?{kind:"retained"}:(void 0!==o&&Ne(du(r,a),o),i(u,du(r,a)),l.delete(u),{kind:"tombstoned",record:e})})},completeExpunge(e,t){let n=y(e),i=du(r,n);return!(void 0!==t&&!function(e,t,n){return ve(e,()=>Z(t)&&Ae(Pe(t),n))}(cu(r,n),i,t))&&(ou(r,n,l,c),o(i,{force:!0}),Te(i),!0)},loadExpunging:e=>uu(du(r,y(e))),restoreExpunging(e,t){let n=y(e),i=cu(r,n);(function(e,t,n){return ve(e,()=>!(!Z(t)||Z(e)||void 0!==n&&!Ae(Pe(t),n)||(F(t,e),Te(t),0)))})(i,du(r,n),t)&&l.delete(i)},readExpungeOwner:e=>Pe(du(r,y(e))),takeOverExpunging(e,t,n){let i=y(e);return function(e,t,n,r){return ve(e,()=>{if(!Z(t))return!1;let e=Pe(t);return!!(void 0===e?void 0===n:Ae(e,n))&&(Ne(t,r),!0)})}(cu(r,i),du(r,i),t,n)},listExpunging:()=>au(s(r,"tasks")).filter(e=>e.endsWith(lu)).map(e=>e.slice(0,e.length-lu.length)).filter(fu).toSorted()}}function ou(e,t,n,r){o(s(e,"children",String(t)),{recursive:!0,force:!0}),o(s(e,"completion-results",`${t}.txt`),{force:!0});let i=P(e,String(t));o(i,{force:!0}),function(e,t){let n=t.get(e);void 0!==n&&(t.delete(e),O(n))}(i,r);let a=cu(e,t);o(a,{force:!0}),n.delete(a)}function au(e){try{return n(e)}catch(e){if(pu(e))return[];throw e}}function su(e,t){let n;try{n=a(e)}catch(n){if(pu(n))return t.delete(e),null;throw n}let r=t.get(e);if(void 0!==r&&r.mtimeMs===n.mtimeMs&&r.size===n.size)return r.record;let i=[],o=uu(e,i);return null!==o&&t.set(e,{record:o,mtimeMs:n.mtimeMs,size:n.size,warnings:i}),o}function uu(e,t=[]){try{return js(JSON.parse(r(e,"utf8")),e,t)}catch(e){if(e instanceof Error&&"code"in e&&"ENOENT"===e.code)return null;throw e}}var lu=".json.expunging";function cu(e,t){return s(e,"tasks",`${t}.json`)}function du(e,t){return s(e,"tasks",`${t}${lu}`)}function fu(e){try{return y(e),!0}catch{return!1}}function pu(e){return e instanceof Error&&"code"in e&&"ENOENT"===e.code}var hu=new Set(["daemon_unavailable","host_draining"]),mu=new Set(["model_not_in_child_profile","catalog_probe_timed_out","catalog_probe_failed","protocol","capability","engine_mismatch","engine_refused","win32","runtime","host_unreachable","ensure_failed","ensure_timed_out","open_timed_out","session_path_in_use","session_reservation_limit","invalid_path","open_failed","invalid_session_context","invalid_session_kind","invalid_launch_profile","invalid_session_id","session_id_in_use","host_memory_pressure","host_draining"]);function _u(e,t){let n=iu({project_dir:e,task:{state_dir:e}}).list();if(n.diagnostics.some(e=>"parse_error"===e.type))throw Error(`rollback migration refused malformed records in ${e}`);let r=n.records.filter(e=>vu(e,t));return{store_dir:e,migrate:r.length,skipped:n.records.length-r.length,sockets:[...new Set(r.map(e=>e.host_session?.socket).filter(e=>void 0!==e&&e!==t))].toSorted()}}function vu(e,t){return void 0!==e.host_session&&e.host_session.socket!==t||void 0!==e.suspension_reason&&!hu.has(e.suspension_reason)||void 0!==e.failure_reason&&!mu.has(e.failure_reason)}import{existsSync as yu}from"node:fs";import{randomUUID as gu}from"node:crypto";import{closeSync as bu,fsyncSync as wu,mkdirSync as ku,openSync as zu,readFileSync as $u,renameSync as Eu,rmSync as Ou,writeSync as Su}from"node:fs";import{dirname as xu}from"node:path";var ju={read:function(e){try{return $u(e,"utf8")}catch(e){if(e instanceof Error&&"code"in e&&"ENOENT"===e.code)return;throw e}},write:function(e,t){ku(xu(e),{recursive:!0,mode:448});let n=`${e}.${process.pid}.${gu()}.tmp`,r=zu(n,"w",384);try{Su(r,t),wu(r)}finally{bu(r)}try{Eu(n,e)}catch(e){throw Ou(n,{force:!0}),e}!function(e){if("win32"===process.platform)return;let t=zu(e,"r");try{wu(t)}catch(e){let t=e instanceof Error&&"code"in e?e.code:void 0;if("EINVAL"!==t&&"ENOTSUP"!==t)throw e}finally{bu(t)}}(xu(e))}},Iu={holderWaitMs:1e4};function Nu(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}var Tu=JSON.parse(e(0,"utf8")),Pu="prune-store-index"===Tu.operation?{removed:await async function(e,t={}){let n=t.exists??yu,r=t.fs??ju;return ye(e,async()=>{await(t._test?.afterLockAcquired?.());let i=function(e){if(void 0===e)return{version:1,stores:{}};let t=JSON.parse(e);if(!Nu(t)||1!==t.version||!Nu(t.stores))throw Error("the store index is not a version 1 index");let n={};for(let[e,r]of Object.entries(t.stores)){if(!Nu(r)||"string"!=typeof r.first_seen||"string"!=typeof r.last_seen)throw Error(`the store index entry for ${e} is malformed`);n[e]={first_seen:r.first_seen,last_seen:r.last_seen}}return{version:1,stores:n}}(r.read(e));await(t._test?.afterRead?.());let o={},a=[];for(let[e,t]of Object.entries(i.stores))n(e)?o[e]=t:a.push(e);return 0===a.length?[]:(r.write(e,`${JSON.stringify({...i,stores:o},null,2)}\n`),a)},Iu)}(Tu.indexPath)}:Tu.planOnly?_u(Tu.storeDir,Tu.to):function(e,t){let n=_u(e,t.to);for(let e of n.sockets)if(!t.deadEndpoints.has(e))throw Error(`rollback migration refused live or unverified endpoint ${e}`);if(t.dryRun)return{...n,migrated:0};let r=iu({project_dir:e,task:{state_dir:e}}),i=0;for(let e of r.list().records){let n=e.host_session?.socket;vu(e,t.to)&&(null!==r.mutate(e.task_id,e=>{if(!vu(e,t.to))return e;let n=void 0!==e.host_session&&e.host_session.socket!==t.to;return{...e,...n?{host_session:{...e.host_session,socket:t.to}}:{},...void 0===e.suspension_reason||hu.has(e.suspension_reason)?{}:{suspension_reason:void 0},...void 0===e.failure_reason||mu.has(e.failure_reason)?{}:{failure_reason:void 0}}})&&(void 0!==n&&n!==t.to&&r.appendEvent(e.task_id,{type:"host_session_migrated",payload:{from:n,to:t.to,reason:"rollback"}}),i+=1))}return{...n,migrated:i}}(Tu.storeDir,{to:Tu.to,deadEndpoints:new Set(Tu.deadEndpoints??[]),dryRun:Tu.dryRun});process.stdout.write(`${JSON.stringify(Pu)}\n`);
|