@fibteq/myrel-runner 0.28.1 → 0.28.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +22 -22
- package/dist/index.js +20 -20
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var Pb=Object.defineProperty;var tt=(e,t)=>{for(var r in t)Pb(e,r,{get:t[r],enumerable:!0})};import{fileURLToPath as zb}from"node:url";import{parseArgs as aj}from"node:util";var jb={message:"cmsg",thread:"thr",project:"proj",usage:"use",apiKey:"key",invite:"inv",runner:"rnr",task:"task",artifact:"art",routine:"rtn",notification:"ntf",connector:"mcp",skill:"skl",suggestion:"sug",question:"qst",sshHost:"ssh",sshRun:"sshr"};function fe(e){return new RegExp(`^${jb[e]}_[0-9A-HJKMNP-TV-Z]{26}$`)}var c={};tt(c,{$brand:()=>zs,$input:()=>Qu,$output:()=>Yu,INVALID:()=>ye,NEVER:()=>Is,TimePrecision:()=>dl,ZodAny:()=>Yd,ZodArray:()=>np,ZodBase64:()=>va,ZodBase64URL:()=>ya,ZodBigInt:()=>Bn,ZodBigIntFormat:()=>_a,ZodBoolean:()=>Jn,ZodCIDRv4:()=>ga,ZodCIDRv6:()=>ha,ZodCUID:()=>ca,ZodCUID2:()=>ua,ZodCatch:()=>kp,ZodCodec:()=>Yr,ZodCompileAsyncError:()=>Le,ZodCompileUnsupportedError:()=>M,ZodCreditCard:()=>Kd,ZodCustom:()=>Qr,ZodCustomStringFormat:()=>Gt,ZodDate:()=>Br,ZodDefault:()=>vp,ZodDiscriminatedUnion:()=>ip,ZodE164:()=>$a,ZodEmail:()=>ia,ZodEmoji:()=>aa,ZodEnum:()=>Fn,ZodError:()=>Gw,ZodExactOptional:()=>Sa,ZodFile:()=>fp,ZodFirstPartyTypeKind:()=>Ep,ZodFunction:()=>Np,ZodGUID:()=>oa,ZodIBAN:()=>Jd,ZodIPv4:()=>fa,ZodIPv6:()=>ma,ZodISODate:()=>kt,ZodISODateTime:()=>xt,ZodISODuration:()=>St,ZodISOTime:()=>wt,ZodInstanceOf:()=>Cp,ZodIntersection:()=>op,ZodIssueCode:()=>Xw,ZodJWT:()=>ba,ZodKSUID:()=>pa,ZodLazy:()=>Ap,ZodLiteral:()=>pp,ZodMAC:()=>Vd,ZodMap:()=>lp,ZodNaN:()=>Sp,ZodNanoID:()=>sa,ZodNever:()=>ep,ZodNonOptional:()=>Ia,ZodNull:()=>Hd,ZodNullable:()=>hp,ZodNumber:()=>Kn,ZodNumberFormat:()=>qt,ZodObject:()=>Gr,ZodOptional:()=>Hr,ZodPipe:()=>Xr,ZodPrefault:()=>$p,ZodPreprocess:()=>Ip,ZodPromise:()=>Tp,ZodReadonly:()=>zp,ZodRealError:()=>Ie,ZodRecord:()=>Zn,ZodSet:()=>dp,ZodString:()=>Vn,ZodStringFormat:()=>W,ZodSuccess:()=>xp,ZodSymbol:()=>Gd,ZodTemplateLiteral:()=>jp,ZodTransform:()=>mp,ZodTuple:()=>sp,ZodType:()=>C,ZodULID:()=>la,ZodURL:()=>Jr,ZodUUID:()=>We,ZodUndefined:()=>qd,ZodUnion:()=>qr,ZodUnknown:()=>Qd,ZodVoid:()=>tp,ZodXID:()=>da,ZodXor:()=>rp,_ZodString:()=>ra,_default:()=>yp,_function:()=>Pv,any:()=>ov,array:()=>Wr,base64:()=>Mh,base64url:()=>Lh,bigint:()=>ev,boolean:()=>Wd,catch:()=>wp,check:()=>jv,cidrv4:()=>Eh,cidrv6:()=>Rh,clone:()=>F,codec:()=>wv,coerce:()=>Mp,compile:()=>rl,config:()=>te,core:()=>at,creditCard:()=>Fh,cuid:()=>jh,cuid2:()=>Ah,currencyCode:()=>Gh,custom:()=>Av,date:()=>sv,decode:()=>Cd,decodeAsync:()=>Rd,deepPartial:()=>Vv,describe:()=>Ov,discriminatedUnion:()=>fv,e164:()=>Zh,email:()=>$h,emoji:()=>zh,encode:()=>Ud,encodeAsync:()=>Ed,endsWith:()=>An,enum:()=>ka,exactOptional:()=>gp,file:()=>bv,flattenError:()=>mr,float32:()=>Hh,float64:()=>Xh,formatError:()=>gr,fromJSONSchema:()=>Zv,function:()=>Pv,getDiscriminatedOption:()=>Iu,getErrorMap:()=>Qw,globalRegistry:()=>le,gt:()=>Je,gte:()=>Te,guid:()=>bh,hash:()=>qh,hex:()=>Wh,hostname:()=>Bh,httpUrl:()=>Ih,iban:()=>Vh,includes:()=>Pn,input:()=>Jv,instanceof:()=>Nv,int:()=>ta,int32:()=>Yh,int64:()=>tv,intersection:()=>ap,invertCodec:()=>Sv,ipv4:()=>Dh,ipv6:()=>Ch,iso:()=>ei,json:()=>Uv,jwt:()=>Kh,keyof:()=>cv,ksuid:()=>Nh,lazy:()=>Op,length:()=>Vt,literal:()=>$v,locales:()=>Ur,looseObject:()=>dv,looseRecord:()=>gv,lowercase:()=>In,lt:()=>Ke,lte:()=>Oe,mac:()=>Uh,map:()=>hv,maxLength:()=>Ft,maxSize:()=>yt,memoizer:()=>Nr,meta:()=>Tv,mime:()=>Tn,minLength:()=>ot,minSize:()=>Be,multipleOf:()=>vt,nan:()=>kv,nanoid:()=>Ph,nativeEnum:()=>yv,negative:()=>Ko,never:()=>xa,nonnegative:()=>Bo,nonoptional:()=>_p,nonpositive:()=>Jo,normalize:()=>Nn,null:()=>Xd,nullable:()=>Kr,nullish:()=>_v,number:()=>Bd,object:()=>uv,optional:()=>Bt,output:()=>Bv,overwrite:()=>Ze,parse:()=>Od,parseAsync:()=>Td,partialRecord:()=>mv,pipe:()=>na,positive:()=>Vo,prefault:()=>bp,preprocess:()=>Cv,prettifyError:()=>Ts,promise:()=>zv,properties:()=>On,property:()=>Wo,readonly:()=>Pp,record:()=>up,refine:()=>Dp,regex:()=>Sn,regexes:()=>Ee,registry:()=>yo,safeDecode:()=>Ld,safeDecodeAsync:()=>Fd,safeEncode:()=>Md,safeEncodeAsync:()=>Zd,safeParse:()=>Nd,safeParseAsync:()=>Dd,set:()=>vv,setErrorMap:()=>Yw,size:()=>Zt,slugify:()=>En,startsWith:()=>jn,strictObject:()=>lv,string:()=>Vr,stringFormat:()=>Jh,stringbool:()=>Dv,success:()=>xv,superRefine:()=>Up,symbol:()=>rv,templateLiteral:()=>Iv,toJSONSchema:()=>Xo,toLowerCase:()=>Un,toUpperCase:()=>Cn,toZod:()=>ir,transform:()=>wa,treeifyError:()=>Os,trim:()=>Dn,tuple:()=>cp,uint32:()=>Qh,uint64:()=>nv,ulid:()=>Oh,undefined:()=>iv,union:()=>Wn,unknown:()=>Jt,uppercase:()=>zn,url:()=>Sh,util:()=>$,uuid:()=>_h,uuidv4:()=>xh,uuidv6:()=>kh,uuidv7:()=>wh,validate:()=>hr,validateAsync:()=>vr,void:()=>av,withParser:()=>$o,xid:()=>Th,xor:()=>pv});var at={};tt(at,{$ZodAny:()=>vu,$ZodArray:()=>ku,$ZodAsyncError:()=>we,$ZodBase64:()=>ou,$ZodBase64URL:()=>au,$ZodBigInt:()=>ro,$ZodBigIntFormat:()=>fu,$ZodBoolean:()=>zr,$ZodCIDRv4:()=>ru,$ZodCIDRv6:()=>iu,$ZodCUID:()=>Jc,$ZodCUID2:()=>Bc,$ZodCatch:()=>Fu,$ZodCheck:()=>G,$ZodCheckBigIntFormat:()=>yc,$ZodCheckEndsWith:()=>Ac,$ZodCheckGreaterThan:()=>Zi,$ZodCheckIncludes:()=>Pc,$ZodCheckLengthEquals:()=>wc,$ZodCheckLessThan:()=>Li,$ZodCheckLowerCase:()=>Ic,$ZodCheckMaxLength:()=>xc,$ZodCheckMaxSize:()=>$c,$ZodCheckMimeType:()=>Nc,$ZodCheckMinLength:()=>kc,$ZodCheckMinSize:()=>bc,$ZodCheckMultipleOf:()=>hc,$ZodCheckNumberFormat:()=>vc,$ZodCheckOverwrite:()=>Dc,$ZodCheckProperties:()=>Tc,$ZodCheckProperty:()=>Oc,$ZodCheckRegex:()=>Sc,$ZodCheckSizeEquals:()=>_c,$ZodCheckStartsWith:()=>jc,$ZodCheckStringFormat:()=>bn,$ZodCheckUpperCase:()=>zc,$ZodCodec:()=>jr,$ZodCreditCard:()=>cu,$ZodCustom:()=>qu,$ZodCustomStringFormat:()=>du,$ZodCyclicError:()=>lo,$ZodDate:()=>_u,$ZodDefault:()=>Ru,$ZodDiscriminatedUnion:()=>zu,$ZodE164:()=>su,$ZodEmail:()=>Mc,$ZodEmoji:()=>Vc,$ZodEncodeError:()=>gt,$ZodEnum:()=>Tu,$ZodError:()=>As,$ZodExactOptional:()=>Cu,$ZodFile:()=>Du,$ZodFunction:()=>Wu,$ZodGUID:()=>Ec,$ZodIBAN:()=>uu,$ZodIPv4:()=>eu,$ZodIPv6:()=>tu,$ZodISODate:()=>Xc,$ZodISODateTime:()=>Hc,$ZodISODuration:()=>Qc,$ZodISOTime:()=>Yc,$ZodIntersection:()=>Pu,$ZodJWT:()=>lu,$ZodKSUID:()=>qc,$ZodLazy:()=>Ar,$ZodLiteral:()=>Nu,$ZodMAC:()=>nu,$ZodMap:()=>Au,$ZodNaN:()=>Vu,$ZodNanoID:()=>Kc,$ZodNever:()=>$u,$ZodNonOptional:()=>Lu,$ZodNull:()=>hu,$ZodNullable:()=>Eu,$ZodNumber:()=>no,$ZodNumberFormat:()=>pu,$ZodObject:()=>jm,$ZodObjectJIT:()=>wu,$ZodOptional:()=>oo,$ZodPipe:()=>ao,$ZodPrefault:()=>Mu,$ZodPreprocess:()=>Ku,$ZodPromise:()=>Gu,$ZodReadonly:()=>Ju,$ZodRealError:()=>Se,$ZodRecord:()=>ju,$ZodRegistry:()=>vo,$ZodSet:()=>Ou,$ZodString:()=>Et,$ZodStringFormat:()=>V,$ZodSuccess:()=>Zu,$ZodSymbol:()=>mu,$ZodTemplateLiteral:()=>Bu,$ZodTransform:()=>Uu,$ZodTuple:()=>io,$ZodType:()=>D,$ZodULID:()=>Wc,$ZodURL:()=>Fc,$ZodUUID:()=>Rc,$ZodUndefined:()=>gu,$ZodUnion:()=>Pr,$ZodUnknown:()=>yu,$ZodVoid:()=>bu,$ZodXID:()=>Gc,$ZodXor:()=>Su,$brand:()=>zs,$constructor:()=>h,$input:()=>Qu,$output:()=>Yu,Doc:()=>Ct,INVALID:()=>ye,JSONSchema:()=>hh,JSONSchemaGenerator:()=>Yo,NEVER:()=>Is,TimePrecision:()=>dl,URL_BAD_FORMAT:()=>Lc,URL_UNPARSEABLE:()=>xr,ZodCompileAsyncError:()=>Le,ZodCompileUnsupportedError:()=>M,_any:()=>Pl,_array:()=>Ul,_base64:()=>Mo,_base64url:()=>Lo,_bigint:()=>_l,_boolean:()=>$l,_catch:()=>Cw,_check:()=>eh,_cidrv4:()=>Eo,_cidrv6:()=>Ro,_coercedBigint:()=>xl,_coercedBoolean:()=>bl,_coercedDate:()=>Nl,_coercedNumber:()=>fl,_coercedString:()=>sl,_creditCard:()=>ul,_cuid:()=>Ao,_cuid2:()=>Oo,_custom:()=>El,_date:()=>Tl,_decode:()=>ji,_decodeAsync:()=>Oi,_default:()=>Nw,_discriminatedUnion:()=>_w,_e164:()=>Zo,_email:()=>xo,_emoji:()=>Po,_encode:()=>Pi,_encodeAsync:()=>Ai,_endsWith:()=>An,_enum:()=>zw,_file:()=>Cl,_float32:()=>gl,_float64:()=>hl,_gt:()=>Je,_gte:()=>Te,_guid:()=>ko,_iban:()=>ll,_includes:()=>Pn,_int:()=>ml,_int32:()=>vl,_int64:()=>kl,_intersection:()=>xw,_ipv4:()=>Uo,_ipv6:()=>Co,_isoDate:()=>Rr,_isoDateTime:()=>Er,_isoDuration:()=>Lr,_isoTime:()=>Mr,_jwt:()=>Fo,_ksuid:()=>Do,_lazy:()=>Lw,_length:()=>Vt,_literal:()=>jw,_lowercase:()=>In,_lt:()=>Ke,_lte:()=>Oe,_mac:()=>cl,_map:()=>Sw,_max:()=>Oe,_maxLength:()=>Ft,_maxSize:()=>yt,_mime:()=>Tn,_min:()=>Te,_minLength:()=>ot,_minSize:()=>Be,_multipleOf:()=>vt,_nan:()=>Dl,_nanoid:()=>jo,_nativeEnum:()=>Pw,_negative:()=>Ko,_never:()=>Al,_nonnegative:()=>Bo,_nonoptional:()=>Dw,_nonpositive:()=>Jo,_normalize:()=>Nn,_null:()=>zl,_nullable:()=>Tw,_number:()=>pl,_optional:()=>Ow,_overwrite:()=>Ze,_parse:()=>hn,_parseAsync:()=>vn,_pipe:()=>Ew,_positive:()=>Vo,_promise:()=>Zw,_properties:()=>On,_property:()=>Wo,_readonly:()=>Rw,_record:()=>ww,_refine:()=>Rl,_regex:()=>Sn,_safeDecode:()=>Ni,_safeDecodeAsync:()=>Ui,_safeEncode:()=>Ti,_safeEncodeAsync:()=>Di,_safeParse:()=>yn,_safeParseAsync:()=>$n,_set:()=>Iw,_size:()=>Zt,_slugify:()=>En,_startsWith:()=>jn,_string:()=>al,_stringFormat:()=>Kt,_stringbool:()=>Fl,_success:()=>Uw,_superRefine:()=>Ml,_symbol:()=>Sl,_templateLiteral:()=>Mw,_toLowerCase:()=>Un,_toUpperCase:()=>Cn,_transform:()=>Aw,_trim:()=>Dn,_tuple:()=>kw,_uint32:()=>yl,_uint64:()=>wl,_ulid:()=>To,_undefined:()=>Il,_union:()=>$w,_unknown:()=>jl,_uppercase:()=>zn,_url:()=>Cr,_uuid:()=>wo,_uuidv4:()=>So,_uuidv6:()=>Io,_uuidv7:()=>zo,_void:()=>Ol,_xid:()=>No,_xor:()=>bw,base64Charset:()=>Xi,base64urlCharset:()=>Ir,canParseURL:()=>Zc,clone:()=>F,compile:()=>rl,compileFn:()=>bo,config:()=>te,createStandardJSONSchemaMethod:()=>Rn,createToJSONSchemaMethod:()=>Kl,decode:()=>b_,decodeAsync:()=>x_,describe:()=>Ll,encode:()=>$_,encodeAsync:()=>__,extractDefs:()=>bt,finalize:()=>_t,flattenError:()=>mr,formatError:()=>gr,getDiscriminatedOption:()=>Iu,globalConfig:()=>se,globalRegistry:()=>le,handleUnrepresentable:()=>oe,initializeContext:()=>$t,isBackEdge:()=>fo,isRecursiveSchema:()=>po,isValidBase64:()=>Sr,isValidBase64URL:()=>Yi,isValidCIDRv6:()=>Hi,isValidCreditCard:()=>Qi,isValidIBAN:()=>eo,isValidIPv6:()=>wr,isValidJWT:()=>to,locales:()=>Ur,memoizer:()=>Nr,mergeValues:()=>_n,meta:()=>Zl,parse:()=>Ii,parseAsync:()=>zi,parseURLObject:()=>Im,prettifyError:()=>Ts,process:()=>K,processSchema:()=>K,regexes:()=>Ee,registry:()=>yo,safeDecode:()=>w_,safeDecodeAsync:()=>I_,safeEncode:()=>k_,safeEncodeAsync:()=>S_,safeParse:()=>m_,safeParseAsync:()=>g_,standardProps:()=>Bi,stripTabAndNewline:()=>kr,toDotPath:()=>om,toJSONSchema:()=>Xo,toZod:()=>ir,treeifyError:()=>Os,urlHostnameOk:()=>Gi,urlProtocolOk:()=>qi,util:()=>$,validate:()=>hr,validateAsync:()=>vr,validateURL:()=>Wi,version:()=>Uc,withParser:()=>$o});var $={};tt($,{BIGINT_FORMAT_RANGES:()=>ur,CONSTANT_CATCH:()=>wi,Class:()=>hs,NUMBER_FORMAT_RANGES:()=>cr,aborted:()=>ve,allowsEval:()=>$s,assert:()=>Db,assertEqual:()=>Ab,assertIs:()=>Tb,assertNever:()=>Nb,assertNotEqual:()=>Ob,assignProp:()=>ue,attachSchema:()=>lr,base64ToUint8Array:()=>Qf,base64urlToUint8Array:()=>Qb,cached:()=>pn,captureStackTrace:()=>xi,cleanEnum:()=>Yb,cleanRegex:()=>rt,clone:()=>F,cloneDef:()=>Eb,codePointLength:()=>Dt,constantCatch:()=>ws,createTransparentProxy:()=>Vb,defineLazy:()=>vs,defineLazyInternal:()=>E,derived:()=>r_,esc:()=>he,escapeRegex:()=>Ce,explicitlyAborted:()=>xs,extend:()=>Bb,finalizeIssue:()=>ke,floatSafeRemainder:()=>or,getElementAtPath:()=>Rb,getEnumValues:()=>ln,getLengthableOrigin:()=>pr,getParsedType:()=>Fb,getSizableOrigin:()=>dr,hexToUint8Array:()=>t_,hide:()=>fr,installLazyProp:()=>s_,isObject:()=>Nt,isPlainObject:()=>Ue,issue:()=>gn,joinValues:()=>v,jsonStringifyReplacer:()=>dn,members:()=>ks,merge:()=>Gb,mergeDefs:()=>Me,normalizeParams:()=>k,nullish:()=>_i,numKeys:()=>Zb,objectClone:()=>Ub,omit:()=>Jb,optionalKeys:()=>_s,own:()=>mt,parsedType:()=>_,partial:()=>qb,pick:()=>Kb,prefixIssues:()=>xe,primitiveTypes:()=>bs,promiseAllObject:()=>Mb,propertyKeyTypes:()=>sr,randomString:()=>Lb,rawShape:()=>fn,required:()=>Hb,safeExtend:()=>Wb,shallowClone:()=>ar,sizeCaps:()=>mn,slugify:()=>ys,stringifyPrimitive:()=>b,toZod:()=>ir,uint8ArrayToBase64:()=>em,uint8ArrayToBase64url:()=>e_,uint8ArrayToHex:()=>n_,unwrapMessage:()=>un});function Ab(e){return e}function Ob(e){return e}function ir(){return e=>e}function Tb(e){}function Nb(e){throw new Error("Unexpected value in exhaustive check")}function Db(e){}function ln(e){let t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function v(e,t="|"){return e.map(r=>b(r)).join(t)}function dn(e,t){return typeof t=="bigint"?t.toString():t}var gs=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function pn(e){return new gs(e)}function _i(e){return e==null}function rt(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function or(e,t){let r=e/t,o=Math.round(r),n=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-o)<n?0:r-o}var qf=Symbol("evaluating");function vs(e,t,r){let o;Object.defineProperty(e,t,{get(){if(o!==qf)return o===void 0&&(o=qf,o=r()),o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ub(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function ue(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function fn(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function nt(e){return fn(e._zod.def)??e._zod.def.shape}function Hf(e,t,r){Object.defineProperty(e,t,{get(){let o=r();return ue(this,t,o),o},enumerable:!0,configurable:!0})}function Xf(e,t,r){t in e?ue(e,t,r):e[t]=r}function Tt(e,t,r,o){let n=nt(t);for(let i of r){let a=Object.getOwnPropertyDescriptor(n,i);a.enumerable&&(a.get?Hf(e,i,()=>{let s=t._zod.def.shape[i];return o?o(s,i):s}):Xf(e,i,o?o(a.value,i):a.value))}}function Cb(e,t){for(let r of Reflect.ownKeys(t)){let o=Object.getOwnPropertyDescriptor(t,r);o.enumerable&&(o.get?Hf(e,r,()=>t[r]):Xf(e,r,o.value))}}function Me(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function Eb(e){return Me(e._zod.def)}function Rb(e,t){return t?t.reduce((r,o)=>r?.[o],e):e}function Mb(e){let t=Object.keys(e),r=t.map(o=>e[o]);return Promise.all(r).then(o=>{let n={};for(let i=0;i<t.length;i++)n[t[i]]=o[i];return n})}function Lb(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let o=0;o<e;o++)r+=t[Math.floor(Math.random()*t.length)];return r}function he(e){return JSON.stringify(e)}function ys(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var xi="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Nt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var $s=pn(()=>{if(se.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Ue(e){if(Nt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Nt(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function ar(e){return Ue(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Zb(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var Fb=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},sr=new Set(["string","number","symbol"]),bs=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Ce(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function F(e,t,r){let o=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(o._zod.parent=e),o}function k(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Vb(e){let t;return new Proxy({},{get(r,o,n){return t??(t=e()),Reflect.get(t,o,n)},set(r,o,n,i){return t??(t=e()),Reflect.set(t,o,n,i)},has(r,o){return t??(t=e()),Reflect.has(t,o)},deleteProperty(r,o){return t??(t=e()),Reflect.deleteProperty(t,o)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,o){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,o)},defineProperty(r,o,n){return t??(t=e()),Reflect.defineProperty(t,o,n)}})}function b(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function _s(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var cr={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]},ur={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Kb(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i={};return Tt(i,e,ki(e,t)),F(e,Me(r,{shape:i,checks:[]}))}function ki(e,t){let r=nt(e),o=[];for(let n of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,n)?.enumerable)throw new Error(`Unrecognized key: "${String(n)}"`);t[n]&&o.push(n)}return o}function Jb(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=new Set(ki(e,t)),a={};return Tt(a,e,Reflect.ownKeys(nt(e)).filter(s=>!i.has(s))),F(e,Me(r,{shape:a,checks:[]}))}function Bb(e,t){if(!Ue(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let n=nt(e);for(let i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return F(e,Me(e._zod.def,{shape:Yf(e,t)}))}function Yf(e,t){let r={};return Tt(r,e,Reflect.ownKeys(nt(e))),Cb(r,t),r}function Wb(e,t){if(!Ue(t))throw new Error("Invalid input to safeExtend: expected a plain object");return F(e,Me(e._zod.def,{shape:Yf(e,t)}))}function Gb(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Tt(r,e,Reflect.ownKeys(nt(e))),Tt(r,t,Reflect.ownKeys(nt(t)));let o=Me(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return F(e,o)}function qb(e,t,r,o="partial"){let i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${o}() cannot be used on object schemas containing refinements`);let s=r?new Set(ki(t,r)):void 0,u={};return Tt(u,t,Reflect.ownKeys(nt(t)),e&&((l,d)=>s&&!s.has(d)?l:new e({type:"optional",innerType:l}))),F(t,Me(t._zod.def,{shape:u,checks:[]}))}function Hb(e,t,r){let o=r?new Set(ki(t,r)):void 0,n={};return Tt(n,t,Reflect.ownKeys(nt(t)),(i,a)=>o&&!o.has(a)?i:new e({type:"nonoptional",innerType:i})),F(t,Me(t._zod.def,{shape:n}))}function ve(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function xs(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function xe(e,t){return t.map(r=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function un(e){return typeof e=="string"?e:e?.message}function mn(e){let t=[];for(let r of e??[]){let o=r._zod.def;if(!/_(length|size)$|_equals$/.test(o.check))break;let n=o.maximum??o.length??o.size;n>=0&&t.push([n,r])}return t}function lr(e,t,r){var o;for(let n=t;n<e.length;n++)(o=e[n]).schema??(o.schema=r)}function ke(e,t,r){var o;let n=e.inst?._zod?.traits;n?.has("$ZodType")&&(n.has("$ZodCheck")?(o=e).schema??(o.schema=e.inst):e.schema=e.inst);let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,a=e.message?e.message:un(e.inst?._zod.def?.error?.(e))??un(i?.(e))??un(t?.error?.(e))??un(r.customError?.(e))??un(r.localeError?.(e))??"Invalid input",s={};for(let u of Object.keys(e))u==="inst"||u==="schema"||u==="continue"||u==="input"||u==="__proto__"||(s[u]=e[u]);return s.path??(s.path=[]),s.message=a,t?.reportInput&&(s.input=e.input),s}function dr(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var Xb=/[\uD800-\uDBFF]/;function Dt(e){let t=e.length;if(!Xb.test(e))return t;let r=t;for(let o=0;o<t-1;o++)(e.charCodeAt(o)&64512)===55296&&(e.charCodeAt(o+1)&64512)===56320&&(r--,o++);return r}function pr(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function _(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function gn(...e){let[t,r,o]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:o}:{...t}}function Yb(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Qf(e){let t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return r}function em(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Qb(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return Qf(t+r)}function e_(e){return em(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function t_(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let o=0;o<t.length;o+=2)r[o/2]=Number.parseInt(t.slice(o,o+2),16);return r}function n_(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var hs=class{constructor(...t){}};function ks(e,t){for(let r in t){let o=Object.getOwnPropertyDescriptor(t,r);o.get?Object.defineProperty(e,r,{...o,enumerable:!1}):i_(e,r,o.value)}}function mt(e,t,r,o=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:o,value:r}),r}function fr(e,t,r){return mt(e,t,r,!1)}function r_(e,t){for(let r in e){let o=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return mt(this,r,o(this))},set(n){mt(this,r,n)}})}return t}function i_(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:mt(this,t,r.bind(this))},set(o){mt(this,t,o)}})}function o_(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var ms,ft=!1,a_={configurable:!0,get(){ft=!0}};function E(e,t,r){let o=Object.getPrototypeOf(e._zod);if(t in o&&ms!==e._zod){ms=void 0;return}ms=e._zod,Object.defineProperty(o,t,{configurable:!0,get(){Object.defineProperty(this,t,a_);let n=ft;ft=!1;try{let i=r(this);return ft?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),ft=ft||n,i}catch(i){throw delete this[t],ft=ft||n,i}},set(n){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:n})}})}function s_(e,t,r,o){let n=o_(e,t);n&&Object.defineProperty(n,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:o,value:void 0};return Object.defineProperty(this,t,i),i.value=r(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:o,value:i})}})}var wi="~constantCatch";function ws(e){let t=()=>e;return t[wi]=!0,t}var tm,Is=Object.freeze({status:"aborted"}),Ss={value:void 0,enumerable:!1},nm="captureStackTrace"in Error?Error:null;function c_(e){let t=nm;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return nm=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function h(e,t,r,o){let n={};function i(m){this.def=m,this.constr=p,this.traits=new Set}i.prototype=n;let a=r,s=a&&new WeakSet;function u(m,f){if(m._zod){if(m._zod.traits.has(e))return}else{Ss.value=new i(f);try{Object.defineProperty(m,"_zod",Ss)}finally{Ss.value=void 0}}if(m._zod.traits.add(e),t(m,f),s){let y=Object.getPrototypeOf(m),x=m._zod.constr.prototype,P=y;for(;P&&P!==x;)P=Object.getPrototypeOf(P);let I=P??y;s.has(I)||(s.add(I),ks(I,a))}let g=p.prototype;for(let y in g)Object.prototype.hasOwnProperty.call(g,y)&&(y in m||(m[y]=g[y].bind(m)))}let l=o?.Parent??Object;class d extends l{}Object.defineProperty(d,"name",{value:e});function p(m){let f=o?.Parent?c_(d):this;u(f,m);let g=f._zod.deferred;if(g){for(let x of g)x();f._zod.deferred=void 0}let y=globalThis.__zod_globalConfig?.postProcessor;return y&&y(f),f}return Object.defineProperty(p,"init",{value:u}),Object.defineProperty(p,Symbol.hasInstance,{value:m=>o?.Parent&&m instanceof o.Parent?!0:m?._zod?.traits?.has(e)}),Object.defineProperty(p,"name",{value:e}),p}var zs=Symbol("zod_brand"),we=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},gt=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(tm=globalThis).__zod_globalConfig??(tm.__zod_globalConfig={});var se=globalThis.__zod_globalConfig;function te(e){return e&&Object.assign(se,e),se}function u_(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,dn,2)),e.message}function l_(e){this._zod.message=e}var d_={get:u_,set:l_,enumerable:!0,configurable:!0},js={value:void 0,enumerable:!1},rm=new WeakSet([Object.prototype,Error.prototype]),im=(e,t)=>{e.name="$ZodError",js.value=t,Object.defineProperty(e,"issues",js),js.value=void 0,Object.defineProperty(e,"message",d_);let r=Object.getPrototypeOf(e);rm.has(r)||(rm.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let o=()=>this.message;return Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0})}}))},As=h("$ZodError",im),Se=h("$ZodError",im,void 0,{Parent:Error});function p_(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function mr(e,t=r=>r.message){let r={},o=[];for(let n of e.issues)n.path.length>0?p_(r,n.path[0],()=>[]).push(t(n)):o.push(t(n));return{formErrors:o,fieldErrors:r}}function gr(e,t=r=>r.message){let r={_errors:[]},o=(n,i=[])=>{for(let a of n.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(s=>o({issues:s},[...i,...a.path]));else if(a.code==="invalid_key")o({issues:a.issues},[...i,...a.path]);else if(a.code==="invalid_element")o({issues:a.issues},[...i,...a.path]);else{let s=[...i,...a.path];if(s.length===0)r._errors.push(t(a));else{let u=r,l=0;for(;l<s.length;){let d=s[l],p=l===s.length-1;if(d==="_errors"){p&&u._errors.push(t(a)),l++;continue}Object.prototype.hasOwnProperty.call(u,d)||Object.defineProperty(u,d,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let m=u[d];p&&m._errors.push(t(a)),u=m,l++}}}};return o(e),r}function Os(e,t=r=>r.message){let r={errors:[]},o=(n,i=[])=>{var a;for(let s of n.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(u=>o({issues:u},[...i,...s.path]));else if(s.code==="invalid_key")o({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")o({issues:s.issues},[...i,...s.path]);else{let u=[...i,...s.path];if(u.length===0){r.errors.push(t(s));continue}let l=r,d=0;for(;d<u.length;){let p=u[d],m=d===u.length-1;typeof p=="string"?(l.properties??(l.properties={}),Object.prototype.hasOwnProperty.call(l.properties,p)||Object.defineProperty(l.properties,p,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),l=l.properties[p]):(l.items??(l.items=[]),(a=l.items)[p]??(a[p]={errors:[]}),l=l.items[p]),m&&l.errors.push(t(s)),d++}}};return o(e),r}function om(e){let t=[],r=e.map(o=>typeof o=="object"?o.key:o);for(let o of r)typeof o=="number"?t.push(`[${o}]`):typeof o=="symbol"?t.push(`[${JSON.stringify(String(o))}]`):/[^\w$]/.test(o)?t.push(`[${JSON.stringify(o)}]`):(t.length&&t.push("."),t.push(o));return t.join("")}function Ts(e){let t=[],r=[...e.issues].sort((o,n)=>(o.path??[]).length-(n.path??[]).length);for(let o of r)t.push(`\u2716 ${o.message}`),o.path?.length&&t.push(` \u2192 at ${om(o.path)}`);return t.join(`
|
|
2
|
+
var Pb=Object.defineProperty;var tt=(e,t)=>{for(var r in t)Pb(e,r,{get:t[r],enumerable:!0})};import{fileURLToPath as zb}from"node:url";import{parseArgs as sj}from"node:util";var jb={message:"cmsg",thread:"thr",project:"proj",usage:"use",apiKey:"key",invite:"inv",runner:"rnr",task:"task",artifact:"art",routine:"rtn",notification:"ntf",connector:"mcp",skill:"skl",suggestion:"sug",question:"qst",sshHost:"ssh",sshRun:"sshr"};function fe(e){return new RegExp(`^${jb[e]}_[0-9A-HJKMNP-TV-Z]{26}$`)}var c={};tt(c,{$brand:()=>zs,$input:()=>Qu,$output:()=>Yu,INVALID:()=>ye,NEVER:()=>Is,TimePrecision:()=>dl,ZodAny:()=>Yd,ZodArray:()=>np,ZodBase64:()=>va,ZodBase64URL:()=>ya,ZodBigInt:()=>Bn,ZodBigIntFormat:()=>_a,ZodBoolean:()=>Jn,ZodCIDRv4:()=>ga,ZodCIDRv6:()=>ha,ZodCUID:()=>ca,ZodCUID2:()=>ua,ZodCatch:()=>kp,ZodCodec:()=>Yr,ZodCompileAsyncError:()=>Le,ZodCompileUnsupportedError:()=>M,ZodCreditCard:()=>Kd,ZodCustom:()=>Qr,ZodCustomStringFormat:()=>Gt,ZodDate:()=>Br,ZodDefault:()=>vp,ZodDiscriminatedUnion:()=>ip,ZodE164:()=>$a,ZodEmail:()=>ia,ZodEmoji:()=>aa,ZodEnum:()=>Fn,ZodError:()=>Gw,ZodExactOptional:()=>Sa,ZodFile:()=>fp,ZodFirstPartyTypeKind:()=>Ep,ZodFunction:()=>Np,ZodGUID:()=>oa,ZodIBAN:()=>Jd,ZodIPv4:()=>fa,ZodIPv6:()=>ma,ZodISODate:()=>kt,ZodISODateTime:()=>xt,ZodISODuration:()=>St,ZodISOTime:()=>wt,ZodInstanceOf:()=>Cp,ZodIntersection:()=>op,ZodIssueCode:()=>Xw,ZodJWT:()=>ba,ZodKSUID:()=>pa,ZodLazy:()=>Ap,ZodLiteral:()=>pp,ZodMAC:()=>Vd,ZodMap:()=>lp,ZodNaN:()=>Sp,ZodNanoID:()=>sa,ZodNever:()=>ep,ZodNonOptional:()=>Ia,ZodNull:()=>Hd,ZodNullable:()=>hp,ZodNumber:()=>Kn,ZodNumberFormat:()=>qt,ZodObject:()=>Gr,ZodOptional:()=>Hr,ZodPipe:()=>Xr,ZodPrefault:()=>$p,ZodPreprocess:()=>Ip,ZodPromise:()=>Tp,ZodReadonly:()=>zp,ZodRealError:()=>Ie,ZodRecord:()=>Zn,ZodSet:()=>dp,ZodString:()=>Vn,ZodStringFormat:()=>W,ZodSuccess:()=>xp,ZodSymbol:()=>Gd,ZodTemplateLiteral:()=>jp,ZodTransform:()=>mp,ZodTuple:()=>sp,ZodType:()=>C,ZodULID:()=>la,ZodURL:()=>Jr,ZodUUID:()=>We,ZodUndefined:()=>qd,ZodUnion:()=>qr,ZodUnknown:()=>Qd,ZodVoid:()=>tp,ZodXID:()=>da,ZodXor:()=>rp,_ZodString:()=>ra,_default:()=>yp,_function:()=>Pv,any:()=>ov,array:()=>Wr,base64:()=>Mh,base64url:()=>Lh,bigint:()=>ev,boolean:()=>Wd,catch:()=>wp,check:()=>jv,cidrv4:()=>Eh,cidrv6:()=>Rh,clone:()=>F,codec:()=>wv,coerce:()=>Mp,compile:()=>rl,config:()=>te,core:()=>at,creditCard:()=>Fh,cuid:()=>jh,cuid2:()=>Ah,currencyCode:()=>Gh,custom:()=>Av,date:()=>sv,decode:()=>Cd,decodeAsync:()=>Rd,deepPartial:()=>Vv,describe:()=>Ov,discriminatedUnion:()=>fv,e164:()=>Zh,email:()=>$h,emoji:()=>zh,encode:()=>Ud,encodeAsync:()=>Ed,endsWith:()=>An,enum:()=>ka,exactOptional:()=>gp,file:()=>bv,flattenError:()=>mr,float32:()=>Hh,float64:()=>Xh,formatError:()=>gr,fromJSONSchema:()=>Zv,function:()=>Pv,getDiscriminatedOption:()=>Iu,getErrorMap:()=>Qw,globalRegistry:()=>le,gt:()=>Je,gte:()=>Te,guid:()=>bh,hash:()=>qh,hex:()=>Wh,hostname:()=>Bh,httpUrl:()=>Ih,iban:()=>Vh,includes:()=>Pn,input:()=>Jv,instanceof:()=>Nv,int:()=>ta,int32:()=>Yh,int64:()=>tv,intersection:()=>ap,invertCodec:()=>Sv,ipv4:()=>Dh,ipv6:()=>Ch,iso:()=>ei,json:()=>Uv,jwt:()=>Kh,keyof:()=>cv,ksuid:()=>Nh,lazy:()=>Op,length:()=>Vt,literal:()=>$v,locales:()=>Ur,looseObject:()=>dv,looseRecord:()=>gv,lowercase:()=>In,lt:()=>Ke,lte:()=>Oe,mac:()=>Uh,map:()=>hv,maxLength:()=>Ft,maxSize:()=>yt,memoizer:()=>Nr,meta:()=>Tv,mime:()=>Tn,minLength:()=>ot,minSize:()=>Be,multipleOf:()=>vt,nan:()=>kv,nanoid:()=>Ph,nativeEnum:()=>yv,negative:()=>Ko,never:()=>xa,nonnegative:()=>Bo,nonoptional:()=>_p,nonpositive:()=>Jo,normalize:()=>Nn,null:()=>Xd,nullable:()=>Kr,nullish:()=>_v,number:()=>Bd,object:()=>uv,optional:()=>Bt,output:()=>Bv,overwrite:()=>Ze,parse:()=>Od,parseAsync:()=>Td,partialRecord:()=>mv,pipe:()=>na,positive:()=>Vo,prefault:()=>bp,preprocess:()=>Cv,prettifyError:()=>Ts,promise:()=>zv,properties:()=>On,property:()=>Wo,readonly:()=>Pp,record:()=>up,refine:()=>Dp,regex:()=>Sn,regexes:()=>Ee,registry:()=>yo,safeDecode:()=>Ld,safeDecodeAsync:()=>Fd,safeEncode:()=>Md,safeEncodeAsync:()=>Zd,safeParse:()=>Nd,safeParseAsync:()=>Dd,set:()=>vv,setErrorMap:()=>Yw,size:()=>Zt,slugify:()=>En,startsWith:()=>jn,strictObject:()=>lv,string:()=>Vr,stringFormat:()=>Jh,stringbool:()=>Dv,success:()=>xv,superRefine:()=>Up,symbol:()=>rv,templateLiteral:()=>Iv,toJSONSchema:()=>Xo,toLowerCase:()=>Un,toUpperCase:()=>Cn,toZod:()=>ir,transform:()=>wa,treeifyError:()=>Os,trim:()=>Dn,tuple:()=>cp,uint32:()=>Qh,uint64:()=>nv,ulid:()=>Oh,undefined:()=>iv,union:()=>Wn,unknown:()=>Jt,uppercase:()=>zn,url:()=>Sh,util:()=>$,uuid:()=>_h,uuidv4:()=>xh,uuidv6:()=>kh,uuidv7:()=>wh,validate:()=>hr,validateAsync:()=>vr,void:()=>av,withParser:()=>$o,xid:()=>Th,xor:()=>pv});var at={};tt(at,{$ZodAny:()=>vu,$ZodArray:()=>ku,$ZodAsyncError:()=>we,$ZodBase64:()=>ou,$ZodBase64URL:()=>au,$ZodBigInt:()=>ro,$ZodBigIntFormat:()=>fu,$ZodBoolean:()=>zr,$ZodCIDRv4:()=>ru,$ZodCIDRv6:()=>iu,$ZodCUID:()=>Jc,$ZodCUID2:()=>Bc,$ZodCatch:()=>Fu,$ZodCheck:()=>G,$ZodCheckBigIntFormat:()=>yc,$ZodCheckEndsWith:()=>Ac,$ZodCheckGreaterThan:()=>Zi,$ZodCheckIncludes:()=>Pc,$ZodCheckLengthEquals:()=>wc,$ZodCheckLessThan:()=>Li,$ZodCheckLowerCase:()=>Ic,$ZodCheckMaxLength:()=>xc,$ZodCheckMaxSize:()=>$c,$ZodCheckMimeType:()=>Nc,$ZodCheckMinLength:()=>kc,$ZodCheckMinSize:()=>bc,$ZodCheckMultipleOf:()=>hc,$ZodCheckNumberFormat:()=>vc,$ZodCheckOverwrite:()=>Dc,$ZodCheckProperties:()=>Tc,$ZodCheckProperty:()=>Oc,$ZodCheckRegex:()=>Sc,$ZodCheckSizeEquals:()=>_c,$ZodCheckStartsWith:()=>jc,$ZodCheckStringFormat:()=>bn,$ZodCheckUpperCase:()=>zc,$ZodCodec:()=>jr,$ZodCreditCard:()=>cu,$ZodCustom:()=>qu,$ZodCustomStringFormat:()=>du,$ZodCyclicError:()=>lo,$ZodDate:()=>_u,$ZodDefault:()=>Ru,$ZodDiscriminatedUnion:()=>zu,$ZodE164:()=>su,$ZodEmail:()=>Mc,$ZodEmoji:()=>Vc,$ZodEncodeError:()=>gt,$ZodEnum:()=>Tu,$ZodError:()=>As,$ZodExactOptional:()=>Cu,$ZodFile:()=>Du,$ZodFunction:()=>Wu,$ZodGUID:()=>Ec,$ZodIBAN:()=>uu,$ZodIPv4:()=>eu,$ZodIPv6:()=>tu,$ZodISODate:()=>Xc,$ZodISODateTime:()=>Hc,$ZodISODuration:()=>Qc,$ZodISOTime:()=>Yc,$ZodIntersection:()=>Pu,$ZodJWT:()=>lu,$ZodKSUID:()=>qc,$ZodLazy:()=>Ar,$ZodLiteral:()=>Nu,$ZodMAC:()=>nu,$ZodMap:()=>Au,$ZodNaN:()=>Vu,$ZodNanoID:()=>Kc,$ZodNever:()=>$u,$ZodNonOptional:()=>Lu,$ZodNull:()=>hu,$ZodNullable:()=>Eu,$ZodNumber:()=>no,$ZodNumberFormat:()=>pu,$ZodObject:()=>jm,$ZodObjectJIT:()=>wu,$ZodOptional:()=>oo,$ZodPipe:()=>ao,$ZodPrefault:()=>Mu,$ZodPreprocess:()=>Ku,$ZodPromise:()=>Gu,$ZodReadonly:()=>Ju,$ZodRealError:()=>Se,$ZodRecord:()=>ju,$ZodRegistry:()=>vo,$ZodSet:()=>Ou,$ZodString:()=>Et,$ZodStringFormat:()=>V,$ZodSuccess:()=>Zu,$ZodSymbol:()=>mu,$ZodTemplateLiteral:()=>Bu,$ZodTransform:()=>Uu,$ZodTuple:()=>io,$ZodType:()=>D,$ZodULID:()=>Wc,$ZodURL:()=>Fc,$ZodUUID:()=>Rc,$ZodUndefined:()=>gu,$ZodUnion:()=>Pr,$ZodUnknown:()=>yu,$ZodVoid:()=>bu,$ZodXID:()=>Gc,$ZodXor:()=>Su,$brand:()=>zs,$constructor:()=>h,$input:()=>Qu,$output:()=>Yu,Doc:()=>Ct,INVALID:()=>ye,JSONSchema:()=>hh,JSONSchemaGenerator:()=>Yo,NEVER:()=>Is,TimePrecision:()=>dl,URL_BAD_FORMAT:()=>Lc,URL_UNPARSEABLE:()=>xr,ZodCompileAsyncError:()=>Le,ZodCompileUnsupportedError:()=>M,_any:()=>Pl,_array:()=>Ul,_base64:()=>Mo,_base64url:()=>Lo,_bigint:()=>_l,_boolean:()=>$l,_catch:()=>Cw,_check:()=>eh,_cidrv4:()=>Eo,_cidrv6:()=>Ro,_coercedBigint:()=>xl,_coercedBoolean:()=>bl,_coercedDate:()=>Nl,_coercedNumber:()=>fl,_coercedString:()=>sl,_creditCard:()=>ul,_cuid:()=>Ao,_cuid2:()=>Oo,_custom:()=>El,_date:()=>Tl,_decode:()=>ji,_decodeAsync:()=>Oi,_default:()=>Nw,_discriminatedUnion:()=>_w,_e164:()=>Zo,_email:()=>xo,_emoji:()=>Po,_encode:()=>Pi,_encodeAsync:()=>Ai,_endsWith:()=>An,_enum:()=>zw,_file:()=>Cl,_float32:()=>gl,_float64:()=>hl,_gt:()=>Je,_gte:()=>Te,_guid:()=>ko,_iban:()=>ll,_includes:()=>Pn,_int:()=>ml,_int32:()=>vl,_int64:()=>kl,_intersection:()=>xw,_ipv4:()=>Uo,_ipv6:()=>Co,_isoDate:()=>Rr,_isoDateTime:()=>Er,_isoDuration:()=>Lr,_isoTime:()=>Mr,_jwt:()=>Fo,_ksuid:()=>Do,_lazy:()=>Lw,_length:()=>Vt,_literal:()=>jw,_lowercase:()=>In,_lt:()=>Ke,_lte:()=>Oe,_mac:()=>cl,_map:()=>Sw,_max:()=>Oe,_maxLength:()=>Ft,_maxSize:()=>yt,_mime:()=>Tn,_min:()=>Te,_minLength:()=>ot,_minSize:()=>Be,_multipleOf:()=>vt,_nan:()=>Dl,_nanoid:()=>jo,_nativeEnum:()=>Pw,_negative:()=>Ko,_never:()=>Al,_nonnegative:()=>Bo,_nonoptional:()=>Dw,_nonpositive:()=>Jo,_normalize:()=>Nn,_null:()=>zl,_nullable:()=>Tw,_number:()=>pl,_optional:()=>Ow,_overwrite:()=>Ze,_parse:()=>hn,_parseAsync:()=>vn,_pipe:()=>Ew,_positive:()=>Vo,_promise:()=>Zw,_properties:()=>On,_property:()=>Wo,_readonly:()=>Rw,_record:()=>ww,_refine:()=>Rl,_regex:()=>Sn,_safeDecode:()=>Ni,_safeDecodeAsync:()=>Ui,_safeEncode:()=>Ti,_safeEncodeAsync:()=>Di,_safeParse:()=>yn,_safeParseAsync:()=>$n,_set:()=>Iw,_size:()=>Zt,_slugify:()=>En,_startsWith:()=>jn,_string:()=>al,_stringFormat:()=>Kt,_stringbool:()=>Fl,_success:()=>Uw,_superRefine:()=>Ml,_symbol:()=>Sl,_templateLiteral:()=>Mw,_toLowerCase:()=>Un,_toUpperCase:()=>Cn,_transform:()=>Aw,_trim:()=>Dn,_tuple:()=>kw,_uint32:()=>yl,_uint64:()=>wl,_ulid:()=>To,_undefined:()=>Il,_union:()=>$w,_unknown:()=>jl,_uppercase:()=>zn,_url:()=>Cr,_uuid:()=>wo,_uuidv4:()=>So,_uuidv6:()=>Io,_uuidv7:()=>zo,_void:()=>Ol,_xid:()=>No,_xor:()=>bw,base64Charset:()=>Xi,base64urlCharset:()=>Ir,canParseURL:()=>Zc,clone:()=>F,compile:()=>rl,compileFn:()=>bo,config:()=>te,createStandardJSONSchemaMethod:()=>Rn,createToJSONSchemaMethod:()=>Kl,decode:()=>b_,decodeAsync:()=>x_,describe:()=>Ll,encode:()=>$_,encodeAsync:()=>__,extractDefs:()=>bt,finalize:()=>_t,flattenError:()=>mr,formatError:()=>gr,getDiscriminatedOption:()=>Iu,globalConfig:()=>se,globalRegistry:()=>le,handleUnrepresentable:()=>oe,initializeContext:()=>$t,isBackEdge:()=>fo,isRecursiveSchema:()=>po,isValidBase64:()=>Sr,isValidBase64URL:()=>Yi,isValidCIDRv6:()=>Hi,isValidCreditCard:()=>Qi,isValidIBAN:()=>eo,isValidIPv6:()=>wr,isValidJWT:()=>to,locales:()=>Ur,memoizer:()=>Nr,mergeValues:()=>_n,meta:()=>Zl,parse:()=>Ii,parseAsync:()=>zi,parseURLObject:()=>Im,prettifyError:()=>Ts,process:()=>K,processSchema:()=>K,regexes:()=>Ee,registry:()=>yo,safeDecode:()=>w_,safeDecodeAsync:()=>I_,safeEncode:()=>k_,safeEncodeAsync:()=>S_,safeParse:()=>m_,safeParseAsync:()=>g_,standardProps:()=>Bi,stripTabAndNewline:()=>kr,toDotPath:()=>om,toJSONSchema:()=>Xo,toZod:()=>ir,treeifyError:()=>Os,urlHostnameOk:()=>Gi,urlProtocolOk:()=>qi,util:()=>$,validate:()=>hr,validateAsync:()=>vr,validateURL:()=>Wi,version:()=>Uc,withParser:()=>$o});var $={};tt($,{BIGINT_FORMAT_RANGES:()=>ur,CONSTANT_CATCH:()=>wi,Class:()=>hs,NUMBER_FORMAT_RANGES:()=>cr,aborted:()=>ve,allowsEval:()=>$s,assert:()=>Db,assertEqual:()=>Ab,assertIs:()=>Tb,assertNever:()=>Nb,assertNotEqual:()=>Ob,assignProp:()=>ue,attachSchema:()=>lr,base64ToUint8Array:()=>Qf,base64urlToUint8Array:()=>Qb,cached:()=>pn,captureStackTrace:()=>xi,cleanEnum:()=>Yb,cleanRegex:()=>rt,clone:()=>F,cloneDef:()=>Eb,codePointLength:()=>Dt,constantCatch:()=>ws,createTransparentProxy:()=>Vb,defineLazy:()=>vs,defineLazyInternal:()=>E,derived:()=>r_,esc:()=>he,escapeRegex:()=>Ce,explicitlyAborted:()=>xs,extend:()=>Bb,finalizeIssue:()=>ke,floatSafeRemainder:()=>or,getElementAtPath:()=>Rb,getEnumValues:()=>ln,getLengthableOrigin:()=>pr,getParsedType:()=>Fb,getSizableOrigin:()=>dr,hexToUint8Array:()=>t_,hide:()=>fr,installLazyProp:()=>s_,isObject:()=>Nt,isPlainObject:()=>Ue,issue:()=>gn,joinValues:()=>v,jsonStringifyReplacer:()=>dn,members:()=>ks,merge:()=>Gb,mergeDefs:()=>Me,normalizeParams:()=>k,nullish:()=>_i,numKeys:()=>Zb,objectClone:()=>Ub,omit:()=>Jb,optionalKeys:()=>_s,own:()=>mt,parsedType:()=>_,partial:()=>qb,pick:()=>Kb,prefixIssues:()=>xe,primitiveTypes:()=>bs,promiseAllObject:()=>Mb,propertyKeyTypes:()=>sr,randomString:()=>Lb,rawShape:()=>fn,required:()=>Hb,safeExtend:()=>Wb,shallowClone:()=>ar,sizeCaps:()=>mn,slugify:()=>ys,stringifyPrimitive:()=>b,toZod:()=>ir,uint8ArrayToBase64:()=>em,uint8ArrayToBase64url:()=>e_,uint8ArrayToHex:()=>n_,unwrapMessage:()=>un});function Ab(e){return e}function Ob(e){return e}function ir(){return e=>e}function Tb(e){}function Nb(e){throw new Error("Unexpected value in exhaustive check")}function Db(e){}function ln(e){let t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function v(e,t="|"){return e.map(r=>b(r)).join(t)}function dn(e,t){return typeof t=="bigint"?t.toString():t}var gs=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function pn(e){return new gs(e)}function _i(e){return e==null}function rt(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function or(e,t){let r=e/t,o=Math.round(r),n=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-o)<n?0:r-o}var qf=Symbol("evaluating");function vs(e,t,r){let o;Object.defineProperty(e,t,{get(){if(o!==qf)return o===void 0&&(o=qf,o=r()),o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Ub(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function ue(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function fn(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function nt(e){return fn(e._zod.def)??e._zod.def.shape}function Hf(e,t,r){Object.defineProperty(e,t,{get(){let o=r();return ue(this,t,o),o},enumerable:!0,configurable:!0})}function Xf(e,t,r){t in e?ue(e,t,r):e[t]=r}function Tt(e,t,r,o){let n=nt(t);for(let i of r){let a=Object.getOwnPropertyDescriptor(n,i);a.enumerable&&(a.get?Hf(e,i,()=>{let s=t._zod.def.shape[i];return o?o(s,i):s}):Xf(e,i,o?o(a.value,i):a.value))}}function Cb(e,t){for(let r of Reflect.ownKeys(t)){let o=Object.getOwnPropertyDescriptor(t,r);o.enumerable&&(o.get?Hf(e,r,()=>t[r]):Xf(e,r,o.value))}}function Me(...e){let t={};for(let r of e){let o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function Eb(e){return Me(e._zod.def)}function Rb(e,t){return t?t.reduce((r,o)=>r?.[o],e):e}function Mb(e){let t=Object.keys(e),r=t.map(o=>e[o]);return Promise.all(r).then(o=>{let n={};for(let i=0;i<t.length;i++)n[t[i]]=o[i];return n})}function Lb(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let o=0;o<e;o++)r+=t[Math.floor(Math.random()*t.length)];return r}function he(e){return JSON.stringify(e)}function ys(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var xi="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Nt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var $s=pn(()=>{if(se.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Ue(e){if(Nt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Nt(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function ar(e){return Ue(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Zb(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var Fb=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},sr=new Set(["string","number","symbol"]),bs=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Ce(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function F(e,t,r){let o=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(o._zod.parent=e),o}function k(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Vb(e){let t;return new Proxy({},{get(r,o,n){return t??(t=e()),Reflect.get(t,o,n)},set(r,o,n,i){return t??(t=e()),Reflect.set(t,o,n,i)},has(r,o){return t??(t=e()),Reflect.has(t,o)},deleteProperty(r,o){return t??(t=e()),Reflect.deleteProperty(t,o)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,o){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,o)},defineProperty(r,o,n){return t??(t=e()),Reflect.defineProperty(t,o,n)}})}function b(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function _s(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var cr={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]},ur={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Kb(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i={};return Tt(i,e,ki(e,t)),F(e,Me(r,{shape:i,checks:[]}))}function ki(e,t){let r=nt(e),o=[];for(let n of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,n)?.enumerable)throw new Error(`Unrecognized key: "${String(n)}"`);t[n]&&o.push(n)}return o}function Jb(e,t){let r=e._zod.def,o=r.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=new Set(ki(e,t)),a={};return Tt(a,e,Reflect.ownKeys(nt(e)).filter(s=>!i.has(s))),F(e,Me(r,{shape:a,checks:[]}))}function Bb(e,t){if(!Ue(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let n=nt(e);for(let i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return F(e,Me(e._zod.def,{shape:Yf(e,t)}))}function Yf(e,t){let r={};return Tt(r,e,Reflect.ownKeys(nt(e))),Cb(r,t),r}function Wb(e,t){if(!Ue(t))throw new Error("Invalid input to safeExtend: expected a plain object");return F(e,Me(e._zod.def,{shape:Yf(e,t)}))}function Gb(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Tt(r,e,Reflect.ownKeys(nt(e))),Tt(r,t,Reflect.ownKeys(nt(t)));let o=Me(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return F(e,o)}function qb(e,t,r,o="partial"){let i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${o}() cannot be used on object schemas containing refinements`);let s=r?new Set(ki(t,r)):void 0,u={};return Tt(u,t,Reflect.ownKeys(nt(t)),e&&((l,d)=>s&&!s.has(d)?l:new e({type:"optional",innerType:l}))),F(t,Me(t._zod.def,{shape:u,checks:[]}))}function Hb(e,t,r){let o=r?new Set(ki(t,r)):void 0,n={};return Tt(n,t,Reflect.ownKeys(nt(t)),(i,a)=>o&&!o.has(a)?i:new e({type:"nonoptional",innerType:i})),F(t,Me(t._zod.def,{shape:n}))}function ve(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function xs(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function xe(e,t){return t.map(r=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function un(e){return typeof e=="string"?e:e?.message}function mn(e){let t=[];for(let r of e??[]){let o=r._zod.def;if(!/_(length|size)$|_equals$/.test(o.check))break;let n=o.maximum??o.length??o.size;n>=0&&t.push([n,r])}return t}function lr(e,t,r){var o;for(let n=t;n<e.length;n++)(o=e[n]).schema??(o.schema=r)}function ke(e,t,r){var o;let n=e.inst?._zod?.traits;n?.has("$ZodType")&&(n.has("$ZodCheck")?(o=e).schema??(o.schema=e.inst):e.schema=e.inst);let i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,a=e.message?e.message:un(e.inst?._zod.def?.error?.(e))??un(i?.(e))??un(t?.error?.(e))??un(r.customError?.(e))??un(r.localeError?.(e))??"Invalid input",s={};for(let u of Object.keys(e))u==="inst"||u==="schema"||u==="continue"||u==="input"||u==="__proto__"||(s[u]=e[u]);return s.path??(s.path=[]),s.message=a,t?.reportInput&&(s.input=e.input),s}function dr(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var Xb=/[\uD800-\uDBFF]/;function Dt(e){let t=e.length;if(!Xb.test(e))return t;let r=t;for(let o=0;o<t-1;o++)(e.charCodeAt(o)&64512)===55296&&(e.charCodeAt(o+1)&64512)===56320&&(r--,o++);return r}function pr(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function _(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function gn(...e){let[t,r,o]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:o}:{...t}}function Yb(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Qf(e){let t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return r}function em(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Qb(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return Qf(t+r)}function e_(e){return em(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function t_(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let o=0;o<t.length;o+=2)r[o/2]=Number.parseInt(t.slice(o,o+2),16);return r}function n_(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var hs=class{constructor(...t){}};function ks(e,t){for(let r in t){let o=Object.getOwnPropertyDescriptor(t,r);o.get?Object.defineProperty(e,r,{...o,enumerable:!1}):i_(e,r,o.value)}}function mt(e,t,r,o=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:o,value:r}),r}function fr(e,t,r){return mt(e,t,r,!1)}function r_(e,t){for(let r in e){let o=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return mt(this,r,o(this))},set(n){mt(this,r,n)}})}return t}function i_(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:mt(this,t,r.bind(this))},set(o){mt(this,t,o)}})}function o_(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var ms,ft=!1,a_={configurable:!0,get(){ft=!0}};function E(e,t,r){let o=Object.getPrototypeOf(e._zod);if(t in o&&ms!==e._zod){ms=void 0;return}ms=e._zod,Object.defineProperty(o,t,{configurable:!0,get(){Object.defineProperty(this,t,a_);let n=ft;ft=!1;try{let i=r(this);return ft?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),ft=ft||n,i}catch(i){throw delete this[t],ft=ft||n,i}},set(n){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:n})}})}function s_(e,t,r,o){let n=o_(e,t);n&&Object.defineProperty(n,t,{configurable:!0,get(){let i={configurable:!0,writable:!0,enumerable:o,value:void 0};return Object.defineProperty(this,t,i),i.value=r(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:o,value:i})}})}var wi="~constantCatch";function ws(e){let t=()=>e;return t[wi]=!0,t}var tm,Is=Object.freeze({status:"aborted"}),Ss={value:void 0,enumerable:!1},nm="captureStackTrace"in Error?Error:null;function c_(e){let t=nm;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return nm=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function h(e,t,r,o){let n={};function i(m){this.def=m,this.constr=p,this.traits=new Set}i.prototype=n;let a=r,s=a&&new WeakSet;function u(m,f){if(m._zod){if(m._zod.traits.has(e))return}else{Ss.value=new i(f);try{Object.defineProperty(m,"_zod",Ss)}finally{Ss.value=void 0}}if(m._zod.traits.add(e),t(m,f),s){let y=Object.getPrototypeOf(m),x=m._zod.constr.prototype,P=y;for(;P&&P!==x;)P=Object.getPrototypeOf(P);let I=P??y;s.has(I)||(s.add(I),ks(I,a))}let g=p.prototype;for(let y in g)Object.prototype.hasOwnProperty.call(g,y)&&(y in m||(m[y]=g[y].bind(m)))}let l=o?.Parent??Object;class d extends l{}Object.defineProperty(d,"name",{value:e});function p(m){let f=o?.Parent?c_(d):this;u(f,m);let g=f._zod.deferred;if(g){for(let x of g)x();f._zod.deferred=void 0}let y=globalThis.__zod_globalConfig?.postProcessor;return y&&y(f),f}return Object.defineProperty(p,"init",{value:u}),Object.defineProperty(p,Symbol.hasInstance,{value:m=>o?.Parent&&m instanceof o.Parent?!0:m?._zod?.traits?.has(e)}),Object.defineProperty(p,"name",{value:e}),p}var zs=Symbol("zod_brand"),we=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},gt=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(tm=globalThis).__zod_globalConfig??(tm.__zod_globalConfig={});var se=globalThis.__zod_globalConfig;function te(e){return e&&Object.assign(se,e),se}function u_(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,dn,2)),e.message}function l_(e){this._zod.message=e}var d_={get:u_,set:l_,enumerable:!0,configurable:!0},js={value:void 0,enumerable:!1},rm=new WeakSet([Object.prototype,Error.prototype]),im=(e,t)=>{e.name="$ZodError",js.value=t,Object.defineProperty(e,"issues",js),js.value=void 0,Object.defineProperty(e,"message",d_);let r=Object.getPrototypeOf(e);rm.has(r)||(rm.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let o=()=>this.message;return Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,"toString",{value:o,configurable:!0,writable:!0})}}))},As=h("$ZodError",im),Se=h("$ZodError",im,void 0,{Parent:Error});function p_(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function mr(e,t=r=>r.message){let r={},o=[];for(let n of e.issues)n.path.length>0?p_(r,n.path[0],()=>[]).push(t(n)):o.push(t(n));return{formErrors:o,fieldErrors:r}}function gr(e,t=r=>r.message){let r={_errors:[]},o=(n,i=[])=>{for(let a of n.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(s=>o({issues:s},[...i,...a.path]));else if(a.code==="invalid_key")o({issues:a.issues},[...i,...a.path]);else if(a.code==="invalid_element")o({issues:a.issues},[...i,...a.path]);else{let s=[...i,...a.path];if(s.length===0)r._errors.push(t(a));else{let u=r,l=0;for(;l<s.length;){let d=s[l],p=l===s.length-1;if(d==="_errors"){p&&u._errors.push(t(a)),l++;continue}Object.prototype.hasOwnProperty.call(u,d)||Object.defineProperty(u,d,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let m=u[d];p&&m._errors.push(t(a)),u=m,l++}}}};return o(e),r}function Os(e,t=r=>r.message){let r={errors:[]},o=(n,i=[])=>{var a;for(let s of n.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(u=>o({issues:u},[...i,...s.path]));else if(s.code==="invalid_key")o({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")o({issues:s.issues},[...i,...s.path]);else{let u=[...i,...s.path];if(u.length===0){r.errors.push(t(s));continue}let l=r,d=0;for(;d<u.length;){let p=u[d],m=d===u.length-1;typeof p=="string"?(l.properties??(l.properties={}),Object.prototype.hasOwnProperty.call(l.properties,p)||Object.defineProperty(l.properties,p,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),l=l.properties[p]):(l.items??(l.items=[]),(a=l.items)[p]??(a[p]={errors:[]}),l=l.items[p]),m&&l.errors.push(t(s)),d++}}};return o(e),r}function om(e){let t=[],r=e.map(o=>typeof o=="object"?o.key:o);for(let o of r)typeof o=="number"?t.push(`[${o}]`):typeof o=="symbol"?t.push(`[${JSON.stringify(String(o))}]`):/[^\w$]/.test(o)?t.push(`[${JSON.stringify(o)}]`):(t.length&&t.push("."),t.push(o));return t.join("")}function Ts(e){let t=[],r=[...e.issues].sort((o,n)=>(o.path??[]).length-(n.path??[]).length);for(let o of r)t.push(`\u2716 ${o.message}`),o.path?.length&&t.push(` \u2192 at ${om(o.path)}`);return t.join(`
|
|
3
3
|
`)}function Si(e,t){return{callee:t?.callee??e,Err:t?.Err}}var hn=e=>{let t=(r,o,n,i)=>{let a=n?{...n,async:!1}:{async:!1},s=r._zod.run({value:o,issues:[]},a);if(s instanceof Promise)throw new we;if(s.issues.length){let u=new(i?.Err??e)(s.issues.map(l=>ke(l,a,te())));throw xi(u,i?.callee??t),u}return s.value};return t},Ii=hn(Se),vn=e=>{let t=async(r,o,n,i)=>{let a=n?{...n,async:!0}:{async:!0},s=r._zod.run({value:o,issues:[]},a);if(s instanceof Promise&&(s=await s),s.issues.length){let u=new(i?.Err??e)(s.issues.map(l=>ke(l,a,te())));throw xi(u,i?.callee??t),u}return s.value};return t},zi=vn(Se),yn=e=>(t,r,o)=>{let n=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},n);if(i instanceof Promise)throw new we;return i.issues.length?am(e,i.issues,n):{success:!0,data:i.value}},m_=yn(Se);function am(e,t,r){let o;return{success:!1,get error(){return o||(o=new e(t.map(n=>ke(n,r,te()))),t=void 0,r=void 0),o},set error(n){o=n,t=void 0,r=void 0}}}var $n=e=>async(t,r,o)=>{let n=o?{...o,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},n);return i instanceof Promise&&(i=await i),i.issues.length?am(e,i.issues,n):{success:!0,data:i.value}},g_=$n(Se),h_=Symbol.for("zod.compile.invalid"),v_=Symbol.for("zod.compile.fallback"),hr=((e,t,r)=>{let o=e._zod.bag.validator;if(o!==void 0){if(o(t)!==h_)return!0;if(o.definite===!0&&r===void 0)return!1}return y_(e,t,r)});function y_(e,t,r){let o=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},n=e._zod.bag.fallbackRun,i;if(n?(o[v_]=!0,i=n({value:t,issues:[]},o)):i=e._zod.run({value:t,issues:[]},o),i instanceof Promise)throw new we;return i.issues.length===0}var vr=async(e,t,r)=>{let o=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},n=e._zod.run({value:t,issues:[]},o);return n instanceof Promise&&(n=await n),n.issues.length===0},Pi=e=>{let t=hn(e),r=(o,n,i,a)=>{let s=i?{...i,direction:"backward"}:{direction:"backward"};return t(o,n,s,Si(r,a))};return r},$_=Pi(Se),ji=e=>{let t=hn(e),r=(o,n,i,a)=>t(o,n,i,Si(r,a));return r},b_=ji(Se),Ai=e=>{let t=vn(e),r=async(o,n,i,a)=>{let s=i?{...i,direction:"backward"}:{direction:"backward"};return await t(o,n,s,Si(r,a))};return r},__=Ai(Se),Oi=e=>{let t=vn(e),r=async(o,n,i,a)=>await t(o,n,i,Si(r,a));return r},x_=Oi(Se),Ti=e=>(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return yn(e)(t,r,n)},k_=Ti(Se),Ni=e=>(t,r,o)=>yn(e)(t,r,o),w_=Ni(Se),Di=e=>async(t,r,o)=>{let n=o?{...o,direction:"backward"}:{direction:"backward"};return $n(e)(t,r,n)},S_=Di(Se),Ui=e=>async(t,r,o)=>$n(e)(t,r,o),I_=Ui(Se);var Ee={};tt(Ee,{anyString:()=>oc,base64:()=>Hs,base64url:()=>Xs,bigint:()=>sc,boolean:()=>cc,browserEmail:()=>D_,cidrv4:()=>Gs,cidrv6:()=>qs,creditCard:()=>Ci,cuid:()=>Ds,cuid2:()=>Us,currencyCode:()=>tc,date:()=>nc,datetime:()=>ic,domain:()=>Qs,duration:()=>Zs,e164:()=>ec,email:()=>Vs,emoji:()=>Ks,extendedDuration:()=>z_,guid:()=>Fs,hex:()=>fc,hostname:()=>Ys,html5Email:()=>O_,httpProtocol:()=>yr,iban:()=>Ei,idnEmail:()=>N_,integer:()=>$r,ipv4:()=>Js,ipv6:()=>Bs,ksuid:()=>Rs,lowercase:()=>dc,mac:()=>Ws,md5_base64:()=>R_,md5_base64url:()=>M_,md5_hex:()=>E_,nanoid:()=>Ms,nanoidOfLength:()=>Ls,null:()=>uc,number:()=>it,rfc5322Email:()=>T_,sha1_base64:()=>Z_,sha1_base64url:()=>F_,sha1_hex:()=>L_,sha256_base64:()=>K_,sha256_base64url:()=>J_,sha256_hex:()=>V_,sha384_base64:()=>W_,sha384_base64url:()=>G_,sha384_hex:()=>B_,sha512_base64:()=>H_,sha512_base64url:()=>X_,sha512_hex:()=>q_,string:()=>ac,time:()=>rc,ulid:()=>Cs,undefined:()=>lc,unicodeEmail:()=>sm,uppercase:()=>pc,uuid:()=>Ut,uuid4:()=>P_,uuid6:()=>j_,uuid7:()=>A_,xid:()=>Es});var Ds=/^[cC][0-9a-z]{6,}$/,Us=/^[0-9a-z]+$/,Cs=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Es=/^[0-9a-vA-V]{20}$/,Rs=/^[A-Za-z0-9]{27}$/,Ms=/^[a-zA-Z0-9_-]{21}$/;function Ls(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Zs=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,z_=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Fs=/^([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})$/,Ut=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)$/,P_=Ut(4),j_=Ut(6),A_=Ut(7),Vs=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,O_=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,T_=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,sm=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,N_=sm,D_=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,U_="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Ks(){return new RegExp(U_,"u")}var Js=/^(?:(?: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])$/,Bs=/^(([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}|:))$/,Ws=e=>{let t=Ce(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},Gs=/^((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])$/,qs=/^(([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])$/,Hs=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Xs=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Ys=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,Qs=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,yr=/^https?$/,ec=/^\+[1-9]\d{6,14}$/,Ci=/^\d(?:[ -]?\d){11,18}$/,tc=/^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/,Ei=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,cm="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function C_(e){return new RegExp(`^${e}$`)}var nc=C_(cm);function Ns(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function rc(e){return new RegExp(`^${Ns(e)}$`)}function ic(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${Ns({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,o=e.local?`${r}|${Ns({precision:e.precision})}`:r;return new RegExp(`^${cm}T(?:${o})$`)}var oc=/^[\s\S]{0,}$/,ac=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},sc=/^-?\d+n?$/,$r=/^-?\d+$/,it=/^-?\d+(?:\.\d+)?$/,cc=/^(?:true|false)$/i,uc=/^null$/i;var lc=/^undefined$/i;var dc=/^[^A-Z]*$/,pc=/^[^a-z]*$/,fc=/^[0-9a-fA-F]*$/;function br(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function _r(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var E_=/^[0-9a-fA-F]{32}$/,R_=br(22,"=="),M_=_r(22),L_=/^[0-9a-fA-F]{40}$/,Z_=br(27,"="),F_=_r(27),V_=/^[0-9a-fA-F]{64}$/,K_=br(43,"="),J_=_r(43),B_=/^[0-9a-fA-F]{96}$/,W_=br(64,""),G_=_r(64),q_=/^[0-9a-fA-F]{128}$/,H_=br(86,"=="),X_=_r(86);var G=h("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),mc=e=>{let t=e.value;return!_i(t)&&t.size!==void 0},gc=e=>{let t=e.value;return!_i(t)&&t.length!==void 0},Ri={number:"number",bigint:"bigint",object:"date"},Li=h("$ZodCheckLessThan",(e,t)=>{G.init(e,t);let r=Ri[typeof t.value];e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:Ri[typeof o.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Zi=h("$ZodCheckGreaterThan",(e,t)=>{G.init(e,t);let r=Ri[typeof t.value];e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:Ri[typeof o.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),hc=h("$ZodCheckMultipleOf",(e,t)=>{G.init(e,t),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):or(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),vc=h("$ZodCheckNumberFormat",(e,t)=>{G.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),o=r?"int":"number",[n,i]=cr[t.format];e._zod.check=a=>{let s=a.value;if(r){if(!Number.isInteger(s)){a.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){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:o,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:o,inclusive:!0,continue:!t.abort});return}}s<n&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),yc=h("$ZodCheckBigIntFormat",(e,t)=>{G.init(e,t);let[r,o]=ur[t.format];e._zod.check=n=>{let i=n.value;i<r&&n.issues.push({origin:"bigint",input:i,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),i>o&&n.issues.push({origin:"bigint",input:i,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),$c=h("$ZodCheckMaxSize",(e,t)=>{var r;G.init(e,t),(r=e._zod.def).when??(r.when=mc),e._zod.check=o=>{let n=o.value;n.size<=t.maximum||o.issues.push({origin:dr(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),bc=h("$ZodCheckMinSize",(e,t)=>{var r;G.init(e,t),(r=e._zod.def).when??(r.when=mc),e._zod.check=o=>{let n=o.value;n.size>=t.minimum||o.issues.push({origin:dr(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),_c=h("$ZodCheckSizeEquals",(e,t)=>{var r;G.init(e,t),(r=e._zod.def).when??(r.when=mc),e._zod.check=o=>{let n=o.value,i=n.size;if(i===t.size)return;let a=i>t.size;o.issues.push({origin:dr(n),...a?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),xc=h("$ZodCheckMaxLength",(e,t)=>{var r;G.init(e,t),(r=e._zod.def).when??(r.when=gc),e._zod.check=o=>{let n=o.value,i=n.length;if((typeof n=="string"&&i>t.maximum?Dt(n):i)<=t.maximum)return;let s=pr(n);o.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),kc=h("$ZodCheckMinLength",(e,t)=>{var r;G.init(e,t),(r=e._zod.def).when??(r.when=gc),e._zod.check=o=>{let n=o.value,i=n.length;if((typeof n=="string"&&i>=t.minimum&&i<t.minimum*2?Dt(n):i)>=t.minimum)return;let s=pr(n);o.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),wc=h("$ZodCheckLengthEquals",(e,t)=>{var r;G.init(e,t),(r=e._zod.def).when??(r.when=gc),e._zod.check=o=>{let n=o.value,i=n.length,a=typeof n=="string"&&i>=t.length&&i<=t.length*2?Dt(n):i;if(a===t.length)return;let s=pr(n),u=a>t.length;o.issues.push({origin:s,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),bn=h("$ZodCheckStringFormat",(e,t)=>{var r,o;G.init(e,t),t.pattern?(r=e._zod).check??(r.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})}):(o=e._zod).check??(o.check=()=>{})}),Sc=h("$ZodCheckRegex",(e,t)=>{bn.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ic=h("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=dc),bn.init(e,t)}),zc=h("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=pc),bn.init(e,t)}),Pc=h("$ZodCheckIncludes",(e,t)=>{G.init(e,t);let r=Ce(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=o,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})}}),jc=h("$ZodCheckStartsWith",(e,t)=>{G.init(e,t);let r=new RegExp(`^${Ce(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),Ac=h("$ZodCheckEndsWith",(e,t)=>{G.init(e,t);let r=new RegExp(`.*${Ce(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});function Mi(e,t,r){e.issues.length&&t.issues.push(...xe(r,e.issues))}var Oc=h("$ZodCheckProperty",(e,t)=>{G.init(e,t),e._zod.check=r=>{let o=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(o instanceof Promise)return o.then(n=>Mi(n,r,t.property));Mi(o,r,t.property)}}),Tc=h("$ZodCheckProperties",(e,t)=>{G.init(e,t),fr(e,Symbol.iterator,function*(){yield e});let r;e._zod.check=o=>{if(o.value==null){o.issues.push({expected:"object",code:"invalid_type",input:o.value,inst:e});return}r??(r=Reflect.ownKeys(t.shape).map(a=>[a,t.shape[a]]));let n=o.value,i;for(let[a,s]of r){let u=s._zod.run({value:n[a],issues:[]},{});u instanceof Promise?(i??(i=[]),i.push(u.then(l=>Mi(l,o,a)))):Mi(u,o,a)}if(i)return Promise.all(i).then(()=>{})}}),Nc=h("$ZodCheckMimeType",(e,t)=>{G.init(e,t);let r=new Set(t.mime);e._zod.check=o=>{r.has(o.value.type)||o.issues.push({code:"invalid_value",values:t.mime,input:o.value.type,inst:e,continue:!t.abort})}}),Dc=h("$ZodCheckOverwrite",(e,t)=>{G.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Ct=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let o=t.split(`
|
|
4
4
|
`).filter(a=>a),n=Math.min(...o.map(a=>a.length-a.trimStart().length)),i=o.map(a=>a.slice(n)).map(a=>" ".repeat(this.indent*2)+a);for(let a of i)this.content.push(a)}compile(){let t=Function,r=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
5
5
|
${r.join(`
|
|
@@ -60,7 +60,7 @@ ${u}`:u:"",d=Function,p=`return (input) => {
|
|
|
60
60
|
${u}
|
|
61
61
|
}`,m;try{m=new d(...a,p)(...s)}catch(f){throw new M(`this schema (generated code failed to evaluate: ${f.message})`)}return t?.debug&&(m.code=l),m.definite=o.definite,m}function N(e,t){for(let[o,n]of e.constants)if(n===t)return o;let r=`c${e.constantCounter++}`;return e.constants.set(r,t),r}function Mt(e,t){return e.definite=!1,N(e,t)}function T(e){return`v${e.varCounter++}`}function xk(e,t){let r=e._zod.run({value:t,issues:[]},{});if(r&&typeof r.then=="function")return ye;let o=r;return o.issues.length===0?o.value:ye}function me(e,t,r,o,n=!0){let i=e.content.length,a=t.constants.size,s=t.constantCounter,u=t.varCounter;try{return Y(e,t,r,o,n)}catch(l){if(!(l instanceof M)||!l.islandable)throw l;if(e.content.length=i,t.constants.size>a){let d=Array.from(t.constants.keys()).slice(a);for(let p of d)t.constants.delete(p)}return t.constantCounter=s,t.varCounter=u,kk(e,t,r,o)}}function kk(e,t,r,o){t.definite=!1;let n=N(t,r),i=N(t,xk),a=T(t);return e.write(`const ${a} = ${i}(${n}, ${o});`),e.write(`if (${a} === INVALID) return INVALID;`),a}var wk=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function Sk(e,t,r,o){let n=r._zod.def.checks;if(!n||n.length===0)return o;let i=o;for(let a of n){let s=a._zod.def;if(s.when&&!wk.has(s.check))throw new M('check with a custom "when" condition');switch(s.check){case"greater_than":Ik(e,t,s,i);break;case"less_than":zk(e,t,s,i);break;case"multiple_of":Pk(e,t,s,i);break;case"number_format":Yg(e,s,i);break;case"min_length":{let u=ht(s.minimum,"min_length"),l=el(e,t,i,`${i}.length >= ${u} && ${i}.length < ${s.minimum*2}`);e.write(`if (${l} < ${u}) return INVALID;`);break}case"max_length":{let u=ht(s.maximum,"max_length"),l=el(e,t,i,`${i}.length > ${u}`);e.write(`if (${l} > ${u}) return INVALID;`);break}case"length_equals":{let u=ht(s.length,"length_equals"),l=el(e,t,i,`${i}.length >= ${u} && ${i}.length <= ${s.length*2}`);e.write(`if (${l} !== ${u}) return INVALID;`);break}case"min_size":e.write(`if (${i}.size < ${ht(s.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${i}.size > ${ht(s.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${i}.size !== ${ht(s.size,"size_equals")}) return INVALID;`);break;case"string_format":i=Qg(e,t,s,i);break;case"custom":i=Dk(e,t,a,i);break;case"bigint_format":jk(e,s,i);break;case"mime_type":Ak(e,t,s,i);break;case"property":Tk(e,t,s,i);break;case"properties":Ok(e,t,s,i);break;case"overwrite":{let u=T(t);Nk(e,t,a,i,u),i=u;break}default:throw new M(`check type ${s.check}`)}}return i}function el(e,t,r,o){let n=N(t,Dt),i=T(t);return e.write(`const ${i} = typeof ${r} === "string" && ${o} ? ${n}(${r}) : ${r}.length;`),i}function ht(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new M(`${t} bound of type ${typeof e}`);return`${e}`}function Xg(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new M("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new M("comparison check with Invalid Date bound");return N(e,t)}throw new M(`comparison check bound of type ${typeof t}`)}function Ik(e,t,r,o){let n=r.inclusive?"<":"<=";e.write(`if (${o} ${n} ${Xg(t,r.value)}) return INVALID;`)}function zk(e,t,r,o){let n=r.inclusive?">":">=";e.write(`if (${o} ${n} ${Xg(t,r.value)}) return INVALID;`)}function Pk(e,t,r,o){if(typeof r.value=="bigint"){if(r.value===BigInt(0))throw new M("multiple_of check with a zero divisor");e.write(`if (${o} % ${r.value}n !== 0n) return INVALID;`)}else{let n=N(t,or);e.write(`if (${n}(${o}, ${ht(r.value,"multiple_of")}) !== 0) return INVALID;`)}}function Yg(e,t,r){let o=t.format;switch(o){case"safeint":e.write(`if (!Number.isSafeInteger(${r})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${r}) || ${r} < -2147483648 || ${r} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${r}) || ${r} < 0 || ${r} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${r}) || ${r} < -3.4028234663852886e38 || ${r} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${r})) return INVALID;`);break;default:throw new M(`number format ${o}`)}}function jk(e,t,r){let o=t.format;if(o)switch(o){case"int64":e.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break;default:throw new M(`bigint format ${o}`)}}function Ak(e,t,r,o){let n=r.mime;if(n&&n.length>0){let i=N(t,new Set(n));e.write(`if (!${i}.has(${o}.type)) return INVALID;`)}}function Ok(e,t,r,o){if(r.when)throw new M('check with a custom "when" condition');e.write(`if (${o} == null) return INVALID;`);let n=r.shape;for(let i of Reflect.ownKeys(n)){let a=typeof i=="symbol"?N(t,i):he(i),s=T(t);e.write(`const ${s} = ${o}[${a}];`),me(e,t,n[i],s,!1)}}function Tk(e,t,r,o){let n=`${o}[${JSON.stringify(r.property)}]`;Y(e,t,r.schema,n)}function Nk(e,t,r,o,n){let i=r._zod.def.tx;if(!i)throw new M("overwrite check without a transform function");if(Lt(i))throw new Le("z.compile: async overwrite transforms are not supported");let a=N(t,i);e.write(`const ${n} = ${a}(${o});`)}function tl(){throw new we}function il(e){this.issues.push(e)}function Dk(e,t,r,o){let n=r._zod.def;if(n.fn){if(Lt(n.fn))throw new Le("z.compile: async .refine() predicates are not supported");let i=Mt(t,n.fn),a=N(t,tl),s=T(t);return e.write(`const ${s} = ${i}(${o});`),e.write(`if (${s} instanceof Promise) ${a}();`),e.write(`if (!${s}) return INVALID;`),o}if(r._zod.check){if(Lt(r._zod.check))throw new Le("z.compile: async .superRefine() / check functions are not supported");let i=r._zod.check,s=Mt(t,l=>{let d={value:l,issues:[],addIssue:il};return i(d)instanceof Promise&&tl(),d.issues.length===0?d.value:ye}),u=T(t);return e.write(`const ${u} = ${s}(${o});`),e.write(`if (${u} === INVALID) return INVALID;`),u}throw new M("custom check without a predicate or check function")}var Uk=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function Qg(e,t,r,o,n=!0){let i=r.format;if(i==="base64"){let l=N(t,Sr);return e.write(`if (!${l}(${o})) return INVALID;`),o}if(i==="base64url"){let l=N(t,Yi);return e.write(`if (!${l}(${o})) return INVALID;`),o}if(i==="jwt"){let l=N(t,to),d=N(t,r.alg??null);return e.write(`if (!${l}(${o}, ${d})) return INVALID;`),o}if(i==="ipv6"){let l=N(t,wr);return e.write(`if (!${l}(${o})) return INVALID;`),o}if(i==="cidrv6"){let l=N(t,Hi);return e.write(`if (!${l}(${o})) return INVALID;`),o}if(i==="credit_card"){let l=N(t,Qi);return e.write(`if (!${l}(${o})) return INVALID;`),o}if(i==="iban"){let l=N(t,eo);return e.write(`if (!${l}(${o})) return INVALID;`),o}let a=r;if(i==="url"||i==="httpurl"||a.normalize||a.hostname!==void 0||a.protocol!==void 0){let l=N(t,Wi),d=N(t,r),p=T(t),m=T(t);if(e.write(`const ${p} = ${o}.trim();`),e.write(`const ${m} = ${l}(${p}, ${d});`),e.write(`if (typeof ${m} === "number") return INVALID;`),a.hostname!==void 0){let y=N(t,Gi);e.write(`if (!${y}(${m}, ${d}.hostname)) return INVALID;`)}if(a.protocol!==void 0){let y=N(t,qi);e.write(`if (!${y}(${m}, ${d}.protocol)) return INVALID;`)}if(!n)return null;let f=T(t),g=a.normalize?`${m}.href`:`${N(t,kr)}(${p})`;return e.write(`const ${f} = ${g};`),f}let s=r.fn;if(s){if(Lt(s))throw new M(`async string format ${i}`);let l=N(t,s);return e.write(`if (!${l}(${o})) return INVALID;`),o}if(Uk.has(i)&&r.pattern){let l=N(t,r.pattern);return e.write(`${l}.lastIndex = 0;`),e.write(`if (!${l}.test(${o})) return INVALID;`),o}let u=r.format;switch(u){case"regex":throw new M("regex format without a pattern");case"lowercase":e.write(`if (${o} !== ${o}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${o} !== ${o}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${o}.includes(${he(r.includes)})) return INVALID;`);break;case"starts_with":{let l=r.prefix;e.write(`if (${o}.slice(0, ${l.length}) !== ${he(l)}) return INVALID;`);break}case"ends_with":{let l=r.suffix;e.write(`if (${o}.slice(-${l.length}) !== ${he(l)}) return INVALID;`);break}default:throw new M(`string format ${u}`)}return o}function Y(e,t,r,o,n=!0){let i=r._zod.def,a=i.type;if(i.coerce)throw new M(`coercion (z.coerce.${a}())`);let s=n||!!i.checks?.length,u;switch(a){case"string":u=Ck(e,t,r,o,s);break;case"number":u=Ek(e,r,o);break;case"boolean":u=Rk(e,o);break;case"bigint":u=Mk(e,r,o);break;case"symbol":u=Lk(e,o);break;case"undefined":u=Zk(e,o);break;case"null":u=Fk(e,o);break;case"any":case"unknown":u=o;break;case"never":e.write("return INVALID;"),u=o;break;case"void":u=Vk(e,o);break;case"nan":u=Kk(e,o);break;case"date":u=Jk(e,o);break;case"object":u=Bk(e,t,r,o,s);break;case"optional":u=Wk(e,t,r,o,s);break;case"nullable":u=Hk(e,t,r,o,s);break;case"array":u=Xk(e,t,r,o,s);break;case"literal":u=Yk(e,t,r,o);break;case"enum":u=Qk(e,t,r,o);break;case"readonly":{let l=Gg(e,t,r,o),d=T(t);e.write(`const ${d} = Object.freeze(${l});`),u=d;break}case"success":Gg(e,t,r,o),u="true";break;case"default":case"prefault":u=ew(e,t,r,o);break;case"nonoptional":u=tw(e,t,r,o);break;case"tuple":u=nw(e,t,r,o);break;case"union":u=rw(e,t,r,o);break;case"intersection":u=aw(e,t,r,o);break;case"record":u=sw(e,t,r,o);break;case"map":u=uw(e,t,r,o);break;case"set":u=lw(e,t,r,o);break;case"file":u=dw(e,o);break;case"template_literal":u=pw(e,t,r,o);break;case"lazy":u=fw(e,t,r,o);break;case"pipe":u=mw(e,t,r,o);break;case"custom":u=gw(e,t,r,o);break;case"transform":u=yw(e,t,r,o);break;case"catch":u=vw(e,t,r,o);break;default:throw new M(`schema type ${a}`)}return u===null?null:Sk(e,t,r,u)}function Ck(e,t,r,o,n=!0){e.write(`if (typeof ${o} !== "string") return INVALID;`);let i=r._zod.def;return i.format===void 0?o:Qg(e,t,i,o,n)}function Ek(e,t,r){e.write(`if (typeof ${r} !== "number" || !Number.isFinite(${r})) return INVALID;`);let o=t._zod.def;return o.check==="number_format"&&o.format&&Yg(e,{format:o.format},r),r}function Rk(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function Mk(e,t,r){e.write(`if (typeof ${r} !== "bigint") return INVALID;`);let o=t._zod.def;if(o.format)switch(o.format){case"int64":e.write(`if (${r} < -9223372036854775808n || ${r} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${r} < 0n || ${r} > 18446744073709551615n) return INVALID;`);break}return r}function Lk(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function Zk(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function Fk(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function Vk(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function Kk(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function Jk(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function Bk(e,t,r,o,n=!0){let i=r._zod.def;e.write(`if (typeof ${o} !== "object" || ${o} === null || Array.isArray(${o})) return INVALID;`);let a=i.shape,s=Object.keys(a),u=Object.getOwnPropertySymbols(a),l=u.length?[...s,...u]:s,d=I=>typeof I=="symbol"?N(t,I):he(I),p=I=>typeof I=="symbol"?`[${d(I)}]`:he(I),m=a;if(s.includes("__proto__"))throw new M('object shape key "__proto__"');let f=new Map;for(let I of l){let A=m[I],S=d(I),z=T(t);if(e.write(`const ${z} = ${o}[${S}];`),A._zod.optin!==void 0){let O=T(t);e.write(`let ${O} = (() => {`),e.indented(X=>{let je=me(X,t,A,z);X.write(`return ${je};`)}),e.write("})();"),A._zod.optout==="optional"?(e.write(`if (${O} === INVALID) {`),e.indented(X=>{X.write(`if (${S} in ${o}) return INVALID;`),X.write(`${O} = undefined;`)}),e.write("}")):e.write(`if (${O} === INVALID) return INVALID;`),f.set(I,O)}else{qk(A)&&e.write(`if (!(${S} in ${o})) return INVALID;`);let O=me(e,t,A,z,n);O!==null&&f.set(I,O)}}let g=i.catchall,y="none";if(g){let I=g._zod.def.type;if(I==="never"){let A=s.map(S=>`k !== ${he(S)}`).join(" && ")||"true";e.write(`for (const k in ${o}) {`),e.indented(S=>{S.write(`if (${A}) return INVALID;`)}),e.write("}")}else(I==="unknown"||I==="any")&&!g._zod.def.checks?.length?y="passthrough":y="schema"}let x=T(t),P=l.some(I=>Wg(m[I])||nl(m[I]));if(!n){if(y==="schema"){let I=s.length>0?N(t,new Set(s)):null;e.write(`for (const k in ${o}) {`),e.indented(A=>{A.write('if (k === "__proto__") continue;'),I&&A.write(`if (${I}.has(k)) continue;`);let S=T(t);A.write(`const ${S} = ${o}[k];`),me(A,t,g,S,!1)}),e.write("}")}return null}if(P){e.write(`const ${x} = {};`);for(let I of l){let A=d(I),S=f.get(I);nl(m[I])?e.write(`if (${A} in ${o}) ${x}[${A}] = ${S};`):Wg(m[I])?e.write(`if (${S} !== undefined || ${A} in ${o}) ${x}[${A}] = ${S};`):e.write(`${x}[${A}] = ${S};`)}}else{let I=l.map(A=>`${p(A)}: ${f.get(A)}`).join(", ");e.write(`const ${x} = { ${I} };`)}if(y!=="none"){let I=s.length>0?N(t,new Set(s)):null;e.write(`for (const k in ${o}) {`),e.indented(A=>{if(A.write('if (k === "__proto__") continue;'),I&&A.write(`if (${I}.has(k)) continue;`),y==="passthrough")A.write(`${x}[k] = ${o}[k];`);else{let S=T(t);A.write(`const ${S} = ${o}[k];`);let z=me(A,t,g,S);A.write(`${x}[k] = ${z};`)}}),e.write("}")}return x}function Wk(e,t,r,o,n=!0){let i=r._zod.def;if(Gk(r))return Y(e,t,i.innerType,o,n);if(i.innerType._zod.optin==="defaulted"){let s=T(t),u=T(t);return e.write(`let ${s};`),e.write(`if (${o} === undefined) {`),e.indented(l=>{l.write(`const ${u} = (() => {`),l.indented(d=>{let p=Y(d,t,i.innerType,o);d.write(`return ${p};`)}),l.write("})();"),l.write(`if (${u} !== INVALID) ${s} = ${u};`)}),e.write("} else {"),e.indented(l=>{let d=Y(l,t,i.innerType,o);l.write(`${s} = ${d};`)}),e.write("}"),s}let a=n?T(t):null;return a&&e.write(`let ${a};`),e.write(`if (${o} !== undefined) {`),e.indented(s=>{let u=Y(s,t,i.innerType,o,n);a&&u!==null&&s.write(`${a} = ${u};`)}),e.write("}"),a}function Gk(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function qk(e){return e._zod.optin===void 0&&Rt(e)}function Rt(e){if(e._zod.def.coerce)return!0;let t=e._zod.def;switch(t.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return t.innerType?Rt(t.innerType):!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return t.innerType?Rt(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(Rt):!0;case"intersection":return!t.left||!t.right?!0:Rt(t.left)&&Rt(t.right);case"pipe":return t.in?Rt(t.in):!0;default:return!0}}function nl(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function Wg(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&wn(e)}function wn(e){let t=e._zod.def;switch(t.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return t.innerType?wn(t.innerType):!0;case"union":return t.options?t.options.some(wn):!0;case"intersection":return!t.left||!t.right||wn(t.left)||wn(t.right);case"pipe":return t.out?wn(t.out):!0;default:return!0}}function Hk(e,t,r,o,n=!0){let i=r._zod.def,a=n?T(t):null;return a&&e.write(`let ${a} = null;`),e.write(`if (${o} !== null) {`),e.indented(s=>{let u=Y(s,t,i.innerType,o,n);a&&u!==null&&s.write(`${a} = ${u};`)}),e.write("}"),a}function ol(e,t,r){for(let[o,n]of mn(t._zod.def.checks))e.write(`if (${r} > ${ht(o,n._zod.def.check)}) return INVALID;`)}function Xk(e,t,r,o,n=!0){let i=r._zod.def;e.write(`if (!Array.isArray(${o})) return INVALID;`),ol(e,r,`${o}.length`);let a=n?T(t):null,s=T(t),u=T(t);return a&&e.write(`const ${a} = new Array(${o}.length);`),e.write(`for (let ${s} = 0; ${s} < ${o}.length; ${s}++) {`),e.indented(l=>{l.write(`const ${u} = ${o}[${s}];`);let d=me(l,t,i.element,u,n);a&&d!==null&&l.write(`${a}[${s}] = ${d};`)}),e.write("}"),a}function Yk(e,t,r,o){let i=r._zod.def.values;if(i.length!==1){let s=N(t,new Set(i));return e.write(`if (!${s}.has(${o})) return INVALID;`),o}let a=i[0];if(typeof a=="number"&&Number.isNaN(a)){let s=N(t,new Set(i));return e.write(`if (!${s}.has(${o})) return INVALID;`),o}if(typeof a=="string")e.write(`if (${o} !== ${he(a)}) return INVALID;`);else if(typeof a=="number"||typeof a=="boolean")e.write(`if (${o} !== ${a}) return INVALID;`);else if(a===null)e.write(`if (${o} !== null) return INVALID;`);else if(a===void 0)e.write(`if (${o} !== undefined) return INVALID;`);else if(typeof a=="bigint")e.write(`if (${o} !== ${a}n) return INVALID;`);else throw new M(`literal type ${typeof a}`);return o}function Qk(e,t,r,o){let n=r._zod.values;if(!n)throw new M("enum schema without enumerated values");let i=N(t,n);return e.write(`if (!${i}.has(${o})) return INVALID;`),o}function Gg(e,t,r,o){let n=r._zod.def;return Y(e,t,n.innerType,o)}function ew(e,t,r,o){let n=r._zod.def,a=Object.getOwnPropertyDescriptor(r._zod.def,"defaultValue")?()=>r._zod.def.defaultValue:void 0;if(r._zod.def.type==="prefault"){if(!a)return Y(e,t,n.innerType,o);let u=N(t,a),l=T(t);return e.write(`let ${l} = ${o};`),e.write(`if (${o} === undefined) ${l} = ${u}();`),Y(e,t,n.innerType,l)}let s=T(t);if(a){let u=N(t,a),l=N(t,ar);e.write(`let ${s};`),e.write(`if (${o} === undefined) {`),e.indented(d=>{d.write(`${s} = ${l}(${u}());`)}),e.write("} else {"),e.indented(d=>{let p=Y(d,t,n.innerType,o);d.write(`${s} = ${p} === undefined ? ${l}(${u}()) : ${p};`)}),e.write("}")}else e.write(`let ${s};`),e.write(`if (${o} !== undefined) {`),e.indented(u=>{let l=Y(u,t,n.innerType,o);u.write(`${s} = ${l};`)}),e.write("}");return s}function tw(e,t,r,o){let n=r._zod.def,i=Y(e,t,n.innerType,o),a=T(t);return e.write(`const ${a} = ${i};`),e.write(`if (${a} === undefined) return INVALID;`),a}function nw(e,t,r,o){let n=r._zod.def,i=n.items,a=n.rest;e.write(`if (!Array.isArray(${o})) return INVALID;`);let s=qg(i,"optin"),u=qg(i,"optout");a?e.write(`if (${o}.length < ${s}) return INVALID;`):e.write(`if (${o}.length < ${s} || ${o}.length > ${i.length}) return INVALID;`);let l=T(t);e.write(`const ${l} = [];`);for(let d=0;d<i.length;d++){let p=i[d];if(d>=u)e.write(`if (${l}.length === ${d}) {`),e.indented(m=>{m.write(`if (${d} < ${o}.length) {`),m.indented(f=>{let g=T(t);f.write(`const ${g} = ${o}[${d}];`);let y=me(f,t,p,g);f.write(`${l}[${d}] = ${y};`)}),m.write("} else {"),m.indented(f=>{if(nl(p)){f.write(`${l}.length = ${d};`);return}let g=T(t),y=T(t);f.write(`const ${g} = undefined;`),f.write(`const ${y} = (() => {`),f.indented(x=>{let P=me(x,t,p,g);x.write(`return ${P};`)}),f.write("})();"),f.write(`if (${y} === INVALID || ${y} === undefined) ${l}.length = ${d};`),f.write(`else ${l}[${d}] = ${y};`)}),m.write("}")}),e.write("}");else{let m=T(t);e.write(`const ${m} = ${o}[${d}];`);let f=me(e,t,p,m);e.write(`${l}[${d}] = ${f};`)}}if(a){let d=T(t),p=T(t);e.write(`for (let ${d} = ${i.length}; ${d} < ${o}.length; ${d}++) {`),e.indented(m=>{m.write(`const ${p} = ${o}[${d}];`);let f=me(m,t,a,p);m.write(`${l}[${d}] = ${f};`)}),e.write("}")}return l}function qg(e,t){for(let r=e.length-1;r>=0;r--)if(!(t==="optin"?e[r]._zod.optin!==void 0:e[r]._zod.optout==="optional"))return r+1;return 0}function rw(e,t,r,o){let n=r._zod.def,i=n.options;if(n.discriminator)return iw(e,t,n,o);if(n.inclusive===!1)throw new M("exclusive unions (z.xor)");if(i.length===0)return e.write("return INVALID;"),o;if(i.length===1)return Y(e,t,i[0],o);if(i.every(u=>u._zod.def.type==="literal"&&!u._zod.def.checks?.length)){let u=new Set(i.flatMap(d=>d._zod.def.values)),l=N(t,u);return e.write(`if (!${l}.has(${o})) return INVALID;`),o}let s=T(t);e.write(`let ${s};`);for(let u=0;u<i.length;u++){let l=i[u];u===0?e.write(`${s} = (() => {`):e.write(`if (${s} === INVALID) ${s} = (() => {`),e.indented(d=>{let p=Y(d,t,l,o);d.write(`return ${p};`)}),e.write("})();")}return e.write(`if (${s} === INVALID) return INVALID;`),s}function iw(e,t,r,o){if(r.unionFallback)throw new M("discriminated union with unionFallback");if(r.options.length===0)return e.write("return INVALID;"),o;let n=T(t),i=T(t);e.write(`const ${n} = ${o}?.[${he(r.discriminator)}];`),e.write(`let ${i};`);let a=!0,s=new Set;for(let u of r.options){let l=u._zod.propValues?.[r.discriminator];if(!l||l.size===0)throw new M("discriminated union option without static discriminator values");for(let m of l){if(s.has(m))throw new M(`duplicate discriminator value ${String(m)}`);s.add(m)}let d=Array.from(l,m=>ow(t,n,m)),p=a?"if":"else if";e.write(`${p} (${d.join(" || ")}) {`),e.indented(m=>{let f=Y(m,t,u,o);m.write(`${i} = ${f};`)}),e.write("}"),a=!1}return e.write("else { return INVALID; }"),i}function ow(e,t,r){if(typeof r=="string")return`${t} === ${he(r)}`;if(typeof r=="number")return Number.isNaN(r)?`Number.isNaN(${t})`:`${t} === ${r}`;if(typeof r=="boolean")return`${t} === ${r}`;if(r===null)return`${t} === null`;if(r===void 0)return`${t} === undefined`;if(typeof r=="bigint")return`${t} === ${r}n`;if(typeof r=="symbol"){let o=N(e,r);return`${t} === ${o}`}throw new M(`literal discriminator value ${String(r)}`)}function aw(e,t,r,o){let n=r._zod.def;t.definite=!1;let i=me(e,t,n.left,o),a=me(e,t,n.right,o),s=N(t,_n),u=T(t);return e.write(`const ${u} = ${s}(${i}, ${a});`),e.write(`if (!${u}.valid) return INVALID;`),`${u}.data`}function sw(e,t,r,o){let n=r._zod.def,i=N(t,Ue);e.write(`if (!${i}(${o})) return INVALID;`);let a=T(t),s=T(t),u=T(t);e.write(`const ${a} = {};`);let l=n,d=l.partial?void 0:n.keyType._zod.values;if(d){let f=[];for(let y of d){if(!(typeof y=="string"||typeof y=="number"||typeof y=="symbol"))throw new M(`record key value ${String(y)}`);let x=typeof y=="number"?y.toString():y;if(x==="__proto__")throw new M('record key "__proto__"');f.push(x);let P=N(t,y),I=Y(e,t,n.keyType,P),A=T(t);e.write(`const ${A} = ${o}[${cw(t,x)}];`);let S=me(e,t,n.valueType,A);e.write(`${a}[${I}] = ${S};`)}let g=N(t,new Set(f));return e.write(`for (const ${s} in ${o}) {`),e.indented(y=>{y.write(`if (${g}.has(${s})) continue;`),l.mode==="loose"?y.write(`if (${s} !== "__proto__") ${a}[${s}] = ${o}[${s}];`):y.write("return INVALID;")}),e.write("}"),a}let p=n.keyType._zod.def;if(!(p.type==="string"&&p.format===void 0&&!p.coerce&&(p.checks?.length??0)===0)){let f=n.mode==="loose",g=bo(n.keyType);g.definite===!1&&(t.definite=!1);let y=N(t,g),x=N(t,it),P=T(t);return Hg(e,t,o,s,I=>{I.write(`let ${P} = ${y}(${s});`),I.write(`if (${P} === INVALID && typeof ${s} === "string" && ${x}.test(${s})) ${P} = ${y}(Number(${s}));`),f?I.write(`if (${P} === INVALID) { ${a}[${s}] = ${o}[${s}]; continue; }`):I.write(`if (${P} === INVALID) return INVALID;`),I.write(`if (${P} === "__proto__") continue;`);let A=T(t);I.write(`const ${A} = ${o}[${s}];`);let S=me(I,t,n.valueType,A);I.write(`${a}[${P}] = ${S};`)}),a}return Hg(e,t,o,s,f=>{f.write(`const ${u} = ${o}[${s}];`);let g=me(f,t,n.valueType,u);f.write(`${a}[${s}] = ${g};`)},"return INVALID;"),a}function Hg(e,t,r,o,n,i){let a=N(t,Object.prototype.propertyIsEnumerable),s=T(t),u=T(t),l=T(t);e.write(`const ${s} = Object.getOwnPropertySymbols(${r});`),e.write(`const ${u} = Object.getOwnPropertyNames(${r});`),e.write(`for (let ${l} = 0; ${l} < ${u}.length; ${l}++) {`),e.indented(d=>{d.write(`const ${o} = ${u}[${l}];`),d.write(`if (${o} === "__proto__" || !${a}.call(${r}, ${o})) continue;`),n(d)}),e.write("}"),e.write(`for (let ${l} = 0; ${l} < ${s}.length; ${l}++) {`),e.indented(d=>{d.write(`const ${o} = ${s}[${l}];`),d.write(`if (!${a}.call(${r}, ${o})) continue;`),i?d.write(i):n(d)}),e.write("}")}function cw(e,t){return typeof t=="string"?he(t):N(e,t)}function uw(e,t,r,o){let n=r._zod.def;e.write(`if (!(${o} instanceof Map)) return INVALID;`),ol(e,r,`${o}.size`);let i=T(t),a=T(t),s=T(t);return e.write(`const ${i} = new Map();`),e.write(`for (const [${a}, ${s}] of ${o}) {`),e.indented(u=>{let l=Y(u,t,n.keyType,a),d=Y(u,t,n.valueType,s);u.write(`${i}.set(${l}, ${d});`)}),e.write("}"),i}function lw(e,t,r,o){let n=r._zod.def;e.write(`if (!(${o} instanceof Set)) return INVALID;`),ol(e,r,`${o}.size`);let i=T(t),a=T(t);return e.write(`const ${i} = new Set();`),e.write(`for (const ${a} of ${o}) {`),e.indented(s=>{let u=Y(s,t,n.valueType,a);s.write(`${i}.add(${u});`)}),e.write("}"),i}function dw(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function pw(e,t,r,o){e.write(`if (typeof ${o} !== "string") return INVALID;`);let n=r._zod.pattern;if(n){let i=N(t,n);e.write(`${i}.lastIndex = 0;`),e.write(`if (!${i}.test(${o})) return INVALID;`)}return o}function fw(e,t,r,o){let n=r._zod.def,i=Mt(t,n.getter),a=N(t,{parser:null});e.write(`if (!${a}.parser) {`),e.indented(u=>{u.write(`const inner = ${i}();`),u.write(`${a}.parser = function(input) {`),u.indented(l=>{l.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),l.write("return result.issues.length === 0 ? result.value : INVALID;")}),u.write("};")}),e.write("}");let s=T(t);return e.write(`const ${s} = ${a}.parser(${o});`),e.write(`if (${s} === INVALID) return INVALID;`),s}function mw(e,t,r,o){let n=r._zod.def,i=Y(e,t,n.in,o);if(n.transform){if(Lt(n.transform))throw new Le("z.compile: async transforms in pipes are not supported");let a=n.transform,u=Mt(t,d=>{let p={value:d,issues:[],addIssue:il},m=a(d,p);return m instanceof Promise?ye:p.issues.length===0?m:ye}),l=T(t);return e.write(`const ${l} = ${u}(${i});`),e.write(`if (${l} === INVALID) return INVALID;`),Y(e,t,n.out,l)}else return Y(e,t,n.out,i)}function Lt(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function gw(e,t,r,o){let n=r._zod.def;if(n.fn){if(Lt(n.fn))throw new Le("z.compile: async custom predicates are not supported");let i=Mt(t,n.fn),a=N(t,tl),s=T(t);e.write(`const ${s} = ${i}(${o});`),e.write(`if (${s} instanceof Promise) ${a}();`),e.write(`if (!${s}) return INVALID;`)}else throw new M("custom schema without a predicate function");return o}function hw(e,t,r){let o=e._zod.run({value:r,issues:[]},{});if(o&&typeof o.then=="function")return ye;let n=o;return n.issues.length===0?n.value:t()}function vw(e,t,r,o){let n=r._zod.def;if(!n.catchValue[wi])throw new M("catch with a callback (only a constant catch value compiles)",!1);let i=T(t);e.write(`let ${i} = (() => {`),e.indented(l=>{let d=me(l,t,n.innerType,o);l.write(`return ${d};`)}),e.write("})();");let a=N(t,n.innerType),s=Mt(t,n.catchValue),u=N(t,hw);return e.write(`if (${i} === INVALID) {`),e.indented(l=>{l.write(`${i} = ${u}(${a}, ${s}, ${o});`),l.write(`if (${i} === INVALID) return INVALID;`)}),e.write("}"),i}function yw(e,t,r,o){let n=r._zod.def;if(n.transform){if(Lt(n.transform))throw new Le("z.compile: async transforms are not supported");let i=n.transform,s=Mt(t,l=>{let d={value:l,issues:[],addIssue:il},p=i(l,d);return p instanceof Promise?ye:d.issues.length===0?p:ye}),u=T(t);return e.write(`const ${u} = ${s}(${o});`),e.write(`if (${u} === INVALID) return INVALID;`),u}return o}function _o(e){return e.checks&&(e.checks=[...e.checks]),e}function al(e,t){return new e(_o({type:"string",...k(t)}))}function sl(e,t){return new e(_o({type:"string",coerce:!0,...k(t)}))}function xo(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...k(t)})}function ko(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...k(t)})}function wo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...k(t)})}function So(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...k(t)})}function Io(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...k(t)})}function zo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...k(t)})}function Cr(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...k(t)})}function Po(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...k(t)})}function jo(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...k(t)})}function Ao(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...k(t)})}function Oo(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...k(t)})}function To(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...k(t)})}function No(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...k(t)})}function Do(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...k(t)})}function Uo(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...k(t)})}function Co(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...k(t)})}function cl(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...k(t)})}function Eo(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...k(t)})}function Ro(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...k(t)})}function Mo(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...k(t)})}function Lo(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...k(t)})}function Zo(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...k(t)})}function ul(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...k(t)})}function ll(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...k(t)})}function Fo(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...k(t)})}var dl={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Er(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...k(t)})}function Rr(e,t){return new e({type:"string",format:"date",check:"string_format",...k(t)})}function Mr(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...k(t)})}function Lr(e,t){return new e({type:"string",format:"duration",check:"string_format",...k(t)})}function pl(e,t){return new e(_o({type:"number",checks:[],...k(t)}))}function fl(e,t){return new e(_o({type:"number",coerce:!0,checks:[],...k(t)}))}function ml(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...k(t)})}function gl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...k(t)})}function hl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...k(t)})}function vl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...k(t)})}function yl(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...k(t)})}function $l(e,t){return new e({type:"boolean",...k(t)})}function bl(e,t){return new e({type:"boolean",coerce:!0,...k(t)})}function _l(e,t){return new e({type:"bigint",...k(t)})}function xl(e,t){return new e({type:"bigint",coerce:!0,...k(t)})}function kl(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...k(t)})}function wl(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...k(t)})}function Sl(e,t){return new e({type:"symbol",...k(t)})}function Il(e,t){return new e({type:"undefined",...k(t)})}function zl(e,t){return new e({type:"null",...k(t)})}function Pl(e){return new e({type:"any"})}function jl(e){return new e({type:"unknown"})}function Al(e,t){return new e({type:"never",...k(t)})}function Ol(e,t){return new e({type:"void",...k(t)})}function Tl(e,t){return new e({type:"date",...k(t)})}function Nl(e,t){return new e({type:"date",coerce:!0,...k(t)})}function Dl(e,t){return new e({type:"nan",...k(t)})}function Ke(e,t){return new Li({check:"less_than",...k(t),value:e,inclusive:!1})}function Oe(e,t){return new Li({check:"less_than",...k(t),value:e,inclusive:!0})}function Je(e,t){return new Zi({check:"greater_than",...k(t),value:e,inclusive:!1})}function Te(e,t){return new Zi({check:"greater_than",...k(t),value:e,inclusive:!0})}function Vo(e){return Je(0,e)}function Ko(e){return Ke(0,e)}function Jo(e){return Oe(0,e)}function Bo(e){return Te(0,e)}function vt(e,t){return new hc({check:"multiple_of",...k(t),value:e})}function yt(e,t){return new $c({check:"max_size",...k(t),maximum:e})}function Be(e,t){return new bc({check:"min_size",...k(t),minimum:e})}function Zt(e,t){return new _c({check:"size_equals",...k(t),size:e})}function Ft(e,t){return new xc({check:"max_length",...k(t),maximum:e})}function ot(e,t){return new kc({check:"min_length",...k(t),minimum:e})}function Vt(e,t){return new wc({check:"length_equals",...k(t),length:e})}function Sn(e,t){return new Sc({check:"string_format",format:"regex",...k(t),pattern:e})}function In(e){return new Ic({check:"string_format",format:"lowercase",...k(e)})}function zn(e){return new zc({check:"string_format",format:"uppercase",...k(e)})}function Pn(e,t){return new Pc({check:"string_format",format:"includes",...k(t),includes:e})}function jn(e,t){return new jc({check:"string_format",format:"starts_with",...k(t),prefix:e})}function An(e,t){return new Ac({check:"string_format",format:"ends_with",...k(t),suffix:e})}function Wo(e,t,r){return new Oc({check:"property",property:e,schema:t,...k(r)})}function On(e,t){return new Tc({check:"properties",shape:e,...k(t)})}function Tn(e,t){return new Nc({check:"mime_type",mime:e,...k(t)})}function Ze(e){return new Dc({check:"overwrite",tx:e})}function Nn(e){return Ze(t=>t.normalize(e))}function Dn(){return Ze(e=>e.trim())}function Un(){return Ze(e=>e.toLowerCase())}function Cn(){return Ze(e=>e.toUpperCase())}function En(){return Ze(e=>ys(e))}function Ul(e,t,r){return new e({type:"array",element:t,...k(r)})}function $w(e,t,r){return new e({type:"union",options:t,...k(r)})}function bw(e,t,r){return new e({type:"union",options:t,inclusive:!1,...k(r)})}function _w(e,t,r,o){return new e({type:"union",options:r,discriminator:t,...k(o)})}function xw(e,t,r){return new e({type:"intersection",left:t,right:r})}function kw(e,t,r,o){let n=r instanceof D,i=n?o:r,a=n?r:null;return new e({type:"tuple",items:t,rest:a,...k(i)})}function ww(e,t,r,o){return new e({type:"record",keyType:t,valueType:r,...k(o)})}function Sw(e,t,r,o){return new e({type:"map",keyType:t,valueType:r,...k(o)})}function Iw(e,t,r){return new e({type:"set",valueType:t,...k(r)})}function zw(e,t,r){let o=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new e({type:"enum",entries:o,...k(r)})}function Pw(e,t,r){return new e({type:"enum",entries:t,...k(r)})}function jw(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...k(r)})}function Cl(e,t){return new e({type:"file",...k(t)})}function Aw(e,t){return new e({type:"transform",transform:t})}function Ow(e,t){return new e({type:"optional",innerType:t})}function Tw(e,t){return new e({type:"nullable",innerType:t})}function Nw(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():ar(r)}})}function Dw(e,t,r){return new e({type:"nonoptional",innerType:t,...k(r)})}function Uw(e,t){return new e({type:"success",innerType:t})}function Cw(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:ws(r)})}function Ew(e,t,r){return new e({type:"pipe",in:t,out:r})}function Rw(e,t){return new e({type:"readonly",innerType:t})}function Mw(e,t,r){return new e({type:"template_literal",parts:t,...k(r)})}function Lw(e,t){return new e({type:"lazy",getter:t})}function Zw(e,t){return new e({type:"promise",innerType:t})}function El(e,t,r){let o=k(r);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function Rl(e,t,r){return new e({type:"custom",check:"custom",fn:t,...k(r)})}function Ml(e,t){let r=eh(o=>(o.addIssue=n=>{if(typeof n=="string")o.issues.push(gn(n,o.value,r._zod.def));else{let i=n;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=o.value),i.inst??(i.inst=r),i.continue??(i.continue=!r._zod.def.abort),o.issues.push(gn(i))}},e(o.value,o)),t);return r}function eh(e,t){let r=new G({check:"custom",...k(t)});return r._zod.check=e,r}function Ll(e){let t=new G({check:"describe"});return t._zod.onattach=[r=>{let o=le.get(r)??{};le.add(r,{...o,description:e})}],t._zod.check=()=>{},t}function Zl(e){let t=new G({check:"meta"});return t._zod.onattach=[r=>{let o=le.get(r)??{};le.add(r,{...o,...e})}],t._zod.check=()=>{},t}function Fl(e,t){let r=k(t),o=r.truthy??["true","1","yes","on","y","enabled"],n=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(o=o.map(f=>typeof f=="string"?f.toLowerCase():f),n=n.map(f=>typeof f=="string"?f.toLowerCase():f));let i=new Set(o),a=new Set(n),s=e.Codec??jr,u=e.Boolean??zr,l=e.String??Et,d=new l({type:"string",error:r.error}),p=new u({type:"boolean",error:r.error}),m=new s({type:"pipe",in:d,out:p,transform:((f,g)=>{let y=f;return r.case!=="sensitive"&&(y=y.toLowerCase()),i.has(y)?!0:a.has(y)?!1:(g.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...a],input:g.value,inst:m,continue:!1}),{})}),reverseTransform:((f,g)=>f===!0?o[0]||"true":n[0]||"false"),error:r.error});return m._zod.bag.truthy=o,m._zod.bag.falsy=n,m._zod.bag.case=r.case??"insensitive",m}function Kt(e,t,r,o={}){let n=k(o),i={check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:s=>r.test(s),...n};return r instanceof RegExp&&(i.pattern=r),new e(i)}function Zr(e,...t){for(let r of t)for(let o of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,o)&&ue(e,o,r[o]);return e}function $t(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??le,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 oe(e,t,r,o,n){let i=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:o.path,message:n}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw new Error(n);return Object.assign(r,i),!0}function K(e,t,r={path:[],schemaPath:[]}){var o;let n=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{let d={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,d);else{let m=a.schema,f=t.processors[n.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);f(e,t,m,d)}let p=e._zod.parent;p&&(a.ref||(a.ref=p),K(p,t,d),t.seen.get(p).isParent=!0)}let u=t.metadataRegistry.get(e);return u&&Zr(a.schema,u),t.io==="input"&&$e(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&"_prefault"in a.schema&&((o=a.schema).default??(o.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function th(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function bt(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let o=new Map;for(let a of e.seen.entries()){let s=e.metadataRegistry.get(a[0])?.id;if(s){let u=o.get(s);if(u&&u!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(s,a[0])}}let n=a=>{let s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let p=e.external.registry.get(a[0])?.id,m=e.external.uri??(g=>g);if(p)return{ref:m(p)};let f=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=f,{defId:f,ref:`${m("__shared")}#/${s}/${th(f)}`}}let u="#",l=`${u}/${s}/`;if(a[1]===r&&!a[1].schema.id)return{ref:u};let d=a[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:l+th(d)}},i=a=>{if(a[1].schema.$ref)return;let s=a[1],{ref:u,defId:l}=n(a);s.def={...s.schema},l&&(s.defId=l);let d=s.schema;for(let p in d)delete d[p];d.$ref=u};if(e.cycles==="throw")for(let a of e.seen.entries()){let s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
|
|
62
62
|
|
|
63
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let s=a[1];if(t===a[0]){i(a);continue}if(e.external){let l=e.external.registry.get(a[0])?.id;if(t!==a[0]&&l){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(s.cycle){i(a);continue}s.count>1&&e.reused==="ref"&&i(a)}e.external&&(e.sharedDefsExtractedFor=e.external)}function ih(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let o of t){if(!o||typeof o!="object")return;ih(o);let n=Object.keys(o);if(n.length!==1||n[0]!=="type")return;let i=o.type;for(let a of Array.isArray(i)?i:[i]){if(typeof a!="string")return;r.includes(a)||r.push(a)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var oh=new Set(["type","properties","required","additionalProperties"]),nh=["oneOf","anyOf"];function rh(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Vl(e){let t=[];for(let i of e){if(typeof i!="object"||i.type!=="object")return null;for(let a in i)if(!oh.has(a))return null;t.push(i)}let r={},o=new Set;for(let i of t){for(let a in i.properties){if(Object.prototype.hasOwnProperty.call(r,a))continue;let s=[];for(let l of t){let d=l.properties?.[a]??rh(l);d!=null&&(s.some(p=>JSON.stringify(p)===JSON.stringify(d))||s.push(d))}let u=s.length===1?s[0]:Vl(s)??{allOf:s};ue(r,a,u)}for(let a of i.required??[])o.add(a)}let n={type:"object",properties:r};if(o.size&&(n.required=[...o]),t.every(i=>i.additionalProperties===!1))n.additionalProperties=!1;else{let i=[];for(let a of t){let s=rh(a);s&&!i.some(u=>JSON.stringify(u)===JSON.stringify(s))&&i.push(s)}i.length===1?n.additionalProperties=i[0]:i.length>1&&(n.additionalProperties={allOf:i})}return n}function Fw(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let n of oh)if(n in e)return;let r=t.filter(n=>nh.some(i=>Array.isArray(n[i]))),o=null;if(!r.length)o=Vl(t);else{let n=r[0],i=nh.find(u=>Array.isArray(n[u]));if(Object.keys(n).length!==1)return;let a=t.filter(u=>u!==n),s=n[i].map(u=>Vl([...a,u]));if(s.some(u=>!u))return;o={[i]:s}}o&&(delete e.allOf,Zr(e,o))}function _t(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=s=>{let u=e.seen.get(s);if(u.ref===null)return;let l=u.def??u.schema,d={...l},p=u.ref;if(u.ref=null,p){o(p);let f=e.seen.get(p),g=f.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(g)):Zr(l,g),Zr(l,d),s._zod.parent===p)for(let x in l)x==="$ref"||x==="allOf"||x in d||delete l[x];if(g.$ref&&f.def)for(let x in l)x==="$ref"||x==="allOf"||x in f.def&&JSON.stringify(l[x])===JSON.stringify(f.def[x])&&delete l[x]}let m=s._zod.parent;if(m&&m!==p){o(m);let f=e.seen.get(m);if(f?.schema.$ref&&(l.$ref=f.schema.$ref,f.def))for(let g in l)g==="$ref"||g==="allOf"||g in f.def&&JSON.stringify(l[g])===JSON.stringify(f.def[g])&&delete l[g]}e.override({zodSchema:s,jsonSchema:l,path:u.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let s of[...e.seen.entries()].reverse())o(s[0]);if(e.target!=="openapi-3.0")for(let s of e.seen.entries())ih(s[1].def??s[1].schema);for(let s of e.deferred)s();if(e.intersections.length){let s=new Map;for(let u of e.seen.values())for(let l of[u.schema,u.def]){let d=l?.allOf;if(!Array.isArray(d))continue;let p=s.get(d);p?p.push(l):s.set(d,[l])}for(let u of e.intersections)for(let l of s.get(u)??[])Fw(l)}}let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(s)}Zr(n,r.defId?r.schema:r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;i!==void 0&&n.id===i&&delete n.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let s of e.seen.entries()){let u=s[1];u.def&&u.defId&&(u.def.id===u.defId&&delete u.def.id,ue(a,u.defId,u.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?n.$defs=a:n.definitions=a);try{let s=JSON.parse(JSON.stringify(n));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:Rn(t,"input",e.processors),output:Rn(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function $e(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return $e(o.element,r);if(o.type==="set")return $e(o.valueType,r);if(o.type==="lazy")return $e(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault"||o.type==="catch")return $e(o.innerType,r);if(o.type==="intersection")return $e(o.left,r)||$e(o.right,r);if(o.type==="record"||o.type==="map")return $e(o.keyType,r)||$e(o.valueType,r);if(o.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:$e(o.in,r)||$e(o.out,r);if(o.type==="object"){for(let n in o.shape)if($e(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if($e(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if($e(n,r))return!0;return!!(o.rest&&$e(o.rest,r))}return!1}var Kl=(e,t={})=>r=>{let o=$t({...r,processors:t});return K(e,o),bt(o,e),_t(o,e)},Rn=(e,t,r={})=>o=>{let{libraryOptions:n,target:i}=o??{},a=$t({...n??{},target:i,io:t,processors:r});return K(e,a),bt(a,e),_t(a,e)};var Mn=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},Ln=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},ah=(e,t)=>{Mn(e,"minimum",t),Ln(e,"maximum",t)},lh=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},dh=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},ph=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},fh=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},sh=(e,t)=>Mn(e,"minimum",t.minimum),ch=(e,t)=>Ln(e,"maximum",t.maximum),uh=e=>(t,r)=>{fh(t,r.format);let[o,n]=e[r.format];Mn(t,"minimum",o),Ln(t,"maximum",n)},Vw={greater_than:(e,t)=>Mn(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Ln(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>lh(e,t.value),number_format:uh(cr),bigint_format:uh(ur),min_length:sh,max_length:ch,length_equals:(e,t)=>ah(e,t.length),min_size:sh,max_size:ch,size_equals:(e,t)=>ah(e,t.size),string_format:(e,t)=>{fh(e,t.format),t.pattern&&dh(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>ph(e,t.mime)};function ae(e){let t={},r=e._zod.def,o=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let i of o)Vw[i._zod.def.check]?.(t,i._zod.def);let n=e._zod.bag;n.minimum!==void 0&&Mn(t,"minimum",n.minimum),n.exclusiveMinimum!==void 0&&Mn(t,"exclusiveMinimum",n.exclusiveMinimum),n.maximum!==void 0&&Ln(t,"maximum",n.maximum),n.exclusiveMaximum!==void 0&&Ln(t,"exclusiveMaximum",n.exclusiveMaximum),n.multipleOf!==void 0&&lh(t,n.multipleOf),n.format!==void 0&&(t.format??(t.format=n.format),n.format.includes("int")&&(t.isInt=!0)),n.mime&&ph(t,n.mime);for(let i of n.patterns??[])dh(t,i);return t}var Kw={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Jw=new Map([[Xi,Hs],[Ir,Xs]]),mh=e=>Jw.get(e)??e,Wl=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:i,maximum:a,format:s,patterns:u,contentEncoding:l,laxFormat:d}=ae(e);if(typeof i=="number"&&(n.minLength=i),typeof a=="number"&&(n.maxLength=a),s&&(n.format=Kw[s]??s,n.format===""&&delete n.format,(s==="time"||d)&&delete n.format),l&&(n.contentEncoding=l),u&&u.size>0){let p=[...u].map(mh);p.length===1?n.pattern=p[0].source:p.length>1&&(n.allOf=[...p.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},Gl=(e,t,r,o)=>{let n=r,{minimum:i,maximum:a,multipleOf:s,exclusiveMaximum:u,exclusiveMinimum:l,isInt:d}=ae(e);n.type=d?"integer":"number";let p=typeof l=="number"&&l>=(i??Number.NEGATIVE_INFINITY),m=typeof u=="number"&&u<=(a??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(p?f?(n.minimum=l,n.exclusiveMinimum=!0):n.exclusiveMinimum=l:typeof i=="number"&&(n.minimum=i),m?f?(n.maximum=u,n.exclusiveMaximum=!0):n.exclusiveMaximum=u:typeof a=="number"&&(n.maximum=a),s){let g=new Set;for(let P of s)Number.isFinite(P)&&P!==0?g.add(Math.abs(P)):oe(e,t,n,o,`A multipleOf divisor of ${P} cannot be represented in JSON Schema`);let[y,...x]=g;y!==void 0&&(n.multipleOf=y),x.length&&(n.allOf=[...n.allOf??[],...x.map(P=>({multipleOf:P}))])}},ql=(e,t,r,o)=>{r.type="boolean"},Hl=(e,t,r,o)=>{oe(e,t,r,o,"BigInt cannot be represented in JSON Schema")},Xl=(e,t,r,o)=>{oe(e,t,r,o,"Symbols cannot be represented in JSON Schema")},Yl=(e,t,r,o)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},Ql=(e,t,r,o)=>{oe(e,t,r,o,"Undefined cannot be represented in JSON Schema")},ed=(e,t,r,o)=>{oe(e,t,r,o,"Void cannot be represented in JSON Schema")},td=(e,t,r,o)=>{r.not={}},nd=(e,t,r,o)=>{},rd=(e,t,r,o)=>{},id=(e,t,r,o)=>{oe(e,t,r,o,"Date cannot be represented in JSON Schema")},od=(e,t,r,o)=>{let n=e._zod.def,i=ln(n.entries);if(i.length===0){r.not={};return}i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),r.enum=i},ad=(e,t,r,o)=>{let n=e._zod.def;if(n.values.length===0){r.not={};return}let i=[];for(let a of n.values)if(a===void 0){if(oe(e,t,r,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(oe(e,t,r,o,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){let a=i[0];r.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[a]:r.const=a}else i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),i.every(a=>typeof a=="boolean")&&(r.type="boolean"),i.every(a=>a===null)&&(r.type="null"),r.enum=i},sd=(e,t,r,o)=>{oe(e,t,r,o,"NaN cannot be represented in JSON Schema")},cd=(e,t,r,o)=>{let n=r,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},ud=(e,t,r,o)=>{let n=r;n.type="string",n.format="binary",n.contentEncoding="binary";let{minimum:i,maximum:a,mime:s}=ae(e);i!==void 0&&(n.minLength=i),a!==void 0&&(n.maxLength=a),s&&(s.length===0?n.not={}:s.length===1?n.contentMediaType=s[0]:n.anyOf=s.map(u=>({contentMediaType:u})))},ld=(e,t,r,o)=>{r.type="boolean"},dd=(e,t,r,o)=>{oe(e,t,r,o,"Custom types cannot be represented in JSON Schema")},pd=(e,t,r,o)=>{oe(e,t,r,o,"Function types cannot be represented in JSON Schema")},fd=(e,t,r,o)=>{oe(e,t,r,o,"Transforms cannot be represented in JSON Schema")},md=(e,t,r,o)=>{oe(e,t,r,o,"Map cannot be represented in JSON Schema")},gd=(e,t,r,o)=>{oe(e,t,r,o,"Set cannot be represented in JSON Schema")},hd=(e,t,r,o)=>{let n=r,i=e._zod.def,{minimum:a,maximum:s}=ae(e);typeof a=="number"&&(n.minItems=a),typeof s=="number"&&(n.maxItems=s),n.type="array",n.items=K(i.element,t,{...o,path:[...o.path,"items"]})};function Fr(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Fr(t.out):t.type==="catch"?Fr(t.innerType):e._zod.optin}var vd=(e,t,r,o)=>{let n=r,i=e._zod.def,a=i.shape;if(Object.getOwnPropertySymbols(a).length&&oe(e,t,n,o,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(let l in a)ue(n.properties,l,K(a[l],t,{...o,path:[...o.path,"properties",l]}));let u=[];for(let l of Object.keys(a)){let d=i.shape[l];(t.io==="input"?Fr(d)===void 0:d._zod.optout===void 0)&&u.push(l)}u.length>0&&(n.required=u),i.catchall?._zod.def.type==="never"?n.additionalProperties=!1:i.catchall?i.catchall&&(n.additionalProperties=K(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},qo=(e,t,r,o)=>{let n=e._zod.def,i=n.inclusive===!1,a=n.options.map((s,u)=>K(s,t,{...o,path:[...o.path,i?"oneOf":"anyOf",u]}));i?r.oneOf=a:r.anyOf=a},yd=(e,t,r,o)=>{let n=e._zod.def,i=K(n.left,t,{...o,path:[...o.path,"allOf",0]}),a=K(n.right,t,{...o,path:[...o.path,"allOf",1]}),s=l=>"allOf"in l&&Object.keys(l).length===1,u=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]];r.allOf=u,t.intersections.push(u)},$d=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",u=i.items.map((y,x)=>K(y,t,{...o,path:[...o.path,a,x]})),l=i.rest?K(i.rest,t,{...o,path:[...o.path,s,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null,d=i.items.length;for(;d>0;){let y=i.items[d-1];if(!(t.io==="input"?Fr(y)!==void 0:y._zod.optout==="optional"))break;d--}let p=i.items.length,m=!i.rest;t.target==="draft-2020-12"?(n.prefixItems=u,m?n.items=!1:l&&(n.items=l),d>0&&(n.minItems=d),m&&(n.maxItems=p)):t.target==="openapi-3.0"?(n.items={anyOf:u},l&&n.items.anyOf.push(l),d>0&&(n.minItems=d),m&&(n.maxItems=p)):(n.items=u,m?n.additionalItems=!1:l&&(n.additionalItems=l),d>0&&(n.minItems=d),m&&(n.maxItems=p));let{minimum:f,maximum:g}=ae(e);typeof f=="number"&&(n.minItems=f),typeof g=="number"&&(n.maxItems=g)};function Jl(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let g=e.get(t)?.def;if(!g)return t;let y=Jl(e,g,r);return y===g?t:y}for(let g of["anyOf","oneOf"]){let y=t[g];if(!Array.isArray(y))continue;let x=y.map(P=>Jl(e,P,r));x.some((P,I)=>P!==y[I])&&(t={...t,[g]:x})}let o=Array.isArray(t.type)?t.type:[t.type],n=!o.includes("string")&&o.some(g=>g==="number"||g==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!n&&!i?.some(g=>typeof g=="number"))return t;let{minimum:a,maximum:s,exclusiveMinimum:u,exclusiveMaximum:l,multipleOf:d,format:p,id:m,...f}=t;return f.enum?f.enum=f.enum.map(g=>typeof g=="number"?String(g):g):typeof f.const=="number"&&(f.const=String(f.const)),n&&(f.type="string",i||(f.pattern=(o.includes("number")?it:$r).source)),f}var Bl=new WeakMap;function Bw(e){let t=new Map;for(let o of e.seen.values())o.def&&!t.has(o.schema)&&t.set(o.schema,o);let r=new Map;for(let o of Bl.get(e)??[]){let n=e.seen.get(o),i=(n?.def??n?.schema)?.propertyNames;if(!i||i===!0||r.has(i))continue;let a=Jl(t,i,new Set);a!==i&&r.set(i,a)}if(r.size)for(let o of e.seen.values())for(let n of[o.schema,o.def]){let i=n&&r.get(n.propertyNames);i&&(n.propertyNames=i)}}var bd=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object";let a=i.keyType,s=ae(a).patterns;if(i.mode==="loose"&&s&&s.size>0){let d=K(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});n.patternProperties={};for(let p of s)ue(n.patternProperties,mh(p).source,d)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){n.propertyNames=K(i.keyType,t,{...o,path:[...o.path,"propertyNames"]});let d=Bl.get(t);d||(d=[],Bl.set(t,d),t.deferred.push(()=>Bw(t))),d.push(e)}n.additionalProperties=K(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let u=a._zod.values,l=t.io==="input"&&Fr(i.valueType)!==void 0;if(u&&!i.partial&&!l){let d=[...u].filter(p=>typeof p=="string"||typeof p=="number");d.length>0&&(n.required=d.map(String))}},_d=(e,t,r,o)=>{let n=e._zod.def,i=K(n.innerType,t,o),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=n.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},xd=(e,t,r,o)=>{let n=e._zod.def;K(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},kd=Symbol();function gh(e,t,r,o,n){let i=!1,a=JSON.stringify(e,(s,u)=>typeof u!="bigint"?u:(i=!0,null));return i?(oe(t,r,o,n,"BigInt defaults cannot be represented in JSON Schema"),kd):JSON.parse(a)}var wd=(e,t,r,o)=>{let n=e._zod.def;K(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let a=gh(n.defaultValue,e,t,r,o);a!==kd&&(r.default=a)},Sd=(e,t,r,o)=>{let n=e._zod.def;K(n.innerType,t,o);let i=t.seen.get(e);if(i.ref=n.innerType,t.io!=="input")return;let a=gh(n.defaultValue,e,t,r,o);a!==kd&&(r._prefault=a)},Id=(e,t,r,o)=>{let n=e._zod.def;K(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let a;try{a=n.catchValue(void 0)}catch{oe(e,t,r,o,"Dynamic catch values are not supported in JSON Schema");return}r.default=a},zd=(e,t,r,o)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?i?n.out:n.in:n.out;K(a,t,o);let s=t.seen.get(e);s.ref=a},Pd=(e,t,r,o)=>{let n=e._zod.def;K(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0},jd=(e,t,r,o)=>{let n=e._zod.def;K(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},Ho=(e,t,r,o)=>{let n=e._zod.def;K(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},Ad=(e,t,r,o)=>{let n=e._zod.innerType;K(n,t,o);let i=t.seen.get(e);i.ref=n},Go={string:Wl,number:Gl,boolean:ql,bigint:Hl,symbol:Xl,null:Yl,undefined:Ql,void:ed,never:td,any:nd,unknown:rd,date:id,enum:od,literal:ad,nan:sd,template_literal:cd,file:ud,success:ld,custom:dd,function:pd,transform:fd,map:md,set:gd,array:hd,object:vd,union:qo,intersection:yd,tuple:$d,record:bd,nullable:_d,nonoptional:xd,default:wd,prefault:Sd,catch:Id,pipe:zd,readonly:Pd,promise:jd,optional:Ho,lazy:Ad};function Xo(e,t){if("_idmap"in e){let o=e,n=$t({...t,processors:Go}),i={};for(let u of o._idmap.entries()){let[l,d]=u;K(d,n)}let a={},s={registry:o,uri:t?.uri,defs:i};n.external=s;for(let u of o._idmap.entries()){let[l,d]=u;bt(n,d),ue(a,l,_t(n,d))}if(Object.keys(i).length>0){let u=n.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[u]:i}}return{schemas:a}}let r=$t({...t,processors:Go});return K(e,r),bt(r,e),_t(r,e)}var Yo=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=$t({processors:Go,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return K(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,bt(this.ctx,t);let o=_t(this.ctx,t),{"~standard":n,...i}=o;return i}};var hh={};var Gn={};tt(Gn,{ZodAny:()=>Yd,ZodArray:()=>np,ZodBase64:()=>va,ZodBase64URL:()=>ya,ZodBigInt:()=>Bn,ZodBigIntFormat:()=>_a,ZodBoolean:()=>Jn,ZodCIDRv4:()=>ga,ZodCIDRv6:()=>ha,ZodCUID:()=>ca,ZodCUID2:()=>ua,ZodCatch:()=>kp,ZodCodec:()=>Yr,ZodCreditCard:()=>Kd,ZodCustom:()=>Qr,ZodCustomStringFormat:()=>Gt,ZodDate:()=>Br,ZodDefault:()=>vp,ZodDiscriminatedUnion:()=>ip,ZodE164:()=>$a,ZodEmail:()=>ia,ZodEmoji:()=>aa,ZodEnum:()=>Fn,ZodExactOptional:()=>Sa,ZodFile:()=>fp,ZodFunction:()=>Np,ZodGUID:()=>oa,ZodIBAN:()=>Jd,ZodIPv4:()=>fa,ZodIPv6:()=>ma,ZodISODate:()=>kt,ZodISODateTime:()=>xt,ZodISODuration:()=>St,ZodISOTime:()=>wt,ZodInstanceOf:()=>Cp,ZodIntersection:()=>op,ZodJWT:()=>ba,ZodKSUID:()=>pa,ZodLazy:()=>Ap,ZodLiteral:()=>pp,ZodMAC:()=>Vd,ZodMap:()=>lp,ZodNaN:()=>Sp,ZodNanoID:()=>sa,ZodNever:()=>ep,ZodNonOptional:()=>Ia,ZodNull:()=>Hd,ZodNullable:()=>hp,ZodNumber:()=>Kn,ZodNumberFormat:()=>qt,ZodObject:()=>Gr,ZodOptional:()=>Hr,ZodPipe:()=>Xr,ZodPrefault:()=>$p,ZodPreprocess:()=>Ip,ZodPromise:()=>Tp,ZodReadonly:()=>zp,ZodRecord:()=>Zn,ZodSet:()=>dp,ZodString:()=>Vn,ZodStringFormat:()=>W,ZodSuccess:()=>xp,ZodSymbol:()=>Gd,ZodTemplateLiteral:()=>jp,ZodTransform:()=>mp,ZodTuple:()=>sp,ZodType:()=>C,ZodULID:()=>la,ZodURL:()=>Jr,ZodUUID:()=>We,ZodUndefined:()=>qd,ZodUnion:()=>qr,ZodUnknown:()=>Qd,ZodVoid:()=>tp,ZodXID:()=>da,ZodXor:()=>rp,_ZodString:()=>ra,_default:()=>yp,_function:()=>Pv,any:()=>ov,array:()=>Wr,base64:()=>Mh,base64url:()=>Lh,bigint:()=>ev,boolean:()=>Wd,catch:()=>wp,check:()=>jv,cidrv4:()=>Eh,cidrv6:()=>Rh,codec:()=>wv,creditCard:()=>Fh,cuid:()=>jh,cuid2:()=>Ah,currencyCode:()=>Gh,custom:()=>Av,date:()=>sv,describe:()=>Ov,discriminatedUnion:()=>fv,e164:()=>Zh,email:()=>$h,emoji:()=>zh,enum:()=>ka,exactOptional:()=>gp,file:()=>bv,float32:()=>Hh,float64:()=>Xh,function:()=>Pv,guid:()=>bh,hash:()=>qh,hex:()=>Wh,hostname:()=>Bh,httpUrl:()=>Ih,iban:()=>Vh,instanceof:()=>Nv,int:()=>ta,int32:()=>Yh,int64:()=>tv,intersection:()=>ap,invertCodec:()=>Sv,ipv4:()=>Dh,ipv6:()=>Ch,json:()=>Uv,jwt:()=>Kh,keyof:()=>cv,ksuid:()=>Nh,lazy:()=>Op,literal:()=>$v,looseObject:()=>dv,looseRecord:()=>gv,mac:()=>Uh,map:()=>hv,meta:()=>Tv,nan:()=>kv,nanoid:()=>Ph,nativeEnum:()=>yv,never:()=>xa,nonoptional:()=>_p,null:()=>Xd,nullable:()=>Kr,nullish:()=>_v,number:()=>Bd,object:()=>uv,optional:()=>Bt,partialRecord:()=>mv,pipe:()=>na,prefault:()=>bp,preprocess:()=>Cv,promise:()=>zv,readonly:()=>Pp,record:()=>up,refine:()=>Dp,set:()=>vv,strictObject:()=>lv,string:()=>Vr,stringFormat:()=>Jh,stringbool:()=>Dv,success:()=>xv,superRefine:()=>Up,symbol:()=>rv,templateLiteral:()=>Iv,transform:()=>wa,tuple:()=>cp,uint32:()=>Qh,uint64:()=>nv,ulid:()=>Oh,undefined:()=>iv,union:()=>Wn,unknown:()=>Jt,url:()=>Sh,uuid:()=>_h,uuidv4:()=>xh,uuidv6:()=>kh,uuidv7:()=>wh,void:()=>av,xid:()=>Th,xor:()=>pv});var Qo={};tt(Qo,{endsWith:()=>An,gt:()=>Je,gte:()=>Te,includes:()=>Pn,length:()=>Vt,lowercase:()=>In,lt:()=>Ke,lte:()=>Oe,maxLength:()=>Ft,maxSize:()=>yt,mime:()=>Tn,minLength:()=>ot,minSize:()=>Be,multipleOf:()=>vt,negative:()=>Ko,nonnegative:()=>Bo,nonpositive:()=>Jo,normalize:()=>Nn,overwrite:()=>Ze,positive:()=>Vo,properties:()=>On,property:()=>Wo,regex:()=>Sn,size:()=>Zt,slugify:()=>En,startsWith:()=>jn,toLowerCase:()=>Un,toUpperCase:()=>Cn,trim:()=>Dn,uppercase:()=>zn});var vh=new WeakSet([Object.prototype,Error.prototype]);function ea(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let o=r(this);return Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0})}})}var yh=(e,t)=>{As.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);vh.has(r)||(vh.add(r),ea(r,"format",o=>n=>gr(o,n)),ea(r,"flatten",o=>n=>mr(o,n)),ea(r,"addIssue",o=>n=>{o.issues.push(n),o.message=JSON.stringify(o.issues,dn,2)}),ea(r,"addIssues",o=>n=>{o.issues.push(...n),o.message=JSON.stringify(o.issues,dn,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Gw=h("ZodError",yh),Ie=h("ZodError",yh,void 0,{Parent:Error});var Od=hn(Ie),Td=vn(Ie),Nd=yn(Ie),Dd=$n(Ie),Ud=Pi(Ie),Cd=ji(Ie),Ed=Ai(Ie),Rd=Oi(Ie),Md=Ti(Ie),Ld=Ni(Ie),Zd=Di(Ie),Fd=Ui(Ie);function Hw(){se.localeError||te(mo())}function Wt(){se.memoizer||te({memoizer:Nr()})}var C=h("ZodType",(e,t)=>(Hw(),D.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone($.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return F(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Dp(e,t))},superRefine(e,t){return this.check(Up(e,t))},overwrite(e){return this.check(Ze(e))},optional(){return Bt(this)},exactOptional(){return gp(this)},nullable(){return Kr(this)},nullish(){return Bt(Kr(this))},nonoptional(e){return _p(this,e)},array(){return Wr(this)},or(e){return Wn([this,e])},and(e){return ap(this,e)},transform(e){return na(this,wa(e))},default(e){return yp(this,e)},prefault(e){return bp(this,e)},catch(e){return wp(this,e)},pipe(e){return na(this,e)},readonly(){return Pp(this)},describe(e){let t=this.clone();return le.add(t,{description:e}),t},meta(...e){if(e.length===0)return le.get(this);let t=this.clone();return le.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return $.hide(this,"~standard",{...Bi(this),jsonSchema:{input:Rn(this,"input"),output:Rn(this,"output")}})},set"~standard"(e){$.own(this,"~standard",e)},parse:function e(t,r){return Od(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Td(this,t,r,{callee:e})},safeParse(e,t){return Nd(this,e,t)},async safeParseAsync(e,t){return Dd(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){$.own(this,"spa",e)},validate(e,t){return hr(this,e,t)},validateAsync(e,t){return vr(this,e,t)},encode:function e(t,r){return Ud(this,t,r,{callee:e})},decode:function e(t,r){return Cd(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Ed(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Rd(this,t,r,{callee:e})},safeEncode(e,t){return Md(this,e,t)},safeDecode(e,t){return Ld(this,e,t)},async safeEncodeAsync(e,t){return Zd(this,e,t)},async safeDecodeAsync(e,t){return Fd(this,e,t)},toJSONSchema(e){return Kl(this,{})(e)},get description(){return le.get(this)?.description},get _def(){return this._zod.def}}),ra=h("_ZodString",(e,t)=>{Et.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Wl(e,r,o,n)},$.derived({format:e=>ae(e).format??null,minLength:e=>ae(e).minimum??null,maxLength:e=>ae(e).maximum??null},{regex(...e){return this.check(Sn(...e))},includes(...e){return this.check(Pn(...e))},startsWith(...e){return this.check(jn(...e))},endsWith(...e){return this.check(An(...e))},min(...e){return this.check(ot(...e))},max(...e){return this.check(Ft(...e))},length(...e){return this.check(Vt(...e))},nonempty(...e){return this.check(ot(1,...e))},lowercase(e){return this.check(In(e))},uppercase(e){return this.check(zn(e))},trim(){return this.check(Dn())},normalize(...e){return this.check(Nn(...e))},toLowerCase(){return this.check(Un())},toUpperCase(){return this.check(Cn())},slugify(){return this.check(En())}})),Vn=h("ZodString",(e,t)=>{Et.init(e,t),ra.init(e,t)},{email(e){return this.check(xo(ia,e))},url(e){return this.check(Cr(Jr,e))},jwt(e){return this.check(Fo(ba,e))},emoji(e){return this.check(Po(aa,e))},guid(e){return this.check(ko(oa,e))},uuid(e){return this.check(wo(We,e))},uuidv4(e){return this.check(So(We,e))},uuidv6(e){return this.check(Io(We,e))},uuidv7(e){return this.check(zo(We,e))},nanoid(e){return this.check(jo(sa,e))},cuid(e){return this.check(Ao(ca,e))},cuid2(e){return this.check(Oo(ua,e))},ulid(e){return this.check(To(la,e))},base64(e){return this.check(Mo(va,e))},base64url(e){return this.check(Lo(ya,e))},xid(e){return this.check(No(da,e))},ksuid(e){return this.check(Do(pa,e))},ipv4(e){return this.check(Uo(fa,e))},ipv6(e){return this.check(Co(ma,e))},cidrv4(e){return this.check(Eo(ga,e))},cidrv6(e){return this.check(Ro(ha,e))},e164(e){return this.check(Zo($a,e))},datetime(e){return this.check(Er(xt,e))},date(e){return this.check(Rr(kt,e))},time(e){return this.check(Mr(wt,e))},duration(e){return this.check(Lr(St,e))}});function Vr(e){return al(Vn,e)}var W=h("ZodStringFormat",(e,t)=>{V.init(e,t),ra.init(e,t)}),xt=h("ZodISODateTime",(e,t)=>{Hc.init(e,t),W.init(e,t)}),kt=h("ZodISODate",(e,t)=>{Xc.init(e,t),W.init(e,t)}),wt=h("ZodISOTime",(e,t)=>{Yc.init(e,t),W.init(e,t)}),St=h("ZodISODuration",(e,t)=>{Qc.init(e,t),W.init(e,t)}),ia=h("ZodEmail",(e,t)=>{Mc.init(e,t),W.init(e,t)});function $h(e){return xo(ia,e)}var oa=h("ZodGUID",(e,t)=>{Ec.init(e,t),W.init(e,t)});function bh(e){return ko(oa,e)}var We=h("ZodUUID",(e,t)=>{Rc.init(e,t),W.init(e,t)});function _h(e){return wo(We,e)}function xh(e){return So(We,e)}function kh(e){return Io(We,e)}function wh(e){return zo(We,e)}var Jr=h("ZodURL",(e,t)=>{Fc.init(e,t),W.init(e,t)});function Sh(e){return Cr(Jr,e)}function Ih(e){return Cr(Jr,{protocol:yr,hostname:Qs,...$.normalizeParams(e)})}var aa=h("ZodEmoji",(e,t)=>{Vc.init(e,t),W.init(e,t)});function zh(e){return Po(aa,e)}var sa=h("ZodNanoID",(e,t)=>{Kc.init(e,t),W.init(e,t)});function Ph(e){return jo(sa,e)}var ca=h("ZodCUID",(e,t)=>{Jc.init(e,t),W.init(e,t)});function jh(e){return Ao(ca,e)}var ua=h("ZodCUID2",(e,t)=>{Bc.init(e,t),W.init(e,t)});function Ah(e){return Oo(ua,e)}var la=h("ZodULID",(e,t)=>{Wc.init(e,t),W.init(e,t)});function Oh(e){return To(la,e)}var da=h("ZodXID",(e,t)=>{Gc.init(e,t),W.init(e,t)});function Th(e){return No(da,e)}var pa=h("ZodKSUID",(e,t)=>{qc.init(e,t),W.init(e,t)});function Nh(e){return Do(pa,e)}var fa=h("ZodIPv4",(e,t)=>{eu.init(e,t),W.init(e,t)});function Dh(e){return Uo(fa,e)}var Vd=h("ZodMAC",(e,t)=>{nu.init(e,t),W.init(e,t)});function Uh(e){return cl(Vd,e)}var ma=h("ZodIPv6",(e,t)=>{tu.init(e,t),W.init(e,t)});function Ch(e){return Co(ma,e)}var ga=h("ZodCIDRv4",(e,t)=>{ru.init(e,t),W.init(e,t)});function Eh(e){return Eo(ga,e)}var ha=h("ZodCIDRv6",(e,t)=>{iu.init(e,t),W.init(e,t)});function Rh(e){return Ro(ha,e)}var va=h("ZodBase64",(e,t)=>{ou.init(e,t),W.init(e,t)});function Mh(e){return Mo(va,e)}var ya=h("ZodBase64URL",(e,t)=>{au.init(e,t),W.init(e,t)});function Lh(e){return Lo(ya,e)}var $a=h("ZodE164",(e,t)=>{su.init(e,t),W.init(e,t)});function Zh(e){return Zo($a,e)}var Kd=h("ZodCreditCard",(e,t)=>{cu.init(e,t),W.init(e,t)});function Fh(e){return ul(Kd,e)}var Jd=h("ZodIBAN",(e,t)=>{uu.init(e,t),W.init(e,t)});function Vh(e){return ll(Jd,e)}var ba=h("ZodJWT",(e,t)=>{lu.init(e,t),W.init(e,t)});function Kh(e){return Fo(ba,e)}var Gt=h("ZodCustomStringFormat",(e,t)=>{du.init(e,t),W.init(e,t)});function Jh(e,t,r={}){return Kt(Gt,e,t,r)}function Bh(e){return Kt(Gt,"hostname",Ys,e)}function Wh(e){return Kt(Gt,"hex",fc,e)}function Gh(e){return Kt(Gt,"currency_code",tc,e)}function qh(e,t){let r=t?.enc??"hex",o=`${e}_${r}`,n=Ee[o];if(!n)throw new Error(`Unrecognized hash format: ${o}`);return Kt(Gt,o,n,t)}var Kn=h("ZodNumber",(e,t)=>{no.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Gl(e,r,o,n),e.isFinite=!0},$.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=ae(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=ae(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=ae(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>ae(e).format??null},{gt(e,t){return this.check(Je(e,t))},gte(e,t){return this.check(Te(e,t))},min(e,t){return this.check(Te(e,t))},lt(e,t){return this.check(Ke(e,t))},lte(e,t){return this.check(Oe(e,t))},max(e,t){return this.check(Oe(e,t))},int(e){return this.check(ta(e))},safe(e){return this.check(ta(e))},positive(e){return this.check(Je(0,e))},nonnegative(e){return this.check(Te(0,e))},negative(e){return this.check(Ke(0,e))},nonpositive(e){return this.check(Oe(0,e))},multipleOf(e,t){return this.check(vt(e,t))},step(e,t){return this.check(vt(e,t))},finite(){return this}}));function Bd(e){return pl(Kn,e)}var qt=h("ZodNumberFormat",(e,t)=>{pu.init(e,t),Kn.init(e,t)});function ta(e){return ml(qt,e)}function Hh(e){return gl(qt,e)}function Xh(e){return hl(qt,e)}function Yh(e){return vl(qt,e)}function Qh(e){return yl(qt,e)}var Jn=h("ZodBoolean",(e,t)=>{zr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ql(e,r,o,n)});function Wd(e){return $l(Jn,e)}var Bn=h("ZodBigInt",(e,t)=>{ro.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Hl(e,r,o,n)},$.derived({minValue:e=>ae(e).minimum??null,maxValue:e=>ae(e).maximum??null,format:e=>ae(e).format??null},{gte(e,t){return this.check(Te(e,t))},min(e,t){return this.check(Te(e,t))},gt(e,t){return this.check(Je(e,t))},lt(e,t){return this.check(Ke(e,t))},lte(e,t){return this.check(Oe(e,t))},max(e,t){return this.check(Oe(e,t))},positive(e){return this.check(Je(BigInt(0),e))},negative(e){return this.check(Ke(BigInt(0),e))},nonpositive(e){return this.check(Oe(BigInt(0),e))},nonnegative(e){return this.check(Te(BigInt(0),e))},multipleOf(e,t){return this.check(vt(e,t))}}));function ev(e){return _l(Bn,e)}var _a=h("ZodBigIntFormat",(e,t)=>{fu.init(e,t),Bn.init(e,t)});function tv(e){return kl(_a,e)}function nv(e){return wl(_a,e)}var Gd=h("ZodSymbol",(e,t)=>{mu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Xl(e,r,o,n)});function rv(e){return Sl(Gd,e)}var qd=h("ZodUndefined",(e,t)=>{gu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ql(e,r,o,n)});function iv(e){return Il(qd,e)}var Hd=h("ZodNull",(e,t)=>{hu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Yl(e,r,o,n)});function Xd(e){return zl(Hd,e)}var Yd=h("ZodAny",(e,t)=>{vu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>nd(e,r,o,n)});function ov(){return Pl(Yd)}var Qd=h("ZodUnknown",(e,t)=>{yu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>rd(e,r,o,n)});function Jt(){return jl(Qd)}var ep=h("ZodNever",(e,t)=>{$u.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>td(e,r,o,n)});function xa(e){return Al(ep,e)}var tp=h("ZodVoid",(e,t)=>{bu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ed(e,r,o,n)});function av(e){return Ol(tp,e)}var Br=h("ZodDate",(e,t)=>{_u.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>id(e,r,o,n),e.min=(r,o)=>e.check(Te(r,o)),e.max=(r,o)=>e.check(Oe(r,o))},$.derived({minDate:e=>{let{minimum:t}=ae(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=ae(e);return t?new Date(t):null}},{}));function sv(e){return Tl(Br,e)}var np=h("ZodArray",(e,t)=>{Wt(),ku.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>hd(e,r,o,n),e.element=t.element},{min(e,t){return this.check(ot(e,t))},nonempty(e){return this.check(ot(1,e))},max(e,t){return this.check(Ft(e,t))},length(e,t){return this.check(Vt(e,t))},unwrap(){return this.element}});function Wr(e,t){return Ul(np,e,t)}function cv(e){let t=e._zod.def.shape;return ka(Object.keys(t))}var Gr=h("ZodObject",(e,t)=>{Wt(),wu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>vd(e,r,o,n),$.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return ka(Object.keys(this._zod.def.shape))},catchall(e){return this.clone($.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone($.mergeDefs(this._zod.def,{catchall:Jt()}))},loose(){return this.clone($.mergeDefs(this._zod.def,{catchall:Jt()}))},strict(){return this.clone($.mergeDefs(this._zod.def,{catchall:xa()}))},strip(){return this.clone($.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return $.extend(this,e)},safeExtend(e){return $.safeExtend(this,e)},merge(e){return $.merge(this,e)},pick(e){return $.pick(this,e)},omit(e){return $.omit(this,e)},partial(...e){return $.partial(Hr,this,e[0])},exactPartial(...e){return $.partial(Sa,this,e[0],"exactPartial")},required(...e){return $.required(Ia,this,e[0])}});function uv(e,t){let r={type:"object",shape:e??{},...$.normalizeParams(t)};return new Gr(r)}function lv(e,t){return new Gr({type:"object",shape:e,catchall:xa(),...$.normalizeParams(t)})}function dv(e,t){return new Gr({type:"object",shape:e,catchall:Jt(),...$.normalizeParams(t)})}var qr=h("ZodUnion",(e,t)=>{Pr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>qo(e,r,o,n),e.options=t.options});function Wn(e,t){return new qr({type:"union",options:e,...$.normalizeParams(t)})}var rp=h("ZodXor",(e,t)=>{qr.init(e,t),Su.init(e,t),e._zod.processJSONSchema=(r,o,n)=>qo(e,r,o,n),e.options=t.options});function pv(e,t){return new rp({type:"union",options:e,inclusive:!1,...$.normalizeParams(t)})}var ip=h("ZodDiscriminatedUnion",(e,t)=>{qr.init(e,t),zu.init(e,t)});function fv(e,t,r){return new ip({type:"union",options:t,discriminator:e,...$.normalizeParams(r)})}var op=h("ZodIntersection",(e,t)=>{Pu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>yd(e,r,o,n)});function ap(e,t){return new op({type:"intersection",left:e,right:t})}var sp=h("ZodTuple",(e,t)=>{Wt(),io.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>$d(e,r,o,n)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new Hr({type:"optional",innerType:t}))})}});function cp(e,t,r){let o=t instanceof D,n=o?r:t,i=o?t:null;return new sp({type:"tuple",items:e,rest:i,...$.normalizeParams(n)})}var Zn=h("ZodRecord",(e,t)=>{Wt(),ju.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>bd(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});function up(e,t,r){return!t||!t._zod?new Zn({type:"record",keyType:Vr(),valueType:e,...$.normalizeParams(t)}):new Zn({type:"record",keyType:e,valueType:t,...$.normalizeParams(r)})}function mv(e,t,r){return new Zn({type:"record",keyType:e,valueType:t,...$.normalizeParams(r),partial:!0})}function gv(e,t,r){return new Zn({type:"record",keyType:e,valueType:t,mode:"loose",...$.normalizeParams(r)})}var lp=h("ZodMap",(e,t)=>{Wt(),Au.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>md(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Be(...r)),e.nonempty=r=>e.check(Be(1,r)),e.max=(...r)=>e.check(yt(...r)),e.size=(...r)=>e.check(Zt(...r))});function hv(e,t,r){return new lp({type:"map",keyType:e,valueType:t,...$.normalizeParams(r)})}var dp=h("ZodSet",(e,t)=>{Wt(),Ou.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>gd(e,r,o,n),e.min=(...r)=>e.check(Be(...r)),e.nonempty=r=>e.check(Be(1,r)),e.max=(...r)=>e.check(yt(...r)),e.size=(...r)=>e.check(Zt(...r))});function vv(e,t){return new dp({type:"set",valueType:e,...$.normalizeParams(t)})}var Fn=h("ZodEnum",(e,t)=>{Tu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(o,n,i)=>od(e,o,n,i),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let i={};for(let a of o)if(r.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Fn({...t,checks:[],...$.normalizeParams(n),entries:i})},e.exclude=(o,n)=>{let i={...t.entries};for(let a of o)if(r.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new Fn({...t,checks:[],...$.normalizeParams(n),entries:i})}});function ka(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new Fn({type:"enum",entries:r,...$.normalizeParams(t)})}function yv(e,t){return new Fn({type:"enum",entries:e,...$.normalizeParams(t)})}var pp=h("ZodLiteral",(e,t)=>{Nu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ad(e,r,o,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $v(e,t){return new pp({type:"literal",values:Array.isArray(e)?e:[e],...$.normalizeParams(t)})}var fp=h("ZodFile",(e,t)=>{Du.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ud(e,r,o,n),e.min=(r,o)=>e.check(Be(r,o)),e.max=(r,o)=>e.check(yt(r,o)),e.mime=(r,o)=>e.check(Tn(Array.isArray(r)?r:[r],o))});function bv(e){return Cl(fp,e)}var mp=h("ZodTransform",(e,t)=>{Wt(),Uu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>fd(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new gt(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push($.issue(i,r.value,t));else{let a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=r.value),a.inst??(a.inst=e),r.issues.push($.issue(a))}};let n=t.transform(r.value,r);return n instanceof Promise?n.then(i=>(r.value=i,r)):(r.value=n,r)}});function wa(e){return new mp({type:"transform",transform:e})}var Hr=h("ZodOptional",(e,t)=>{oo.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ho(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Bt(e){return new Hr({type:"optional",innerType:e})}var Sa=h("ZodExactOptional",(e,t)=>{Cu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ho(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function gp(e){return new Sa({type:"optional",innerType:e})}var hp=h("ZodNullable",(e,t)=>{Eu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>_d(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Kr(e){return new hp({type:"nullable",innerType:e})}function _v(e){return Bt(Kr(e))}var vp=h("ZodDefault",(e,t)=>{Ru.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>wd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function yp(e,t){return new vp({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():$.shallowClone(t)}})}var $p=h("ZodPrefault",(e,t)=>{Mu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Sd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function bp(e,t){return new $p({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():$.shallowClone(t)}})}var Ia=h("ZodNonOptional",(e,t)=>{Lu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>xd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function _p(e,t){return new Ia({type:"nonoptional",innerType:e,...$.normalizeParams(t)})}var xp=h("ZodSuccess",(e,t)=>{Zu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ld(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function xv(e){return new xp({type:"success",innerType:e})}var kp=h("ZodCatch",(e,t)=>{Fu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Id(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function wp(e,t){return new kp({type:"catch",innerType:e,catchValue:typeof t=="function"?t:$.constantCatch(t)})}var Sp=h("ZodNaN",(e,t)=>{Vu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>sd(e,r,o,n)});function kv(e){return Dl(Sp,e)}var Xr=h("ZodPipe",(e,t)=>{ao.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>zd(e,r,o,n),e.in=t.in,e.out=t.out});function na(e,t){return new Xr({type:"pipe",in:e,out:t})}var Yr=h("ZodCodec",(e,t)=>{Xr.init(e,t),jr.init(e,t)});function wv(e,t,r){return new Yr({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function Sv(e){let t=e._zod.def;return new Yr({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var Ip=h("ZodPreprocess",(e,t)=>{Xr.init(e,t),Ku.init(e,t)}),zp=h("ZodReadonly",(e,t)=>{Ju.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Pd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Pp(e){return new zp({type:"readonly",innerType:e})}var jp=h("ZodTemplateLiteral",(e,t)=>{Bu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>cd(e,r,o,n)});function Iv(e,t){return new jp({type:"template_literal",parts:e,...$.normalizeParams(t)})}var Ap=h("ZodLazy",(e,t)=>{Ar.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ad(e,r,o,n),e.unwrap=()=>e._zod.def.getter()});function Op(e){return new Ap({type:"lazy",getter:e})}var Tp=h("ZodPromise",(e,t)=>{Gu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>jd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function zv(e){return new Tp({type:"promise",innerType:e})}var Np=h("ZodFunction",(e,t)=>{Wu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>pd(e,r,o,n)});function Pv(e){return new Np({type:"function",input:Array.isArray(e?.input)?cp(e?.input):e?.input??Wr(Jt()),output:e?.output??Jt()})}var Qr=h("ZodCustom",(e,t)=>{qu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>dd(e,r,o,n)});function jv(e){let t=new G({check:"custom"});return t._zod.check=e,t}function Av(e,t){return El(Qr,e??(()=>!0),t)}function Dp(e,t={}){return Rl(Qr,e,t)}function Up(e,t){return Ml(e,t)}var Ov=Ll,Tv=Zl,Cp=h("ZodInstanceOf",(e,t)=>{Qr.init(e,t)},{properties(e,t){return this.check(On(e,t))}});function Nv(e,t={}){let r=new Cp({type:"custom",check:"custom",fn:o=>o instanceof e,abort:!0,...$.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=o=>{o.value instanceof e||o.issues.push({code:"invalid_type",expected:e.name,input:o.value,inst:r,path:[...r._zod.def.path??[]]})},r}var Dv=(...e)=>Fl({Codec:Yr,Boolean:Jn,String:Vn},...e);function Uv(e){let t=Op(()=>Wn([Vr(e),Bd(),Wd(),Xd(),Wr(t),up(Vr(),t)]));return t}function Cv(e,t){return new Ip({type:"pipe",in:wa(e),out:t})}var Xw={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function Yw(e){te({customError:e})}function Qw(){return te().customError}var Ep;Ep||(Ep={});var ei={};tt(ei,{ZodISODate:()=>kt,ZodISODateTime:()=>xt,ZodISODuration:()=>St,ZodISOTime:()=>wt,date:()=>tS,datetime:()=>eS,duration:()=>rS,time:()=>nS});function eS(e){return Er(xt,e)}function tS(e){return Rr(kt,e)}function nS(e){return Mr(wt,e)}function rS(e){return Lr(St,e)}var j={...Gn,...Qo,iso:ei},iS=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function oS(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function Ev(e,t){return e.map((r,o)=>o<t?r:r.optional())}function aS(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function sS(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let o=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===o){let n=r[1]===void 0?void 0:aS(r[1]);if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function cS(e,t){return j.transform(o=>o).check(o=>{let n=o.value;if(typeof n!="object"||n===null||Array.isArray(n))return;let i=Object.getOwnPropertyNames(n);if(t.minProperties!==void 0&&i.length<t.minProperties&&o.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:n,inst:e,continue:!0}),t.maxProperties!==void 0&&i.length>t.maxProperties&&o.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:n,inst:e,continue:!0}),t.keySchema)for(let a of i){let s=t.keySchema.safeParse(a);s.success||o.issues.push({code:"invalid_key",origin:"record",issues:s.error.issues,input:a,path:[a],continue:!0})}}).pipe(e)}function Rp(e,t){if(e===null)return"z";let r=typeof e;if(r!=="object"){if(r==="number"&&Number.isNaN(e))return null;let o=String(e);return`${r[0]}${o.length}:${o}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let i=[];for(let a of e){let s=Rp(a,t);if(s===null)return null;i.push(s)}return`a${i.length}:[${i.join(",")}]`}let o=Object.keys(e).sort(),n=[];for(let i of o){let a=Rp(e[i],t);if(a===null)return null;n.push(`${i.length}:${i}=${a}`)}return`o${n.length}:{${n.join(",")}}`}finally{t.delete(e)}}var uS=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),lS=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function ti(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(ti):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,r])=>uS.has(t)?ti(r):!lS.has(t)||typeof r!="object"||r===null?!1:Object.values(r).some(ti))}function Rv(e){return e===1?"element":"elements"}function dS(e,t){return j.transform(o=>o).check(o=>{let n=o.value;if(Array.isArray(n)){if(t.uniqueItems===!0){let i=new Map;for(let a=0;a<n.length;a++){let s=Rp(n[a],new Set);if(s===null)continue;let u=i.get(s);if(u===void 0){i.set(s,a);continue}o.issues.push({code:"custom",message:`Array items must be unique: element at index ${a} duplicates the one at index ${u}`,input:n,path:[a],continue:!0})}}if(t.containsSchema){let i=t.minContains??1,a=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY,s=0;for(let u of n)if(t.containsSchema.safeParse(u).success&&++s>=a)break;s<i&&o.issues.push({code:"custom",message:`Array must contain at least ${i} matching ${Rv(i)}; found ${s}`,input:n,continue:!0}),t.maxContains!==void 0&&s>t.maxContains&&o.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${Rv(t.maxContains)}`,input:n,continue:!0})}}}).pipe(e)}function Mv(e,t){if(e!==!1)return e===void 0||e===!0?j.any():be(e,t)}var pS=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function Lv(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return j.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return j.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let i=sS(n,t),a=be(i,t);return t.refs.set(n,a),t.processing.delete(n),a}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return j.null();if(n.length===0)return j.never();if(n.length===1)return j.literal(n[0]);if(n.every(a=>typeof a=="string"))return j.enum(n);let i=n.map(a=>j.literal(a));return i.length<2?i[0]:j.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return j.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map(i=>{let a={...e,type:i};return Lv(a,t)});return n.length===0?j.never():n.length===1?n[0]:j.union(n)}if(!r)return j.any();let o;switch(r){case"string":{let n=j.string();if(e.format){let i=e.format;i==="email"?n=n.check(j.email()):i==="uri"||i==="uri-reference"?n=n.check(j.url()):i==="uuid"||i==="guid"?n=n.check(j.uuid()):i==="date-time"?n=n.check(j.iso.datetime({offset:!0})):i==="date"?n=n.check(j.iso.date()):i==="time"?n=n.check(j.regex(pS)):i==="duration"?n=n.check(j.iso.duration()):i==="hostname"?n=n.check(j.hostname()):i==="ipv4"?n=n.check(j.ipv4()):i==="ipv6"?n=n.check(j.ipv6()):i==="mac"?n=n.check(j.mac()):i==="cidr"?n=n.check(j.cidrv4()):i==="cidr-v6"?n=n.check(j.cidrv6()):i==="base64"?n=n.check(j.base64()):i==="base64url"?n=n.check(j.base64url()):i==="e164"?n=n.check(j.e164()):i==="credit_card"?n=n.check(j.creditCard()):i==="iban"?n=n.check(j.iban()):i==="jwt"?n=n.check(j.jwt()):i==="emoji"?n=n.check(j.emoji()):i==="nanoid"?n=n.check(j.nanoid()):i==="cuid"?n=n.check(j.cuid()):i==="cuid2"?n=n.check(j.cuid2()):i==="ulid"?n=n.check(j.ulid()):i==="xid"?n=n.check(j.xid()):i==="ksuid"&&(n=n.check(j.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),o=n;break}case"number":case"integer":{let n=r==="integer"?j.number().int():j.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),o=n;break}case"boolean":{o=j.boolean();break}case"null":{o=j.null();break}case"object":{let n={},i=e.properties||{},a=new Set(e.required||[]),s=typeof e.additionalProperties=="object"?be(e.additionalProperties,t):void 0;for(let[p,m]of Object.entries(i)){let f=be(m,t);ue(n,p,a.has(p)?f:f.optional())}if(e.patternProperties){let p=e.patternProperties,m=Object.keys(p),f=[];for(let y of m){let x=be(p[y],t),P=j.string().regex(new RegExp(y));f.push(j.looseRecord(P,x))}let g=[];if(Object.keys(n).length>0&&g.push(j.object(n).passthrough()),g.push(...f),g.length===0)o=j.object({}).passthrough();else if(g.length===1)o=g[0];else{let y=j.intersection(g[0],g[1]);for(let x=2;x<g.length;x++)y=j.intersection(y,g[x]);o=y}if(e.additionalProperties===!1){let y=Object.keys(n),x=m.map(I=>new RegExp(I)),P=o;o=o.check(I=>{if(!Ue(I.value))return;let A=[];for(let S of Object.keys(I.value))y.includes(S)||x.some(z=>z.test(S))||A.push(S);A.length&&I.issues.push({code:"unrecognized_keys",keys:A,input:I.value,inst:P})})}}else{let p=j.object(n);e.additionalProperties===!1?o=p.strict():s?o=p.catchall(s):o=p.passthrough()}let u=e.propertyNames!==void 0&&e.propertyNames!==!0,l=typeof e.minProperties=="number"?e.minProperties:void 0,d=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(u||l!==void 0||d!==void 0){let p;if(u){let m=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;p=be(m,t)}o=cS(o,{keySchema:p,minProperties:l,maxProperties:d})}break}case"array":{let n=e.prefixItems,i=e.items;if(n&&Array.isArray(n)){let a=typeof e.minItems=="number"?e.minItems:0,s=n.map(p=>be(p,t)),u=Ev(s,a),l=Array.isArray(i)?void 0:Mv(i,t),d=j.tuple(u);o=l?d.rest(l):d,typeof e.minItems=="number"&&(o=o.check(j.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(j.maxLength(e.maxItems)))}else if(Array.isArray(i)){let a=typeof e.minItems=="number"?e.minItems:0,s=i.map(p=>be(p,t)),u=Ev(s,a),l=Mv(e.additionalItems,t),d=j.tuple(u);o=l?d.rest(l):d,typeof e.minItems=="number"&&(o=o.check(j.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(j.maxLength(e.maxItems)))}else if(i!==void 0){let a=be(i,t),s=j.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),o=s}else o=j.array(j.any());(e.uniqueItems===!0||e.contains!==void 0)&&(o=dS(o,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?be(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${r}`)}return o}function be(e,t){if(typeof e=="boolean")return e?j.any():j.never();let r=Lv(e,t),o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(l=>be(l,t)),u=j.union(s);r=o?j.intersection(r,u):u}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(l=>be(l,t)),u=j.xor(s);r=o?j.intersection(r,u):u}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=o?r:j.any();else{let s=o?r:be(e.allOf[0],t),u=o?0:1;for(let l=u;l<e.allOf.length;l++)s=j.intersection(s,be(e.allOf[l],t));r=s}e.nullable===!0&&t.version==="openapi-3.0"&&(r=j.nullable(r)),e.readOnly===!0&&(r=j.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let n={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of i)s in e&&(n[s]=e[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in e&&(n[s]=e[s]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!ti(e.propertyNames)&&(n.propertyNames=e.propertyNames);for(let s of["minProperties","maxProperties"])e[s]!==void 0&&(n[s]=e[s])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!ti(e.contains)&&(n.contains=e.contains);for(let s of["uniqueItems","minContains","maxContains"])e[s]!==void 0&&(n[s]=e[s])}for(let s of Object.keys(e))iS.has(s)||ue(n,s,e[s]);return Object.keys(n).length>0&&t.registry.add(r,n),e.description&&(r=r.describe(e.description)),r}function Zv(e,t){if(typeof e=="boolean")return e?j.any():j.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let o=oS(r,t?.defaultTarget),n=r.$defs||r.definitions||{},i={version:o,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??le};return be(r,i)}var Fv=Symbol("z.visit/resolving");function ni(e,t){let r=typeof t=="function"?t:(a,s)=>{let u=t[a._zod.def.type];return u?u(a,s):a},o=new Map;function n(a){let s=o.get(a);if(s===Fv)return new Ar({type:"lazy",getter:()=>o.get(a)});if(s!==void 0)return s;o.set(a,Fv);let u=i(a),l=r(u,u!==a);return o.set(a,l),l}function i(a){let s=a._zod.def,u=s.type;switch(u){case"object":{let l=s.shape,d=Object.keys(l),p=!1,m={};for(let g of d){let y=n(l[g]);y!==l[g]&&(p=!0),m[g]=y}let f=s.catchall;return s.catchall&&(f=n(s.catchall),f!==s.catchall&&(p=!0)),p?F(a,{...s,shape:m,catchall:f}):a}case"array":{let l=n(s.element);return l===s.element?a:F(a,{...s,element:l})}case"tuple":{let l=s.items,d=!1,p=[];for(let f of l){let g=n(f);g!==f&&(d=!0),p.push(g)}let m=s.rest;return s.rest&&(m=n(s.rest),m!==s.rest&&(d=!0)),d?F(a,{...s,items:p,rest:m}):a}case"record":case"map":{let l=n(s.keyType),d=n(s.valueType);return l===s.keyType&&d===s.valueType?a:F(a,{...s,keyType:l,valueType:d})}case"set":{let l=n(s.valueType);return l===s.valueType?a:F(a,{...s,valueType:l})}case"union":{let l=s.options,d=!1,p=[];for(let m of l){let f=n(m);f!==m&&(d=!0),p.push(f)}return d?F(a,{...s,options:p}):a}case"intersection":{let l=n(s.left),d=n(s.right);return l===s.left&&d===s.right?a:F(a,{...s,left:l,right:d})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let l=n(s.innerType);return l===s.innerType?a:F(a,{...s,innerType:l})}case"pipe":{let l=n(s.in),d=n(s.out);return l===s.in&&d===s.out?a:F(a,{...s,in:l,out:d})}case"function":{let l=n(s.input),d=n(s.output);return l===s.input&&d===s.output?a:F(a,{...s,input:l,output:d})}case"lazy":{let l=s.getter,{_cachedInner:d,...p}=s;return F(a,{...p,getter:()=>n(l())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return a;default:return a}}return n(e)}function Vv(e){return ni(e,{object:t=>t.partial(),union:t=>{let r=t._zod.def;return r.discriminator===void 0?t:Wn(r.options)}})}function fS(e,t){if(!t?.length)return e;let r=e._zod.def;return F(e,Me(r,{checks:[...r.checks??[],...t]}),{parent:!0})}function Kv(e){return fS(e.out,e.checks)}function mS(e){return e.in._zod.traits.has("$ZodTransform")?Kv(e):e.in}function Jv(e){return ni(e,{pipe:t=>mS(t._zod.def),default:(t,r)=>r?Bt(t._zod.def.innerType):t,catch:(t,r)=>r?t._zod.def.innerType:t})}function Bv(e){return ni(e,{pipe:t=>Kv(t._zod.def),prefault:(t,r)=>r?t._zod.def.innerType:t})}var Mp={};tt(Mp,{bigint:()=>yS,boolean:()=>vS,date:()=>$S,number:()=>hS,string:()=>gS});function gS(e){return sl(Vn,e)}function hS(e){return fl(Kn,e)}function vS(e){return bl(Jn,e)}function yS(e){return xl(Bn,e)}function $S(e){return Nl(Br,e)}var qn=c.string().min(1).max(512).refine(bS,"Invalid path: use segments like notes/plan.md, without .. or a leading /");function bS(e){return/[\u0000-\u001f\u007f\\]/.test(e)?!1:e.split("/").every(r=>r.length>0&&r.length<=255&&r!=="."&&r!=="..")}var ri=c.string().regex(fe("message")),q=c.string().regex(fe("thread")),ze=c.string().regex(fe("project")),Pe=c.string().regex(fe("task")),Lp=c.string().regex(fe("artifact")),R=c.iso.datetime(),ii=c.enum(["user","agent","system"]),_S=c.object({path:qn,name:c.string(),size:c.number().int().nonnegative(),contentType:c.string()}),xS=c.object({artifactId:Lp,version:c.number().int().positive(),title:c.string()}),Wv=c.enum(["cloud","local"]),H=c.number().int().nonnegative(),kS=c.object({title:c.string(),harness:c.string(),runtime:Wv,model:c.string().nullable(),durationMs:H,inputTokens:H,outputTokens:H,costMicros:H.nullable()}),wS=c.object({chars:H,limit:H,parts:c.object({instructions:H,skills:H,knowledge:H,brief:H,conversation:H,notes:H,other:H}),droppedMessages:H,droppedNotes:H,cut:c.boolean()}),SS=c.object({model:c.string(),durationMs:H,calls:H,inputTokens:H,cachedInputTokens:H,outputTokens:H,costMicros:H.nullable(),runtime:Wv,computer:c.string().optional(),harness:c.string().optional(),task:kS.optional(),prompt:wS.optional()}),IS=c.enum(["brief","follow_up","reply","relay","answer"]),zS=c.object({kind:IS,threadId:q,fromThreadId:q.optional(),note:c.string()}),za=8,Ht=c.object({id:ri,projectId:ze,threadId:q.nullable(),authorKind:ii,authorId:c.string().min(1),body:c.string(),attachments:c.array(_S).optional(),artifacts:c.array(xS).optional(),stats:SS.optional(),relay:zS.optional(),clis:c.array(c.string().max(40)).max(za).optional(),seq:c.number().int().positive(),createdAt:R,editedAt:R.optional()}),PS=c.enum(["working","blocked","review_ready","done","failed"]),jS=c.object({id:c.string().max(40),options:c.array(c.string().max(40)).max(za),by:c.enum(["person","coordinator"]),reason:c.string().max(300).nullable()}),AS=c.object({cli:c.string().max(40),model:c.string().max(200).nullable(),effort:c.string().max(20).nullable()}),Gv="cloud",OS=c.object({id:c.string().max(60),by:c.enum(["person","auto","coordinator"]),reason:c.string().max(300).nullable().default(null)}),Zp=c.enum(["duplicate","misrouted","cancelled"]),TS=c.object({replies:H,usage:c.object({tokens:H,durationMs:H,costMicros:H.nullable()}).nullable(),planMessageId:ri.nullable()}),Fp=c.object({id:q,projectId:ze,rootMessageId:ri,ackMessageId:ri.nullable().default(null),title:c.string(),status:PS,statusText:c.string().nullable(),resolved:c.boolean(),closeReason:Zp.nullable().default(null),duplicateOf:q.nullable().default(null),label:c.string().nullable(),cli:jS.nullable().default(null),runner:OS.nullable().default(null),model:AS.nullable().default(null),seenSeq:c.number().int().nonnegative().nullable().default(null),summary:TS.nullable().default(null),createdAt:R,updatedAt:R}),NS=c.enum(["running","done","failed","cancelled"]),qv=c.object({id:Pe,threadId:q,title:c.string(),harness:c.string(),backend:c.string(),status:NS,prUrl:c.string().nullable(),summary:c.string().nullable(),createdAt:R,finishedAt:R.nullable()}),oN=c.object({ref:c.string(),commits:c.array(c.object({hash:c.string(),message:c.string(),at:c.string()})),entries:c.array(c.object({name:c.string(),path:c.string(),type:c.enum(["file","folder"])})).nullable(),file:c.object({path:c.string(),text:c.string().nullable(),size:c.number(),truncated:c.boolean()}).nullable()}),Vp=c.object({id:c.string().min(1).max(200),label:c.string().max(100),state:c.enum(["started","done","failed"]).optional(),model:c.string().max(200).optional(),tokens:c.number().int().nonnegative().optional()}),Hv=c.object({stream:c.enum(["stdout","stderr","system"]),text:c.string(),at:c.number().optional(),ms:c.number().nonnegative().optional(),tool:c.boolean().optional(),agent:Vp.optional()}),Kp=c.object({messageId:ri,emoji:c.string().min(1).max(32),authorKind:ii,authorId:c.string().min(1)}),Pa=c.enum(["owner","admin","member"]),DS=c.object({working:c.number().int().nonnegative(),waiting:c.number().int().nonnegative()}),US=c.object({monthMicros:c.number().int().nonnegative(),totalMicros:c.number().int().nonnegative()}),ja=c.enum(["indigo","blue","teal","green","amber","orange","red","pink","purple","gray"]),Aa=c.enum(["folder","rocket","code","terminal","globe","smartphone","server","database","cpu","bot","book","pen","palette","camera","music","gamepad","briefcase","cart","chart","shield","flask","leaf","heart","star","zap","home"]),aN=c.object({id:ze,name:c.string().min(1).max(120),role:Pa,icon:Aa.nullable().optional(),color:ja.nullable().optional(),createdAt:R,activity:DS.optional(),cost:US.optional(),pinned:c.boolean().optional()}),sN=c.object({pinned:c.boolean()}),cN=c.object({name:c.string().trim().min(1).max(120)}),uN=c.object({id:c.string(),name:c.string(),role:Pa,email:c.string().optional()}),Jp=32e3,CS=c.object({id:c.number().int(),accountLogin:c.string(),accountType:c.enum(["User","Organization"]),accountAvatarUrl:c.string().nullable()}),lN=c.object({configured:c.boolean(),installUrl:c.string().nullable(),installations:c.array(CS)}),dN=c.object({id:c.number().int(),installationId:c.number().int(),fullName:c.string(),defaultBranch:c.string(),private:c.boolean(),description:c.string().nullable()}),pN=c.object({repoId:c.number().int(),installationId:c.number().int(),fullName:c.string(),defaultBranch:c.string(),private:c.boolean(),createdAt:R}),Xv=c.object({repo:c.string(),number:c.number().int(),url:c.string(),threadId:q,title:c.string(),state:c.enum(["open","closed","merged"]),draft:c.boolean(),checks:c.enum(["pending","success","failure"]).nullable(),review:c.enum(["approved","changes_requested"]).nullable(),conflict:c.boolean().default(!1),branch:c.string().default(""),additions:c.number().int().nullable().default(null),deletions:c.number().int().nullable().default(null),changedFiles:c.number().int().nullable().default(null),updatedAt:R}),ES=c.object({path:c.string(),previousPath:c.string().nullable(),status:c.enum(["added","removed","modified","renamed","copied","changed","unchanged"]),additions:c.number().int(),deletions:c.number().int(),patch:c.string().nullable()}),fN=c.object({files:c.array(ES),truncated:c.boolean()}),Yv=c.enum(["merge","squash","rebase"]),mN=c.object({permitted:c.boolean(),blocked:c.enum(["closed","draft","conflict","checks_failed","checks_pending","changes_requested","protected","checking"]).nullable(),methods:c.array(Yv),sha:c.string()}),gN=c.object({method:Yv,sha:c.string().min(1),deleteBranch:c.boolean().default(!1)}),hN=c.object({merged:c.literal(!0),branchDeleted:c.boolean(),branchKept:c.enum(["fork","default","protected","gone","in_use","reopened","failed"]).nullable()}),vN=c.object({installationId:c.number().int().positive(),repoId:c.number().int().positive()});var RS=16e3,MS=16e3,xN=25*1024*1024,Qv=10;var kN=c.object({path:qn,size:c.number().int().nonnegative(),contentType:c.string(),updatedAt:R,updatedByKind:ii,updatedBy:c.string()}),LS=c.string().trim().min(1).max(80).regex(/^[\p{L}\p{N}][\p{L}\p{N} _.-]*$/u,"Use letters, numbers, spaces, dots, dashes or underscores"),ZS=c.enum(["ok","stale"]),FS=c.object({name:LS,description:c.string().max(300),content:c.string().max(MS),updatedAt:R,updatedByKind:ii,updatedBy:c.string(),status:ZS.default("ok"),staleReason:c.string().max(300).nullable().default(null),verifiedAt:R.nullable().default(null),previousContent:c.string().nullable().default(null),previousAt:R.nullable().default(null)}),wN=FS.pick({description:!0,content:!0}),SN=c.discriminatedUnion("status",[c.object({status:c.literal("ok")}),c.object({status:c.literal("stale"),reason:c.string().trim().min(1).max(300)})]),VS=c.object({text:c.string().max(RS),updatedAt:R.nullable(),updatedBy:c.string().nullable()}),IN=VS.pick({text:!0}),ey=c.enum(["files","memory","instructions"]),ty=c.enum(["auto","on","off"]),zN=c.object({mode:ty,active:c.boolean(),lastRunAt:R.nullable(),threadsSince:c.number().int().nonnegative(),threadsNeeded:c.number().int().positive(),threadId:c.string().nullable()}),PN=c.object({mode:ty});var Bp=c.object({id:Lp,projectId:ze,threadId:q.nullable(),title:c.string(),description:c.string().nullable(),version:c.number().int().positive(),createdAt:R,updatedAt:R}),TN=c.object({version:c.number().int().positive(),size:c.number().int().nonnegative(),threadId:q.nullable(),createdAt:R}),NN=c.object({version:c.number().int().positive(),url:c.string().nullable(),expiresAt:R.nullable()}),DN=2*1024*1024;var Wp=c.string().regex(fe("routine")),KS=/^(\*|\d+(-\d+)?)(\/\d+)?(,(\*|\d+(-\d+)?)(\/\d+)?)*$/,JS=c.string().trim().refine(e=>{let t=e.split(/\s+/);return t.length===5&&t.every(r=>KS.test(r))},"Expected a five-field cron expression, e.g. 0 9 * * 1-5"),BS=c.string().min(1).max(64).refine(e=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),!0}catch{return!1}},"Unknown time zone"),Gp=c.discriminatedUnion("kind",[c.object({kind:c.literal("cron"),cron:JS,timezone:BS.default("UTC")}),c.object({kind:c.literal("once"),at:R})]),qp=c.discriminatedUnion("kind",[c.object({kind:c.literal("coordinator")}),c.object({kind:c.literal("thread"),threadId:q})]),Hp=c.object({id:Wp,projectId:ze,name:c.string(),prompt:c.string(),target:qp,schedule:Gp,paused:c.boolean(),nextRunAt:R.nullable(),lastRunAt:R.nullable(),runCount:c.number().int().nonnegative(),createdBy:c.string(),createdAt:R}),MN=c.object({name:c.string().trim().min(1).max(120),prompt:c.string().trim().min(1).max(8e3),target:qp.default({kind:"coordinator"}),schedule:Gp}),LN=c.object({name:c.string().trim().min(1).max(120),prompt:c.string().trim().min(1).max(8e3),target:qp,schedule:Gp,paused:c.boolean()}).partial();var Xp=c.object({text:c.string(),until:c.string(),createdBy:c.string(),createdAt:c.string(),wakes:c.number().int().nonnegative(),threads:c.number().int().nonnegative(),idle:c.number().int().nonnegative()});var WS=c.string().regex(fe("sshHost")),Yp=c.string().regex(/^[a-z0-9][a-z0-9_-]{0,39}$/,"Use lowercase letters, digits, - and _ (up to 40)."),Oa=c.string().trim().min(1).max(253).regex(/^(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)*\.?|\[?[0-9A-Fa-f:.]+\]?)$/,"Enter a host name or IP address."),ny=c.string().trim().regex(/^[A-Za-z0-9_][A-Za-z0-9_.-]{0,63}$/,"Enter the user name on the server."),ry=c.enum(["ask","off"]),WN=c.string().max(16e3).regex(/^(?:ssh|ecdsa|sk)-[\w@.-]+ [A-Za-z0-9+/=]+(?: .*)?$/),iy=c.string().max(200).regex(/^SHA256:[A-Za-z0-9+/=]+$/),GS=c.object({id:WS,projectId:ze,alias:Yp,host:c.string(),port:c.number().int(),user:c.string(),runnerId:c.string(),runnerName:c.string(),mine:c.boolean(),keySource:c.enum(["new","existing"]),publicKey:c.string().nullable(),keyFingerprint:c.string().nullable(),hostFingerprint:c.string().nullable(),rule:ry,testedAt:R.nullable(),createdAt:R}),qS=c.object({id:c.string(),alias:c.string(),threadId:c.string().nullable(),command:c.string(),reason:c.string().nullable(),decision:c.enum(["once","turn","deny","timeout","failed"]),approvedBy:c.string().nullable(),exitCode:c.number().int().nullable(),ms:c.number().int().nullable(),at:R}),GN=c.object({hosts:c.array(GS),history:c.array(qS)}),qN=c.object({runnerId:c.string(),alias:Yp,host:Oa,port:c.number().int().min(1).max(65535).default(22),user:ny,existingKey:c.string().min(1).max(1024).optional()}),HN=c.object({rule:ry}),XN=c.object({hostKey:c.string().min(1).max(16e3)}),oy=c.object({type:c.string().max(60),key:c.string().max(16e3),fingerprint:iy}),ay=c.object({path:c.string().max(1024),name:c.string().max(255),type:c.string().max(60),fingerprint:iy,comment:c.string().max(500)}),sy=c.object({exitCode:c.number().int().nullable(),stdout:c.string(),stderr:c.string(),truncated:c.boolean(),ms:c.number().int().nonnegative(),error:c.enum(["hostkey","auth","connect","timeout","nokey","other"]).optional()}),cy=300*1e3,uy=200*1024,Ta=c.object({projectId:ze,alias:Yp}),Qp=Ta.extend({host:Oa,port:c.number().int().min(1).max(65535),user:ny,hostKey:c.string().min(1).max(16e3)});var py=2,st=c.string().regex(fe("runner")),Ge=c.enum(["claude","codex","antigravity","opencode","hermes","cursor","muse","kimi"]),tf={claude:"Claude Code",codex:"Codex CLI",antigravity:"Antigravity CLI",opencode:"OpenCode",hermes:"Hermes Agent",cursor:"Cursor CLI",muse:"Muse Code",kimi:"Kimi Code"},fy=c.object({path:c.string().min(1).max(1024),name:c.string().max(255)}),HS=c.object({kind:c.string().max(40),usedPercent:c.number().min(0).max(1e3).nullable(),resetsAt:R.nullable()}),XS=c.object({status:c.enum(["ok","warning","limited"]).optional(),windows:c.array(HS).max(8),at:R});var YS=c.object({id:c.string().min(1).max(200),name:c.string().max(200),efforts:c.array(c.string().min(1).max(20)).max(10)});var QS=c.object({id:Ge,version:c.string().max(200).nullable(),limits:XS.optional().catch(void 0),models:c.array(YS).max(100).optional().catch(void 0)}),eI=c.enum(["folders","cancel","agent","agent-clis","connectors","skills","project-folders","files","settings","update","models","github-token","git-token","steer","steer-claude","ssh"]),tI=c.discriminatedUnion("transport",[c.object({transport:c.literal("http"),name:c.string().regex(/^[a-z][a-z0-9_-]{0,40}$/),path:c.string().regex(/^\/api\/[\w/-]+$/).max(300)}),c.object({transport:c.literal("stdio"),name:c.string().regex(/^[a-z][a-z0-9_-]{0,40}$/),command:c.string().min(1).max(200),args:c.array(c.string().max(2e3)).max(50),env:c.record(c.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),c.string().max(4e3))})]),nI=c.enum(["read","edit","auto","full"]),nf=c.object({access:nI,worktrees:c.boolean(),autoUpdate:c.boolean(),remote:c.boolean()}),my=nf.omit({remote:!0}).partial(),rI=c.enum(["service","app","manual"]),ef=c.object({state:c.enum(["waiting","downloading","restarting","failed","rolled-back"]),version:c.string().max(50),running:c.number().int().nonnegative().optional(),message:c.string().max(500).optional(),at:R}),gy=c.object({version:c.string().max(50),hostname:c.string().max(255),platform:c.string().max(50),folders:c.array(fy).max(200),clis:c.array(c.unknown()).max(10).transform(e=>e.flatMap(t=>{let r=QS.safeParse(t);return r.success?[r.data]:[]})),features:c.array(c.string().max(50)).max(20).default([]).transform(e=>e.filter(t=>eI.safeParse(t).success)),settings:nf.optional().catch(void 0),updates:rI.optional().catch(void 0),update:ef.optional().catch(void 0)}),Na=1e5,Q=c.string().min(1).max(64),iI=c.object({name:c.string().max(255),path:c.string().max(1024)}),oI=c.object({path:c.string().max(1024),parent:c.string().max(1024).nullable(),home:c.string().max(1024),dirs:c.array(iI).max(1e3)}),ly=c.object({inputTokens:c.number().int().nonnegative(),outputTokens:c.number().int().nonnegative(),model:c.string().max(200).optional()}),rf=512*1024,aI=c.object({path:c.string().max(4096),size:c.number().int().nonnegative(),data:c.string().max(Math.ceil(rf/3)*4+4),truncated:c.boolean()}),sI=c.object({model:c.string().min(1).max(200).optional(),effort:c.string().min(1).max(20).optional()}),dy=c.object({token:c.string().min(20).max(4096),expiresAt:R,repos:c.array(c.string().regex(/^[\w.-]+\/[\w.-]+$/).max(200)).max(100)}),rD=c.discriminatedUnion("type",[gy.extend({type:c.literal("hello"),protocol:c.number().int().positive(),running:c.array(Pe).max(100).default([]),interrupted:c.array(Pe).max(100).default([])}),c.object({type:c.literal("task.progress"),taskId:Pe,text:c.string().max(2e3),usage:ly.optional(),agent:Vp.optional(),ms:c.number().nonnegative().optional()}),c.object({type:c.literal("task.done"),taskId:Pe,ok:c.boolean(),usage:ly.optional(),result:c.string().max(Na),cancelled:c.boolean().optional()}),c.object({type:c.literal("ping")}),c.object({type:c.literal("task.folders"),taskId:Pe,folders:c.array(c.string().min(1).max(1024)).max(60)}),oI.extend({type:c.literal("dirs"),requestId:Q}),c.object({type:c.literal("folders"),requestId:Q,folders:c.array(fy).max(200)}),c.object({type:c.literal("request.failed"),requestId:Q,message:c.string().max(500)}),aI.extend({type:c.literal("file"),requestId:Q}),c.object({type:c.literal("settings"),requestId:Q,settings:nf}),c.object({type:c.literal("update.accepted"),requestId:Q,update:ef}),c.object({type:c.literal("update.status"),update:ef.nullable()}),c.object({type:c.literal("task.steered"),requestId:Q,taken:c.boolean()}),c.object({type:c.literal("ssh.key"),requestId:Q,publicKey:c.string().max(16e3),fingerprint:c.string().max(200),protected:c.boolean()}),c.object({type:c.literal("ssh.keylist"),requestId:Q,keys:c.array(ay).max(100)}),c.object({type:c.literal("ssh.hostkeylist"),requestId:Q,keys:c.array(oy).max(10)}),sy.extend({type:c.literal("ssh.result"),requestId:Q})]),hy=c.discriminatedUnion("type",[c.object({type:c.literal("welcome"),runnerId:st,name:c.string()}),c.object({type:c.literal("task.start"),taskId:Pe,threadId:q,folder:c.string().min(1).max(1024),cli:Ge,prompt:c.string().min(1).max(Na),model:sI.optional(),folders:c.array(c.string().min(1).max(1024)).max(50).optional(),agent:c.object({mcpPath:c.string().regex(/^\/api\/[\w/-]+$/).max(300),token:c.string().min(20).max(200),connectors:c.array(tI).max(30).optional(),skills:c.object({path:c.string().regex(/^\/api\/[\w/-]+$/).max(300)}).optional(),resume:c.object({after:Pe,prompt:c.string().min(1).max(Na)}).optional()}).optional(),github:dy.optional()}),c.object({type:c.literal("task.github"),taskId:Pe,github:dy}),c.object({type:c.literal("task.steer"),requestId:Q,taskId:Pe,text:c.string().min(1).max(Na)}),c.object({type:c.literal("task.cancel"),taskId:Pe}),c.object({type:c.literal("pong")}),c.object({type:c.literal("dirs.list"),requestId:Q,path:c.string().max(1024).optional()}),c.object({type:c.literal("folder.share"),requestId:Q,path:c.string().min(1).max(1024)}),c.object({type:c.literal("folder.unshare"),requestId:Q,path:c.string().min(1).max(1024)}),c.object({type:c.literal("file.read"),requestId:Q,path:c.string().min(1).max(4096),folders:c.array(c.string().min(1).max(1024)).min(1).max(51),threadId:q.optional()}),c.object({type:c.literal("settings.set"),requestId:Q,settings:my}),c.object({type:c.literal("runner.update"),requestId:Q,version:c.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/).max(50),now:c.boolean().default(!1)}),Ta.extend({type:c.literal("ssh.keygen"),requestId:Q,comment:c.string().max(200),existing:c.string().min(1).max(1024).optional()}),c.object({type:c.literal("ssh.keys"),requestId:Q}),c.object({type:c.literal("ssh.hostkeys"),requestId:Q,host:Oa,port:c.number().int().min(1).max(65535)}),c.object({type:c.literal("ssh.test"),requestId:Q,target:Qp}),c.object({type:c.literal("ssh.run"),requestId:Q,target:Qp,command:c.string().min(1).max(2e4)}),Ta.extend({type:c.literal("ssh.forget"),requestId:Q})]),cI=gy.extend({id:st,name:c.string(),version:c.string().nullable(),online:c.boolean(),lastSeenAt:R.nullable(),createdAt:R}),iD=c.object({name:c.string().trim().min(1).max(80).optional(),settings:my.optional()}),oD=c.object({now:c.boolean().default(!1)}),aD=c.object({runners:c.array(cI),latestVersion:c.string().nullable()}),sD=c.object({code:c.string(),expiresAt:R}),cD=c.object({code:c.string().trim().min(4).max(20),name:c.string().trim().min(1).max(80),hostname:c.string().max(255).default(""),platform:c.string().max(50).default("")}),vy=c.object({runner:c.object({id:st,name:c.string()}),token:c.string()}),uD=c.object({projectId:ze,runnerId:st,runnerName:c.string(),path:c.string(),folders:c.array(c.string()).default([]),cli:Ge,online:c.boolean(),isDefault:c.boolean().default(!0)}),lD=c.object({path:c.string().trim().min(1).max(1024)}),dD=c.object({runnerId:st,path:c.string().min(1).max(1024),cli:Ge,add:c.boolean().optional()}),pD=c.object({path:c.string().min(1).max(1024),runnerId:st.optional()}),fD=c.object({runnerId:st});function yy(e,t){let r=i=>i.split("-")[0].split(".").map(a=>Number.parseInt(a,10)||0),[o,n]=[r(e),r(t)];for(let i=0;i<3;i++)if((o[i]??0)!==(n[i]??0))return(o[i]??0)>(n[i]??0);return!1}var uI=200,lI=c.object({threadId:q.nullable(),hasEarlier:c.boolean()});var kD=c.discriminatedUnion("type",[c.object({type:c.literal("message.send"),clientId:c.string().max(64).optional(),threadId:q.nullable().default(null),body:c.string().trim().max(Jp),attachments:c.array(qn).max(Qv).default([]),clis:c.array(Ge).max(za).optional()}).refine(e=>e.body.length>0||e.attachments.length>0,"Write something or attach a file"),c.object({type:c.literal("message.edit"),messageId:Ht.shape.id,body:c.string().trim().max(Jp)}),c.object({type:c.literal("thread.resolve"),threadId:q,resolved:c.boolean(),reason:Zp.optional()}),c.object({type:c.literal("thread.cli"),threadId:q,cli:Ge.nullable()}),c.object({type:c.literal("thread.runner"),threadId:q,runnerId:c.union([st,c.literal(Gv)]).nullable()}),c.object({type:c.literal("thread.model"),threadId:q,cli:Ge,model:c.string().trim().min(1).max(200).nullable(),effort:c.string().trim().min(1).max(20).nullable()}),c.object({type:c.literal("goal.stop")}),c.object({type:c.literal("sync"),afterSeq:c.number().int().nonnegative(),all:c.boolean().optional(),recent:c.number().int().positive().max(uI).optional()})]),wD=c.discriminatedUnion("type",[c.object({type:c.literal("message.created"),message:Ht}),c.object({type:c.literal("message.updated"),message:Ht}),c.object({type:c.literal("message.ack"),clientId:c.string(),messageId:Ht.shape.id,seq:Ht.shape.seq}),c.object({type:c.literal("sync.result"),messages:c.array(Ht),hasMore:c.boolean(),streamed:c.boolean().optional(),threads:c.array(Fp).default([]),reactions:c.array(Kp).default([]),artifacts:c.array(Bp).default([]),routines:c.array(Hp).default([]),goal:Xp.nullable().optional(),windows:c.array(lI).optional(),reset:c.boolean().optional(),lastSeq:c.number().int().nonnegative().optional()}),c.object({type:c.literal("thread.updated"),thread:Fp}),c.object({type:c.literal("reaction.added"),reaction:Kp}),c.object({type:c.literal("artifact.updated"),artifact:Bp}),c.object({type:c.literal("routine.updated"),routine:Hp}),c.object({type:c.literal("routine.deleted"),routineId:Wp}),c.object({type:c.literal("goal.updated"),goal:Xp.nullable()}),c.object({type:c.literal("agent.activity"),threadId:q.nullable(),active:c.boolean(),label:c.string().max(200).optional()}),c.object({type:c.literal("knowledge.changed"),kind:ey}),c.object({type:c.literal("workspace.changed")}),c.object({type:c.literal("task.updated"),task:qv}),c.object({type:c.literal("task.output"),taskId:Pe,threadId:q,lines:c.array(Hv)}),c.object({type:c.literal("pr.updated"),pullRequest:Xv}),c.object({type:c.literal("error"),code:c.string(),message:c.string()})]);var zD=c.object({app:c.literal("myrel"),apiVersion:c.number().int().positive(),name:c.string(),auth:c.object({emailPassword:c.boolean(),signUp:c.boolean().default(!0),emailVerification:c.boolean().default(!1),captcha:c.object({provider:c.literal("turnstile"),siteKey:c.string()}).nullable().default(null),passwordReset:c.boolean().default(!1)}),billing:c.boolean().default(!1),legal:c.object({terms:c.string().url(),privacy:c.string().url(),version:c.string()}).nullable().default(null)});var AD=c.object({question:c.string().min(1).max(300),options:c.array(c.object({label:c.string().min(1).max(40),consequence:c.string().max(200).default("")})).min(2).max(4),recommended:c.number().int().nonnegative().optional(),danger:c.boolean().optional()});var oi=c.enum(["fireworks","anthropic","openai"]),ED=c.object({id:oi,name:c.string(),defaultModel:c.string(),serverKey:c.boolean()}),RD=c.object({id:c.string(),provider:oi,label:c.string(),hint:c.string(),scope:c.enum(["user","instance"]),createdAt:c.iso.datetime()}),MD=c.object({provider:oi,label:c.string().trim().min(1).max(80),key:c.string().trim().min(8).max(500),scope:c.enum(["user","instance"]).default("user")}),$y=c.enum(["auto","local","cloud"]),by=c.enum(["opencode","claude","codex"]),dI=c.object({model:c.string().trim().min(1).max(200).nullable(),effort:c.string().trim().min(1).max(20).nullable()}),_y=c.partialRecord(Ge,dI),LD=c.object({name:c.string(),provider:oi.nullable(),model:c.string().nullable(),keyId:c.string().nullable(),taskTarget:$y,icon:Aa.nullable().default(null),color:ja.nullable().default(null),cloudCli:by.default("opencode"),cliModels:_y.default({})}),ZD=c.object({name:c.string().trim().min(1).max(120).optional(),provider:oi.nullable().optional(),model:c.string().trim().max(200).nullable().optional(),keyId:c.string().nullable().optional(),taskTarget:$y.optional(),icon:Aa.nullable().optional(),color:ja.nullable().optional(),cloudCli:by.optional(),cliModels:_y.optional()}),xy=c.enum(["admin","member"]),FD=c.object({id:c.string(),projectId:c.string(),projectName:c.string(),email:c.string(),role:xy,invitedBy:c.string(),createdAt:c.iso.datetime()}),VD=c.object({email:c.email().trim().toLowerCase(),role:xy.default("member")}),KD=c.object({role:Pa}),pI=c.enum(["admin","user"]),JD=c.enum(["computer","decision"]),BD=c.object({id:c.string(),name:c.string(),email:c.string(),role:pI,onboarded:c.boolean().optional(),tips:c.array(c.string()).optional()}),fI=c.object({signUpEnabled:c.boolean()}),mI=c.enum(["api","agent","cron","web","desktop","mobile"]),WD=c.object({platform:c.enum(["web","desktop","mobile"]),where:c.string().trim().min(1).max(200),name:c.string().max(100).default("Error"),message:c.string().max(500),stack:c.string().max(4e3).optional(),version:c.string().max(40).optional()}),GD=c.object({id:c.string(),source:mI,where:c.string(),name:c.string(),message:c.string(),stack:c.string().nullable(),count:c.number().int(),firstSeenAt:c.number(),lastSeenAt:c.number()}),qD=c.object({days:c.number().int(),signedUp:c.number().int(),verified:c.number().int(),inProject:c.number().int(),asked:c.number().int(),threadRan:c.number().int(),pairedComputer:c.number().int()}),HD=fI.partial();var ky=c.string().regex(fe("notification")),gI=c.enum(["done","ready","decision","blocked","failed"]),tU=c.object({id:ky,projectId:ze,threadId:q.nullable(),kind:gI,title:c.string(),body:c.string(),url:c.string(),readAt:R.nullable(),createdAt:R}),nU=c.object({email:c.boolean(),push:c.boolean()}),rU=c.object({webPushKey:c.string().nullable(),email:c.boolean()}),hI=[/^fcm\.googleapis\.com$/,/^updates\.push\.services\.mozilla\.com$/,/^web\.push\.apple\.com$/,/^[a-z0-9-]+\.notify\.windows\.com$/];function vI(e){try{let t=new URL(e);return t.protocol==="https:"&&hI.some(r=>r.test(t.hostname))}catch{return!1}}var iU=c.discriminatedUnion("kind",[c.object({kind:c.literal("webpush"),endpoint:c.url().max(2048).refine(vI,"Not a browser push service"),keys:c.object({p256dh:c.string().min(1).max(256),auth:c.string().min(1).max(64)})}),c.object({kind:c.literal("expo"),token:c.string().regex(/^Expo(nent)?PushToken\[[^\]]+\]$/).max(256)})]),oU=c.union([c.object({ids:c.array(ky).min(1).max(200)}),c.object({all:c.literal(!0)})]);var yI=new RegExp(fe("thread").source.slice(1,-1)),dU=new RegExp(`^#(${yI.source})$`);var $I=c.enum(["http","stdio"]),bI=c.enum(["user","project"]),af=c.enum(["cloud","local","both"]),_I=c.enum(["unknown","ok","error","needs_auth"]),xI=c.enum(["none","headers","oauth"]),wy=c.string().regex(/^[a-z][a-z0-9_-]{0,31}$/).refine(e=>e!=="myrel","That name is taken by Myrel's own tools."),kI=c.object({name:c.string(),description:c.string().optional()}),wI=/^[A-Za-z_][\w-]{0,99}$/,SI=/^[A-Za-z_][A-Za-z0-9_]{0,99}$/,Sy=(e,t,r)=>c.record(c.string().regex(e),c.string().max(4e3),{error:o=>o.code==="invalid_key"?`${t} name ${JSON.stringify(o.input)} is not valid: use only ${r}, with no spaces or ":". Put the value in its own field.`:void 0}),Iy=Sy(wI,"Header","letters, digits, - and _"),II=Sy(SI,"Variable","letters, digits and _"),mU=c.object({id:c.string(),name:c.string(),slug:c.string(),scope:bI,transport:$I,url:c.string().nullable(),auth:xI,command:c.string().nullable(),args:c.array(c.string()),runsOn:af,secretNames:c.array(c.string()),enabled:c.boolean(),status:_I,lastError:c.string().nullable(),tools:c.array(kI),canEdit:c.boolean(),createdAt:c.iso.datetime(),official:c.object({id:c.string(),title:c.string(),iconUrl:c.string().nullable()}).nullable().default(null)}),of=c.string().trim().min(1).max(60),gU=c.discriminatedUnion("transport",[c.object({transport:c.literal("http"),name:of,slug:wy.optional(),url:c.url({protocol:/^https$/}).max(2e3),auth:c.enum(["headers","oauth"]).default("headers"),headers:Iy.default({})}),c.object({transport:c.literal("stdio"),name:of,slug:wy.optional(),command:c.string().trim().min(1).max(200),args:c.array(c.string().max(2e3)).max(50).default([]),env:II.default({}),runsOn:af.default("both")})]),hU=c.object({name:of.optional(),enabled:c.boolean().optional(),url:c.url({protocol:/^https$/}).max(2e3).optional(),command:c.string().trim().min(1).max(200).optional(),args:c.array(c.string().max(2e3)).max(50).optional(),runsOn:af.optional(),secrets:Iy.optional()});var vU=c.object({authorizeUrl:c.url()});var zI=["developer","productivity","communication","design","data","sales","finance","search","ai","other"],zy=c.enum(zI);var PI=c.object({id:c.string(),title:c.string(),description:c.string(),websiteUrl:c.string().nullable(),iconUrl:c.string().nullable(),url:c.string(),auth:c.enum(["oauth","headers"]),headerHint:c.object({name:c.string(),placeholder:c.string()}).nullable(),category:zy,official:c.boolean()}),yU=c.object({connectors:c.array(PI),nextOffset:c.number().nullable(),syncedAt:c.iso.datetime().nullable(),categories:c.array(c.object({id:zy,count:c.number()}))}),jI=[{id:"com.notion/mcp",category:"productivity"},{id:"app.linear/linear",category:"productivity"},{id:"com.atlassian/atlassian-mcp-server",category:"productivity"},{id:"com.figma.mcp/mcp",category:"design"},{id:"com.stripe/mcp",category:"finance"},{id:"com.canva.mcp/mcp",category:"design"},{id:"com.vercel/vercel-mcp",category:"developer"},{id:"com.gitlab/mcp",category:"developer"},{id:"io.github.PostHog/mcp",category:"data"},{id:"com.zapier/mcp",category:"productivity"},{id:"com.airtable/mcp",category:"data"},{id:"com.monday/monday.com",category:"productivity"},{id:"com.paypal.mcp/mcp",category:"finance"},{id:"com.webflow/mcp",category:"design"},{id:"com.wix/mcp",category:"design"},{id:"com.neon/mcp",category:"developer"},{id:"com.railway/mcp",category:"developer"},{id:"co.huggingface/hf-mcp-server",category:"ai"},{id:"com.cloudflare.mcp/mcp",category:"developer"},{id:"com.apify/apify-mcp-server",category:"search"},{id:"ai.exa/exa",category:"search"},{id:"com.microsoft/microsoft-learn-mcp",category:"search"}],$U=jI.map(e=>e.id);var AI=c.enum(["user","project"]),OI=c.string().max(64).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,"Use lowercase letters, digits and hyphens, like pdf-forms."),Py=c.string().trim().min(1).max(1024),TI=c.string().min(1).max(300).regex(/^[\w@+=,.~ -]+(\/[\w@+=,.~ -]+)*$/,"Invalid file path.").refine(e=>!e.split("/").some(t=>t==="."||t===".."),"Invalid file path."),jy={files:200,bytes:5*1024*1024,fileBytes:1024*1024};var NI=c.discriminatedUnion("kind",[c.object({kind:c.literal("write")}),c.object({kind:c.literal("upload")}),c.object({kind:c.literal("github"),repo:c.string(),path:c.string(),ref:c.string().optional(),commit:c.string()})]),DI=c.object({path:c.string(),size:c.number().int().nonnegative()}),UI=c.object({id:c.string(),name:c.string(),description:c.string(),scope:AI,source:NI,enabled:c.boolean(),files:c.array(DI),size:c.number().int().nonnegative(),canEdit:c.boolean(),createdAt:c.iso.datetime(),updatedAt:c.iso.datetime()}),xU=UI.extend({skillMd:c.string()}),CI=c.object({path:TI,content:c.string().max(Math.ceil(jy.fileBytes*4/3)+4)}),kU=c.discriminatedUnion("kind",[c.object({kind:c.literal("write"),name:OI,description:Py,instructions:c.string().max(1e5)}),c.object({kind:c.literal("upload"),files:c.array(CI).min(1).max(jy.files)}),c.object({kind:c.literal("github"),source:c.string().trim().min(3).max(500),skill:c.string().max(64).optional()})]),wU=c.object({error:c.literal("choose_skill"),skills:c.array(c.object({name:c.string(),description:c.string(),path:c.string()}))}),SU=c.object({enabled:c.boolean().optional(),description:Py.optional(),instructions:c.string().max(1e5).optional()}),IU=c.object({skills:c.array(c.object({name:c.string(),files:c.array(c.object({path:c.string(),content:c.string()}))}))});var zU=c.object({on:c.boolean()});var EI=c.object({id:c.string().min(1).max(200),name:c.string().min(1).max(80),description:c.string().max(300).default(""),url:c.string().max(2e3),auth:c.enum(["oauth","headers"]),headerHint:c.object({name:c.string(),placeholder:c.string()}).nullable().default(null),iconUrl:c.string().nullable().default(null),official:c.boolean().default(!1),featured:c.boolean().default(!1)}),RI=c.enum(["open","connected","dismissed"]),AU=c.object({id:c.string(),reason:c.string().min(1).max(400),offers:c.array(EI).min(1).max(3),state:RI.default("open"),connected:c.string().optional(),signIn:c.boolean().optional()});var OU=c.object({offerId:c.string().min(1).max(200),headers:c.record(c.string().regex(/^[A-Za-z_][\w-]{0,99}$/),c.string().min(1).max(4e3)).optional()}),TU=c.object({authorizeUrl:c.string().optional(),connected:c.boolean()});var MI=/^(?:\/(?:usr\/)?(?:local\/)?bin\/)?(?:ba|z|da|k)?sh\s+-l?c\s+(\S[\s\S]*)$/;function Hn(e){let t=MI.exec(e.trim());return t?LI(t[1])??e:e}function LI(e){let t="",r=0;for(;r<e.length;){let o=e[r];if(o==="'"){let n=e.indexOf("'",r+1);if(n<0)return null;t+=e.slice(r+1,n),r=n+1}else if(o==='"'){for(r++;;){if(r>=e.length)return null;let n=e[r];if(n==='"')break;n==="\\"&&r+1<e.length&&'"\\$`\n'.includes(e[r+1])?(t+=e[r+1],r+=2):(t+=n,r++)}r++}else if(o==="\\"){if(r+1>=e.length)return null;t+=e[r+1],r+=2}else{if(/\s/.test(o)||"|&;<>()$`".includes(o))return null;t+=o,r++}}return t}import{spawn as ZI}from"node:child_process";import{mkdir as FI,readFile as Ny,rename as VI,writeFile as KI}from"node:fs/promises";import{homedir as Dy}from"node:os";import{dirname as JI,join as Ay}from"node:path";import{createInterface as Uy}from"node:readline";var lf="MYREL_MCP_BRIDGE";function BI(e=Dy()){return{mcp:Ay(e,".gemini","config","mcp_config.json"),settings:Ay(e,".gemini","antigravity-cli","settings.json")}}function ai(){let e=process.argv[1],t=!e||/\$bunfs|~BUN/.test(e);return{command:process.execPath,args:t?[]:[e]}}async function Cy(e,t=Dy()){let r=BI(t),o=ai(),n={command:o.command,args:[...o.args,"mcp-bridge"]};await Oy(r.mcp,a=>{let s=sf(a.mcpServers)?a.mcpServers:{};return JSON.stringify(s[e])===JSON.stringify(n)?!1:(a.mcpServers={...s,[e]:n},!0)});let i=`mcp(${e}/*)`;await Oy(r.settings,a=>{let s=sf(a.permissions)?a.permissions:{},u=Array.isArray(s.allow)?s.allow:[];return u.includes(i)?!1:(a.permissions={...s,allow:[...u,i]},!0)})}async function Oy(e,t){let r=await Ny(e,"utf8").catch(i=>{if(i.code==="ENOENT")return"";throw i}),o={};if(r.trim())try{o=JSON.parse(r)}catch{throw new Error(`Could not read ${e} as JSON, so Myrel's tools were not added to Antigravity CLI. Fix the file and try again.`)}if(!sf(o))throw new Error(`${e} is not a JSON object, so Myrel's tools were not added to Antigravity CLI.`);if(!t(o))return;await FI(JI(e),{recursive:!0});let n=`${e}.myrel-${process.pid}`;await KI(n,`${JSON.stringify(o,null,2)}
|
|
63
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let s=a[1];if(t===a[0]){i(a);continue}if(e.external){let l=e.external.registry.get(a[0])?.id;if(t!==a[0]&&l){i(a);continue}}if(e.metadataRegistry.get(a[0])?.id){i(a);continue}if(s.cycle){i(a);continue}s.count>1&&e.reused==="ref"&&i(a)}e.external&&(e.sharedDefsExtractedFor=e.external)}function ih(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let o of t){if(!o||typeof o!="object")return;ih(o);let n=Object.keys(o);if(n.length!==1||n[0]!=="type")return;let i=o.type;for(let a of Array.isArray(i)?i:[i]){if(typeof a!="string")return;r.includes(a)||r.push(a)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var oh=new Set(["type","properties","required","additionalProperties"]),nh=["oneOf","anyOf"];function rh(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Vl(e){let t=[];for(let i of e){if(typeof i!="object"||i.type!=="object")return null;for(let a in i)if(!oh.has(a))return null;t.push(i)}let r={},o=new Set;for(let i of t){for(let a in i.properties){if(Object.prototype.hasOwnProperty.call(r,a))continue;let s=[];for(let l of t){let d=l.properties?.[a]??rh(l);d!=null&&(s.some(p=>JSON.stringify(p)===JSON.stringify(d))||s.push(d))}let u=s.length===1?s[0]:Vl(s)??{allOf:s};ue(r,a,u)}for(let a of i.required??[])o.add(a)}let n={type:"object",properties:r};if(o.size&&(n.required=[...o]),t.every(i=>i.additionalProperties===!1))n.additionalProperties=!1;else{let i=[];for(let a of t){let s=rh(a);s&&!i.some(u=>JSON.stringify(u)===JSON.stringify(s))&&i.push(s)}i.length===1?n.additionalProperties=i[0]:i.length>1&&(n.additionalProperties={allOf:i})}return n}function Fw(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let n of oh)if(n in e)return;let r=t.filter(n=>nh.some(i=>Array.isArray(n[i]))),o=null;if(!r.length)o=Vl(t);else{let n=r[0],i=nh.find(u=>Array.isArray(n[u]));if(Object.keys(n).length!==1)return;let a=t.filter(u=>u!==n),s=n[i].map(u=>Vl([...a,u]));if(s.some(u=>!u))return;o={[i]:s}}o&&(delete e.allOf,Zr(e,o))}function _t(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let o=s=>{let u=e.seen.get(s);if(u.ref===null)return;let l=u.def??u.schema,d={...l},p=u.ref;if(u.ref=null,p){o(p);let f=e.seen.get(p),g=f.schema;if(g.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(g)):Zr(l,g),Zr(l,d),s._zod.parent===p)for(let x in l)x==="$ref"||x==="allOf"||x in d||delete l[x];if(g.$ref&&f.def)for(let x in l)x==="$ref"||x==="allOf"||x in f.def&&JSON.stringify(l[x])===JSON.stringify(f.def[x])&&delete l[x]}let m=s._zod.parent;if(m&&m!==p){o(m);let f=e.seen.get(m);if(f?.schema.$ref&&(l.$ref=f.schema.$ref,f.def))for(let g in l)g==="$ref"||g==="allOf"||g in f.def&&JSON.stringify(l[g])===JSON.stringify(f.def[g])&&delete l[g]}e.override({zodSchema:s,jsonSchema:l,path:u.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let s of[...e.seen.entries()].reverse())o(s[0]);if(e.target!=="openapi-3.0")for(let s of e.seen.entries())ih(s[1].def??s[1].schema);for(let s of e.deferred)s();if(e.intersections.length){let s=new Map;for(let u of e.seen.values())for(let l of[u.schema,u.def]){let d=l?.allOf;if(!Array.isArray(d))continue;let p=s.get(d);p?p.push(l):s.set(d,[l])}for(let u of e.intersections)for(let l of s.get(u)??[])Fw(l)}}let n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(s)}Zr(n,r.defId?r.schema:r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;i!==void 0&&n.id===i&&delete n.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let s of e.seen.entries()){let u=s[1];u.def&&u.defId&&(u.def.id===u.defId&&delete u.def.id,ue(a,u.defId,u.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?n.$defs=a:n.definitions=a);try{let s=JSON.parse(JSON.stringify(n));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:Rn(t,"input",e.processors),output:Rn(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function $e(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return $e(o.element,r);if(o.type==="set")return $e(o.valueType,r);if(o.type==="lazy")return $e(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault"||o.type==="catch")return $e(o.innerType,r);if(o.type==="intersection")return $e(o.left,r)||$e(o.right,r);if(o.type==="record"||o.type==="map")return $e(o.keyType,r)||$e(o.valueType,r);if(o.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:$e(o.in,r)||$e(o.out,r);if(o.type==="object"){for(let n in o.shape)if($e(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(let n of o.options)if($e(n,r))return!0;return!1}if(o.type==="tuple"){for(let n of o.items)if($e(n,r))return!0;return!!(o.rest&&$e(o.rest,r))}return!1}var Kl=(e,t={})=>r=>{let o=$t({...r,processors:t});return K(e,o),bt(o,e),_t(o,e)},Rn=(e,t,r={})=>o=>{let{libraryOptions:n,target:i}=o??{},a=$t({...n??{},target:i,io:t,processors:r});return K(e,a),bt(a,e),_t(a,e)};var Mn=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},Ln=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},ah=(e,t)=>{Mn(e,"minimum",t),Ln(e,"maximum",t)},lh=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},dh=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},ph=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},fh=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},sh=(e,t)=>Mn(e,"minimum",t.minimum),ch=(e,t)=>Ln(e,"maximum",t.maximum),uh=e=>(t,r)=>{fh(t,r.format);let[o,n]=e[r.format];Mn(t,"minimum",o),Ln(t,"maximum",n)},Vw={greater_than:(e,t)=>Mn(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Ln(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>lh(e,t.value),number_format:uh(cr),bigint_format:uh(ur),min_length:sh,max_length:ch,length_equals:(e,t)=>ah(e,t.length),min_size:sh,max_size:ch,size_equals:(e,t)=>ah(e,t.size),string_format:(e,t)=>{fh(e,t.format),t.pattern&&dh(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>ph(e,t.mime)};function ae(e){let t={},r=e._zod.def,o=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let i of o)Vw[i._zod.def.check]?.(t,i._zod.def);let n=e._zod.bag;n.minimum!==void 0&&Mn(t,"minimum",n.minimum),n.exclusiveMinimum!==void 0&&Mn(t,"exclusiveMinimum",n.exclusiveMinimum),n.maximum!==void 0&&Ln(t,"maximum",n.maximum),n.exclusiveMaximum!==void 0&&Ln(t,"exclusiveMaximum",n.exclusiveMaximum),n.multipleOf!==void 0&&lh(t,n.multipleOf),n.format!==void 0&&(t.format??(t.format=n.format),n.format.includes("int")&&(t.isInt=!0)),n.mime&&ph(t,n.mime);for(let i of n.patterns??[])dh(t,i);return t}var Kw={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Jw=new Map([[Xi,Hs],[Ir,Xs]]),mh=e=>Jw.get(e)??e,Wl=(e,t,r,o)=>{let n=r;n.type="string";let{minimum:i,maximum:a,format:s,patterns:u,contentEncoding:l,laxFormat:d}=ae(e);if(typeof i=="number"&&(n.minLength=i),typeof a=="number"&&(n.maxLength=a),s&&(n.format=Kw[s]??s,n.format===""&&delete n.format,(s==="time"||d)&&delete n.format),l&&(n.contentEncoding=l),u&&u.size>0){let p=[...u].map(mh);p.length===1?n.pattern=p[0].source:p.length>1&&(n.allOf=[...p.map(m=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:m.source}))])}},Gl=(e,t,r,o)=>{let n=r,{minimum:i,maximum:a,multipleOf:s,exclusiveMaximum:u,exclusiveMinimum:l,isInt:d}=ae(e);n.type=d?"integer":"number";let p=typeof l=="number"&&l>=(i??Number.NEGATIVE_INFINITY),m=typeof u=="number"&&u<=(a??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(p?f?(n.minimum=l,n.exclusiveMinimum=!0):n.exclusiveMinimum=l:typeof i=="number"&&(n.minimum=i),m?f?(n.maximum=u,n.exclusiveMaximum=!0):n.exclusiveMaximum=u:typeof a=="number"&&(n.maximum=a),s){let g=new Set;for(let P of s)Number.isFinite(P)&&P!==0?g.add(Math.abs(P)):oe(e,t,n,o,`A multipleOf divisor of ${P} cannot be represented in JSON Schema`);let[y,...x]=g;y!==void 0&&(n.multipleOf=y),x.length&&(n.allOf=[...n.allOf??[],...x.map(P=>({multipleOf:P}))])}},ql=(e,t,r,o)=>{r.type="boolean"},Hl=(e,t,r,o)=>{oe(e,t,r,o,"BigInt cannot be represented in JSON Schema")},Xl=(e,t,r,o)=>{oe(e,t,r,o,"Symbols cannot be represented in JSON Schema")},Yl=(e,t,r,o)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},Ql=(e,t,r,o)=>{oe(e,t,r,o,"Undefined cannot be represented in JSON Schema")},ed=(e,t,r,o)=>{oe(e,t,r,o,"Void cannot be represented in JSON Schema")},td=(e,t,r,o)=>{r.not={}},nd=(e,t,r,o)=>{},rd=(e,t,r,o)=>{},id=(e,t,r,o)=>{oe(e,t,r,o,"Date cannot be represented in JSON Schema")},od=(e,t,r,o)=>{let n=e._zod.def,i=ln(n.entries);if(i.length===0){r.not={};return}i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),r.enum=i},ad=(e,t,r,o)=>{let n=e._zod.def;if(n.values.length===0){r.not={};return}let i=[];for(let a of n.values)if(a===void 0){if(oe(e,t,r,o,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(oe(e,t,r,o,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){let a=i[0];r.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[a]:r.const=a}else i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),i.every(a=>typeof a=="boolean")&&(r.type="boolean"),i.every(a=>a===null)&&(r.type="null"),r.enum=i},sd=(e,t,r,o)=>{oe(e,t,r,o,"NaN cannot be represented in JSON Schema")},cd=(e,t,r,o)=>{let n=r,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},ud=(e,t,r,o)=>{let n=r;n.type="string",n.format="binary",n.contentEncoding="binary";let{minimum:i,maximum:a,mime:s}=ae(e);i!==void 0&&(n.minLength=i),a!==void 0&&(n.maxLength=a),s&&(s.length===0?n.not={}:s.length===1?n.contentMediaType=s[0]:n.anyOf=s.map(u=>({contentMediaType:u})))},ld=(e,t,r,o)=>{r.type="boolean"},dd=(e,t,r,o)=>{oe(e,t,r,o,"Custom types cannot be represented in JSON Schema")},pd=(e,t,r,o)=>{oe(e,t,r,o,"Function types cannot be represented in JSON Schema")},fd=(e,t,r,o)=>{oe(e,t,r,o,"Transforms cannot be represented in JSON Schema")},md=(e,t,r,o)=>{oe(e,t,r,o,"Map cannot be represented in JSON Schema")},gd=(e,t,r,o)=>{oe(e,t,r,o,"Set cannot be represented in JSON Schema")},hd=(e,t,r,o)=>{let n=r,i=e._zod.def,{minimum:a,maximum:s}=ae(e);typeof a=="number"&&(n.minItems=a),typeof s=="number"&&(n.maxItems=s),n.type="array",n.items=K(i.element,t,{...o,path:[...o.path,"items"]})};function Fr(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Fr(t.out):t.type==="catch"?Fr(t.innerType):e._zod.optin}var vd=(e,t,r,o)=>{let n=r,i=e._zod.def,a=i.shape;if(Object.getOwnPropertySymbols(a).length&&oe(e,t,n,o,"Symbol keys cannot be represented in JSON Schema"))return;n.type="object",n.properties={};for(let l in a)ue(n.properties,l,K(a[l],t,{...o,path:[...o.path,"properties",l]}));let u=[];for(let l of Object.keys(a)){let d=i.shape[l];(t.io==="input"?Fr(d)===void 0:d._zod.optout===void 0)&&u.push(l)}u.length>0&&(n.required=u),i.catchall?._zod.def.type==="never"?n.additionalProperties=!1:i.catchall?i.catchall&&(n.additionalProperties=K(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},qo=(e,t,r,o)=>{let n=e._zod.def,i=n.inclusive===!1,a=n.options.map((s,u)=>K(s,t,{...o,path:[...o.path,i?"oneOf":"anyOf",u]}));i?r.oneOf=a:r.anyOf=a},yd=(e,t,r,o)=>{let n=e._zod.def,i=K(n.left,t,{...o,path:[...o.path,"allOf",0]}),a=K(n.right,t,{...o,path:[...o.path,"allOf",1]}),s=l=>"allOf"in l&&Object.keys(l).length===1,u=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]];r.allOf=u,t.intersections.push(u)},$d=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",u=i.items.map((y,x)=>K(y,t,{...o,path:[...o.path,a,x]})),l=i.rest?K(i.rest,t,{...o,path:[...o.path,s,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null,d=i.items.length;for(;d>0;){let y=i.items[d-1];if(!(t.io==="input"?Fr(y)!==void 0:y._zod.optout==="optional"))break;d--}let p=i.items.length,m=!i.rest;t.target==="draft-2020-12"?(n.prefixItems=u,m?n.items=!1:l&&(n.items=l),d>0&&(n.minItems=d),m&&(n.maxItems=p)):t.target==="openapi-3.0"?(n.items={anyOf:u},l&&n.items.anyOf.push(l),d>0&&(n.minItems=d),m&&(n.maxItems=p)):(n.items=u,m?n.additionalItems=!1:l&&(n.additionalItems=l),d>0&&(n.minItems=d),m&&(n.maxItems=p));let{minimum:f,maximum:g}=ae(e);typeof f=="number"&&(n.minItems=f),typeof g=="number"&&(n.maxItems=g)};function Jl(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let g=e.get(t)?.def;if(!g)return t;let y=Jl(e,g,r);return y===g?t:y}for(let g of["anyOf","oneOf"]){let y=t[g];if(!Array.isArray(y))continue;let x=y.map(P=>Jl(e,P,r));x.some((P,I)=>P!==y[I])&&(t={...t,[g]:x})}let o=Array.isArray(t.type)?t.type:[t.type],n=!o.includes("string")&&o.some(g=>g==="number"||g==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!n&&!i?.some(g=>typeof g=="number"))return t;let{minimum:a,maximum:s,exclusiveMinimum:u,exclusiveMaximum:l,multipleOf:d,format:p,id:m,...f}=t;return f.enum?f.enum=f.enum.map(g=>typeof g=="number"?String(g):g):typeof f.const=="number"&&(f.const=String(f.const)),n&&(f.type="string",i||(f.pattern=(o.includes("number")?it:$r).source)),f}var Bl=new WeakMap;function Bw(e){let t=new Map;for(let o of e.seen.values())o.def&&!t.has(o.schema)&&t.set(o.schema,o);let r=new Map;for(let o of Bl.get(e)??[]){let n=e.seen.get(o),i=(n?.def??n?.schema)?.propertyNames;if(!i||i===!0||r.has(i))continue;let a=Jl(t,i,new Set);a!==i&&r.set(i,a)}if(r.size)for(let o of e.seen.values())for(let n of[o.schema,o.def]){let i=n&&r.get(n.propertyNames);i&&(n.propertyNames=i)}}var bd=(e,t,r,o)=>{let n=r,i=e._zod.def;n.type="object";let a=i.keyType,s=ae(a).patterns;if(i.mode==="loose"&&s&&s.size>0){let d=K(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});n.patternProperties={};for(let p of s)ue(n.patternProperties,mh(p).source,d)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){n.propertyNames=K(i.keyType,t,{...o,path:[...o.path,"propertyNames"]});let d=Bl.get(t);d||(d=[],Bl.set(t,d),t.deferred.push(()=>Bw(t))),d.push(e)}n.additionalProperties=K(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})}let u=a._zod.values,l=t.io==="input"&&Fr(i.valueType)!==void 0;if(u&&!i.partial&&!l){let d=[...u].filter(p=>typeof p=="string"||typeof p=="number");d.length>0&&(n.required=d.map(String))}},_d=(e,t,r,o)=>{let n=e._zod.def,i=K(n.innerType,t,o),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=n.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},xd=(e,t,r,o)=>{let n=e._zod.def;K(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},kd=Symbol();function gh(e,t,r,o,n){let i=!1,a=JSON.stringify(e,(s,u)=>typeof u!="bigint"?u:(i=!0,null));return i?(oe(t,r,o,n,"BigInt defaults cannot be represented in JSON Schema"),kd):JSON.parse(a)}var wd=(e,t,r,o)=>{let n=e._zod.def;K(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let a=gh(n.defaultValue,e,t,r,o);a!==kd&&(r.default=a)},Sd=(e,t,r,o)=>{let n=e._zod.def;K(n.innerType,t,o);let i=t.seen.get(e);if(i.ref=n.innerType,t.io!=="input")return;let a=gh(n.defaultValue,e,t,r,o);a!==kd&&(r._prefault=a)},Id=(e,t,r,o)=>{let n=e._zod.def;K(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType;let a;try{a=n.catchValue(void 0)}catch{oe(e,t,r,o,"Dynamic catch values are not supported in JSON Schema");return}r.default=a},zd=(e,t,r,o)=>{let n=e._zod.def,i=n.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?i?n.out:n.in:n.out;K(a,t,o);let s=t.seen.get(e);s.ref=a},Pd=(e,t,r,o)=>{let n=e._zod.def;K(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0},jd=(e,t,r,o)=>{let n=e._zod.def;K(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},Ho=(e,t,r,o)=>{let n=e._zod.def;K(n.innerType,t,o);let i=t.seen.get(e);i.ref=n.innerType},Ad=(e,t,r,o)=>{let n=e._zod.innerType;K(n,t,o);let i=t.seen.get(e);i.ref=n},Go={string:Wl,number:Gl,boolean:ql,bigint:Hl,symbol:Xl,null:Yl,undefined:Ql,void:ed,never:td,any:nd,unknown:rd,date:id,enum:od,literal:ad,nan:sd,template_literal:cd,file:ud,success:ld,custom:dd,function:pd,transform:fd,map:md,set:gd,array:hd,object:vd,union:qo,intersection:yd,tuple:$d,record:bd,nullable:_d,nonoptional:xd,default:wd,prefault:Sd,catch:Id,pipe:zd,readonly:Pd,promise:jd,optional:Ho,lazy:Ad};function Xo(e,t){if("_idmap"in e){let o=e,n=$t({...t,processors:Go}),i={};for(let u of o._idmap.entries()){let[l,d]=u;K(d,n)}let a={},s={registry:o,uri:t?.uri,defs:i};n.external=s;for(let u of o._idmap.entries()){let[l,d]=u;bt(n,d),ue(a,l,_t(n,d))}if(Object.keys(i).length>0){let u=n.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[u]:i}}return{schemas:a}}let r=$t({...t,processors:Go});return K(e,r),bt(r,e),_t(r,e)}var Yo=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=$t({processors:Go,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return K(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,bt(this.ctx,t);let o=_t(this.ctx,t),{"~standard":n,...i}=o;return i}};var hh={};var Gn={};tt(Gn,{ZodAny:()=>Yd,ZodArray:()=>np,ZodBase64:()=>va,ZodBase64URL:()=>ya,ZodBigInt:()=>Bn,ZodBigIntFormat:()=>_a,ZodBoolean:()=>Jn,ZodCIDRv4:()=>ga,ZodCIDRv6:()=>ha,ZodCUID:()=>ca,ZodCUID2:()=>ua,ZodCatch:()=>kp,ZodCodec:()=>Yr,ZodCreditCard:()=>Kd,ZodCustom:()=>Qr,ZodCustomStringFormat:()=>Gt,ZodDate:()=>Br,ZodDefault:()=>vp,ZodDiscriminatedUnion:()=>ip,ZodE164:()=>$a,ZodEmail:()=>ia,ZodEmoji:()=>aa,ZodEnum:()=>Fn,ZodExactOptional:()=>Sa,ZodFile:()=>fp,ZodFunction:()=>Np,ZodGUID:()=>oa,ZodIBAN:()=>Jd,ZodIPv4:()=>fa,ZodIPv6:()=>ma,ZodISODate:()=>kt,ZodISODateTime:()=>xt,ZodISODuration:()=>St,ZodISOTime:()=>wt,ZodInstanceOf:()=>Cp,ZodIntersection:()=>op,ZodJWT:()=>ba,ZodKSUID:()=>pa,ZodLazy:()=>Ap,ZodLiteral:()=>pp,ZodMAC:()=>Vd,ZodMap:()=>lp,ZodNaN:()=>Sp,ZodNanoID:()=>sa,ZodNever:()=>ep,ZodNonOptional:()=>Ia,ZodNull:()=>Hd,ZodNullable:()=>hp,ZodNumber:()=>Kn,ZodNumberFormat:()=>qt,ZodObject:()=>Gr,ZodOptional:()=>Hr,ZodPipe:()=>Xr,ZodPrefault:()=>$p,ZodPreprocess:()=>Ip,ZodPromise:()=>Tp,ZodReadonly:()=>zp,ZodRecord:()=>Zn,ZodSet:()=>dp,ZodString:()=>Vn,ZodStringFormat:()=>W,ZodSuccess:()=>xp,ZodSymbol:()=>Gd,ZodTemplateLiteral:()=>jp,ZodTransform:()=>mp,ZodTuple:()=>sp,ZodType:()=>C,ZodULID:()=>la,ZodURL:()=>Jr,ZodUUID:()=>We,ZodUndefined:()=>qd,ZodUnion:()=>qr,ZodUnknown:()=>Qd,ZodVoid:()=>tp,ZodXID:()=>da,ZodXor:()=>rp,_ZodString:()=>ra,_default:()=>yp,_function:()=>Pv,any:()=>ov,array:()=>Wr,base64:()=>Mh,base64url:()=>Lh,bigint:()=>ev,boolean:()=>Wd,catch:()=>wp,check:()=>jv,cidrv4:()=>Eh,cidrv6:()=>Rh,codec:()=>wv,creditCard:()=>Fh,cuid:()=>jh,cuid2:()=>Ah,currencyCode:()=>Gh,custom:()=>Av,date:()=>sv,describe:()=>Ov,discriminatedUnion:()=>fv,e164:()=>Zh,email:()=>$h,emoji:()=>zh,enum:()=>ka,exactOptional:()=>gp,file:()=>bv,float32:()=>Hh,float64:()=>Xh,function:()=>Pv,guid:()=>bh,hash:()=>qh,hex:()=>Wh,hostname:()=>Bh,httpUrl:()=>Ih,iban:()=>Vh,instanceof:()=>Nv,int:()=>ta,int32:()=>Yh,int64:()=>tv,intersection:()=>ap,invertCodec:()=>Sv,ipv4:()=>Dh,ipv6:()=>Ch,json:()=>Uv,jwt:()=>Kh,keyof:()=>cv,ksuid:()=>Nh,lazy:()=>Op,literal:()=>$v,looseObject:()=>dv,looseRecord:()=>gv,mac:()=>Uh,map:()=>hv,meta:()=>Tv,nan:()=>kv,nanoid:()=>Ph,nativeEnum:()=>yv,never:()=>xa,nonoptional:()=>_p,null:()=>Xd,nullable:()=>Kr,nullish:()=>_v,number:()=>Bd,object:()=>uv,optional:()=>Bt,partialRecord:()=>mv,pipe:()=>na,prefault:()=>bp,preprocess:()=>Cv,promise:()=>zv,readonly:()=>Pp,record:()=>up,refine:()=>Dp,set:()=>vv,strictObject:()=>lv,string:()=>Vr,stringFormat:()=>Jh,stringbool:()=>Dv,success:()=>xv,superRefine:()=>Up,symbol:()=>rv,templateLiteral:()=>Iv,transform:()=>wa,tuple:()=>cp,uint32:()=>Qh,uint64:()=>nv,ulid:()=>Oh,undefined:()=>iv,union:()=>Wn,unknown:()=>Jt,url:()=>Sh,uuid:()=>_h,uuidv4:()=>xh,uuidv6:()=>kh,uuidv7:()=>wh,void:()=>av,xid:()=>Th,xor:()=>pv});var Qo={};tt(Qo,{endsWith:()=>An,gt:()=>Je,gte:()=>Te,includes:()=>Pn,length:()=>Vt,lowercase:()=>In,lt:()=>Ke,lte:()=>Oe,maxLength:()=>Ft,maxSize:()=>yt,mime:()=>Tn,minLength:()=>ot,minSize:()=>Be,multipleOf:()=>vt,negative:()=>Ko,nonnegative:()=>Bo,nonpositive:()=>Jo,normalize:()=>Nn,overwrite:()=>Ze,positive:()=>Vo,properties:()=>On,property:()=>Wo,regex:()=>Sn,size:()=>Zt,slugify:()=>En,startsWith:()=>jn,toLowerCase:()=>Un,toUpperCase:()=>Cn,trim:()=>Dn,uppercase:()=>zn});var vh=new WeakSet([Object.prototype,Error.prototype]);function ea(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let o=r(this);return Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0}),o},set(o){Object.defineProperty(this,t,{value:o,configurable:!0,writable:!0})}})}var yh=(e,t)=>{As.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);vh.has(r)||(vh.add(r),ea(r,"format",o=>n=>gr(o,n)),ea(r,"flatten",o=>n=>mr(o,n)),ea(r,"addIssue",o=>n=>{o.issues.push(n),o.message=JSON.stringify(o.issues,dn,2)}),ea(r,"addIssues",o=>n=>{o.issues.push(...n),o.message=JSON.stringify(o.issues,dn,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Gw=h("ZodError",yh),Ie=h("ZodError",yh,void 0,{Parent:Error});var Od=hn(Ie),Td=vn(Ie),Nd=yn(Ie),Dd=$n(Ie),Ud=Pi(Ie),Cd=ji(Ie),Ed=Ai(Ie),Rd=Oi(Ie),Md=Ti(Ie),Ld=Ni(Ie),Zd=Di(Ie),Fd=Ui(Ie);function Hw(){se.localeError||te(mo())}function Wt(){se.memoizer||te({memoizer:Nr()})}var C=h("ZodType",(e,t)=>(Hw(),D.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone($.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return F(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Dp(e,t))},superRefine(e,t){return this.check(Up(e,t))},overwrite(e){return this.check(Ze(e))},optional(){return Bt(this)},exactOptional(){return gp(this)},nullable(){return Kr(this)},nullish(){return Bt(Kr(this))},nonoptional(e){return _p(this,e)},array(){return Wr(this)},or(e){return Wn([this,e])},and(e){return ap(this,e)},transform(e){return na(this,wa(e))},default(e){return yp(this,e)},prefault(e){return bp(this,e)},catch(e){return wp(this,e)},pipe(e){return na(this,e)},readonly(){return Pp(this)},describe(e){let t=this.clone();return le.add(t,{description:e}),t},meta(...e){if(e.length===0)return le.get(this);let t=this.clone();return le.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return $.hide(this,"~standard",{...Bi(this),jsonSchema:{input:Rn(this,"input"),output:Rn(this,"output")}})},set"~standard"(e){$.own(this,"~standard",e)},parse:function e(t,r){return Od(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Td(this,t,r,{callee:e})},safeParse(e,t){return Nd(this,e,t)},async safeParseAsync(e,t){return Dd(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){$.own(this,"spa",e)},validate(e,t){return hr(this,e,t)},validateAsync(e,t){return vr(this,e,t)},encode:function e(t,r){return Ud(this,t,r,{callee:e})},decode:function e(t,r){return Cd(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Ed(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Rd(this,t,r,{callee:e})},safeEncode(e,t){return Md(this,e,t)},safeDecode(e,t){return Ld(this,e,t)},async safeEncodeAsync(e,t){return Zd(this,e,t)},async safeDecodeAsync(e,t){return Fd(this,e,t)},toJSONSchema(e){return Kl(this,{})(e)},get description(){return le.get(this)?.description},get _def(){return this._zod.def}}),ra=h("_ZodString",(e,t)=>{Et.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Wl(e,r,o,n)},$.derived({format:e=>ae(e).format??null,minLength:e=>ae(e).minimum??null,maxLength:e=>ae(e).maximum??null},{regex(...e){return this.check(Sn(...e))},includes(...e){return this.check(Pn(...e))},startsWith(...e){return this.check(jn(...e))},endsWith(...e){return this.check(An(...e))},min(...e){return this.check(ot(...e))},max(...e){return this.check(Ft(...e))},length(...e){return this.check(Vt(...e))},nonempty(...e){return this.check(ot(1,...e))},lowercase(e){return this.check(In(e))},uppercase(e){return this.check(zn(e))},trim(){return this.check(Dn())},normalize(...e){return this.check(Nn(...e))},toLowerCase(){return this.check(Un())},toUpperCase(){return this.check(Cn())},slugify(){return this.check(En())}})),Vn=h("ZodString",(e,t)=>{Et.init(e,t),ra.init(e,t)},{email(e){return this.check(xo(ia,e))},url(e){return this.check(Cr(Jr,e))},jwt(e){return this.check(Fo(ba,e))},emoji(e){return this.check(Po(aa,e))},guid(e){return this.check(ko(oa,e))},uuid(e){return this.check(wo(We,e))},uuidv4(e){return this.check(So(We,e))},uuidv6(e){return this.check(Io(We,e))},uuidv7(e){return this.check(zo(We,e))},nanoid(e){return this.check(jo(sa,e))},cuid(e){return this.check(Ao(ca,e))},cuid2(e){return this.check(Oo(ua,e))},ulid(e){return this.check(To(la,e))},base64(e){return this.check(Mo(va,e))},base64url(e){return this.check(Lo(ya,e))},xid(e){return this.check(No(da,e))},ksuid(e){return this.check(Do(pa,e))},ipv4(e){return this.check(Uo(fa,e))},ipv6(e){return this.check(Co(ma,e))},cidrv4(e){return this.check(Eo(ga,e))},cidrv6(e){return this.check(Ro(ha,e))},e164(e){return this.check(Zo($a,e))},datetime(e){return this.check(Er(xt,e))},date(e){return this.check(Rr(kt,e))},time(e){return this.check(Mr(wt,e))},duration(e){return this.check(Lr(St,e))}});function Vr(e){return al(Vn,e)}var W=h("ZodStringFormat",(e,t)=>{V.init(e,t),ra.init(e,t)}),xt=h("ZodISODateTime",(e,t)=>{Hc.init(e,t),W.init(e,t)}),kt=h("ZodISODate",(e,t)=>{Xc.init(e,t),W.init(e,t)}),wt=h("ZodISOTime",(e,t)=>{Yc.init(e,t),W.init(e,t)}),St=h("ZodISODuration",(e,t)=>{Qc.init(e,t),W.init(e,t)}),ia=h("ZodEmail",(e,t)=>{Mc.init(e,t),W.init(e,t)});function $h(e){return xo(ia,e)}var oa=h("ZodGUID",(e,t)=>{Ec.init(e,t),W.init(e,t)});function bh(e){return ko(oa,e)}var We=h("ZodUUID",(e,t)=>{Rc.init(e,t),W.init(e,t)});function _h(e){return wo(We,e)}function xh(e){return So(We,e)}function kh(e){return Io(We,e)}function wh(e){return zo(We,e)}var Jr=h("ZodURL",(e,t)=>{Fc.init(e,t),W.init(e,t)});function Sh(e){return Cr(Jr,e)}function Ih(e){return Cr(Jr,{protocol:yr,hostname:Qs,...$.normalizeParams(e)})}var aa=h("ZodEmoji",(e,t)=>{Vc.init(e,t),W.init(e,t)});function zh(e){return Po(aa,e)}var sa=h("ZodNanoID",(e,t)=>{Kc.init(e,t),W.init(e,t)});function Ph(e){return jo(sa,e)}var ca=h("ZodCUID",(e,t)=>{Jc.init(e,t),W.init(e,t)});function jh(e){return Ao(ca,e)}var ua=h("ZodCUID2",(e,t)=>{Bc.init(e,t),W.init(e,t)});function Ah(e){return Oo(ua,e)}var la=h("ZodULID",(e,t)=>{Wc.init(e,t),W.init(e,t)});function Oh(e){return To(la,e)}var da=h("ZodXID",(e,t)=>{Gc.init(e,t),W.init(e,t)});function Th(e){return No(da,e)}var pa=h("ZodKSUID",(e,t)=>{qc.init(e,t),W.init(e,t)});function Nh(e){return Do(pa,e)}var fa=h("ZodIPv4",(e,t)=>{eu.init(e,t),W.init(e,t)});function Dh(e){return Uo(fa,e)}var Vd=h("ZodMAC",(e,t)=>{nu.init(e,t),W.init(e,t)});function Uh(e){return cl(Vd,e)}var ma=h("ZodIPv6",(e,t)=>{tu.init(e,t),W.init(e,t)});function Ch(e){return Co(ma,e)}var ga=h("ZodCIDRv4",(e,t)=>{ru.init(e,t),W.init(e,t)});function Eh(e){return Eo(ga,e)}var ha=h("ZodCIDRv6",(e,t)=>{iu.init(e,t),W.init(e,t)});function Rh(e){return Ro(ha,e)}var va=h("ZodBase64",(e,t)=>{ou.init(e,t),W.init(e,t)});function Mh(e){return Mo(va,e)}var ya=h("ZodBase64URL",(e,t)=>{au.init(e,t),W.init(e,t)});function Lh(e){return Lo(ya,e)}var $a=h("ZodE164",(e,t)=>{su.init(e,t),W.init(e,t)});function Zh(e){return Zo($a,e)}var Kd=h("ZodCreditCard",(e,t)=>{cu.init(e,t),W.init(e,t)});function Fh(e){return ul(Kd,e)}var Jd=h("ZodIBAN",(e,t)=>{uu.init(e,t),W.init(e,t)});function Vh(e){return ll(Jd,e)}var ba=h("ZodJWT",(e,t)=>{lu.init(e,t),W.init(e,t)});function Kh(e){return Fo(ba,e)}var Gt=h("ZodCustomStringFormat",(e,t)=>{du.init(e,t),W.init(e,t)});function Jh(e,t,r={}){return Kt(Gt,e,t,r)}function Bh(e){return Kt(Gt,"hostname",Ys,e)}function Wh(e){return Kt(Gt,"hex",fc,e)}function Gh(e){return Kt(Gt,"currency_code",tc,e)}function qh(e,t){let r=t?.enc??"hex",o=`${e}_${r}`,n=Ee[o];if(!n)throw new Error(`Unrecognized hash format: ${o}`);return Kt(Gt,o,n,t)}var Kn=h("ZodNumber",(e,t)=>{no.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Gl(e,r,o,n),e.isFinite=!0},$.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=ae(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=ae(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=ae(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>ae(e).format??null},{gt(e,t){return this.check(Je(e,t))},gte(e,t){return this.check(Te(e,t))},min(e,t){return this.check(Te(e,t))},lt(e,t){return this.check(Ke(e,t))},lte(e,t){return this.check(Oe(e,t))},max(e,t){return this.check(Oe(e,t))},int(e){return this.check(ta(e))},safe(e){return this.check(ta(e))},positive(e){return this.check(Je(0,e))},nonnegative(e){return this.check(Te(0,e))},negative(e){return this.check(Ke(0,e))},nonpositive(e){return this.check(Oe(0,e))},multipleOf(e,t){return this.check(vt(e,t))},step(e,t){return this.check(vt(e,t))},finite(){return this}}));function Bd(e){return pl(Kn,e)}var qt=h("ZodNumberFormat",(e,t)=>{pu.init(e,t),Kn.init(e,t)});function ta(e){return ml(qt,e)}function Hh(e){return gl(qt,e)}function Xh(e){return hl(qt,e)}function Yh(e){return vl(qt,e)}function Qh(e){return yl(qt,e)}var Jn=h("ZodBoolean",(e,t)=>{zr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ql(e,r,o,n)});function Wd(e){return $l(Jn,e)}var Bn=h("ZodBigInt",(e,t)=>{ro.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Hl(e,r,o,n)},$.derived({minValue:e=>ae(e).minimum??null,maxValue:e=>ae(e).maximum??null,format:e=>ae(e).format??null},{gte(e,t){return this.check(Te(e,t))},min(e,t){return this.check(Te(e,t))},gt(e,t){return this.check(Je(e,t))},lt(e,t){return this.check(Ke(e,t))},lte(e,t){return this.check(Oe(e,t))},max(e,t){return this.check(Oe(e,t))},positive(e){return this.check(Je(BigInt(0),e))},negative(e){return this.check(Ke(BigInt(0),e))},nonpositive(e){return this.check(Oe(BigInt(0),e))},nonnegative(e){return this.check(Te(BigInt(0),e))},multipleOf(e,t){return this.check(vt(e,t))}}));function ev(e){return _l(Bn,e)}var _a=h("ZodBigIntFormat",(e,t)=>{fu.init(e,t),Bn.init(e,t)});function tv(e){return kl(_a,e)}function nv(e){return wl(_a,e)}var Gd=h("ZodSymbol",(e,t)=>{mu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Xl(e,r,o,n)});function rv(e){return Sl(Gd,e)}var qd=h("ZodUndefined",(e,t)=>{gu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ql(e,r,o,n)});function iv(e){return Il(qd,e)}var Hd=h("ZodNull",(e,t)=>{hu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Yl(e,r,o,n)});function Xd(e){return zl(Hd,e)}var Yd=h("ZodAny",(e,t)=>{vu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>nd(e,r,o,n)});function ov(){return Pl(Yd)}var Qd=h("ZodUnknown",(e,t)=>{yu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>rd(e,r,o,n)});function Jt(){return jl(Qd)}var ep=h("ZodNever",(e,t)=>{$u.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>td(e,r,o,n)});function xa(e){return Al(ep,e)}var tp=h("ZodVoid",(e,t)=>{bu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ed(e,r,o,n)});function av(e){return Ol(tp,e)}var Br=h("ZodDate",(e,t)=>{_u.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>id(e,r,o,n),e.min=(r,o)=>e.check(Te(r,o)),e.max=(r,o)=>e.check(Oe(r,o))},$.derived({minDate:e=>{let{minimum:t}=ae(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=ae(e);return t?new Date(t):null}},{}));function sv(e){return Tl(Br,e)}var np=h("ZodArray",(e,t)=>{Wt(),ku.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>hd(e,r,o,n),e.element=t.element},{min(e,t){return this.check(ot(e,t))},nonempty(e){return this.check(ot(1,e))},max(e,t){return this.check(Ft(e,t))},length(e,t){return this.check(Vt(e,t))},unwrap(){return this.element}});function Wr(e,t){return Ul(np,e,t)}function cv(e){let t=e._zod.def.shape;return ka(Object.keys(t))}var Gr=h("ZodObject",(e,t)=>{Wt(),wu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>vd(e,r,o,n),$.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return ka(Object.keys(this._zod.def.shape))},catchall(e){return this.clone($.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone($.mergeDefs(this._zod.def,{catchall:Jt()}))},loose(){return this.clone($.mergeDefs(this._zod.def,{catchall:Jt()}))},strict(){return this.clone($.mergeDefs(this._zod.def,{catchall:xa()}))},strip(){return this.clone($.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return $.extend(this,e)},safeExtend(e){return $.safeExtend(this,e)},merge(e){return $.merge(this,e)},pick(e){return $.pick(this,e)},omit(e){return $.omit(this,e)},partial(...e){return $.partial(Hr,this,e[0])},exactPartial(...e){return $.partial(Sa,this,e[0],"exactPartial")},required(...e){return $.required(Ia,this,e[0])}});function uv(e,t){let r={type:"object",shape:e??{},...$.normalizeParams(t)};return new Gr(r)}function lv(e,t){return new Gr({type:"object",shape:e,catchall:xa(),...$.normalizeParams(t)})}function dv(e,t){return new Gr({type:"object",shape:e,catchall:Jt(),...$.normalizeParams(t)})}var qr=h("ZodUnion",(e,t)=>{Pr.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>qo(e,r,o,n),e.options=t.options});function Wn(e,t){return new qr({type:"union",options:e,...$.normalizeParams(t)})}var rp=h("ZodXor",(e,t)=>{qr.init(e,t),Su.init(e,t),e._zod.processJSONSchema=(r,o,n)=>qo(e,r,o,n),e.options=t.options});function pv(e,t){return new rp({type:"union",options:e,inclusive:!1,...$.normalizeParams(t)})}var ip=h("ZodDiscriminatedUnion",(e,t)=>{qr.init(e,t),zu.init(e,t)});function fv(e,t,r){return new ip({type:"union",options:t,discriminator:e,...$.normalizeParams(r)})}var op=h("ZodIntersection",(e,t)=>{Pu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>yd(e,r,o,n)});function ap(e,t){return new op({type:"intersection",left:e,right:t})}var sp=h("ZodTuple",(e,t)=>{Wt(),io.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>$d(e,r,o,n)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new Hr({type:"optional",innerType:t}))})}});function cp(e,t,r){let o=t instanceof D,n=o?r:t,i=o?t:null;return new sp({type:"tuple",items:e,rest:i,...$.normalizeParams(n)})}var Zn=h("ZodRecord",(e,t)=>{Wt(),ju.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>bd(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});function up(e,t,r){return!t||!t._zod?new Zn({type:"record",keyType:Vr(),valueType:e,...$.normalizeParams(t)}):new Zn({type:"record",keyType:e,valueType:t,...$.normalizeParams(r)})}function mv(e,t,r){return new Zn({type:"record",keyType:e,valueType:t,...$.normalizeParams(r),partial:!0})}function gv(e,t,r){return new Zn({type:"record",keyType:e,valueType:t,mode:"loose",...$.normalizeParams(r)})}var lp=h("ZodMap",(e,t)=>{Wt(),Au.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>md(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...r)=>e.check(Be(...r)),e.nonempty=r=>e.check(Be(1,r)),e.max=(...r)=>e.check(yt(...r)),e.size=(...r)=>e.check(Zt(...r))});function hv(e,t,r){return new lp({type:"map",keyType:e,valueType:t,...$.normalizeParams(r)})}var dp=h("ZodSet",(e,t)=>{Wt(),Ou.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>gd(e,r,o,n),e.min=(...r)=>e.check(Be(...r)),e.nonempty=r=>e.check(Be(1,r)),e.max=(...r)=>e.check(yt(...r)),e.size=(...r)=>e.check(Zt(...r))});function vv(e,t){return new dp({type:"set",valueType:e,...$.normalizeParams(t)})}var Fn=h("ZodEnum",(e,t)=>{Tu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(o,n,i)=>od(e,o,n,i),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{let i={};for(let a of o)if(r.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Fn({...t,checks:[],...$.normalizeParams(n),entries:i})},e.exclude=(o,n)=>{let i={...t.entries};for(let a of o)if(r.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new Fn({...t,checks:[],...$.normalizeParams(n),entries:i})}});function ka(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new Fn({type:"enum",entries:r,...$.normalizeParams(t)})}function yv(e,t){return new Fn({type:"enum",entries:e,...$.normalizeParams(t)})}var pp=h("ZodLiteral",(e,t)=>{Nu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ad(e,r,o,n),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function $v(e,t){return new pp({type:"literal",values:Array.isArray(e)?e:[e],...$.normalizeParams(t)})}var fp=h("ZodFile",(e,t)=>{Du.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ud(e,r,o,n),e.min=(r,o)=>e.check(Be(r,o)),e.max=(r,o)=>e.check(yt(r,o)),e.mime=(r,o)=>e.check(Tn(Array.isArray(r)?r:[r],o))});function bv(e){return Cl(fp,e)}var mp=h("ZodTransform",(e,t)=>{Wt(),Uu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>fd(e,r,o,n),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new gt(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push($.issue(i,r.value,t));else{let a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=r.value),a.inst??(a.inst=e),r.issues.push($.issue(a))}};let n=t.transform(r.value,r);return n instanceof Promise?n.then(i=>(r.value=i,r)):(r.value=n,r)}});function wa(e){return new mp({type:"transform",transform:e})}var Hr=h("ZodOptional",(e,t)=>{oo.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ho(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Bt(e){return new Hr({type:"optional",innerType:e})}var Sa=h("ZodExactOptional",(e,t)=>{Cu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ho(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function gp(e){return new Sa({type:"optional",innerType:e})}var hp=h("ZodNullable",(e,t)=>{Eu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>_d(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Kr(e){return new hp({type:"nullable",innerType:e})}function _v(e){return Bt(Kr(e))}var vp=h("ZodDefault",(e,t)=>{Ru.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>wd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function yp(e,t){return new vp({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():$.shallowClone(t)}})}var $p=h("ZodPrefault",(e,t)=>{Mu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Sd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function bp(e,t){return new $p({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():$.shallowClone(t)}})}var Ia=h("ZodNonOptional",(e,t)=>{Lu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>xd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function _p(e,t){return new Ia({type:"nonoptional",innerType:e,...$.normalizeParams(t)})}var xp=h("ZodSuccess",(e,t)=>{Zu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ld(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function xv(e){return new xp({type:"success",innerType:e})}var kp=h("ZodCatch",(e,t)=>{Fu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Id(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function wp(e,t){return new kp({type:"catch",innerType:e,catchValue:typeof t=="function"?t:$.constantCatch(t)})}var Sp=h("ZodNaN",(e,t)=>{Vu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>sd(e,r,o,n)});function kv(e){return Dl(Sp,e)}var Xr=h("ZodPipe",(e,t)=>{ao.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>zd(e,r,o,n),e.in=t.in,e.out=t.out});function na(e,t){return new Xr({type:"pipe",in:e,out:t})}var Yr=h("ZodCodec",(e,t)=>{Xr.init(e,t),jr.init(e,t)});function wv(e,t,r){return new Yr({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}function Sv(e){let t=e._zod.def;return new Yr({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var Ip=h("ZodPreprocess",(e,t)=>{Xr.init(e,t),Ku.init(e,t)}),zp=h("ZodReadonly",(e,t)=>{Ju.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Pd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function Pp(e){return new zp({type:"readonly",innerType:e})}var jp=h("ZodTemplateLiteral",(e,t)=>{Bu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>cd(e,r,o,n)});function Iv(e,t){return new jp({type:"template_literal",parts:e,...$.normalizeParams(t)})}var Ap=h("ZodLazy",(e,t)=>{Ar.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ad(e,r,o,n),e.unwrap=()=>e._zod.def.getter()});function Op(e){return new Ap({type:"lazy",getter:e})}var Tp=h("ZodPromise",(e,t)=>{Gu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>jd(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function zv(e){return new Tp({type:"promise",innerType:e})}var Np=h("ZodFunction",(e,t)=>{Wu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>pd(e,r,o,n)});function Pv(e){return new Np({type:"function",input:Array.isArray(e?.input)?cp(e?.input):e?.input??Wr(Jt()),output:e?.output??Jt()})}var Qr=h("ZodCustom",(e,t)=>{qu.init(e,t),C.init(e,t),e._zod.processJSONSchema=(r,o,n)=>dd(e,r,o,n)});function jv(e){let t=new G({check:"custom"});return t._zod.check=e,t}function Av(e,t){return El(Qr,e??(()=>!0),t)}function Dp(e,t={}){return Rl(Qr,e,t)}function Up(e,t){return Ml(e,t)}var Ov=Ll,Tv=Zl,Cp=h("ZodInstanceOf",(e,t)=>{Qr.init(e,t)},{properties(e,t){return this.check(On(e,t))}});function Nv(e,t={}){let r=new Cp({type:"custom",check:"custom",fn:o=>o instanceof e,abort:!0,...$.normalizeParams(t)});return r._zod.bag.Class=e,r._zod.check=o=>{o.value instanceof e||o.issues.push({code:"invalid_type",expected:e.name,input:o.value,inst:r,path:[...r._zod.def.path??[]]})},r}var Dv=(...e)=>Fl({Codec:Yr,Boolean:Jn,String:Vn},...e);function Uv(e){let t=Op(()=>Wn([Vr(e),Bd(),Wd(),Xd(),Wr(t),up(Vr(),t)]));return t}function Cv(e,t){return new Ip({type:"pipe",in:wa(e),out:t})}var Xw={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function Yw(e){te({customError:e})}function Qw(){return te().customError}var Ep;Ep||(Ep={});var ei={};tt(ei,{ZodISODate:()=>kt,ZodISODateTime:()=>xt,ZodISODuration:()=>St,ZodISOTime:()=>wt,date:()=>tS,datetime:()=>eS,duration:()=>rS,time:()=>nS});function eS(e){return Er(xt,e)}function tS(e){return Rr(kt,e)}function nS(e){return Mr(wt,e)}function rS(e){return Lr(St,e)}var j={...Gn,...Qo,iso:ei},iS=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function oS(e,t){let r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function Ev(e,t){return e.map((r,o)=>o<t?r:r.optional())}function aS(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function sS(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;let o=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===o){let n=r[1]===void 0?void 0:aS(r[1]);if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function cS(e,t){return j.transform(o=>o).check(o=>{let n=o.value;if(typeof n!="object"||n===null||Array.isArray(n))return;let i=Object.getOwnPropertyNames(n);if(t.minProperties!==void 0&&i.length<t.minProperties&&o.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:n,inst:e,continue:!0}),t.maxProperties!==void 0&&i.length>t.maxProperties&&o.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:n,inst:e,continue:!0}),t.keySchema)for(let a of i){let s=t.keySchema.safeParse(a);s.success||o.issues.push({code:"invalid_key",origin:"record",issues:s.error.issues,input:a,path:[a],continue:!0})}}).pipe(e)}function Rp(e,t){if(e===null)return"z";let r=typeof e;if(r!=="object"){if(r==="number"&&Number.isNaN(e))return null;let o=String(e);return`${r[0]}${o.length}:${o}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let i=[];for(let a of e){let s=Rp(a,t);if(s===null)return null;i.push(s)}return`a${i.length}:[${i.join(",")}]`}let o=Object.keys(e).sort(),n=[];for(let i of o){let a=Rp(e[i],t);if(a===null)return null;n.push(`${i.length}:${i}=${a}`)}return`o${n.length}:{${n.join(",")}}`}finally{t.delete(e)}}var uS=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),lS=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function ti(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(ti):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,r])=>uS.has(t)?ti(r):!lS.has(t)||typeof r!="object"||r===null?!1:Object.values(r).some(ti))}function Rv(e){return e===1?"element":"elements"}function dS(e,t){return j.transform(o=>o).check(o=>{let n=o.value;if(Array.isArray(n)){if(t.uniqueItems===!0){let i=new Map;for(let a=0;a<n.length;a++){let s=Rp(n[a],new Set);if(s===null)continue;let u=i.get(s);if(u===void 0){i.set(s,a);continue}o.issues.push({code:"custom",message:`Array items must be unique: element at index ${a} duplicates the one at index ${u}`,input:n,path:[a],continue:!0})}}if(t.containsSchema){let i=t.minContains??1,a=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY,s=0;for(let u of n)if(t.containsSchema.safeParse(u).success&&++s>=a)break;s<i&&o.issues.push({code:"custom",message:`Array must contain at least ${i} matching ${Rv(i)}; found ${s}`,input:n,continue:!0}),t.maxContains!==void 0&&s>t.maxContains&&o.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${Rv(t.maxContains)}`,input:n,continue:!0})}}}).pipe(e)}function Mv(e,t){if(e!==!1)return e===void 0||e===!0?j.any():be(e,t)}var pS=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function Lv(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return j.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return j.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);let i=sS(n,t),a=be(i,t);return t.refs.set(n,a),t.processing.delete(n),a}if(e.enum!==void 0){let n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return j.null();if(n.length===0)return j.never();if(n.length===1)return j.literal(n[0]);if(n.every(a=>typeof a=="string"))return j.enum(n);let i=n.map(a=>j.literal(a));return i.length<2?i[0]:j.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return j.literal(e.const);let r=e.type;if(Array.isArray(r)){let n=r.map(i=>{let a={...e,type:i};return Lv(a,t)});return n.length===0?j.never():n.length===1?n[0]:j.union(n)}if(!r)return j.any();let o;switch(r){case"string":{let n=j.string();if(e.format){let i=e.format;i==="email"?n=n.check(j.email()):i==="uri"||i==="uri-reference"?n=n.check(j.url()):i==="uuid"||i==="guid"?n=n.check(j.uuid()):i==="date-time"?n=n.check(j.iso.datetime({offset:!0})):i==="date"?n=n.check(j.iso.date()):i==="time"?n=n.check(j.regex(pS)):i==="duration"?n=n.check(j.iso.duration()):i==="hostname"?n=n.check(j.hostname()):i==="ipv4"?n=n.check(j.ipv4()):i==="ipv6"?n=n.check(j.ipv6()):i==="mac"?n=n.check(j.mac()):i==="cidr"?n=n.check(j.cidrv4()):i==="cidr-v6"?n=n.check(j.cidrv6()):i==="base64"?n=n.check(j.base64()):i==="base64url"?n=n.check(j.base64url()):i==="e164"?n=n.check(j.e164()):i==="credit_card"?n=n.check(j.creditCard()):i==="iban"?n=n.check(j.iban()):i==="jwt"?n=n.check(j.jwt()):i==="emoji"?n=n.check(j.emoji()):i==="nanoid"?n=n.check(j.nanoid()):i==="cuid"?n=n.check(j.cuid()):i==="cuid2"?n=n.check(j.cuid2()):i==="ulid"?n=n.check(j.ulid()):i==="xid"?n=n.check(j.xid()):i==="ksuid"&&(n=n.check(j.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),o=n;break}case"number":case"integer":{let n=r==="integer"?j.number().int():j.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),o=n;break}case"boolean":{o=j.boolean();break}case"null":{o=j.null();break}case"object":{let n={},i=e.properties||{},a=new Set(e.required||[]),s=typeof e.additionalProperties=="object"?be(e.additionalProperties,t):void 0;for(let[p,m]of Object.entries(i)){let f=be(m,t);ue(n,p,a.has(p)?f:f.optional())}if(e.patternProperties){let p=e.patternProperties,m=Object.keys(p),f=[];for(let y of m){let x=be(p[y],t),P=j.string().regex(new RegExp(y));f.push(j.looseRecord(P,x))}let g=[];if(Object.keys(n).length>0&&g.push(j.object(n).passthrough()),g.push(...f),g.length===0)o=j.object({}).passthrough();else if(g.length===1)o=g[0];else{let y=j.intersection(g[0],g[1]);for(let x=2;x<g.length;x++)y=j.intersection(y,g[x]);o=y}if(e.additionalProperties===!1){let y=Object.keys(n),x=m.map(I=>new RegExp(I)),P=o;o=o.check(I=>{if(!Ue(I.value))return;let A=[];for(let S of Object.keys(I.value))y.includes(S)||x.some(z=>z.test(S))||A.push(S);A.length&&I.issues.push({code:"unrecognized_keys",keys:A,input:I.value,inst:P})})}}else{let p=j.object(n);e.additionalProperties===!1?o=p.strict():s?o=p.catchall(s):o=p.passthrough()}let u=e.propertyNames!==void 0&&e.propertyNames!==!0,l=typeof e.minProperties=="number"?e.minProperties:void 0,d=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(u||l!==void 0||d!==void 0){let p;if(u){let m=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;p=be(m,t)}o=cS(o,{keySchema:p,minProperties:l,maxProperties:d})}break}case"array":{let n=e.prefixItems,i=e.items;if(n&&Array.isArray(n)){let a=typeof e.minItems=="number"?e.minItems:0,s=n.map(p=>be(p,t)),u=Ev(s,a),l=Array.isArray(i)?void 0:Mv(i,t),d=j.tuple(u);o=l?d.rest(l):d,typeof e.minItems=="number"&&(o=o.check(j.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(j.maxLength(e.maxItems)))}else if(Array.isArray(i)){let a=typeof e.minItems=="number"?e.minItems:0,s=i.map(p=>be(p,t)),u=Ev(s,a),l=Mv(e.additionalItems,t),d=j.tuple(u);o=l?d.rest(l):d,typeof e.minItems=="number"&&(o=o.check(j.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(j.maxLength(e.maxItems)))}else if(i!==void 0){let a=be(i,t),s=j.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),o=s}else o=j.array(j.any());(e.uniqueItems===!0||e.contains!==void 0)&&(o=dS(o,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?be(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${r}`)}return o}function be(e,t){if(typeof e=="boolean")return e?j.any():j.never();let r=Lv(e,t),o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(l=>be(l,t)),u=j.union(s);r=o?j.intersection(r,u):u}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(l=>be(l,t)),u=j.xor(s);r=o?j.intersection(r,u):u}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=o?r:j.any();else{let s=o?r:be(e.allOf[0],t),u=o?0:1;for(let l=u;l<e.allOf.length;l++)s=j.intersection(s,be(e.allOf[l],t));r=s}e.nullable===!0&&t.version==="openapi-3.0"&&(r=j.nullable(r)),e.readOnly===!0&&(r=j.readonly(r)),e.default!==void 0&&(r=r.default(e.default));let n={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of i)s in e&&(n[s]=e[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in e&&(n[s]=e[s]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!ti(e.propertyNames)&&(n.propertyNames=e.propertyNames);for(let s of["minProperties","maxProperties"])e[s]!==void 0&&(n[s]=e[s])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!ti(e.contains)&&(n.contains=e.contains);for(let s of["uniqueItems","minContains","maxContains"])e[s]!==void 0&&(n[s]=e[s])}for(let s of Object.keys(e))iS.has(s)||ue(n,s,e[s]);return Object.keys(n).length>0&&t.registry.add(r,n),e.description&&(r=r.describe(e.description)),r}function Zv(e,t){if(typeof e=="boolean")return e?j.any():j.never();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let o=oS(r,t?.defaultTarget),n=r.$defs||r.definitions||{},i={version:o,defs:n,refs:new Map,processing:new Set,rootSchema:r,registry:t?.registry??le};return be(r,i)}var Fv=Symbol("z.visit/resolving");function ni(e,t){let r=typeof t=="function"?t:(a,s)=>{let u=t[a._zod.def.type];return u?u(a,s):a},o=new Map;function n(a){let s=o.get(a);if(s===Fv)return new Ar({type:"lazy",getter:()=>o.get(a)});if(s!==void 0)return s;o.set(a,Fv);let u=i(a),l=r(u,u!==a);return o.set(a,l),l}function i(a){let s=a._zod.def,u=s.type;switch(u){case"object":{let l=s.shape,d=Object.keys(l),p=!1,m={};for(let g of d){let y=n(l[g]);y!==l[g]&&(p=!0),m[g]=y}let f=s.catchall;return s.catchall&&(f=n(s.catchall),f!==s.catchall&&(p=!0)),p?F(a,{...s,shape:m,catchall:f}):a}case"array":{let l=n(s.element);return l===s.element?a:F(a,{...s,element:l})}case"tuple":{let l=s.items,d=!1,p=[];for(let f of l){let g=n(f);g!==f&&(d=!0),p.push(g)}let m=s.rest;return s.rest&&(m=n(s.rest),m!==s.rest&&(d=!0)),d?F(a,{...s,items:p,rest:m}):a}case"record":case"map":{let l=n(s.keyType),d=n(s.valueType);return l===s.keyType&&d===s.valueType?a:F(a,{...s,keyType:l,valueType:d})}case"set":{let l=n(s.valueType);return l===s.valueType?a:F(a,{...s,valueType:l})}case"union":{let l=s.options,d=!1,p=[];for(let m of l){let f=n(m);f!==m&&(d=!0),p.push(f)}return d?F(a,{...s,options:p}):a}case"intersection":{let l=n(s.left),d=n(s.right);return l===s.left&&d===s.right?a:F(a,{...s,left:l,right:d})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let l=n(s.innerType);return l===s.innerType?a:F(a,{...s,innerType:l})}case"pipe":{let l=n(s.in),d=n(s.out);return l===s.in&&d===s.out?a:F(a,{...s,in:l,out:d})}case"function":{let l=n(s.input),d=n(s.output);return l===s.input&&d===s.output?a:F(a,{...s,input:l,output:d})}case"lazy":{let l=s.getter,{_cachedInner:d,...p}=s;return F(a,{...p,getter:()=>n(l())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return a;default:return a}}return n(e)}function Vv(e){return ni(e,{object:t=>t.partial(),union:t=>{let r=t._zod.def;return r.discriminator===void 0?t:Wn(r.options)}})}function fS(e,t){if(!t?.length)return e;let r=e._zod.def;return F(e,Me(r,{checks:[...r.checks??[],...t]}),{parent:!0})}function Kv(e){return fS(e.out,e.checks)}function mS(e){return e.in._zod.traits.has("$ZodTransform")?Kv(e):e.in}function Jv(e){return ni(e,{pipe:t=>mS(t._zod.def),default:(t,r)=>r?Bt(t._zod.def.innerType):t,catch:(t,r)=>r?t._zod.def.innerType:t})}function Bv(e){return ni(e,{pipe:t=>Kv(t._zod.def),prefault:(t,r)=>r?t._zod.def.innerType:t})}var Mp={};tt(Mp,{bigint:()=>yS,boolean:()=>vS,date:()=>$S,number:()=>hS,string:()=>gS});function gS(e){return sl(Vn,e)}function hS(e){return fl(Kn,e)}function vS(e){return bl(Jn,e)}function yS(e){return xl(Bn,e)}function $S(e){return Nl(Br,e)}var qn=c.string().min(1).max(512).refine(bS,"Invalid path: use segments like notes/plan.md, without .. or a leading /");function bS(e){return/[\u0000-\u001f\u007f\\]/.test(e)?!1:e.split("/").every(r=>r.length>0&&r.length<=255&&r!=="."&&r!=="..")}var ri=c.string().regex(fe("message")),q=c.string().regex(fe("thread")),ze=c.string().regex(fe("project")),Pe=c.string().regex(fe("task")),Lp=c.string().regex(fe("artifact")),R=c.iso.datetime(),ii=c.enum(["user","agent","system"]),_S=c.object({path:qn,name:c.string(),size:c.number().int().nonnegative(),contentType:c.string()}),xS=c.object({artifactId:Lp,version:c.number().int().positive(),title:c.string()}),Wv=c.enum(["cloud","local"]),H=c.number().int().nonnegative(),kS=c.object({title:c.string(),harness:c.string(),runtime:Wv,model:c.string().nullable(),durationMs:H,inputTokens:H,outputTokens:H,costMicros:H.nullable()}),wS=c.object({chars:H,limit:H,parts:c.object({instructions:H,skills:H,knowledge:H,brief:H,conversation:H,notes:H,other:H}),droppedMessages:H,droppedNotes:H,cut:c.boolean()}),SS=c.object({model:c.string(),durationMs:H,calls:H,inputTokens:H,cachedInputTokens:H,outputTokens:H,costMicros:H.nullable(),runtime:Wv,computer:c.string().optional(),harness:c.string().optional(),task:kS.optional(),prompt:wS.optional()}),IS=c.enum(["brief","follow_up","reply","relay","answer"]),zS=c.object({kind:IS,threadId:q,fromThreadId:q.optional(),note:c.string()}),za=8,Ht=c.object({id:ri,projectId:ze,threadId:q.nullable(),authorKind:ii,authorId:c.string().min(1),body:c.string(),attachments:c.array(_S).optional(),artifacts:c.array(xS).optional(),stats:SS.optional(),relay:zS.optional(),clis:c.array(c.string().max(40)).max(za).optional(),seq:c.number().int().positive(),createdAt:R,editedAt:R.optional()}),PS=c.enum(["working","blocked","review_ready","done","failed"]),jS=c.object({id:c.string().max(40),options:c.array(c.string().max(40)).max(za),by:c.enum(["person","coordinator"]),reason:c.string().max(300).nullable()}),AS=c.object({cli:c.string().max(40),model:c.string().max(200).nullable(),effort:c.string().max(20).nullable()}),Gv="cloud",OS=c.object({id:c.string().max(60),by:c.enum(["person","auto","coordinator"]),reason:c.string().max(300).nullable().default(null)}),Zp=c.enum(["duplicate","misrouted","cancelled"]),TS=c.object({replies:H,usage:c.object({tokens:H,durationMs:H,costMicros:H.nullable()}).nullable(),planMessageId:ri.nullable()}),Fp=c.object({id:q,projectId:ze,rootMessageId:ri,ackMessageId:ri.nullable().default(null),title:c.string(),status:PS,statusText:c.string().nullable(),resolved:c.boolean(),closeReason:Zp.nullable().default(null),duplicateOf:q.nullable().default(null),label:c.string().nullable(),cli:jS.nullable().default(null),runner:OS.nullable().default(null),model:AS.nullable().default(null),seenSeq:c.number().int().nonnegative().nullable().default(null),summary:TS.nullable().default(null),createdAt:R,updatedAt:R}),NS=c.enum(["running","done","failed","cancelled"]),qv=c.object({id:Pe,threadId:q,title:c.string(),harness:c.string(),backend:c.string(),status:NS,prUrl:c.string().nullable(),summary:c.string().nullable(),createdAt:R,finishedAt:R.nullable()}),aN=c.object({ref:c.string(),commits:c.array(c.object({hash:c.string(),message:c.string(),at:c.string()})),entries:c.array(c.object({name:c.string(),path:c.string(),type:c.enum(["file","folder"])})).nullable(),file:c.object({path:c.string(),text:c.string().nullable(),size:c.number(),truncated:c.boolean()}).nullable()}),Vp=c.object({id:c.string().min(1).max(200),label:c.string().max(100),state:c.enum(["started","done","failed"]).optional(),model:c.string().max(200).optional(),tokens:c.number().int().nonnegative().optional()}),Hv=c.object({stream:c.enum(["stdout","stderr","system"]),text:c.string(),at:c.number().optional(),ms:c.number().nonnegative().optional(),tool:c.boolean().optional(),agent:Vp.optional()}),Kp=c.object({messageId:ri,emoji:c.string().min(1).max(32),authorKind:ii,authorId:c.string().min(1)}),Pa=c.enum(["owner","admin","member"]),DS=c.object({working:c.number().int().nonnegative(),waiting:c.number().int().nonnegative()}),US=c.object({monthMicros:c.number().int().nonnegative(),totalMicros:c.number().int().nonnegative()}),ja=c.enum(["indigo","blue","teal","green","amber","orange","red","pink","purple","gray"]),Aa=c.enum(["folder","rocket","code","terminal","globe","smartphone","server","database","cpu","bot","book","pen","palette","camera","music","gamepad","briefcase","cart","chart","shield","flask","leaf","heart","star","zap","home"]),sN=c.object({id:ze,name:c.string().min(1).max(120),role:Pa,icon:Aa.nullable().optional(),color:ja.nullable().optional(),createdAt:R,activity:DS.optional(),cost:US.optional(),pinned:c.boolean().optional()}),cN=c.object({pinned:c.boolean()}),uN=c.object({name:c.string().trim().min(1).max(120)}),lN=c.object({id:c.string(),name:c.string(),role:Pa,email:c.string().optional()}),Jp=32e3,CS=c.object({id:c.number().int(),accountLogin:c.string(),accountType:c.enum(["User","Organization"]),accountAvatarUrl:c.string().nullable()}),dN=c.object({configured:c.boolean(),installUrl:c.string().nullable(),installations:c.array(CS)}),pN=c.object({id:c.number().int(),installationId:c.number().int(),fullName:c.string(),defaultBranch:c.string(),private:c.boolean(),description:c.string().nullable()}),fN=c.object({repoId:c.number().int(),installationId:c.number().int(),fullName:c.string(),defaultBranch:c.string(),private:c.boolean(),createdAt:R}),Xv=c.object({repo:c.string(),number:c.number().int(),url:c.string(),threadId:q,title:c.string(),state:c.enum(["open","closed","merged"]),draft:c.boolean(),checks:c.enum(["pending","success","failure"]).nullable(),review:c.enum(["approved","changes_requested"]).nullable(),conflict:c.boolean().default(!1),branch:c.string().default(""),additions:c.number().int().nullable().default(null),deletions:c.number().int().nullable().default(null),changedFiles:c.number().int().nullable().default(null),updatedAt:R}),ES=c.object({path:c.string(),previousPath:c.string().nullable(),status:c.enum(["added","removed","modified","renamed","copied","changed","unchanged"]),additions:c.number().int(),deletions:c.number().int(),patch:c.string().nullable()}),mN=c.object({files:c.array(ES),truncated:c.boolean()}),Yv=c.enum(["merge","squash","rebase"]),gN=c.object({permitted:c.boolean(),blocked:c.enum(["closed","draft","conflict","checks_failed","checks_pending","changes_requested","protected","checking"]).nullable(),methods:c.array(Yv),sha:c.string()}),hN=c.object({method:Yv,sha:c.string().min(1),deleteBranch:c.boolean().default(!1)}),vN=c.object({merged:c.literal(!0),branchDeleted:c.boolean(),branchKept:c.enum(["fork","default","protected","gone","in_use","reopened","failed"]).nullable()}),yN=c.object({installationId:c.number().int().positive(),repoId:c.number().int().positive()});var RS=16e3,MS=16e3,kN=25*1024*1024,Qv=10;var wN=c.object({path:qn,size:c.number().int().nonnegative(),contentType:c.string(),updatedAt:R,updatedByKind:ii,updatedBy:c.string()}),LS=c.string().trim().min(1).max(80).regex(/^[\p{L}\p{N}][\p{L}\p{N} _.-]*$/u,"Use letters, numbers, spaces, dots, dashes or underscores"),ZS=c.enum(["ok","stale"]),FS=c.object({name:LS,description:c.string().max(300),content:c.string().max(MS),updatedAt:R,updatedByKind:ii,updatedBy:c.string(),status:ZS.default("ok"),staleReason:c.string().max(300).nullable().default(null),verifiedAt:R.nullable().default(null),previousContent:c.string().nullable().default(null),previousAt:R.nullable().default(null)}),SN=FS.pick({description:!0,content:!0}),IN=c.discriminatedUnion("status",[c.object({status:c.literal("ok")}),c.object({status:c.literal("stale"),reason:c.string().trim().min(1).max(300)})]),VS=c.object({text:c.string().max(RS),updatedAt:R.nullable(),updatedBy:c.string().nullable()}),zN=VS.pick({text:!0}),ey=c.enum(["files","memory","instructions"]),ty=c.enum(["auto","on","off"]),PN=c.object({mode:ty,active:c.boolean(),lastRunAt:R.nullable(),threadsSince:c.number().int().nonnegative(),threadsNeeded:c.number().int().positive(),threadId:c.string().nullable()}),jN=c.object({mode:ty});var Bp=c.object({id:Lp,projectId:ze,threadId:q.nullable(),title:c.string(),description:c.string().nullable(),version:c.number().int().positive(),createdAt:R,updatedAt:R}),NN=c.object({version:c.number().int().positive(),size:c.number().int().nonnegative(),threadId:q.nullable(),createdAt:R}),DN=c.object({version:c.number().int().positive(),url:c.string().nullable(),expiresAt:R.nullable()}),UN=2*1024*1024;var Wp=c.string().regex(fe("routine")),KS=/^(\*|\d+(-\d+)?)(\/\d+)?(,(\*|\d+(-\d+)?)(\/\d+)?)*$/,JS=c.string().trim().refine(e=>{let t=e.split(/\s+/);return t.length===5&&t.every(r=>KS.test(r))},"Expected a five-field cron expression, e.g. 0 9 * * 1-5"),BS=c.string().min(1).max(64).refine(e=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:e}),!0}catch{return!1}},"Unknown time zone"),Gp=c.discriminatedUnion("kind",[c.object({kind:c.literal("cron"),cron:JS,timezone:BS.default("UTC")}),c.object({kind:c.literal("once"),at:R})]),qp=c.discriminatedUnion("kind",[c.object({kind:c.literal("coordinator")}),c.object({kind:c.literal("thread"),threadId:q})]),Hp=c.object({id:Wp,projectId:ze,name:c.string(),prompt:c.string(),target:qp,schedule:Gp,paused:c.boolean(),nextRunAt:R.nullable(),lastRunAt:R.nullable(),runCount:c.number().int().nonnegative(),createdBy:c.string(),createdAt:R}),LN=c.object({name:c.string().trim().min(1).max(120),prompt:c.string().trim().min(1).max(8e3),target:qp.default({kind:"coordinator"}),schedule:Gp}),ZN=c.object({name:c.string().trim().min(1).max(120),prompt:c.string().trim().min(1).max(8e3),target:qp,schedule:Gp,paused:c.boolean()}).partial();var Xp=c.object({text:c.string(),until:c.string(),createdBy:c.string(),createdAt:c.string(),wakes:c.number().int().nonnegative(),threads:c.number().int().nonnegative(),idle:c.number().int().nonnegative()});var WS=c.string().regex(fe("sshHost")),Yp=c.string().regex(/^[a-z0-9][a-z0-9_-]{0,39}$/,"Use lowercase letters, digits, - and _ (up to 40)."),Oa=c.string().trim().min(1).max(253).regex(/^(?:[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]*[A-Za-z0-9])?)*\.?|\[?[0-9A-Fa-f:.]+\]?)$/,"Enter a host name or IP address."),ny=c.string().trim().regex(/^[A-Za-z0-9_][A-Za-z0-9_.-]{0,63}$/,"Enter the user name on the server."),ry=c.enum(["ask","off"]),GN=c.string().max(16e3).regex(/^(?:ssh|ecdsa|sk)-[\w@.-]+ [A-Za-z0-9+/=]+(?: .*)?$/),iy=c.string().max(200).regex(/^SHA256:[A-Za-z0-9+/=]+$/),GS=c.object({id:WS,projectId:ze,alias:Yp,host:c.string(),port:c.number().int(),user:c.string(),runnerId:c.string(),runnerName:c.string(),mine:c.boolean(),keySource:c.enum(["new","existing"]),publicKey:c.string().nullable(),keyFingerprint:c.string().nullable(),hostFingerprint:c.string().nullable(),rule:ry,testedAt:R.nullable(),createdAt:R}),qS=c.object({id:c.string(),alias:c.string(),threadId:c.string().nullable(),command:c.string(),reason:c.string().nullable(),decision:c.enum(["once","turn","deny","timeout","failed"]),approvedBy:c.string().nullable(),exitCode:c.number().int().nullable(),ms:c.number().int().nullable(),at:R}),qN=c.object({hosts:c.array(GS),history:c.array(qS)}),HN=c.object({runnerId:c.string(),alias:Yp,host:Oa,port:c.number().int().min(1).max(65535).default(22),user:ny,existingKey:c.string().min(1).max(1024).optional()}),XN=c.object({rule:ry}),YN=c.object({hostKey:c.string().min(1).max(16e3)}),oy=c.object({type:c.string().max(60),key:c.string().max(16e3),fingerprint:iy}),ay=c.object({path:c.string().max(1024),name:c.string().max(255),type:c.string().max(60),fingerprint:iy,comment:c.string().max(500)}),sy=c.object({exitCode:c.number().int().nullable(),stdout:c.string(),stderr:c.string(),truncated:c.boolean(),ms:c.number().int().nonnegative(),error:c.enum(["hostkey","auth","connect","timeout","nokey","other"]).optional()}),cy=300*1e3,uy=200*1024,Ta=c.object({projectId:ze,alias:Yp}),Qp=Ta.extend({host:Oa,port:c.number().int().min(1).max(65535),user:ny,hostKey:c.string().min(1).max(16e3)});var py=2,st=c.string().regex(fe("runner")),Ge=c.enum(["claude","codex","antigravity","opencode","hermes","cursor","muse","kimi"]),tf={claude:"Claude Code",codex:"Codex CLI",antigravity:"Antigravity CLI",opencode:"OpenCode",hermes:"Hermes Agent",cursor:"Cursor CLI",muse:"Muse Code",kimi:"Kimi Code"},fy=c.object({path:c.string().min(1).max(1024),name:c.string().max(255)}),HS=c.object({kind:c.string().max(40),usedPercent:c.number().min(0).max(1e3).nullable(),resetsAt:R.nullable()}),XS=c.object({status:c.enum(["ok","warning","limited"]).optional(),windows:c.array(HS).max(8),at:R});var YS=c.object({id:c.string().min(1).max(200),name:c.string().max(200),efforts:c.array(c.string().min(1).max(20)).max(10)});var QS=c.object({id:Ge,version:c.string().max(200).nullable(),limits:XS.optional().catch(void 0),models:c.array(YS).max(100).optional().catch(void 0)}),eI=c.enum(["folders","cancel","agent","agent-clis","connectors","skills","project-folders","files","settings","update","models","github-token","git-token","steer","steer-claude","ssh"]),tI=c.discriminatedUnion("transport",[c.object({transport:c.literal("http"),name:c.string().regex(/^[a-z][a-z0-9_-]{0,40}$/),path:c.string().regex(/^\/api\/[\w/-]+$/).max(300)}),c.object({transport:c.literal("stdio"),name:c.string().regex(/^[a-z][a-z0-9_-]{0,40}$/),command:c.string().min(1).max(200),args:c.array(c.string().max(2e3)).max(50),env:c.record(c.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/),c.string().max(4e3))})]),nI=c.enum(["read","edit","auto","full"]),nf=c.object({access:nI,worktrees:c.boolean(),autoUpdate:c.boolean(),remote:c.boolean()}),my=nf.omit({remote:!0}).partial(),rI=c.enum(["service","app","manual"]),ef=c.object({state:c.enum(["waiting","downloading","restarting","failed","rolled-back"]),version:c.string().max(50),running:c.number().int().nonnegative().optional(),message:c.string().max(500).optional(),at:R}),gy=c.object({version:c.string().max(50),hostname:c.string().max(255),platform:c.string().max(50),folders:c.array(fy).max(200),clis:c.array(c.unknown()).max(10).transform(e=>e.flatMap(t=>{let r=QS.safeParse(t);return r.success?[r.data]:[]})),features:c.array(c.string().max(50)).max(20).default([]).transform(e=>e.filter(t=>eI.safeParse(t).success)),settings:nf.optional().catch(void 0),updates:rI.optional().catch(void 0),update:ef.optional().catch(void 0)}),Na=1e5,Q=c.string().min(1).max(64),iI=c.object({name:c.string().max(255),path:c.string().max(1024)}),oI=c.object({path:c.string().max(1024),parent:c.string().max(1024).nullable(),home:c.string().max(1024),dirs:c.array(iI).max(1e3)}),ly=c.object({inputTokens:c.number().int().nonnegative(),outputTokens:c.number().int().nonnegative(),model:c.string().max(200).optional()}),rf=512*1024,aI=c.object({path:c.string().max(4096),size:c.number().int().nonnegative(),data:c.string().max(Math.ceil(rf/3)*4+4),truncated:c.boolean()}),sI=c.object({model:c.string().min(1).max(200).optional(),effort:c.string().min(1).max(20).optional()}),dy=c.object({token:c.string().min(20).max(4096),expiresAt:R,repos:c.array(c.string().regex(/^[\w.-]+\/[\w.-]+$/).max(200)).max(100)}),iD=c.discriminatedUnion("type",[gy.extend({type:c.literal("hello"),protocol:c.number().int().positive(),running:c.array(Pe).max(100).default([]),interrupted:c.array(Pe).max(100).default([])}),c.object({type:c.literal("task.progress"),taskId:Pe,text:c.string().max(2e3),usage:ly.optional(),agent:Vp.optional(),ms:c.number().nonnegative().optional()}),c.object({type:c.literal("task.done"),taskId:Pe,ok:c.boolean(),usage:ly.optional(),result:c.string().max(Na),cancelled:c.boolean().optional()}),c.object({type:c.literal("ping")}),c.object({type:c.literal("task.folders"),taskId:Pe,folders:c.array(c.string().min(1).max(1024)).max(60)}),oI.extend({type:c.literal("dirs"),requestId:Q}),c.object({type:c.literal("folders"),requestId:Q,folders:c.array(fy).max(200)}),c.object({type:c.literal("request.failed"),requestId:Q,message:c.string().max(500)}),aI.extend({type:c.literal("file"),requestId:Q}),c.object({type:c.literal("settings"),requestId:Q,settings:nf}),c.object({type:c.literal("update.accepted"),requestId:Q,update:ef}),c.object({type:c.literal("update.status"),update:ef.nullable()}),c.object({type:c.literal("task.steered"),requestId:Q,taken:c.boolean()}),c.object({type:c.literal("ssh.key"),requestId:Q,publicKey:c.string().max(16e3),fingerprint:c.string().max(200),protected:c.boolean()}),c.object({type:c.literal("ssh.keylist"),requestId:Q,keys:c.array(ay).max(100)}),c.object({type:c.literal("ssh.hostkeylist"),requestId:Q,keys:c.array(oy).max(10)}),sy.extend({type:c.literal("ssh.result"),requestId:Q})]),hy=c.discriminatedUnion("type",[c.object({type:c.literal("welcome"),runnerId:st,name:c.string()}),c.object({type:c.literal("task.start"),taskId:Pe,threadId:q,folder:c.string().min(1).max(1024),cli:Ge,prompt:c.string().min(1).max(Na),model:sI.optional(),folders:c.array(c.string().min(1).max(1024)).max(50).optional(),agent:c.object({mcpPath:c.string().regex(/^\/api\/[\w/-]+$/).max(300),token:c.string().min(20).max(200),connectors:c.array(tI).max(30).optional(),skills:c.object({path:c.string().regex(/^\/api\/[\w/-]+$/).max(300)}).optional(),resume:c.object({after:Pe,prompt:c.string().min(1).max(Na)}).optional()}).optional(),github:dy.optional()}),c.object({type:c.literal("task.github"),taskId:Pe,github:dy}),c.object({type:c.literal("task.steer"),requestId:Q,taskId:Pe,text:c.string().min(1).max(Na)}),c.object({type:c.literal("task.cancel"),taskId:Pe}),c.object({type:c.literal("pong")}),c.object({type:c.literal("dirs.list"),requestId:Q,path:c.string().max(1024).optional()}),c.object({type:c.literal("folder.share"),requestId:Q,path:c.string().min(1).max(1024)}),c.object({type:c.literal("folder.unshare"),requestId:Q,path:c.string().min(1).max(1024)}),c.object({type:c.literal("file.read"),requestId:Q,path:c.string().min(1).max(4096),folders:c.array(c.string().min(1).max(1024)).min(1).max(51),threadId:q.optional()}),c.object({type:c.literal("settings.set"),requestId:Q,settings:my}),c.object({type:c.literal("runner.update"),requestId:Q,version:c.string().regex(/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/).max(50),now:c.boolean().default(!1)}),Ta.extend({type:c.literal("ssh.keygen"),requestId:Q,comment:c.string().max(200),existing:c.string().min(1).max(1024).optional()}),c.object({type:c.literal("ssh.keys"),requestId:Q}),c.object({type:c.literal("ssh.hostkeys"),requestId:Q,host:Oa,port:c.number().int().min(1).max(65535)}),c.object({type:c.literal("ssh.test"),requestId:Q,target:Qp}),c.object({type:c.literal("ssh.run"),requestId:Q,target:Qp,command:c.string().min(1).max(2e4)}),Ta.extend({type:c.literal("ssh.forget"),requestId:Q})]),cI=gy.extend({id:st,name:c.string(),version:c.string().nullable(),online:c.boolean(),lastSeenAt:R.nullable(),createdAt:R}),oD=c.object({name:c.string().trim().min(1).max(80).optional(),settings:my.optional()}),aD=c.object({now:c.boolean().default(!1)}),sD=c.object({runners:c.array(cI),latestVersion:c.string().nullable()}),cD=c.object({code:c.string(),expiresAt:R}),uD=c.object({code:c.string().trim().min(4).max(20),name:c.string().trim().min(1).max(80),hostname:c.string().max(255).default(""),platform:c.string().max(50).default("")}),vy=c.object({runner:c.object({id:st,name:c.string()}),token:c.string()}),lD=c.object({projectId:ze,runnerId:st,runnerName:c.string(),path:c.string(),folders:c.array(c.string()).default([]),cli:Ge,online:c.boolean(),isDefault:c.boolean().default(!0)}),dD=c.object({path:c.string().trim().min(1).max(1024)}),pD=c.object({runnerId:st,path:c.string().min(1).max(1024),cli:Ge,add:c.boolean().optional()}),fD=c.object({path:c.string().min(1).max(1024),runnerId:st.optional()}),mD=c.object({runnerId:st});function yy(e,t){let r=i=>i.split("-")[0].split(".").map(a=>Number.parseInt(a,10)||0),[o,n]=[r(e),r(t)];for(let i=0;i<3;i++)if((o[i]??0)!==(n[i]??0))return(o[i]??0)>(n[i]??0);return!1}var uI=200,lI=c.object({threadId:q.nullable(),hasEarlier:c.boolean()});var wD=c.discriminatedUnion("type",[c.object({type:c.literal("message.send"),clientId:c.string().max(64).optional(),threadId:q.nullable().default(null),body:c.string().trim().max(Jp),attachments:c.array(qn).max(Qv).default([]),clis:c.array(Ge).max(za).optional()}).refine(e=>e.body.length>0||e.attachments.length>0,"Write something or attach a file"),c.object({type:c.literal("message.edit"),messageId:Ht.shape.id,body:c.string().trim().max(Jp)}),c.object({type:c.literal("thread.resolve"),threadId:q,resolved:c.boolean(),reason:Zp.optional()}),c.object({type:c.literal("thread.cli"),threadId:q,cli:Ge.nullable()}),c.object({type:c.literal("thread.runner"),threadId:q,runnerId:c.union([st,c.literal(Gv)]).nullable()}),c.object({type:c.literal("thread.model"),threadId:q,cli:Ge,model:c.string().trim().min(1).max(200).nullable(),effort:c.string().trim().min(1).max(20).nullable()}),c.object({type:c.literal("goal.stop")}),c.object({type:c.literal("sync"),afterSeq:c.number().int().nonnegative(),all:c.boolean().optional(),recent:c.number().int().positive().max(uI).optional()})]),SD=c.discriminatedUnion("type",[c.object({type:c.literal("message.created"),message:Ht}),c.object({type:c.literal("message.updated"),message:Ht}),c.object({type:c.literal("message.ack"),clientId:c.string(),messageId:Ht.shape.id,seq:Ht.shape.seq}),c.object({type:c.literal("sync.result"),messages:c.array(Ht),hasMore:c.boolean(),streamed:c.boolean().optional(),threads:c.array(Fp).default([]),reactions:c.array(Kp).default([]),artifacts:c.array(Bp).default([]),routines:c.array(Hp).default([]),goal:Xp.nullable().optional(),windows:c.array(lI).optional(),reset:c.boolean().optional(),lastSeq:c.number().int().nonnegative().optional()}),c.object({type:c.literal("thread.updated"),thread:Fp}),c.object({type:c.literal("reaction.added"),reaction:Kp}),c.object({type:c.literal("artifact.updated"),artifact:Bp}),c.object({type:c.literal("routine.updated"),routine:Hp}),c.object({type:c.literal("routine.deleted"),routineId:Wp}),c.object({type:c.literal("goal.updated"),goal:Xp.nullable()}),c.object({type:c.literal("agent.activity"),threadId:q.nullable(),active:c.boolean(),label:c.string().max(200).optional()}),c.object({type:c.literal("knowledge.changed"),kind:ey}),c.object({type:c.literal("workspace.changed")}),c.object({type:c.literal("task.updated"),task:qv}),c.object({type:c.literal("task.output"),taskId:Pe,threadId:q,lines:c.array(Hv)}),c.object({type:c.literal("pr.updated"),pullRequest:Xv}),c.object({type:c.literal("error"),code:c.string(),message:c.string()})]);var PD=c.object({app:c.literal("myrel"),apiVersion:c.number().int().positive(),name:c.string(),auth:c.object({emailPassword:c.boolean(),signUp:c.boolean().default(!0),emailVerification:c.boolean().default(!1),captcha:c.object({provider:c.literal("turnstile"),siteKey:c.string()}).nullable().default(null),passwordReset:c.boolean().default(!1)}),billing:c.boolean().default(!1),legal:c.object({terms:c.string().url(),privacy:c.string().url(),version:c.string()}).nullable().default(null)});var OD=c.object({question:c.string().min(1).max(300),options:c.array(c.object({label:c.string().min(1).max(40),consequence:c.string().max(200).default("")})).min(2).max(4),recommended:c.number().int().nonnegative().optional(),danger:c.boolean().optional()});var oi=c.enum(["fireworks","anthropic","openai"]),RD=c.object({id:oi,name:c.string(),defaultModel:c.string(),serverKey:c.boolean()}),MD=c.object({id:c.string(),provider:oi,label:c.string(),hint:c.string(),scope:c.enum(["user","instance"]),createdAt:c.iso.datetime()}),LD=c.object({provider:oi,label:c.string().trim().min(1).max(80),key:c.string().trim().min(8).max(500),scope:c.enum(["user","instance"]).default("user")}),$y=c.enum(["auto","local","cloud"]),by=c.enum(["opencode","claude","codex"]),dI=c.object({model:c.string().trim().min(1).max(200).nullable(),effort:c.string().trim().min(1).max(20).nullable()}),_y=c.partialRecord(Ge,dI),ZD=c.object({name:c.string(),provider:oi.nullable(),model:c.string().nullable(),keyId:c.string().nullable(),taskTarget:$y,icon:Aa.nullable().default(null),color:ja.nullable().default(null),cloudCli:by.default("opencode"),cliModels:_y.default({})}),FD=c.object({name:c.string().trim().min(1).max(120).optional(),provider:oi.nullable().optional(),model:c.string().trim().max(200).nullable().optional(),keyId:c.string().nullable().optional(),taskTarget:$y.optional(),icon:Aa.nullable().optional(),color:ja.nullable().optional(),cloudCli:by.optional(),cliModels:_y.optional()}),xy=c.enum(["admin","member"]),VD=c.object({id:c.string(),projectId:c.string(),projectName:c.string(),email:c.string(),role:xy,invitedBy:c.string(),createdAt:c.iso.datetime()}),KD=c.object({email:c.email().trim().toLowerCase(),role:xy.default("member")}),JD=c.object({role:Pa}),pI=c.enum(["admin","user"]),BD=c.enum(["computer","decision"]),WD=c.object({id:c.string(),name:c.string(),email:c.string(),role:pI,onboarded:c.boolean().optional(),tips:c.array(c.string()).optional()}),fI=c.object({signUpEnabled:c.boolean()}),mI=c.enum(["api","agent","cron","web","desktop","mobile"]),GD=c.object({platform:c.enum(["web","desktop","mobile"]),where:c.string().trim().min(1).max(200),name:c.string().max(100).default("Error"),message:c.string().max(500),stack:c.string().max(4e3).optional(),version:c.string().max(40).optional()}),qD=c.object({id:c.string(),source:mI,where:c.string(),name:c.string(),message:c.string(),stack:c.string().nullable(),count:c.number().int(),firstSeenAt:c.number(),lastSeenAt:c.number()}),HD=c.object({days:c.number().int(),signedUp:c.number().int(),verified:c.number().int(),inProject:c.number().int(),asked:c.number().int(),threadRan:c.number().int(),pairedComputer:c.number().int()}),XD=fI.partial();var ky=c.string().regex(fe("notification")),gI=c.enum(["done","ready","decision","blocked","failed"]),nU=c.object({id:ky,projectId:ze,threadId:q.nullable(),kind:gI,title:c.string(),body:c.string(),url:c.string(),readAt:R.nullable(),createdAt:R}),rU=c.object({email:c.boolean(),push:c.boolean()}),iU=c.object({webPushKey:c.string().nullable(),email:c.boolean()}),hI=[/^fcm\.googleapis\.com$/,/^updates\.push\.services\.mozilla\.com$/,/^web\.push\.apple\.com$/,/^[a-z0-9-]+\.notify\.windows\.com$/];function vI(e){try{let t=new URL(e);return t.protocol==="https:"&&hI.some(r=>r.test(t.hostname))}catch{return!1}}var oU=c.discriminatedUnion("kind",[c.object({kind:c.literal("webpush"),endpoint:c.url().max(2048).refine(vI,"Not a browser push service"),keys:c.object({p256dh:c.string().min(1).max(256),auth:c.string().min(1).max(64)})}),c.object({kind:c.literal("expo"),token:c.string().regex(/^Expo(nent)?PushToken\[[^\]]+\]$/).max(256)})]),aU=c.union([c.object({ids:c.array(ky).min(1).max(200)}),c.object({all:c.literal(!0)})]);var yI=new RegExp(fe("thread").source.slice(1,-1)),pU=new RegExp(`^#(${yI.source})$`);var $I=c.enum(["http","stdio"]),bI=c.enum(["user","project"]),af=c.enum(["cloud","local","both"]),_I=c.enum(["unknown","ok","error","needs_auth"]),xI=c.enum(["none","headers","oauth"]),wy=c.string().regex(/^[a-z][a-z0-9_-]{0,31}$/).refine(e=>e!=="myrel","That name is taken by Myrel's own tools."),kI=c.object({name:c.string(),description:c.string().optional()}),wI=/^[A-Za-z_][\w-]{0,99}$/,SI=/^[A-Za-z_][A-Za-z0-9_]{0,99}$/,Sy=(e,t,r)=>c.record(c.string().regex(e),c.string().max(4e3),{error:o=>o.code==="invalid_key"?`${t} name ${JSON.stringify(o.input)} is not valid: use only ${r}, with no spaces or ":". Put the value in its own field.`:void 0}),Iy=Sy(wI,"Header","letters, digits, - and _"),II=Sy(SI,"Variable","letters, digits and _"),gU=c.object({id:c.string(),name:c.string(),slug:c.string(),scope:bI,transport:$I,url:c.string().nullable(),auth:xI,command:c.string().nullable(),args:c.array(c.string()),runsOn:af,secretNames:c.array(c.string()),enabled:c.boolean(),status:_I,lastError:c.string().nullable(),tools:c.array(kI),canEdit:c.boolean(),createdAt:c.iso.datetime(),official:c.object({id:c.string(),title:c.string(),iconUrl:c.string().nullable()}).nullable().default(null)}),of=c.string().trim().min(1).max(60),hU=c.discriminatedUnion("transport",[c.object({transport:c.literal("http"),name:of,slug:wy.optional(),url:c.url({protocol:/^https$/}).max(2e3),auth:c.enum(["headers","oauth"]).default("headers"),headers:Iy.default({})}),c.object({transport:c.literal("stdio"),name:of,slug:wy.optional(),command:c.string().trim().min(1).max(200),args:c.array(c.string().max(2e3)).max(50).default([]),env:II.default({}),runsOn:af.default("both")})]),vU=c.object({name:of.optional(),enabled:c.boolean().optional(),url:c.url({protocol:/^https$/}).max(2e3).optional(),command:c.string().trim().min(1).max(200).optional(),args:c.array(c.string().max(2e3)).max(50).optional(),runsOn:af.optional(),secrets:Iy.optional()});var yU=c.object({authorizeUrl:c.url()});var zI=["developer","productivity","communication","design","data","sales","finance","search","ai","other"],zy=c.enum(zI);var PI=c.object({id:c.string(),title:c.string(),description:c.string(),websiteUrl:c.string().nullable(),iconUrl:c.string().nullable(),url:c.string(),auth:c.enum(["oauth","headers"]),headerHint:c.object({name:c.string(),placeholder:c.string()}).nullable(),category:zy,official:c.boolean()}),$U=c.object({connectors:c.array(PI),nextOffset:c.number().nullable(),syncedAt:c.iso.datetime().nullable(),categories:c.array(c.object({id:zy,count:c.number()}))}),jI=[{id:"com.notion/mcp",category:"productivity"},{id:"app.linear/linear",category:"productivity"},{id:"com.atlassian/atlassian-mcp-server",category:"productivity"},{id:"com.figma.mcp/mcp",category:"design"},{id:"com.stripe/mcp",category:"finance"},{id:"com.canva.mcp/mcp",category:"design"},{id:"com.vercel/vercel-mcp",category:"developer"},{id:"com.gitlab/mcp",category:"developer"},{id:"io.github.PostHog/mcp",category:"data"},{id:"com.zapier/mcp",category:"productivity"},{id:"com.airtable/mcp",category:"data"},{id:"com.monday/monday.com",category:"productivity"},{id:"com.paypal.mcp/mcp",category:"finance"},{id:"com.webflow/mcp",category:"design"},{id:"com.wix/mcp",category:"design"},{id:"com.neon/mcp",category:"developer"},{id:"com.railway/mcp",category:"developer"},{id:"co.huggingface/hf-mcp-server",category:"ai"},{id:"com.cloudflare.mcp/mcp",category:"developer"},{id:"com.apify/apify-mcp-server",category:"search"},{id:"ai.exa/exa",category:"search"},{id:"com.microsoft/microsoft-learn-mcp",category:"search"}],bU=jI.map(e=>e.id);var AI=c.enum(["user","project"]),OI=c.string().max(64).regex(/^[a-z0-9]+(-[a-z0-9]+)*$/,"Use lowercase letters, digits and hyphens, like pdf-forms."),Py=c.string().trim().min(1).max(1024),TI=c.string().min(1).max(300).regex(/^[\w@+=,.~ -]+(\/[\w@+=,.~ -]+)*$/,"Invalid file path.").refine(e=>!e.split("/").some(t=>t==="."||t===".."),"Invalid file path."),jy={files:200,bytes:5*1024*1024,fileBytes:1024*1024};var NI=c.discriminatedUnion("kind",[c.object({kind:c.literal("write")}),c.object({kind:c.literal("upload")}),c.object({kind:c.literal("github"),repo:c.string(),path:c.string(),ref:c.string().optional(),commit:c.string()})]),DI=c.object({path:c.string(),size:c.number().int().nonnegative()}),UI=c.object({id:c.string(),name:c.string(),description:c.string(),scope:AI,source:NI,enabled:c.boolean(),files:c.array(DI),size:c.number().int().nonnegative(),canEdit:c.boolean(),createdAt:c.iso.datetime(),updatedAt:c.iso.datetime()}),kU=UI.extend({skillMd:c.string()}),CI=c.object({path:TI,content:c.string().max(Math.ceil(jy.fileBytes*4/3)+4)}),wU=c.discriminatedUnion("kind",[c.object({kind:c.literal("write"),name:OI,description:Py,instructions:c.string().max(1e5)}),c.object({kind:c.literal("upload"),files:c.array(CI).min(1).max(jy.files)}),c.object({kind:c.literal("github"),source:c.string().trim().min(3).max(500),skill:c.string().max(64).optional()})]),SU=c.object({error:c.literal("choose_skill"),skills:c.array(c.object({name:c.string(),description:c.string(),path:c.string()}))}),IU=c.object({enabled:c.boolean().optional(),description:Py.optional(),instructions:c.string().max(1e5).optional()}),zU=c.object({skills:c.array(c.object({name:c.string(),files:c.array(c.object({path:c.string(),content:c.string()}))}))});var PU=c.object({on:c.boolean()});var EI=c.object({id:c.string().min(1).max(200),name:c.string().min(1).max(80),description:c.string().max(300).default(""),url:c.string().max(2e3),auth:c.enum(["oauth","headers"]),headerHint:c.object({name:c.string(),placeholder:c.string()}).nullable().default(null),iconUrl:c.string().nullable().default(null),official:c.boolean().default(!1),featured:c.boolean().default(!1)}),RI=c.enum(["open","connected","dismissed"]),OU=c.object({id:c.string(),reason:c.string().min(1).max(400),offers:c.array(EI).min(1).max(3),state:RI.default("open"),connected:c.string().optional(),signIn:c.boolean().optional()});var TU=c.object({offerId:c.string().min(1).max(200),headers:c.record(c.string().regex(/^[A-Za-z_][\w-]{0,99}$/),c.string().min(1).max(4e3)).optional()}),NU=c.object({authorizeUrl:c.string().optional(),connected:c.boolean()});var MI=/^(?:\/(?:usr\/)?(?:local\/)?bin\/)?(?:ba|z|da|k)?sh\s+-l?c\s+(\S[\s\S]*)$/;function Hn(e){let t=MI.exec(e.trim());return t?LI(t[1])??e:e}function LI(e){let t="",r=0;for(;r<e.length;){let o=e[r];if(o==="'"){let n=e.indexOf("'",r+1);if(n<0)return null;t+=e.slice(r+1,n),r=n+1}else if(o==='"'){for(r++;;){if(r>=e.length)return null;let n=e[r];if(n==='"')break;n==="\\"&&r+1<e.length&&'"\\$`\n'.includes(e[r+1])?(t+=e[r+1],r+=2):(t+=n,r++)}r++}else if(o==="\\"){if(r+1>=e.length)return null;t+=e[r+1],r+=2}else{if(/\s/.test(o)||"|&;<>()$`".includes(o))return null;t+=o,r++}}return t}import{spawn as ZI}from"node:child_process";import{mkdir as FI,readFile as Ny,rename as VI,writeFile as KI}from"node:fs/promises";import{homedir as Dy}from"node:os";import{dirname as JI,join as Ay}from"node:path";import{createInterface as Uy}from"node:readline";var lf="MYREL_MCP_BRIDGE";function BI(e=Dy()){return{mcp:Ay(e,".gemini","config","mcp_config.json"),settings:Ay(e,".gemini","antigravity-cli","settings.json")}}function ai(){let e=process.argv[1],t=!e||/\$bunfs|~BUN/.test(e);return{command:process.execPath,args:t?[]:[e]}}async function Cy(e,t=Dy()){let r=BI(t),o=ai(),n={command:o.command,args:[...o.args,"mcp-bridge"]};await Oy(r.mcp,a=>{let s=sf(a.mcpServers)?a.mcpServers:{};return JSON.stringify(s[e])===JSON.stringify(n)?!1:(a.mcpServers={...s,[e]:n},!0)});let i=`mcp(${e}/*)`;await Oy(r.settings,a=>{let s=sf(a.permissions)?a.permissions:{},u=Array.isArray(s.allow)?s.allow:[];return u.includes(i)?!1:(a.permissions={...s,allow:[...u,i]},!0)})}async function Oy(e,t){let r=await Ny(e,"utf8").catch(i=>{if(i.code==="ENOENT")return"";throw i}),o={};if(r.trim())try{o=JSON.parse(r)}catch{throw new Error(`Could not read ${e} as JSON, so Myrel's tools were not added to Antigravity CLI. Fix the file and try again.`)}if(!sf(o))throw new Error(`${e} is not a JSON object, so Myrel's tools were not added to Antigravity CLI.`);if(!t(o))return;await FI(JI(e),{recursive:!0});let n=`${e}.myrel-${process.pid}`;await KI(n,`${JSON.stringify(o,null,2)}
|
|
64
64
|
`,{mode:384}),await VI(n,e)}function sf(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Xt=class extends Error{constructor(r){super(typeof r?.message=="string"?r.message:"MCP error");this.error=r}error},cf=class{constructor(t,r){this.url=t;this.token=r}url;token;session;version;next=1;async request(t,r){let o=this.next++,n=await this.post({jsonrpc:"2.0",id:o,method:t,...r!==void 0&&{params:r}}),i=await this.answer(n,o);if(t==="initialize"&&(this.version=i.result?.protocolVersion),i.error)throw new Xt(i.error);return i.result}async notify(t,r){await(await this.post({jsonrpc:"2.0",method:t,...r!==void 0&&{params:r}})).body?.cancel()}close(){}async post(t){let r=await fetch(this.url,{method:"POST",headers:{"content-type":"application/json",accept:"application/json, text/event-stream",authorization:`Bearer ${this.token}`,...this.session&&{"mcp-session-id":this.session},...this.version&&{"mcp-protocol-version":this.version}},body:JSON.stringify(t)});if(this.session=r.headers.get("mcp-session-id")??this.session,!r.ok&&r.status!==202)throw await r.body?.cancel(),new Error(`${this.url} answered ${r.status}`);return r}async answer(t,r){if(!(t.headers.get("content-type")??"").includes("text/event-stream"))return await t.json();let o=t.body.pipeThrough(new TextDecoderStream).getReader(),n="";try{for(;;){let{done:i,value:a}=await o.read();if(i)break;n+=a;let s;for(;(s=n.search(/\r?\n\r?\n/))>=0;){let u=n.slice(0,s);n=n.slice(s).replace(/^\r?\n\r?\n/,"");let l=u.split(/\r?\n/).filter(p=>p.startsWith("data:")).map(p=>p.slice(5).trimStart()).join(`
|
|
65
65
|
`);if(!l)continue;let d=JSON.parse(l);if(d.id===r)return d}}}finally{o.cancel().catch(()=>{})}throw new Error(`${this.url} closed the stream without an answer`)}},uf=class{child;waiting=new Map;next=1;constructor(t,r,o){this.child=ZI(t,r,{env:{...process.env,...o},stdio:["pipe","pipe","inherit"],shell:process.platform==="win32"}),this.child.on("error",()=>this.fail(`could not start ${t}`)),this.child.on("exit",()=>this.fail(`${t} exited`)),Uy({input:this.child.stdout}).on("line",n=>{try{let i=JSON.parse(n);typeof i.id=="number"&&!i.method&&this.waiting.get(i.id)?.(i)}catch{}})}request(t,r){let o=this.next++;return new Promise((n,i)=>{this.waiting.set(o,a=>{this.waiting.delete(o),a.error?i(new Xt(a.error)):n(a.result)}),this.write({jsonrpc:"2.0",id:o,method:t,...r!==void 0&&{params:r}})})}async notify(t,r){this.write({jsonrpc:"2.0",method:t,...r!==void 0&&{params:r}})}close(){this.child.kill()}write(t){this.child.stdin?.write(`${JSON.stringify(t)}
|
|
66
66
|
`)}fail(t){for(let[r,o]of this.waiting)o({jsonrpc:"2.0",id:r,error:{code:-32e3,message:t}})}},WI="__";async function Ey(e){let{run:t,write:r}=e,o=new Map;for(let f of t?.servers??[])o.set(f.name,f.transport==="http"?new cf(f.url,t.token):new uf(f.command,f.args,f.env));let n=t?.servers[0]?.name,i=new Map,a,s,u=f=>a??=Promise.all([...o].map(async([g,y])=>{try{return await y.request("initialize",f),await y.notify("notifications/initialized"),g}catch(x){return process.stderr.write(`myrel-runner mcp-bridge: ${g}: ${x.message}
|
|
@@ -83,7 +83,7 @@ ${e$[t]}`:e,agent:async e=>({args:[],mcpServers:s$(e)}),line:(e,t)=>t.acp?.recei
|
|
|
83
83
|
`)[0]??"").slice(0,200)}import{randomBytes as Yz}from"node:crypto";import{createServer as Qz}from"node:http";var d$="MYREL_GIT_CREDENTIALS",e0=40,Ja=class{lent=new Map;keyOf=new Map;port=null;server=null;async lend(t,r){let o=Yz(32).toString("hex");this.keyOf.set(t,o),this.lent.set(o,{token:r.token,expiresAt:Date.parse(r.expiresAt)});try{return t0(`http://127.0.0.1:${await this.listen()}/${o}`,r.repos)}catch(n){throw this.end(t),n}}renew(t,r){let o=this.keyOf.get(t);o&&this.lent.set(o,{token:r.token,expiresAt:Date.parse(r.expiresAt)})}end(t){let r=this.keyOf.get(t);r&&(this.keyOf.delete(t),this.lent.delete(r),this.lent.size===0&&this.server&&(this.server.close(),this.server=null,this.port=null))}listen(){return this.port??=new Promise((t,r)=>{let o=Qz((n,i)=>{let a=n.method==="GET"?this.lent.get((n.url??"").slice(1)):void 0;if(!a||a.expiresAt<=Date.now()){i.writeHead(404).end();return}i.writeHead(200,{"content-type":"text/plain","cache-control":"no-store"}),i.end(`username=x-access-token
|
|
84
84
|
password=${a.token}
|
|
85
85
|
`)});o.once("error",n=>{this.server=null,this.port=null,r(n)}),this.server=o,o.listen(0,"127.0.0.1",()=>{o.unref(),t(o.address().port)})}),this.port}};function t0(e,t,r=process.env.GIT_CONFIG_PARAMETERS,o=ai()){let n=`!${[o.command,...o.args].map(r0).join(" ")} git-credential`,i=[],a=[...new Set(t.slice(0,e0).flatMap(u=>[u,u.toLowerCase()]))];for(let u of a){for(let l of[`https://github.com/${u}`,`https://github.com/${u}.git`])i.push([`credential.${l}.helper`,""],[`credential.${l}.helper`,n]);i.push([`url.https://github.com/${u}.git.insteadOf`,`git@github.com:${u}.git`],[`url.https://github.com/${u}.git.insteadOf`,`ssh://git@github.com/${u}.git`])}let s=i.map(([u,l])=>n0(`${u}=${l}`)).join(" ");return{[d$]:e,GIT_CONFIG_PARAMETERS:r?`${r} ${s}`:s}}var n0=e=>`'${e.replaceAll("'","'\\''")}'`;function r0(e){return`"${(process.platform==="win32"?e.replaceAll("\\","/"):e).replace(/["\\$`]/g,"\\$&")}"`}async function p$(e,t,r){let o="";for await(let a of t)o+=String(a);let n=process.env[d$];if(e!=="get"||!n)return;let i=new Map(o.split(`
|
|
86
|
-
`).filter(a=>a.includes("=")).map(a=>[a.slice(0,a.indexOf("=")),a.slice(a.indexOf("=")+1)]));if(!(i.get("protocol")!=="https"||i.get("host")!=="github.com"))try{let a=await fetch(n,{signal:AbortSignal.timeout(5e3)});a.ok&&r(await a.text())}catch{}}import{watchFile as
|
|
86
|
+
`).filter(a=>a.includes("=")).map(a=>[a.slice(0,a.indexOf("=")),a.slice(a.indexOf("=")+1)]));if(!(i.get("protocol")!=="https"||i.get("host")!=="github.com"))try{let a=await fetch(n,{signal:AbortSignal.timeout(5e3)});a.ok&&r(await a.text())}catch{}}import{watchFile as QP,unwatchFile as ej}from"node:fs";import{hostname as Jf,platform as kb}from"node:os";import{open as J0,realpath as O$,stat as B0}from"node:fs/promises";import{isAbsolute as W0,join as G0,relative as q0,resolve as H0,sep as A$}from"node:path";import{spawn as Z0}from"node:child_process";import{mkdtemp as w$,realpath as S$,rm as I$,writeFile as F0}from"node:fs/promises";import{tmpdir as z$}from"node:os";import{join as kf}from"node:path";var Ba=class{constructor(t,r,o){this.io=t;this.opts=r;this.state=o}io;opts;state;nextId=0;pending=new Map;finished=!1;prompting=!1;start(){this.call("initialize",{protocolVersion:1,clientCapabilities:{fs:{readTextFile:!1,writeTextFile:!1},terminal:!1}},t=>{let{cwd:r,mcpServers:o,resume:n,dirs:i=[]}=this.opts,a=t?.agentCapabilities?.sessionCapabilities,s=i.length&&a?.additionalDirectories?{additionalDirectories:i}:{};n?this.call("session/resume",{sessionId:n,cwd:r,mcpServers:o},()=>this.opened(n)):this.call("session/new",{cwd:r,mcpServers:o,...s},u=>{this.configured(u),this.opened(String(u.sessionId??""))})})}receive(t){let r;try{r=JSON.parse(t)}catch{return}if(r.method&&r.id!==void 0)return this.answer(r);if(r.method==="session/update")return this.update(r.params?.update??{});if(typeof r.id=="number"){let o=this.pending.get(r.id);this.pending.delete(r.id),o?.(r)}}opened(t){if(!t)return this.fail("The agent started no session.");this.state.sessionId=t;let r=()=>{this.prompting=!0,this.call("session/prompt",{sessionId:t,prompt:[{type:"text",text:this.opts.prompt}]},i=>{let{stopReason:a,usage:s}=i??{};if(s){let u=l=>typeof l=="number"&&l>0?Math.round(l):0;this.state.usage={inputTokens:u(s.inputTokens),outputTokens:u(s.outputTokens)+u(s.thoughtTokens)}}this.state.failed=a==="refusal"||a==="cancelled",this.state.result=(this.state.draft??"").trim(),this.state.failed&&!this.state.result&&(this.state.result=`The agent stopped: ${String(a)}.`),this.finish()})},o=[...this.opts.config??[]],n=()=>{let i=o.shift();if(!i)return r();this.request("session/set_config_option",{sessionId:t,configId:i.id,value:i.value},a=>{a.error||this.configured(a.result),n()})};this.opts.mode?this.call("session/set_mode",{sessionId:t,modeId:this.opts.mode},n):n()}configured(t){let r=t?.configOptions;if(!Array.isArray(r))return;let o=r.find(n=>n.category==="model");typeof o?.currentValue=="string"&&o.currentValue&&(this.state.model=o.currentValue)}update(t){if(!this.prompting)return;let r=t.content;t.sessionUpdate==="agent_message_chunk"&&typeof r?.text=="string"&&(this.state.draft=(this.state.draft??"")+r.text,this.state.draft.trim()&&(this.state.progress=this.state.draft.trim().slice(0,2e3))),t.sessionUpdate==="tool_call"&&(this.state.draft=void 0,typeof t.title=="string"&&t.title&&(this.state.progress=t.title.slice(0,2e3)))}answer(t){if(t.method==="session/request_permission"){let r=t.params??{},o=r.options??[],n=this.opts.allow||this.ownTool(r.toolCall?.title),i=o.find(s=>s.kind===(n?"allow_once":"reject_once")),a=i?{outcome:"selected",optionId:i.optionId}:{outcome:"cancelled"};return this.send({jsonrpc:"2.0",id:t.id,result:{outcome:a}})}this.send({jsonrpc:"2.0",id:t.id,error:{code:-32601,message:`${t.method} is not offered by myrel-runner`}})}ownTool(t){let{serverTools:r,mcpServers:o}=this.opts;return!!r&&typeof t=="string"&&o.some(n=>t.startsWith(r(n.name)))}call(t,r,o){this.request(t,r,n=>n.error?this.fail(n.error.message||`${t} failed`):o(n.result))}request(t,r,o){let n=++this.nextId;this.pending.set(n,o),this.send({jsonrpc:"2.0",id:n,method:t,params:r})}fail(t){this.state.failed=!0,this.state.result=t,this.finish()}finish(){this.finished||(this.finished=!0,this.io.end())}send(t){this.io.write(`${JSON.stringify(t)}
|
|
87
87
|
`)}};import{request as i0}from"node:http";import{request as o0}from"node:https";var B=e=>e&&typeof e=="object"?e:{},J=e=>typeof e=="string"&&e?e:void 0,Wa=e=>typeof e=="number"&&Number.isFinite(e)&&e>0?Math.round(e):0,a0=e=>e.trim().slice(0,2e3),Ga=class{constructor(t,r,o){this.io=t;this.opts=r;this.state=o}io;opts;state;nextId=0;pending=new Map;finished=!1;threadId;turnId;stopping=!1;steering=new Set;changes=new Map;start(){this.call("initialize",{clientInfo:{name:"myrel-runner",title:"Myrel",version:this.opts.clientVersion}},()=>{this.send({jsonrpc:"2.0",method:"initialized"});let{cwd:t,resume:r,sandbox:o,approvalPolicy:n,model:i,config:a}=this.opts,s={cwd:t,sandbox:o,approvalPolicy:n,...i?.model&&{model:i.model},...a&&{config:a}};r?this.call("thread/resume",{...s,threadId:r},u=>this.opened(u)):this.call("thread/start",s,u=>this.opened(u))})}interrupt(){return this.finished?!1:(this.stopping=!0,this.threadId&&this.turnId&&this.request("turn/interrupt",{threadId:this.threadId,turnId:this.turnId},()=>{}),!0)}steer(t){let{threadId:r,turnId:o}=this;return this.finished||this.stopping||!r||!o?Promise.resolve(!1):new Promise(n=>{let i=a=>{this.steering.delete(i),n(a)};this.steering.add(i),this.request("turn/steer",{threadId:r,expectedTurnId:o,input:[{type:"text",text:t}]},a=>i(!a.error))})}receive(t){if(!t.startsWith("{"))return;let r;try{r=JSON.parse(t)}catch{return}if(r.method&&r.id!==void 0)return void this.answer(r);if(r.method)return this.notified(r.method,B(r.params));if(typeof r.id=="number"){let o=this.pending.get(r.id);this.pending.delete(r.id),o?.(r)}}opened(t){let r=B(B(t).thread),o=J(r.id);if(!o)return this.fail("Codex started no session.");this.threadId=o,this.state.sessionId=o;let n=J(B(t).model)??J(r.model);n&&(this.state.model=n);let i=this.opts.model?.effort;this.call("turn/start",{threadId:o,input:[{type:"text",text:this.opts.prompt}],...i&&{effort:i}},a=>{this.turnId=J(B(B(a).turn).id),this.stopping&&this.interrupt()})}notified(t,r){if(this.threadId&&r.threadId!==void 0&&r.threadId!==this.threadId)return this.subagent(t,r,String(r.threadId));switch(t){case"item/started":case"item/completed":return this.item(t,B(r.item));case"thread/tokenUsage/updated":return this.addUsage(r);case"account/rateLimits/updated":{let o=s0(r.rateLimits);o&&(this.state.limits=o);return}case"model/rerouted":{let o=J(r.toModel)??J(r.model);o&&(this.state.model=o);return}case"error":{let o=J(B(r.error).message);o&&(this.state.error=o);return}case"turn/completed":return this.completed(B(r.turn))}}subagent(t,r,o){if(t==="item/started"||t==="item/completed")return this.item(t,B(r.item),o);if(t==="thread/tokenUsage/updated"){let n=B(B(r.tokenUsage).last);return Ma(this.state,o,Wa(n.inputTokens)+Wa(n.outputTokens)),this.addUsage(r)}}addUsage(t){let r=B(B(t.tokenUsage).last),o=this.state.usage??={inputTokens:0,outputTokens:0};o.inputTokens+=Wa(r.inputTokens),o.outputTokens+=Wa(r.outputTokens)}item(t,r,o){let n=i=>si(this.state,a0(i),o);switch(r.type){case"commandExecution":{if(t!=="item/started")return;let a=J(B(r.commandActions?.[0]).command)??Hn(J(r.command)??"");a&&n(`$ ${a}`);return}case"fileChange":{let i=Array.isArray(r.changes)?r.changes.map(a=>J(B(a).path)).filter(a=>!!a):[];typeof r.id=="string"&&i.length&&this.changes.set(r.id,i),t==="item/started"&&i.length&&n(`Edit ${i.join(", ")}`);return}case"mcpToolCall":t==="item/started"&&n(`${J(r.server)??"mcp"}.${J(r.tool)??"tool"}`);return;case"webSearch":t==="item/started"&&J(r.query)&&n(`Search ${J(r.query)}`);return;case"agentMessage":{let i=J(r.text)?.trim();if(t!=="item/completed"||!i)return;n(i),o||(this.state.result=i);return}case"collabAgentToolCall":return this.collab(t,r);case"subAgentActivity":{let i=J(r.agentThreadId);if(!i)return;r.kind==="started"?Yn(this.state,i,l0(r.agentPath),"",{model:J(r.model)}):r.kind==="completed"?Pt(this.state,i,!0):r.kind==="interrupted"&&Pt(this.state,i,!1);return}}}collab(t,r){let o=Array.isArray(r.receiverThreadIds)?r.receiverThreadIds.filter(n=>typeof n=="string"):[];if(r.tool==="spawnAgent")for(let n of o)Yn(this.state,n,"",J(r.prompt)??"",{model:J(r.model)});if(t==="item/completed")for(let[n,i]of Object.entries(B(r.agentsStates))){let a=B(i),s=J(a.message)??"";a.status==="completed"||a.status==="shutdown"?Pt(this.state,n,!0,s):(a.status==="errored"||a.status==="interrupted")&&Pt(this.state,n,!1,s)}}completed(t){if(this.turnId&&t.id!==void 0&&t.id!==this.turnId)return;let r=t.status;if(r!=="completed"){this.state.failed=!0;let o=J(B(t.error).message)??this.state.error;r==="interrupted"?this.state.result??="Codex stopped.":this.state.result=o??`Codex ended the turn: ${String(r)}.`}else this.state.failed=!1;this.finish()}async answer(t){let r=B(t.params),o=n=>this.send({jsonrpc:"2.0",id:t.id,result:n});switch(t.method){case"item/commandExecution/requestApproval":{let i=J(B(r.commandActions?.[0]).command)??Hn(J(r.command)??""),a=!!i&&await this.ask("Bash",{command:i,...J(r.reason)&&{description:J(r.reason)}});return o({decision:a?"accept":"decline"})}case"item/fileChange/requestApproval":{let n=[...J(r.grantRoot)?[J(r.grantRoot)]:[],...this.changes.get(String(r.itemId))??[]],i=n.length>0;for(let a of n)i&&(i=await this.ask("Edit",{file_path:a}));return o({decision:i?"accept":"decline"})}case"item/permissions/requestApproval":{let n=B(r.permissions),i=B(n.fileSystem),a=[...i.write??[],...i.read??[]].filter(l=>typeof l=="string"),s=B(n.network).enabled===!0,u=a.length>0||s;for(let l of a)u&&(u=await this.ask("Edit",{file_path:l}));return u&&s&&(u=await this.ask("Bash",{command:J(r.reason)??"network access"})),o({permissions:u?n:{},scope:"turn"})}case"mcpServer/elicitation/request":return o({action:"decline"});case"applyPatchApproval":case"execCommandApproval":return o({decision:"denied"});default:return this.send({jsonrpc:"2.0",id:t.id,error:{code:-32601,message:`${t.method} is not offered by myrel-runner`}})}}async ask(t,r){return!this.opts.ask||this.finished?!1:this.opts.ask(t,r).catch(()=>!1)}call(t,r,o){this.request(t,r,n=>n.error?this.fail(n.error.message||`${t} failed`):o(n.result))}request(t,r,o){let n=++this.nextId;this.pending.set(n,o),this.send({jsonrpc:"2.0",id:n,method:t,params:r})}fail(t){this.state.failed=!0,this.state.result=t,this.finish()}finish(){if(!this.finished){this.finished=!0;for(let t of[...this.steering])t(!1);this.io.end()}}send(t){this.finished||this.io.write(`${JSON.stringify(t)}
|
|
88
88
|
`)}};function s0(e){let t=B(e),r=o=>{let n=B(o);return Object.keys(n).length?{used_percent:n.usedPercent,window_minutes:n.windowDurationMins,resets_at:n.resetsAt}:null};return pf({primary:r(t.primary),secondary:r(t.secondary)},new Date().toISOString())}var c0=900*1e3;function f$(e,t){return(r,o)=>new Promise(n=>{let i=JSON.stringify({jsonrpc:"2.0",id:1,method:"tools/call",params:{name:"approve_access",arguments:{tool_name:r,input:o}}}),s=(e.startsWith("https:")?o0:i0)(e,{method:"POST",headers:{"content-type":"application/json",accept:"application/json",authorization:`Bearer ${t}`,"content-length":Buffer.byteLength(i)},timeout:c0},u=>{let l="";u.setEncoding("utf8"),u.on("data",d=>{l.length<1e6&&(l+=d)}),u.on("end",()=>n(u.statusCode===200&&u0(l))),u.on("error",()=>n(!1))});s.on("timeout",()=>s.destroy()),s.on("error",()=>n(!1)),s.end(i)})}function u0(e){try{let t=B(B(JSON.parse(e)).result).content,r=Array.isArray(t)?J(B(t[0]).text):void 0;return!!r&&B(JSON.parse(r)).behavior==="allow"}catch{return!1}}function l0(e){return(J(e)??"").split("/").filter(Boolean).pop()??""}var qa=class{constructor(t,r){this.io=t;this.prompt=r}io;prompt;written=0;echoed=0;ended=!1;stopping=!1;requests=0;start(){this.user(this.prompt)}steer(t){return this.ended||this.stopping?Promise.resolve(!1):(this.user(t),Promise.resolve(!0))}interrupt(){return this.ended?!1:(this.stopping=!0,this.io.write(`${JSON.stringify({type:"control_request",request_id:`myrel-${++this.requests}`,request:{subtype:"interrupt"}})}
|
|
89
89
|
`),!0)}receive(t){this.ended||(t.type==="user"&&t.isReplay===!0&&this.echoed++,t.type==="result"&&(this.stopping||this.echoed>=this.written)&&this.end())}end(){this.ended||(this.ended=!0,this.io.end())}user(t){this.written++;let r={type:"user",message:{role:"user",content:[{type:"text",text:t}]},parent_tool_use_id:null,session_id:""};this.io.write(`${JSON.stringify(r)}
|
|
@@ -102,19 +102,19 @@ To run tasks in the folder itself instead, run \`myrel-runner worktrees off\`.`)
|
|
|
102
102
|
(myrel-runner: worked on branch ${i.worktree.branch} in ${i.cwd}, a git worktree of ${n}.)`:"";i&&this.worktrees.set(t.taskId,i.worktree.path),t.agent&&this.send({type:"task.folders",taskId:t.taskId,folders:[a,...u]});let A=t.github?{...g.env,...await this.git.lend(t.taskId,t.github)}:g.env;if(t.agent&&f&&o.server){let S=await y$(f,{url:`${o.server.replace(/\/$/,"")}${t.agent.mcpPath}`,token:t.agent.token}).catch(z=>(s(` could not put Myrel's ssh on PATH: ${j$(z)}`),{}));A={...A,...S}}try{let S=l.appServer&&await c$(l.bin)?{...l.appServer({access:o.access,dirs:u,asks:!!x}),ask:x}:void 0;S&&s(" as its app server");let z=!!l.streamInput&&await u$(l.bin),O={cwd:a,adapter:l,agent:g,env:A,dirs:u,asks:d&&!!f,skills:y,where:I,cleanup:P,appServer:S,stream:z};await this.attempt(t,O,p?.id,m??t.prompt)&&(s(` could not resume the ${l.id} session; starting a new one`),await this.attempt(t,O,void 0,t.prompt))}finally{this.git.end(t.taskId)}}async steer(t,r){return await this.turns.get(t)?.steer(r)??!1}renewGithub(t,r){this.git.renew(t,r)}async attempt(t,r,o,n){let i=this.opts.config(),a=this.opts.log??(()=>{}),{cwd:s,adapter:u,agent:l,dirs:d,skills:p,where:m,cleanup:f}=r,g=p?`${n}
|
|
103
103
|
|
|
104
104
|
Skills folder for this run: ${p.skills}`:n,y=u.input?u.input(g,i.access):g,x=u.promptFile?await w$(kf(z$(),"myrel-prompt-")):void 0,P=x?kf(x,"prompt.md"):void 0;P&&await F0(P,y,{mode:384});let I=[...r.appServer?[]:a$(u,t.model),...l.args],A=r.appServer?["app-server",...l.args]:u.args({access:i.access,resume:o,extra:I,dirs:d,asks:r.asks,promptFile:P,stream:r.stream}),S=(this.opts.spawn??Z0)(u.bin,A,{cwd:s,env:zt(r.env),stdio:["pipe","pipe","pipe"],shell:process.platform==="win32"});if(x){let L=()=>{I$(x,{recursive:!0,force:!0}).catch(()=>{})};S.once("close",L),S.once("error",L)}this.running.set(t.taskId,S),this.opts.onChange?.(this.runningIds());let z={},O="",X="",je="",Qe=0,pt,et="",on,Ot,nr=L=>{!L||L===on||(on=L,this.opts.onLimits?.(t.cli,L))},an=()=>z.usage?{...z.usage,...z.model&&{model:z.model.slice(0,200)}}:void 0,$i=()=>{for(let ie of z.agentNotes?.splice(0)??[])this.send({type:"task.progress",taskId:t.taskId,text:ie.text,agent:ie.agent,...ie.ms!==void 0&&{ms:ie.ms}});let L=an(),ee=L?JSON.stringify(L):"",pe=!!z.progress&&z.progress!==pt;if(pe||ee!==et){pt=z.progress,et=ee,Qe=Date.now();let ie=pe&&z.progressAgent;this.send({type:"task.progress",taskId:t.taskId,text:pe?z.progress:"",...L&&{usage:L},...ie&&{agent:ie}})}};if(S.stdout.setEncoding("utf8"),S.stdout.on("data",L=>{O.length<4*P$&&(O+=L),je+=L;let ee=je.split(`
|
|
105
|
-
`);je=ee.pop();for(let ie of ee)u.line(ie.trim(),z);nr(z.limits),z.sessionId&&z.sessionId!==Ot&&wf.has(t.cli)&&(Ot=z.sessionId,this.opts.sessions.set(t.threadId,t.cli,{id:z.sessionId,task:t.taskId}).catch(()=>{}));let pe=an();(Date.now()-Qe>=V0||pe&&JSON.stringify(pe)!==et||z.agentNotes?.length)&&$i()}),S.stderr.setEncoding("utf8"),S.stderr.on("data",L=>{X.length<2e4&&(X+=L)}),S.stdin.on("error",()=>{}),u.acp){let L={write:pe=>{S.stdin.write(pe)},end:()=>S.stdin.end()},ee={cwd:s,prompt:y,mcpServers:l.mcpServers??[],resume:o,dirs:d,...u.acp(i.access,Ka(t.model))};z.acp=new Ba(L,ee,z),z.acp.start()}else if(r.appServer){let L={write:pe=>{S.stdin.write(pe)},end:()=>S.stdin.end()},ee={cwd:s,prompt:y,resume:o,model:Ka(t.model),clientVersion:this.opts.version??"0",...r.appServer};z.appServer=new Ga(L,ee,z),this.turns.set(t.taskId,z.appServer),z.appServer.start()}else if(r.stream){let L={write:ee=>{S.stdin.write(ee)},end:()=>S.stdin.end()};z.claudeStream=new qa(L,y),this.turns.set(t.taskId,z.claudeStream),z.claudeStream.start()}else S.stdin.end(P?"":y);let rr=setTimeout(()=>S.kill("SIGTERM"),this.opts.timeoutMs??3600*1e3);return await new Promise(L=>{let ee=!1,pe=(ie,w)=>{if(ee)return;if(ee=!0,clearTimeout(rr),f(),this.running.delete(t.taskId),this.turns.delete(t.taskId),this.worktrees.delete(t.taskId),this.opts.onChange?.(this.runningIds()),this.interrupted.delete(t.taskId))return a(`\u25A0 ${u.id} task interrupted; it continues after the runner restarts`),L(!1);if(this.cancelled.delete(t.taskId))return a(`\u25A0 ${u.id} task stopped`),this.send({type:"task.done",taskId:t.taskId,ok:!1,cancelled:!0,result:"Stopped from Myrel."}),L(!1);a(`${ie?"\u2713":"\u2717"} ${u.id} task finished`);let U=an();this.send({type:"task.done",taskId:t.taskId,ok:ie,result:w.slice(0,P$-m.length)+m,...U&&{usage:U}}),L(!1)};S.on("error",ie=>{pe(!1,ie.code==="ENOENT"?`${u.bin} is not installed on this computer, or not on PATH for myrel-runner.`:`Could not start ${u.bin}: ${ie.message}`)}),S.on("exit",()=>{(this.cancelled.has(t.taskId)||this.interrupted.has(t.taskId))&&pe(!1,"")}),S.on("close",async(ie,w)=>{je.trim()&&u.line(je.trim(),z),u.end?.(O,z),nr(z.limits??await u.limits?.(z).catch(()=>{}));let U=ie===0&&!z.failed;if(o&&!U&&!z.usage&&!z.progress&&!this.cancelled.has(t.taskId))return ee=!0,clearTimeout(rr),this.running.delete(t.taskId),this.turns.delete(t.taskId),this.interrupted.has(t.taskId)?(this.interrupted.delete(t.taskId),this.worktrees.delete(t.taskId),this.opts.onChange?.(this.runningIds()),f(),L(!1)):L(!0);z.sessionId&&wf.has(t.cli)&&await this.opts.sessions.set(t.threadId,t.cli,{id:z.sessionId,task:t.taskId}).catch(()=>{});let Z=z.result??(U?O.trim()
|
|
106
|
-
|
|
107
|
-
`
|
|
108
|
-
`,{mode:384})}import{spawn as
|
|
109
|
-
`,timeoutMs:15e3});if(o.code!==0||/error/i.test(o.stderr))throw new Error(`Keychain: ${o.stderr.trim()||`exit ${o.code}`}`)},async get(t){let r=await Xe("security",["find-generic-password","-a",t,"-s",er,"-w"],{timeoutMs:15e3});return r.code===0?r.stdout.replace(/\n$/,""):null},async remove(t){await Xe("security",["delete-generic-password","-a",t,"-s",er],{timeoutMs:15e3}).catch(()=>{})}}:e==="linux"?{async set(t,r){let o=await Xe("secret-tool",["store",`--label=Myrel SSH key ${t}`,"service",er,"account",t],{input:r,timeoutMs:15e3});if(o.code!==0)throw new Error(`Secret Service: ${o.stderr.trim()||`exit ${o.code}`}`)},async get(t){let r=await Xe("secret-tool",["lookup","service",er,"account",t],{timeoutMs:15e3});return r.code===0&&r.stdout?r.stdout.replace(/\n$/,""):null},async remove(t){await Xe("secret-tool",["clear","service",er,"account",t],{timeoutMs:15e3}).catch(()=>{})}}:null}async function
|
|
110
|
-
`).pop()})`:""}.`);return o}var
|
|
111
|
-
`)){if(!o.trim()||o.startsWith("#"))continue;let[,n,i]=o.trim().split(/\s+/);if(!n||!i||!/^[A-Za-z0-9+/=]+$/.test(i))continue;let a=`${n} ${i}`;t.some(s=>s.key===a)||t.push({type:n,key:a,fingerprint:rs(a)})}let r=o=>
|
|
105
|
+
`);je=ee.pop();for(let ie of ee)u.line(ie.trim(),z);nr(z.limits),z.sessionId&&z.sessionId!==Ot&&wf.has(t.cli)&&(Ot=z.sessionId,this.opts.sessions.set(t.threadId,t.cli,{id:z.sessionId,task:t.taskId}).catch(()=>{}));let pe=an();(Date.now()-Qe>=V0||pe&&JSON.stringify(pe)!==et||z.agentNotes?.length)&&$i()}),S.stderr.setEncoding("utf8"),S.stderr.on("data",L=>{X.length<2e4&&(X+=L)}),S.stdin.on("error",()=>{}),u.acp){let L={write:pe=>{S.stdin.write(pe)},end:()=>S.stdin.end()},ee={cwd:s,prompt:y,mcpServers:l.mcpServers??[],resume:o,dirs:d,...u.acp(i.access,Ka(t.model))};z.acp=new Ba(L,ee,z),z.acp.start()}else if(r.appServer){let L={write:pe=>{S.stdin.write(pe)},end:()=>S.stdin.end()},ee={cwd:s,prompt:y,resume:o,model:Ka(t.model),clientVersion:this.opts.version??"0",...r.appServer};z.appServer=new Ga(L,ee,z),this.turns.set(t.taskId,z.appServer),z.appServer.start()}else if(r.stream){let L={write:ee=>{S.stdin.write(ee)},end:()=>S.stdin.end()};z.claudeStream=new qa(L,y),this.turns.set(t.taskId,z.claudeStream),z.claudeStream.start()}else S.stdin.end(P?"":y);let rr=setTimeout(()=>S.kill("SIGTERM"),this.opts.timeoutMs??3600*1e3);return await new Promise(L=>{let ee=!1,pe=(ie,w)=>{if(ee)return;if(ee=!0,clearTimeout(rr),f(),this.running.delete(t.taskId),this.turns.delete(t.taskId),this.worktrees.delete(t.taskId),this.opts.onChange?.(this.runningIds()),this.interrupted.delete(t.taskId))return a(`\u25A0 ${u.id} task interrupted; it continues after the runner restarts`),L(!1);if(this.cancelled.delete(t.taskId))return a(`\u25A0 ${u.id} task stopped`),this.send({type:"task.done",taskId:t.taskId,ok:!1,cancelled:!0,result:"Stopped from Myrel."}),L(!1);a(`${ie?"\u2713":"\u2717"} ${u.id} task finished`);let U=an();this.send({type:"task.done",taskId:t.taskId,ok:ie,result:w.slice(0,P$-m.length)+m,...U&&{usage:U}}),L(!1)};S.on("error",ie=>{pe(!1,ie.code==="ENOENT"?`${u.bin} is not installed on this computer, or not on PATH for myrel-runner.`:`Could not start ${u.bin}: ${ie.message}`)}),S.on("exit",()=>{(this.cancelled.has(t.taskId)||this.interrupted.has(t.taskId))&&pe(!1,"")}),S.on("close",async(ie,w)=>{je.trim()&&u.line(je.trim(),z),u.end?.(O,z),nr(z.limits??await u.limits?.(z).catch(()=>{}));let U=ie===0&&!z.failed;if(o&&!U&&!z.usage&&!z.progress&&!this.cancelled.has(t.taskId))return ee=!0,clearTimeout(rr),this.running.delete(t.taskId),this.turns.delete(t.taskId),this.interrupted.has(t.taskId)?(this.interrupted.delete(t.taskId),this.worktrees.delete(t.taskId),this.opts.onChange?.(this.runningIds()),f(),L(!1)):L(!0);z.sessionId&&wf.has(t.cli)&&await this.opts.sessions.set(t.threadId,t.cli,{id:z.sessionId,task:t.taskId}).catch(()=>{});let Z=z.result??(U?O.trim():K0(u.bin,ie,w,z.error??(X.trim()||O.trim())));pe(U,Z||"(no output)")})})}cancel(t){let r=this.running.get(t);if(!r)return;this.cancelled.add(t);let o=this.turns.get(t)?.interrupt()?5e3:0,n=()=>{r.exitCode===null&&(r.kill("SIGTERM"),setTimeout(()=>r.exitCode===null&&r.kill("SIGKILL"),5e3).unref())};o?setTimeout(n,o).unref():n()}stopAll(){let t=this.runningIds();for(let[r,o]of this.running)this.interrupted.add(r),o.kill("SIGTERM");return t}};async function ts(e,t){let r=await S$(t).catch(()=>null);if(!r)return null;for(let o of e.folders)if(await S$(o.path).catch(()=>null)===r)return r;return null}var j$=e=>(e.stderr||e.message||String(e)).trim().split(`
|
|
106
|
+
`).at(-1);function K0(e,t,r,o){return r==="SIGKILL"?`${e} was killed (SIGKILL), most likely because this computer ran out of memory. Stop programs it does not need (dev servers left running, say) or add swap, then send the message again.`:`${e} exited with ${r??`code ${t}`}.
|
|
107
|
+
${o}`}async function T$(e,t){let r=await X0(e,t.folders,t.threadId);if(!r.length)throw new Error("None of this project's folders is shared on this computer.");let o=Y0(t.path),n=W0(o)?[o]:r.map(i=>H0(i,o));for(let i of n){let a=await O$(i).catch(()=>null);if(!a||!r.some(p=>N$(a,p)))continue;let s=await B0(a);if(!s.isFile())continue;let u=Math.min(s.size,rf),l=Buffer.alloc(u),d=await J0(a,"r");try{await d.read(l,0,u,0)}finally{await d.close()}return{path:a,size:s.size,data:l.toString("base64"),truncated:s.size>u}}throw new Error(`${t.path} is not a file in this project's folders.`)}async function X0(e,t,r){let o=(await Promise.all(t.map(a=>ts(e,a)))).filter(a=>a!==null),n=r?(await Qt()).filter(a=>a.threadId===r):[],i=[];for(let a of o)for(let s of n){if(!N$(a,s.repo))continue;let u=await O$(G0(s.path,q0(s.repo,a))).catch(()=>null);u&&i.push(u)}return[...i,...o]}function Y0(e){let t=e.trim();t.startsWith("file://")&&(t=t.slice(7));try{t=decodeURIComponent(t)}catch{}return t.replace(/#L\d+(-L?\d+)?$/,"").replace(/(:\d+){1,2}$/,"")}function N$(e,t){return e===t||e.startsWith(t.endsWith(A$)?t:t+A$)}import{readdir as Q0,realpath as Sf,stat as D$}from"node:fs/promises";import{homedir as U$}from"node:os";import{dirname as eP,isAbsolute as tP,join as nP,parse as rP}from"node:path";var iP=1e3;async function C$(e){let t=U$(),r=await Sf(e?R$(e):t),n=(await Q0(r,{withFileTypes:!0})).filter(u=>(u.isDirectory()||u.isSymbolicLink())&&!u.name.startsWith(".")).map(u=>({name:u.name,path:nP(r,u.name)})),a=(await Promise.all(n.map(async u=>(await D$(u.path).catch(()=>null))?.isDirectory()?u:null))).filter(u=>u!==null);a.sort((u,l)=>u.name.localeCompare(l.name,void 0,{sensitivity:"base"}));let s=eP(r);return{path:r,parent:s===r?null:s,home:t,dirs:a.slice(0,iP)}}async function E$(e){let t=await Sf(R$(e)).catch(()=>{throw new Error(`${e} does not exist on this computer.`)});if(!(await D$(t)).isDirectory())throw new Error(`${e} is not a folder.`);if(t===rP(t).root||t===await Sf(U$()))throw new Error("Pick a project folder, not your whole home folder or disk.");return t}function R$(e){if(!tP(e))throw new Error(`${e} is not a full path.`);return e}import{readFileSync as oP,rmSync as aP,writeFileSync as sP,mkdirSync as cP}from"node:fs";import{join as M$}from"node:path";var uP=3600*1e3,If=()=>M$(ne(),"interrupted.json"),L$=()=>M$(ne(),"running.json");function Z$(e,t=Date.now()){if(!e.length)return;let r=[...V$(t),...e.map(o=>({taskId:o,at:t}))];J$(If(),r)}function F$(e=Date.now()){let t=[...new Set(V$(e).map(r=>r.taskId))];return aP(If(),{force:!0}),t}function V$(e){let t=K$(If());return Array.isArray(t)?t.filter(r=>typeof r?.taskId=="string"&&e-r.at<uP):[]}function zf(e){try{J$(L$(),{pid:process.pid,running:e})}catch{}}function Pf(){let e=K$(L$());return!e?.pid||!Array.isArray(e.running)||!lP(e.pid)?[]:e.running}function lP(e){try{return process.kill(e,0),!0}catch(t){return t.code==="EPERM"}}function K$(e){try{return JSON.parse(oP(e,"utf8"))}catch{return}}function J$(e,t){cP(ne(),{recursive:!0,mode:448}),sP(e,`${JSON.stringify(t)}
|
|
108
|
+
`,{mode:384})}import{spawn as dP}from"node:child_process";import{createHash as pP,randomBytes as fP}from"node:crypto";import{access as Of,chmod as mP,mkdir as ns,readdir as gP,readFile as Tf,rm as B$,writeFile as G$}from"node:fs/promises";import{homedir as q$}from"node:os";import{dirname as hP,join as dt,relative as vP,resolve as W$}from"node:path";var tn=()=>dt(ne(),"ssh"),pi=()=>dt(tn(),"keys.json"),jf=()=>dt(tn(),"known_hosts"),yP=()=>dt(tn(),"askpass.sh"),er="myrel-runner-ssh",$P=3e4,Nf=e=>dt(tn(),e.projectId,e.alias),en=e=>`${e.projectId}/${e.alias}`,H$=e=>`myrel.${e.projectId}.${e.alias}`;function rs(e){let t=e.trim().split(/\s+/)[1]??"";return`SHA256:${pP("sha256").update(Buffer.from(t,"base64")).digest("base64").replace(/=+$/,"")}`}function Xe(e,t,r={}){let o=r.max??uy;return new Promise((n,i)=>{let a=dP(e,t,{env:r.env??Af(),stdio:[r.input===void 0?"ignore":"pipe","pipe","pipe"],windowsHide:!0}),s="",u="",l=!1,d=!1,p=(f,g)=>f.length+g.length<=o?f+g:(l=!0,f+g.slice(0,Math.max(0,o-f.length)));a.stdout.setEncoding("utf8").on("data",f=>s=p(s,f)),a.stderr.setEncoding("utf8").on("data",f=>u=p(u,f));let m=r.timeoutMs?setTimeout(()=>{d=!0,a.kill("SIGKILL")},r.timeoutMs):void 0;a.once("error",f=>{clearTimeout(m),i(f)}),a.once("close",f=>{clearTimeout(m),n({code:f,stdout:s,stderr:u,truncated:l,timedOut:d})}),r.input!==void 0&&a.stdin.end(r.input)})}function Af(e={}){let t={...process.env,...e};for(let r of["SSH_AUTH_SOCK","SSH_AGENT_PID","SSH_ASKPASS","SSH_ASKPASS_REQUIRE","MYREL_RUNNER_TOKEN"])r in e||delete t[r];return t}function Df(e=process.platform){return e==="darwin"?{async set(t,r){let o=await Xe("security",["-i"],{input:`add-generic-password -U -a "${t}" -s "${er}" -w "${r}"
|
|
109
|
+
`,timeoutMs:15e3});if(o.code!==0||/error/i.test(o.stderr))throw new Error(`Keychain: ${o.stderr.trim()||`exit ${o.code}`}`)},async get(t){let r=await Xe("security",["find-generic-password","-a",t,"-s",er,"-w"],{timeoutMs:15e3});return r.code===0?r.stdout.replace(/\n$/,""):null},async remove(t){await Xe("security",["delete-generic-password","-a",t,"-s",er],{timeoutMs:15e3}).catch(()=>{})}}:e==="linux"?{async set(t,r){let o=await Xe("secret-tool",["store",`--label=Myrel SSH key ${t}`,"service",er,"account",t],{input:r,timeoutMs:15e3});if(o.code!==0)throw new Error(`Secret Service: ${o.stderr.trim()||`exit ${o.code}`}`)},async get(t){let r=await Xe("secret-tool",["lookup","service",er,"account",t],{timeoutMs:15e3});return r.code===0&&r.stdout?r.stdout.replace(/\n$/,""):null},async remove(t){await Xe("secret-tool",["clear","service",er,"account",t],{timeoutMs:15e3}).catch(()=>{})}}:null}async function bP(e,t,r){if(!e)return!1;try{return await e.set(t,r),await e.get(t)===r}catch{return!1}}async function X$(e,t,r,o=Df()){if(await ns(tn(),{recursive:!0,mode:448}),await Uf(e,o),r){let l=await _P(r),d=await Xe("ssh-keygen",["-y","-P","","-f",l],{timeoutMs:15e3});if(d.code!==0)throw new Error(/passphrase|incorrect/i.test(d.stderr)?"This key has a passphrase, so Myrel cannot use it on its own. Let Myrel make a new key instead.":`Could not read ${l}: ${d.stderr.trim()||`exit ${d.code}`}`);let p=await ge(pi())??{};p[en(e)]=l,await Ve(pi(),p);let m=d.stdout.trim();return{publicKey:m,fingerprint:rs(m),protected:!1}}let n=Nf(e);await ns(hP(n),{recursive:!0,mode:448});let i=fP(24).toString("base64url"),a=await bP(o,en(e),i),s=await Xe("ssh-keygen",["-q","-t","ed25519","-N",a?i:"","-C",t,"-f",n],{timeoutMs:3e4});if(s.code!==0)throw new Error(`ssh-keygen failed: ${s.stderr.trim()||`exit ${s.code}`}. Is OpenSSH installed on this computer?`);await mP(n,384).catch(()=>{});let u=(await Tf(`${n}.pub`,"utf8")).trim();return{publicKey:u,fingerprint:rs(u),protected:a}}async function _P(e,t=q$()){let r=dt(t,".ssh"),o=W$(r,e),n=vP(r,o);if(!n||n.startsWith("..")||W$(r,n)!==o)throw new Error("Only keys in ~/.ssh can be used.");return await Of(o),o}async function Y$(e=q$()){let t=dt(e,".ssh"),r=await gP(t).catch(()=>[]),o=[];for(let n of r.filter(i=>i.endsWith(".pub")).sort()){let i=dt(t,n.slice(0,-4));if(!await Of(i).then(()=>!0,()=>!1))continue;let a=(await Tf(dt(t,n),"utf8").catch(()=>"")).trim(),[s,u,...l]=a.split(/\s+/);!s||!u||o.push({path:i,name:n.slice(0,-4),type:s,fingerprint:rs(a),comment:l.join(" ").slice(0,500)})}return o.slice(0,100)}async function Uf(e,t=Df()){let r=Nf(e);await B$(r,{force:!0}),await B$(`${r}.pub`,{force:!0}),await t?.remove(en(e));let o=await ge(pi());o&&en(e)in o&&(delete o[en(e)],await Ve(pi(),o)),await eb(e,null)}async function xP(e,t){let r=(await ge(pi()))?.[en(e)];if(r)return{path:r,passphrase:null};let o=Nf(e);return await Of(o).then(()=>!0,()=>!1)?{path:o,passphrase:await t?.get(en(e)).catch(()=>null)??null}:null}async function Q$(e,t){let r=await Xe("ssh-keyscan",["-T","10","-p",String(t),"-t","ed25519,ecdsa,rsa","--",e],{timeoutMs:3e4}),o=wP(r.stdout);if(!o.length)throw new Error(`${e}:${t} did not answer with a server key${r.stderr.trim()?` (${r.stderr.trim().split(`
|
|
110
|
+
`).pop()})`:""}.`);return o}var kP=["ssh-ed25519","ecdsa-sha2-nistp256","ecdsa-sha2-nistp384","ecdsa-sha2-nistp521","rsa-sha2-512","ssh-rsa"];function wP(e){let t=[];for(let o of e.split(`
|
|
111
|
+
`)){if(!o.trim()||o.startsWith("#"))continue;let[,n,i]=o.trim().split(/\s+/);if(!n||!i||!/^[A-Za-z0-9+/=]+$/.test(i))continue;let a=`${n} ${i}`;t.some(s=>s.key===a)||t.push({type:n,key:a,fingerprint:rs(a)})}let r=o=>kP.indexOf(o)+1||99;return t.sort((o,n)=>r(o.type)-r(n.type)).slice(0,10)}async function eb(e,t,r=!0){let o=H$(e),n=(await Tf(jf(),"utf8").catch(()=>"")).split(`
|
|
112
112
|
`).filter(Boolean),i=n.filter(u=>u.startsWith(`${o} `)),a=t?`${o} ${t.trim().split(/\s+/).slice(0,2).join(" ")}`:null;if(!r&&i.length){if(a&&i.includes(a))return;throw new is}let s=[...n.filter(u=>!u.startsWith(`${o} `)),...a?[a]:[]];!a&&!i.length||(await ns(tn(),{recursive:!0,mode:448}),await G$(jf(),s.length?`${s.join(`
|
|
113
113
|
`)}
|
|
114
|
-
`:"",{mode:384}))}var is=class extends Error{constructor(){super("The server's key is not the one confirmed in Myrel.")}};function
|
|
114
|
+
`:"",{mode:384}))}var is=class extends Error{constructor(){super("The server's key is not the one confirmed in Myrel.")}};function SP(e,t,r){let o=n=>["-o",n];return["-F","none","-T","-n",...o(`BatchMode=${r.passphrase?"no":"yes"}`),...o("IdentitiesOnly=yes"),...o("IdentityAgent=none"),...o("PasswordAuthentication=no"),...o("KbdInteractiveAuthentication=no"),...o("StrictHostKeyChecking=yes"),...o(`UserKnownHostsFile=${jf()}`),...o(`GlobalKnownHostsFile=${process.platform==="win32"?"NUL":"/dev/null"}`),...o(`HostKeyAlias=${H$(e)}`),...o("UpdateHostKeys=no"),...o("ForwardAgent=no"),...o("ForwardX11=no"),...o("ClearAllForwardings=yes"),...o("PermitLocalCommand=no"),...o(`ConnectTimeout=${r.timeoutSec}`),"-i",t,"-p",String(e.port),"-l",e.user,"--",e.host]}async function Cf(e,t,r={}){let o=Date.now(),n=(p,m)=>({exitCode:null,stdout:"",stderr:m,truncated:!1,ms:Date.now()-o,error:p}),i=r.keychain===void 0?Df():r.keychain,a=await xP(e,i);if(!a)return n("nokey","This computer has no key for this server. Set it up again in the project's SSH settings.");try{await eb(e,e.hostKey,!!r.trust)}catch(p){if(p instanceof is)return n("hostkey",p.message);throw p}let s=r.timeoutMs??cy,u=a.passphrase?Af({SSH_ASKPASS:await zP(),SSH_ASKPASS_REQUIRE:"force",DISPLAY:process.env.DISPLAY||":0",MYREL_SSH_PASSPHRASE:a.passphrase}):Af(),l=await Xe("ssh",[...SP(e,a.path,{passphrase:!!a.passphrase,timeoutSec:15}),t],{env:u,timeoutMs:s}),d=Date.now()-o;return l.timedOut?{exitCode:null,stdout:l.stdout,stderr:l.stderr,truncated:l.truncated,ms:d,error:"timeout"}:{exitCode:l.code,stdout:l.stdout,stderr:l.stderr,truncated:l.truncated,ms:d,...l.code===255&&{error:IP(l.stderr)}}}var tb=(e,t)=>Cf(e,"true",{trust:!0,keychain:t,timeoutMs:$P});function IP(e){return/REMOTE HOST IDENTIFICATION HAS CHANGED|Host key verification failed|No .* host key is known/i.test(e)?"hostkey":/Permission denied|Too many authentication failures|no mutual signature/i.test(e)?"auth":/Connection (refused|timed out|closed)|Could not resolve|No route to host|Network is unreachable|Operation timed out/i.test(e)?"connect":"other"}async function zP(){let e=yP();return await ns(tn(),{recursive:!0,mode:448}),await G$(e,`#!/bin/sh
|
|
115
115
|
printf "%s\\n" "$MYREL_SSH_PASSPHRASE"
|
|
116
|
-
`,{mode:448}),e}import{execFile as
|
|
117
|
-
`).filter(Boolean).at(-1)}). Use \`myrel-runner start\` instead.`)}}else await os(i.file,
|
|
116
|
+
`,{mode:448}),e}import{execFile as FP}from"node:child_process";import{createHash as VP}from"node:crypto";import{copyFile as pb,rename as KP,rm as fb,stat as mb,writeFile as JP}from"node:fs/promises";import{join as Ff,resolve as BP}from"node:path";import{promisify as WP}from"node:util";import{gunzipSync as GP}from"node:zlib";import{execFile as PP,spawn as ib}from"node:child_process";import{copyFile as jP,mkdir as Ef,readFile as AP,rm as ob,stat as OP,writeFile as os}from"node:fs/promises";import{homedir as tr,platform as ab}from"node:os";import{delimiter as nb,join as Ye}from"node:path";import{promisify as TP}from"node:util";var De=TP(PP),nn="io.fibteq.myrel-runner",rn="myrel-runner.service";async function Mf(e){let t=as(),r=mi();await Ef(Ye(ne(),"bin"),{recursive:!0,mode:448}),e!==r&&await jP(e,r);let o=[process.execPath,r,"start"],n=DP(),i=await ss(t);if(t==="launchd")await Ef(Ye(tr(),"Library","LaunchAgents"),{recursive:!0}),await os(i.file,UP(o,n,i.log)),await NP(i.file);else if(t==="systemd"){await Ef(Ye(tr(),".config","systemd","user"),{recursive:!0}),await os(i.file,CP(o,n));try{await De("systemctl",["--user","daemon-reload"]),await De("systemctl",["--user","enable",rn]),await De("systemctl",["--user","restart",rn])}catch(a){throw await ob(i.file,{force:!0}),new Error(`Could not register with systemd (${a.message.split(`
|
|
117
|
+
`).filter(Boolean).at(-1)}). Use \`myrel-runner start\` instead.`)}}else await os(i.file,RP(o,i.log)),ib("wscript.exe",[i.file],{detached:!0,stdio:"ignore"}).unref();return gi()}var mi=()=>Ye(ne(),"bin","myrel-runner.mjs");async function sb(){if(as()!=="startup")return;let e=await ss("startup");e.installed&&ib("wscript.exe",[e.file],{detached:!0,stdio:"ignore"}).unref()}async function NP(e){let t=`gui/${process.getuid?.()}`,r=()=>De("launchctl",["print",`${t}/${nn}`]).then(()=>!0,()=>!1);await De("launchctl",["bootout",`${t}/${nn}`]).catch(()=>{});for(let o=0;o<50&&await r();o++)await Rf(100);for(let o=1;;o++)try{await De("launchctl",["bootstrap",t,e]);break}catch(n){if(o>=5)throw n;await Rf(500*o)}for(let o=0;o<30;o++){if((await De("launchctl",["print",`${t}/${nn}`]).catch(()=>null))?.stdout.includes("state = running"))return;await Rf(100)}}var Rf=e=>new Promise(t=>setTimeout(t,e));async function cb(){let e=as(),t=await ss(e);return e==="launchd"?await De("launchctl",["bootout",`gui/${process.getuid?.()}/${nn}`]).catch(()=>{}):e==="systemd"&&await De("systemctl",["--user","disable","--now",rn]).catch(()=>{}),await ob(t.file,{force:!0}),e==="systemd"&&await De("systemctl",["--user","daemon-reload"]).catch(()=>{}),gi()}async function gi(){let e=await ss(as());if(!e.installed)return{...e,running:!1};if(e.manager==="launchd"){let t=await De("launchctl",["print",`gui/${process.getuid?.()}/${nn}`]).catch(()=>null);return{...e,running:!!t?.stdout.includes("state = running")}}if(e.manager==="systemd"){let t=await De("systemctl",["--user","is-active",rn]).catch(()=>null);return{...e,running:t?.stdout.trim()==="active"}}return{...e,running:null}}function as(){let e=ab();if(e==="darwin")return"launchd";if(e==="linux")return"systemd";if(e==="win32")return"startup";throw new Error(`Running in the background is not supported on ${e} yet. Use \`myrel-runner start\`.`)}async function ss(e){let t=e==="launchd"?Ye(tr(),"Library","LaunchAgents",`${nn}.plist`):e==="systemd"?Ye(tr(),".config","systemd","user",rn):Ye(process.env.APPDATA??Ye(tr(),"AppData","Roaming"),"Microsoft","Windows","Start Menu","Programs","Startup","myrel-runner.vbs"),r=e==="systemd"?`journalctl --user -u ${rn}`:Ye(ne(),"runner.log"),o=!!await OP(t).catch(()=>null);return{manager:e,file:t,installed:o,log:r}}function DP(){let t={PATH:(process.env.PATH??"").split(nb).filter(r=>r&&!/[\\/]_npx[\\/]/.test(r)).join(nb)};return process.env.MYREL_RUNNER_HOME&&(t.MYREL_RUNNER_HOME=process.env.MYREL_RUNNER_HOME),t}var fi=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function UP(e,t,r){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
118
118
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
119
119
|
<plist version="1.0">
|
|
120
120
|
<dict>
|
|
@@ -137,7 +137,7 @@ ${Object.entries(t).map(([o,n])=>` <key>${fi(o)}</key><string>${fi(n)}</strin
|
|
|
137
137
|
<key>StandardErrorPath</key><string>${fi(r)}</string>
|
|
138
138
|
</dict>
|
|
139
139
|
</plist>
|
|
140
|
-
`}var rb=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/%/g,"%%")}"`;function
|
|
140
|
+
`}var rb=e=>`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/%/g,"%%")}"`;function CP(e,t){return`[Unit]
|
|
141
141
|
Description=Myrel runner (connects this computer to Myrel)
|
|
142
142
|
After=network-online.target
|
|
143
143
|
|
|
@@ -151,12 +151,12 @@ ${ub}
|
|
|
151
151
|
|
|
152
152
|
[Install]
|
|
153
153
|
WantedBy=default.target
|
|
154
|
-
`}var ub="OOMPolicy=continue";function
|
|
155
|
-
${ub}`)}async function lb(){if(ab()!=="linux")return;let e=Ye(tr(),".config","systemd","user",rn),t=
|
|
154
|
+
`}var ub="OOMPolicy=continue";function EP(e){return/^OOMPolicy=/m.test(e)||!/^RestartSec=.*$/m.test(e)?null:e.replace(/^RestartSec=.*$/m,t=>`${t}
|
|
155
|
+
${ub}`)}async function lb(){if(ab()!=="linux")return;let e=Ye(tr(),".config","systemd","user",rn),t=EP(await AP(e,"utf8").catch(()=>""));t&&(await os(e,t),await De("systemctl",["--user","daemon-reload"]))}function RP(e,t){return`' Starts myrel-runner at login. Remove with: myrel-runner service uninstall\r
|
|
156
156
|
CreateObject("WScript.Shell").Run "${`cmd.exe /c "${e.map(o=>`"${o}"`).join(" ")} >> "${t}" 2>&1"`.replace(/"/g,'""')}", 0, False\r
|
|
157
|
-
`}import{spawn as
|
|
158
|
-
`)[0]}), so it was not installed.`)}await mb(r).catch(()=>null)&&await pb(r,Zf()),await
|
|
159
|
-
`)[0].slice(0,80)}`),S({type:"ssh.result",requestId:U,...await Cf(w.target,w.command)});if(w.type==="ssh.forget")return await Uf({projectId:w.projectId,alias:w.alias}),t(`Forgot the SSH key for ${w.alias} (from Myrel)`),S({type:"ssh.result",requestId:U,exitCode:0,stdout:"",stderr:"",truncated:!1,ms:0});if(w.type==="runner.update"){if(x!=="service")throw new Error(x==="app"?"This runner came with the Myrel desktop app; it updates with the app.":"This runner was started in a terminal, so it cannot restart itself. Start it again with `npx myrel-runner@latest start`.");return t(`Updating to myrel-runner ${w.version} (from Myrel)${w.now?"":" once the running tasks finish"}`),S({type:"update.accepted",requestId:U,update:P.request(w.version,w.now)})}if(o=await de(),w.type==="settings.set")return gb(o,w.settings),await Fe(o),t(`Settings changed from Myrel: ${Object.entries(w.settings).map(([Z,bi])=>`${Z} ${bi}`).join(", ")}`),S({type:"settings",requestId:U,settings:vi(o)});if(w.type==="folder.share"){let Z=await E$(w.path);Ua(o,Z)&&t(`Shared ${Z} (from Myrel)`)}else Ca(o,w.path)&&t(`Stopped sharing ${w.path} (from Myrel)`);await Fe(o),S({type:"folders",requestId:U,folders:o.folders})},ie=()=>{if(m)return;let w=`${o.server.replace(/^http/,"ws")}/api/runner/connect`;r({state:"connecting"});let U=new WebSocket(w,{headers:{authorization:`Bearer ${o.token}`}});p=U;let Z=!1;U.onopen=()=>{Z=!0,f=0,z(),O()},U.onmessage=Ae=>{let sn=JSON.parse(String(Ae.data)),fs=hy.safeParse(sn);if(!fs.success){let cn=sn;if(cn?.type==="task.start"&&typeof cn.taskId=="string"){let Wf=fs.error.issues[0],Gf=`${Wf?.path.join(".")||"frame"}: ${Wf?.message??"invalid"}`;t(`\u2717 could not read task ${cn.taskId} (${Gf})`),S({type:"task.done",taskId:cn.taskId,ok:!1,result:`myrel-runner ${Re} could not read this task (${Gf}). Update myrel-runner.`})}return}let _e=fs.data;_e.type==="welcome"&&(t(`\u25CF Connected to ${o.server} as "${_e.name}"`),r({state:"online",name:_e.name}),P.confirmed()),_e.type==="task.start"&&(r({state:"task",taskId:_e.taskId,event:"started"}),u.start(_e)),_e.type==="task.cancel"&&u.cancel(_e.taskId),_e.type==="task.github"&&u.renewGithub(_e.taskId,_e.github),"requestId"in _e&&pe(_e).catch(cn=>S({type:"request.failed",requestId:_e.requestId,message:
|
|
157
|
+
`}import{spawn as MP}from"node:child_process";var LP="@fibteq/myrel-runner",Lf="@fibteq%2Fmyrel-runner",ZP=/^\d+\.\d+\.\d+(-[0-9A-Za-z.-]+)?$/;async function cs(e="https://registry.npmjs.org"){try{let t=await fetch(`${e}/${Lf}/latest`,{signal:AbortSignal.timeout(1e4)});if(!t.ok)return null;let{version:r}=await t.json();return typeof r=="string"&&ZP.test(r)?r:null}catch{return null}}var hi=yy;function db(e,t){let r=process.platform==="win32"?"npx.cmd":"npx";return new Promise((o,n)=>{let i=MP(r,["--yes",`--package=${LP}@${e}`,"--","myrel-runner",...t],{stdio:"inherit",shell:process.platform==="win32",env:{...process.env,MYREL_RUNNER_UPDATING:e}});i.on("error",n),i.on("exit",a=>o(a??1))})}var qP=WP(FP);function vi(e){return{access:e.access,worktrees:e.worktrees!==!1,autoUpdate:e.autoUpdate===!0,remote:e.remoteSettings!==!1}}function gb(e,t){if(e.remoteSettings===!1)throw new Error("Changing settings from Myrel is turned off on this computer. Turn it on there with `myrel-runner settings remote on`.");t.access&&(e.access=t.access),t.worktrees!==void 0&&(e.worktrees=t.worktrees),t.autoUpdate!==void 0&&(e.autoUpdate=t.autoUpdate)}function hb(e=process.argv[1]){return process.versions.bun?"app":e&&BP(e)===mi()?"service":"manual"}var Zf=()=>Ff(ne(),"bin","myrel-runner.prev.mjs"),Vf=()=>Ff(ne(),"update.json"),vb=()=>ge(Vf()).catch(()=>{}),us=e=>Ve(Vf(),e),Kf=()=>fb(Vf(),{force:!0}),yb=1440*60*1e3;async function $b(e,t="https://registry.npmjs.org"){let r=await fetch(`${t}/${Lf}/${e}`,{signal:AbortSignal.timeout(3e4)});if(!r.ok)throw new Error(`npm does not have myrel-runner ${e} (${r.status}).`);let{dist:o}=await r.json(),n=o?.integrity?.match(/^sha512-([A-Za-z0-9+/=]+)$/)?.[1];if(!o?.tarball||!n)throw new Error("npm sent no download for this version.");let i=await fetch(o.tarball,{signal:AbortSignal.timeout(12e4)});if(!i.ok)throw new Error(`Could not download myrel-runner ${e} (${i.status}).`);let a=Buffer.from(await i.arrayBuffer());if(VP("sha512").update(a).digest("base64")!==n)throw new Error("The download does not match npm's checksum, so it was not installed.");let s=HP(GP(a),"package/dist/cli.js");if(!s)throw new Error("The download has no dist/cli.js.");return s}function HP(e,t){let r;for(let o=0;o+512<=e.length;){let n=e.subarray(o,o+512);if(n.every(p=>p===0))return null;let i=(p,m)=>n.toString("utf8",p,p+m).replace(/\0.*$/s,""),a=Number.parseInt(i(124,12).trim()||"0",8),s=i(156,1),u=e.subarray(o+512,o+512+a);if(o+=512+Math.ceil(a/512)*512,s==="x"){r=u.toString("utf8").match(/^\d+ path=(.*)$/m)?.[1];continue}let l=i(345,155),d=r??(l?`${l}/${i(0,100)}`:i(0,100));if(r=void 0,(s==="0"||s==="")&&d===t)return Buffer.from(u)}return null}async function bb(e,t){let r=mi(),o=Ff(ne(),"bin","myrel-runner.next.mjs");await JP(o,e,{mode:448});try{let{stdout:n}=await qP(process.execPath,[o,"--version"],{timeout:3e4});if(n.trim()!==t)throw new Error(`it says it is ${n.trim()||"nothing"}`)}catch(n){throw await fb(o,{force:!0}),new Error(`The new version does not start (${n.message.split(`
|
|
158
|
+
`)[0]}), so it was not installed.`)}await mb(r).catch(()=>null)&&await pb(r,Zf()),await KP(o,r)}async function _b(){return await mb(Zf()).catch(()=>null)?(await pb(Zf(),mi()),!0):!1}var XP=600*1e3,YP=360*60*1e3,xb=120*1e3,ls=class{constructor(t){this.opts=t}opts;current=null;pending=null;busy=!1;hurry=!1;until=0;get now(){return(this.opts.now??Date.now)()}state(){return this.current??void 0}async init(){let t=await vb();if(!t)return!1;if(t.state==="restarting"&&t.version===this.opts.version)return this.pending=t,!0;if(t.state==="restarting")return await this.fail(t.version,"The new version did not start, so this one kept running.","failed",!1),!1;if((t.state==="failed"||t.state==="rolled-back")&&this.now-Date.parse(t.at)<yb){let{from:r,...o}=t;return this.current=o,!1}return await Kf(),!1}async confirmed(){this.pending&&(this.opts.log(`\u25CF Updated myrel-runner from ${this.pending.from} to ${this.opts.version}.`),this.pending=null,this.current=null,await Kf(),this.opts.report(null))}async rollback(t){let r=this.pending;if(r){if(this.pending=null,!await(this.opts.restore??_b)().catch(()=>!1)){this.opts.log(`myrel-runner ${this.opts.version} could not connect (${t}), and there is no previous version to go back to.`);return}this.opts.log(`myrel-runner ${this.opts.version} could not connect (${t}); going back to ${r.from}.`),await us({state:"rolled-back",version:this.opts.version,from:r.from,message:t.slice(0,500),at:new Date(this.now).toISOString()}),this.opts.restart()}}get confirming(){return this.pending!==null}request(t,r=!1,o=!1){if(!hi(t,this.opts.version))throw new Error(`myrel-runner ${this.opts.version} is already up to date.`);let n=this.now+(o?this.opts.autoWaitMs??YP:this.opts.waitMs??XP);return this.busy?(r&&(this.hurry=!0),this.until=Math.min(this.until,n),this.current):(this.busy=!0,this.hurry=r,this.until=n,this.set({state:"waiting",version:t,running:this.opts.running().length}),this.run(t).finally(()=>{this.busy=!1}),this.current)}async checkNewest(){if(this.busy||this.pending)return;let t=await(this.opts.latest??cs)();!t||!hi(t,this.opts.version)||this.current&&this.current.version===t&&this.current.state!=="waiting"||(this.opts.log(`Installing myrel-runner ${t} (auto-update is on).`),this.request(t,!1,!0))}async run(t){for(let o=this.opts.running();o.length&&!this.hurry&&this.now<this.until;o=this.opts.running())o.length!==this.current?.running&&this.set({state:"waiting",version:t,running:o.length}),await new Promise(n=>setTimeout(n,this.opts.pollMs??2e3));try{this.set({state:"downloading",version:t});let o=await(this.opts.download??$b)(t);await(this.opts.install??bb)(o,t)}catch(o){await this.fail(t,o.message);return}let r={state:"restarting",version:t,from:this.opts.version,at:new Date(this.now).toISOString()};await us(r),this.set({state:"restarting",version:t}),this.opts.log(`Restarting on myrel-runner ${t}\u2026`),this.opts.restart()}async fail(t,r,o="failed",n=!0){n&&this.opts.log(`Could not update to myrel-runner ${t}: ${r}`);let i=new Date(this.now).toISOString();await us({state:o,version:t,from:this.opts.version,message:r.slice(0,500),at:i}).catch(()=>{}),this.set({state:o,version:t,message:r.slice(0,500)})}set(t){this.current={...t,at:new Date(this.now).toISOString()},this.opts.report(this.current)}};var Re="0.28.2",tj=360*60*1e3;async function wb(e){let t=e.server.replace(/\/+$/,""),r=await fetch(`${t}/api/runner/pair`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({code:e.code,name:e.name||Jf(),hostname:Jf(),platform:kb()})}),o=await r.json().catch(()=>null);if(!r.ok)throw new Error(o?.message??`Pairing failed (${r.status})`);let n=vy.parse(o),i=await de();return Object.assign(i,{server:t,runnerId:n.runner.id,token:n.token}),await Fe(i),i}async function yi(e){if(!e.server||!e.token)return"invalid";try{let t=await fetch(`${e.server}/api/runner/me`,{headers:{authorization:`Bearer ${e.token}`},signal:AbortSignal.timeout(1e4)});return t.ok?"ok":t.status===401?"invalid":"unknown"}catch{return"unknown"}}var nj="This computer is not paired with Myrel any more (it was removed, or paired again elsewhere). Get a new code in Myrel > Devices and run `myrel-runner pair <code> --server <url>`.",rj=900*1e3,Sb=75,ij=300*1e3;function oj(e,t){return e.length===t.length&&e.every(r=>t.some(o=>o.id===r.id&&o.version===r.version))}async function Ib(e={}){let t=e.log??(w=>console.log(w)),r=e.onStatus??(()=>{}),o=await de();if(!o.server||!o.token)throw new Error("This computer is not paired yet. Run `myrel-runner pair <code> --server <url>` first.");let n=await li(),i=await Jy(),a=(w,U)=>{let Z=i[w];!U||Z&&Z.at>=U.at||(i[w]=U,By(i).catch(()=>{}),JSON.stringify({...Z,at:""})!==JSON.stringify({...U,at:""})&&O())},s=()=>{n.some(w=>w.id==="codex")&&Ra().then(w=>a("codex",w),()=>{})},u=new es({config:()=>o,sessions:new Da,log:t,onLimits:a,onChange:zf,version:Re}),l=F$();l.length&&t(`${l.length} task(s) stopped when the runner restarted; Myrel continues them.`),zf([]);let d="stopped",p=null,m=!1,f=0,g,y=new Promise(w=>g=w),x=hb();x==="service"&&lb().catch(()=>{});let P=new ls({version:Re,running:()=>u.runningIds(),report:w=>S({type:"update.status",update:w}),log:t,restart:()=>{sb().catch(()=>{}).finally(()=>{d="restart",ee()})}}),I;await P.init()&&(I=setTimeout(()=>{yi(o).then(w=>{w==="ok"&&P.confirming&&P.rollback("it did not connect within 2 minutes")})},xb),I.unref?.());let A=new Map,S=w=>{w.type==="task.done"&&(r({state:"task",taskId:w.taskId,event:"done",ok:w.ok}),A.set(w.taskId,{frame:w,at:Date.now()})),p?.readyState===WebSocket.OPEN&&p.send(JSON.stringify(w))},z=()=>{for(let[w,{frame:U,at:Z}]of A)Date.now()-Z>rj?A.delete(w):S(U)},O=()=>S({type:"hello",protocol:py,version:Re,hostname:Jf(),platform:kb(),folders:o.folders,clis:n.map(w=>i[w.id]?{...w,limits:i[w.id]}:w),features:["folders","cancel","agent","agent-clis","connectors","skills","project-folders","files","settings","models","git-token","steer","steer-claude","ssh",...x==="service"?["update"]:[]],settings:vi(o),updates:x,...P.state()&&{update:P.state()},running:u.runningIds(),interrupted:l});u.setSender(S);let X=async()=>{o=await de().catch(()=>o),O()};QP(It(),{interval:2e3},X);let je=setInterval(()=>S({type:"ping"}),25e3),Qe=()=>{Promise.all(n.map(async w=>{let U=await ui[w.id].models?.().catch(()=>{}),Z=JSON.stringify(U)!==JSON.stringify(w.models);return U&&(w.models=U),Z&&!!U})).then(w=>w.some(Boolean)&&O())};Qe(),s();let pt=()=>{li().then(w=>{if(oj(n,w))return;let U=new Map(n.map(Z=>[Z.id,Z]));n.splice(0,n.length,...w.map(Z=>U.get(Z.id)?.version===Z.version?U.get(Z.id):Z)),t(`CLIs found: ${n.map(Z=>Z.id).join(", ")||"none"}`),O(),Qe(),s()},()=>{})},et=setInterval(s,600*1e3),on=setInterval(Qe,360*60*1e3),Ot=setInterval(pt,ij);et.unref?.(),Ot.unref?.();let nr=()=>{Qa(w=>u.inUse(w)).then(w=>w.forEach(U=>t(`Removed the finished worktree ${U.path} (${U.branch})`))).catch(()=>{})};nr();let an=setInterval(nr,360*60*1e3);an.unref?.();let $i=()=>{x==="service"&&o.autoUpdate&&P.checkNewest().catch(()=>{})},rr=setTimeout($i,600*1e3);rr.unref?.();let L=setInterval($i,tj);L.unref?.();let ee=()=>{m=!0,clearInterval(je),clearInterval(an),clearInterval(et),clearInterval(on),clearInterval(Ot),clearInterval(L),clearTimeout(rr),clearTimeout(I),ej(It(),X),Z$(u.stopAll()),p?.close(1e3),r({state:"stopped",reason:d}),g(d)},pe=async w=>{let{requestId:U}=w;if(w.type==="dirs.list")return S({type:"dirs",requestId:U,...await C$(w.path)});if(w.type==="task.steer")return S({type:"task.steered",requestId:U,taken:await u.steer(w.taskId,w.text)});if(w.type==="file.read")return S({type:"file",requestId:U,...await T$(o,w)});if(w.type==="ssh.keygen"){let Z=await X$({projectId:w.projectId,alias:w.alias},w.comment,w.existing);return t(`${w.existing?"Using":"Made"} an SSH key for ${w.alias} (${Z.fingerprint}, from Myrel)`),S({type:"ssh.key",requestId:U,...Z})}if(w.type==="ssh.keys")return S({type:"ssh.keylist",requestId:U,keys:await Y$()});if(w.type==="ssh.hostkeys")return S({type:"ssh.hostkeylist",requestId:U,keys:await Q$(w.host,w.port)});if(w.type==="ssh.test")return S({type:"ssh.result",requestId:U,...await tb(w.target)});if(w.type==="ssh.run")return t(`SSH ${w.target.alias}: ${w.command.split(`
|
|
159
|
+
`)[0].slice(0,80)}`),S({type:"ssh.result",requestId:U,...await Cf(w.target,w.command)});if(w.type==="ssh.forget")return await Uf({projectId:w.projectId,alias:w.alias}),t(`Forgot the SSH key for ${w.alias} (from Myrel)`),S({type:"ssh.result",requestId:U,exitCode:0,stdout:"",stderr:"",truncated:!1,ms:0});if(w.type==="runner.update"){if(x!=="service")throw new Error(x==="app"?"This runner came with the Myrel desktop app; it updates with the app.":"This runner was started in a terminal, so it cannot restart itself. Start it again with `npx myrel-runner@latest start`.");return t(`Updating to myrel-runner ${w.version} (from Myrel)${w.now?"":" once the running tasks finish"}`),S({type:"update.accepted",requestId:U,update:P.request(w.version,w.now)})}if(o=await de(),w.type==="settings.set")return gb(o,w.settings),await Fe(o),t(`Settings changed from Myrel: ${Object.entries(w.settings).map(([Z,bi])=>`${Z} ${bi}`).join(", ")}`),S({type:"settings",requestId:U,settings:vi(o)});if(w.type==="folder.share"){let Z=await E$(w.path);Ua(o,Z)&&t(`Shared ${Z} (from Myrel)`)}else Ca(o,w.path)&&t(`Stopped sharing ${w.path} (from Myrel)`);await Fe(o),S({type:"folders",requestId:U,folders:o.folders})},ie=()=>{if(m)return;let w=`${o.server.replace(/^http/,"ws")}/api/runner/connect`;r({state:"connecting"});let U=new WebSocket(w,{headers:{authorization:`Bearer ${o.token}`}});p=U;let Z=!1;U.onopen=()=>{Z=!0,f=0,z(),O()},U.onmessage=Ae=>{let sn=JSON.parse(String(Ae.data)),fs=hy.safeParse(sn);if(!fs.success){let cn=sn;if(cn?.type==="task.start"&&typeof cn.taskId=="string"){let Wf=fs.error.issues[0],Gf=`${Wf?.path.join(".")||"frame"}: ${Wf?.message??"invalid"}`;t(`\u2717 could not read task ${cn.taskId} (${Gf})`),S({type:"task.done",taskId:cn.taskId,ok:!1,result:`myrel-runner ${Re} could not read this task (${Gf}). Update myrel-runner.`})}return}let _e=fs.data;_e.type==="welcome"&&(t(`\u25CF Connected to ${o.server} as "${_e.name}"`),r({state:"online",name:_e.name}),P.confirmed()),_e.type==="task.start"&&(r({state:"task",taskId:_e.taskId,event:"started"}),u.start(_e)),_e.type==="task.cancel"&&u.cancel(_e.taskId),_e.type==="task.github"&&u.renewGithub(_e.taskId,_e.github),"requestId"in _e&&pe(_e).catch(cn=>S({type:"request.failed",requestId:_e.requestId,message:aj(cn)}))};let bi=!1,Bf=async Ae=>{if(bi||p!==U||m)return;if(bi=!0,!Z&&await yi(o)==="invalid")return t(nj),e.onRevoked?.(),d="revoked",ee();if(Ae.code===4401)return t("This computer was removed from Myrel. Pair it again with `myrel-runner pair`."),e.onRevoked?.(),d="revoked",ee();if(Ae.code===4e3)return t("myrel-runner was started somewhere else with this computer's login, so this one stops."),d="replaced",ee();if(Ae.code===4400)return t(`The server refused this runner: ${Ae.reason}`),P.confirming&&(await P.rollback(`the server refused it: ${Ae.reason}`),m)?void 0:(d="refused",ee());let sn=Math.min(3e4,1e3*2**f++);t(`\u25CB Disconnected${Ae.reason?` (${Ae.reason})`:""}. Reconnecting in ${Math.round(sn/1e3)}s\u2026`),r({state:"offline",reason:Ae.reason||`code ${Ae.code}`,retryInMs:sn}),setTimeout(ie,sn)};U.onclose=Ae=>{Bf(Ae)},U.onerror=()=>{Z||Bf({code:1006,reason:""})}};return ie(),t(`Sharing ${o.folders.length} folder(s); CLIs found: ${n.map(w=>w.id).join(", ")||"none"}`),{stop:ee,done:y}}function aj(e){return(e instanceof Error?e.message:String(e)).slice(0,500)}var cj=`myrel-runner ${Re}
|
|
160
160
|
Connects this computer to Myrel, so projects can work in folders you share
|
|
161
161
|
using your own Claude Code, Codex, Antigravity CLI, OpenCode, Hermes Agent, Cursor CLI, Muse Code or Kimi Code. Your CLI logins never leave
|
|
162
162
|
this computer.
|
|
@@ -197,12 +197,12 @@ is merged and that were not used for a day are removed automatically.
|
|
|
197
197
|
|
|
198
198
|
Environment: MYREL_SERVER and MYREL_RUNNER_TOKEN override the saved pairing;
|
|
199
199
|
MYREL_RUNNER_HOME moves the config folder (default ~/.myrel-runner).
|
|
200
|
-
`;async function
|
|
200
|
+
`;async function uj(e){if(e[0]==="ssh-shim"){process.exitCode=await $$(e[1],e.slice(2));return}let{values:t,positionals:r}=sj({args:e,allowPositionals:!0,options:{server:{type:"string"},name:{type:"string"},access:{type:"string"},json:{type:"boolean"},force:{type:"boolean"},now:{type:"boolean"},help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"}}}),[o,n]=r;if(t.version)return console.log(Re);if(t.help||!o)return console.log(cj);switch(o){case"mcp-bridge":return Ey({input:process.stdin,write:i=>process.stdout.write(`${i}
|
|
201
201
|
`),run:await Ry(),version:Re});case"git-credential":return p$(n,process.stdin,i=>process.stdout.write(i));case"pair":{let i=t.server??(await de()).server;if(!n||!i)throw new Error("Usage: myrel-runner pair <code> --server <url>");let a=await wb({server:i,code:n,name:t.name});console.log(`Paired with ${a.server}.`),console.log("Next: `myrel-runner service install` to keep it running in the background, then add folders in Myrel > Devices.");return}case"share":{let i=await de(),a=Ua(i,n??process.cwd());await Fe(i),console.log(a?`Shared ${i.folders.at(-1).path}`:"That folder is already shared.");return}case"unshare":{if(!n)throw new Error("Usage: myrel-runner unshare <folder>");let i=await de(),a=Ca(i,n);await Fe(i),console.log(a?"Stopped sharing it.":"That folder was not shared.");return}case"status":{let i=await de(),a=[],[s,u]=await Promise.all([li(a),yi(i)]);if(t.json){let{token:d,...p}=i;return console.log(JSON.stringify({...p,paired:!!(d&&i.server),pairing:u,clis:s}))}let l={ok:"",invalid:" (not paired any more: run myrel-runner pair)",unknown:" (could not reach it)"};console.log(`Server: ${i.server?`${i.server}${l[u]}`:"(not paired)"}`),console.log(`Config: ${It()}`),console.log(`Access: ${i.access}${i.autoUpdate?" \xB7 auto-update on":""}`),console.log(`Folders: ${i.folders.map(d=>`
|
|
202
202
|
${d.path}`).join("")||"none"}`),console.log(`CLIs: ${s.map(d=>`
|
|
203
203
|
${tf[d.id]} ${d.version??""}`).join("")||"none found"}`),console.log(`Not found: ${a.map(d=>`
|
|
204
|
-
${tf[d.id]}: ${d.reason}`).join("")||"none"}`);return}case"start":{t.access&&await ds(t.access);let i=await Ib(t.json?{log:()=>{},onStatus:a=>console.log(JSON.stringify(a))}:{});for(let a of["SIGINT","SIGTERM"])process.once(a,()=>i.stop());process.exit(await i.done==="restart"?Sb:0)}case"service":{if(n==="install"){let i=await de();if(!i.server||!i.token)throw new Error("Pair this computer first: myrel-runner pair <code> --server <url>");if(await yi(i)==="invalid")throw new Error(`${i.server} does not know this computer any more. Get a new code in Myrel > Devices and run \`myrel-runner pair <code> --server ${i.server}\` first.`);t.access&&await ds(t.access),ps(await Mf(zb(import.meta.url)),t.json);return}if(n==="uninstall")return ps(await cb(),t.json);if(n==="status"||!n)return ps(await gi(),t.json);throw new Error("Usage: myrel-runner service install|uninstall|status")}case"update":{let i=process.env.MYREL_RUNNER_UPDATING,a=i?null:await cs();if(!i&&!a&&console.log("Could not reach npm to look for a newer version."),a&&hi(a,Re)){console.log(`Updating myrel-runner ${Re} to ${a}\u2026`),process.exitCode=await db(a,e);return}if(!i&&a&&console.log(`myrel-runner ${Re} is the newest version.`),!(await gi().catch(()=>null))?.installed){console.log("The background runner is not installed, so there is nothing to restart. Install it with `myrel-runner service install`.");return}t.access&&await ds(t.access),t.now||await
|
|
204
|
+
${tf[d.id]}: ${d.reason}`).join("")||"none"}`);return}case"start":{t.access&&await ds(t.access);let i=await Ib(t.json?{log:()=>{},onStatus:a=>console.log(JSON.stringify(a))}:{});for(let a of["SIGINT","SIGTERM"])process.once(a,()=>i.stop());process.exit(await i.done==="restart"?Sb:0)}case"service":{if(n==="install"){let i=await de();if(!i.server||!i.token)throw new Error("Pair this computer first: myrel-runner pair <code> --server <url>");if(await yi(i)==="invalid")throw new Error(`${i.server} does not know this computer any more. Get a new code in Myrel > Devices and run \`myrel-runner pair <code> --server ${i.server}\` first.`);t.access&&await ds(t.access),ps(await Mf(zb(import.meta.url)),t.json);return}if(n==="uninstall")return ps(await cb(),t.json);if(n==="status"||!n)return ps(await gi(),t.json);throw new Error("Usage: myrel-runner service install|uninstall|status")}case"update":{let i=process.env.MYREL_RUNNER_UPDATING,a=i?null:await cs();if(!i&&!a&&console.log("Could not reach npm to look for a newer version."),a&&hi(a,Re)){console.log(`Updating myrel-runner ${Re} to ${a}\u2026`),process.exitCode=await db(a,e);return}if(!i&&a&&console.log(`myrel-runner ${Re} is the newest version.`),!(await gi().catch(()=>null))?.installed){console.log("The background runner is not installed, so there is nothing to restart. Install it with `myrel-runner service install`.");return}t.access&&await ds(t.access),t.now||await dj();let s=await Mf(zb(import.meta.url));console.log(`Restarted the background runner on ${Re}.`),ps(s,t.json);return}case"worktrees":{if(n==="on"||n==="off"){let u=await de();u.worktrees=n==="on",await Fe(u),console.log(n==="on"?"Each thread now works in its own git worktree.":"Threads now work in the shared folder itself. Two threads at once can change the same files.");return}if(n==="prune"){let u=await Qa();console.log(u.length?u.map(l=>`Removed ${l.path} (${l.branch})`).join(`
|
|
205
205
|
`):"Nothing to clean up.");return}let i=await Qt();if(n==="remove"){let u=r[2],l=i.find(d=>d.path===u||d.branch===u);if(!l)throw new Error("Usage: myrel-runner worktrees remove <path or branch> [--force] (see myrel-runner worktrees)");await xf(l,{force:t.force}),console.log(`Removed ${l.path}. The branch ${l.branch} is kept unless it was merged.`);return}if(n)throw new Error("Usage: myrel-runner worktrees [on|off|prune|remove <path>]");let a=await Promise.all(i.map(u=>Ya(u).catch(()=>null)));if(t.json)return console.log(JSON.stringify(i.map((u,l)=>({...u,...a[l]}))));let s=(await de()).worktrees!==!1;console.log(`Worktrees: ${s?"on":"off (threads share the folder)"}`);for(let[u,l]of i.entries()){let d=a[u],p=[d?.missing&&"missing",d?.dirty&&"uncommitted changes",d?.merged&&"merged"].filter(Boolean).join(", ");console.log(`
|
|
206
206
|
${l.branch}${p?` (${p})`:""}
|
|
207
207
|
${l.path}
|
|
208
|
-
from ${l.repo}, last used ${new Date(l.lastUsed).toLocaleString()}`)}i.length||console.log("No worktrees yet.");return}case"settings":{let i=await de(),a=r[2];if(n==="access"&&a)await ds(a);else if((n==="auto-update"||n==="remote")&&(a==="on"||a==="off"))i[n==="remote"?"remoteSettings":"autoUpdate"]=a==="on",await Fe(i);else if(n)throw new Error("Usage: myrel-runner settings [access read|edit|auto|full | auto-update on|off | remote on|off]");let s=vi(await de());if(t.json)return console.log(JSON.stringify(s));console.log(`Access: ${s.access}`),console.log(`Worktrees: ${s.worktrees?"on":"off"}`),console.log(`Auto-update: ${s.autoUpdate?"on (background runner only)":"off"}`),console.log(`From Myrel: ${s.remote?"can be changed in Myrel > Devices":"off: only here"}`);return}case"logout":{let i=await de();delete i.token,delete i.runnerId,await Fe(i),console.log("Forgot this computer's pairing. Remove it in Myrel > Devices too.");return}default:throw new Error(`Unknown command "${o}". Run myrel-runner --help.`)}}var
|
|
208
|
+
from ${l.repo}, last used ${new Date(l.lastUsed).toLocaleString()}`)}i.length||console.log("No worktrees yet.");return}case"settings":{let i=await de(),a=r[2];if(n==="access"&&a)await ds(a);else if((n==="auto-update"||n==="remote")&&(a==="on"||a==="off"))i[n==="remote"?"remoteSettings":"autoUpdate"]=a==="on",await Fe(i);else if(n)throw new Error("Usage: myrel-runner settings [access read|edit|auto|full | auto-update on|off | remote on|off]");let s=vi(await de());if(t.json)return console.log(JSON.stringify(s));console.log(`Access: ${s.access}`),console.log(`Worktrees: ${s.worktrees?"on":"off"}`),console.log(`Auto-update: ${s.autoUpdate?"on (background runner only)":"off"}`),console.log(`From Myrel: ${s.remote?"can be changed in Myrel > Devices":"off: only here"}`);return}case"logout":{let i=await de();delete i.token,delete i.runnerId,await Fe(i),console.log("Forgot this computer's pairing. Remove it in Myrel > Devices too.");return}default:throw new Error(`Unknown command "${o}". Run myrel-runner --help.`)}}var lj=600*1e3;async function dj(){let e=Date.now()+lj,t=0;for(let r=Pf();r.length;r=Pf()){if(Date.now()>=e){console.log(`Restarting now; Myrel continues the ${r.length} task(s) still running after the restart.`);return}r.length!==t&&(t=r.length,console.log(`${t} task(s) running; restarting once they finish (at most 10 minutes; --now to restart right away)\u2026`)),await new Promise(o=>setTimeout(o,5e3))}}async function ds(e){if(!["read","edit","auto","full"].includes(e))throw new Error("--access must be read, edit, auto or full");let t=await de();t.access=e,await Fe(t)}function ps(e,t){if(t)return console.log(JSON.stringify(e));if(!e.installed)return console.log("The background runner is not installed. Install it with `myrel-runner service install`.");let r=e.running===null?"installed":e.running?"running":"installed, not running";console.log(`Background runner: ${r}. It starts at every login.`),console.log(`Service: ${e.file}`),console.log(`Logs: ${e.log}`)}uj(process.argv.slice(2)).catch(e=>{console.error(e instanceof Error?e.message:String(e)),process.exit(1)});
|