@botpress/sdk 4.8.5 → 4.10.0

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/index.cjs CHANGED
@@ -1,21 +1,21 @@
1
- "use strict";var cu=Object.create;var Gt=Object.defineProperty;var du=Object.getOwnPropertyDescriptor;var uu=Object.getOwnPropertyNames;var pu=Object.getPrototypeOf,fu=Object.prototype.hasOwnProperty;var ht=(t,e)=>{for(var r in e)Gt(t,r,{get:e[r],enumerable:!0})},Fs=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of uu(e))!fu.call(t,s)&&s!==r&&Gt(t,s,{get:()=>e[s],enumerable:!(n=du(e,s))||n.enumerable});return t};var zs=(t,e,r)=>(r=t!=null?cu(pu(t)):{},Fs(e||!t||!t.__esModule?Gt(r,"default",{value:t,enumerable:!0}):r,t)),gu=t=>Fs(Gt({},"__esModule",{value:!0}),t);var Lm={};ht(Lm,{BRAND:()=>$l,Bot:()=>wn,BotDefinition:()=>bn,BotLogger:()=>Pe,BotSpecificClient:()=>ce,DIRTY:()=>Re,EMPTY_PATH:()=>Cl,INVALID:()=>P,Integration:()=>Tn,IntegrationDefinition:()=>hn,IntegrationLogger:()=>we,IntegrationSpecificClient:()=>ft,InterfaceDefinition:()=>Pn,NEVER:()=>td,OK:()=>J,ParseInputLazyPath:()=>ie,ParseStatus:()=>te,Plugin:()=>kn,PluginDefinition:()=>xn,RuntimeError:()=>Sn.RuntimeError,Schema:()=>E,WELL_KNOWN_ATTRIBUTES:()=>am,ZodAny:()=>ot,ZodArray:()=>lt,ZodBigInt:()=>en,ZodBoolean:()=>tn,ZodBranded:()=>rn,ZodCatch:()=>nn,ZodDate:()=>sn,ZodDefault:()=>jt,ZodDiscriminatedUnion:()=>us,ZodEffects:()=>be,ZodEnum:()=>We,ZodError:()=>le,ZodFirstPartyTypeKind:()=>os,ZodFunction:()=>fs,ZodIntersection:()=>an,ZodIssueCode:()=>y,ZodLazy:()=>on,ZodLiteral:()=>ln,ZodMap:()=>gs,ZodNaN:()=>ys,ZodNativeEnum:()=>cn,ZodNever:()=>ut,ZodNull:()=>dn,ZodNullable:()=>De,ZodNumber:()=>un,ZodObject:()=>Me,ZodOptional:()=>fe,ZodParsedType:()=>v,ZodPipeline:()=>pn,ZodPromise:()=>Ut,ZodReadonly:()=>Ft,ZodRecord:()=>hs,ZodRef:()=>ms,ZodSchema:()=>E,ZodSet:()=>vs,ZodString:()=>X,ZodSymbol:()=>Ss,ZodTransformer:()=>be,ZodTuple:()=>Ne,ZodType:()=>E,ZodUndefined:()=>zt,ZodUnion:()=>fn,ZodUnknown:()=>nt,ZodVoid:()=>Es,addIssueToContext:()=>m,agent:()=>cc,aimodel:()=>gc,any:()=>kc,array:()=>Zc,bigint:()=>Tc,boolean:()=>Bs,botIdHeader:()=>Lt,botUserIdHeader:()=>Rs,coerce:()=>ed,configurationHeader:()=>Wt,configurationTypeHeader:()=>Ms,conversation:()=>ic,createZodEnum:()=>Kt,cuid2Regex:()=>Ts,cuidRegex:()=>_s,custom:()=>ds,datasource:()=>yc,date:()=>bc,discriminatedUnion:()=>Ac,effect:()=>Fn,emailRegex:()=>Ps,enum:()=>zc,errorUtil:()=>w,event:()=>dc,function:()=>Kc,getErrorMap:()=>at,getParsedType:()=>pe,instanceof:()=>vc,integrationIdHeader:()=>Hs,intent:()=>fc,intersection:()=>Rc,ipv4Regex:()=>xs,ipv6Regex:()=>ks,isAborted:()=>dr,isApiError:()=>Sn.isApiError,isAsync:()=>Mt,isDirty:()=>ur,isEmojiRegex:()=>Ql,isValid:()=>it,knowledgebase:()=>hc,late:()=>mc,lazy:()=>Uc,literal:()=>Fc,makeIssue:()=>Dt,map:()=>$c,mergeObjectSchemas:()=>pt,message:()=>lc,messages:()=>As,nan:()=>_c,nativeEnum:()=>Lc,never:()=>Ec,null:()=>xc,nullable:()=>Vc,number:()=>Zs,object:()=>Bc,objectUtil:()=>lr,oboolean:()=>Qc,onumber:()=>Yc,operationHeader:()=>qt,optional:()=>qc,ostring:()=>Xc,parseBody:()=>oe,pipeline:()=>Jc,preprocess:()=>Gc,processCreateParams:()=>k,promise:()=>Wc,quotelessJson:()=>Zl,readonly:()=>Nc,record:()=>Dc,ref:()=>Mc,serve:()=>Vt,set:()=>jc,setErrorMap:()=>cs,strictObject:()=>Ic,string:()=>Os,symbol:()=>wc,table:()=>uc,tablerow:()=>pc,transformer:()=>Fn,transforms:()=>Ba,tuple:()=>Hc,typeHeader:()=>Ns,ulidRegex:()=>bs,undefined:()=>Pc,union:()=>Cc,unknown:()=>Sc,user:()=>oc,util:()=>Z,uuidRegex:()=>ws,variable:()=>ac,void:()=>Oc,webhookIdHeader:()=>Ds,z:()=>_});module.exports=gu(Lm);var As={};ht(As,{defaults:()=>sm,markdown:()=>nm});var Wn=Object.defineProperty,yu=Object.defineProperties,hu=Object.getOwnPropertyDescriptors,or=Object.getOwnPropertySymbols,Ea=Object.prototype.hasOwnProperty,Oa=Object.prototype.propertyIsEnumerable,Ls=(t,e,r)=>e in t?Wn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,c=(t,e)=>{for(var r in e||(e={}))Ea.call(e,r)&&Ls(t,r,e[r]);if(or)for(var r of or(e))Oa.call(e,r)&&Ls(t,r,e[r]);return t},p=(t,e)=>yu(t,hu(e)),i=(t,e)=>Wn(t,"name",{value:e,configurable:!0}),Za=(t,e)=>{var r={};for(var n in t)Ea.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&or)for(var n of or(t))e.indexOf(n)<0&&Oa.call(t,n)&&(r[n]=t[n]);return r},Fr=(t,e)=>{for(var r in e)Wn(t,r,{get:e[r],enumerable:!0})},Ba={};Fr(Ba,{errors:()=>Ra,fromJSONSchema:()=>ad,fromJSONSchemaLegacy:()=>Eh,fromObject:()=>zn,toJSONSchema:()=>V,toJSONSchemaLegacy:()=>Qh,toTypescriptSchema:()=>ss,toTypescriptType:()=>qn});var _={};Fr(_,{BRAND:()=>$l,DIRTY:()=>Re,EMPTY_PATH:()=>Cl,INVALID:()=>P,NEVER:()=>td,OK:()=>J,ParseInputLazyPath:()=>ie,ParseStatus:()=>te,Schema:()=>E,ZodAny:()=>ot,ZodArray:()=>lt,ZodBigInt:()=>en,ZodBoolean:()=>tn,ZodBranded:()=>rn,ZodCatch:()=>nn,ZodDate:()=>sn,ZodDefault:()=>jt,ZodDiscriminatedUnion:()=>us,ZodEffects:()=>be,ZodEnum:()=>We,ZodError:()=>le,ZodFirstPartyTypeKind:()=>os,ZodFunction:()=>fs,ZodIntersection:()=>an,ZodIssueCode:()=>y,ZodLazy:()=>on,ZodLiteral:()=>ln,ZodMap:()=>gs,ZodNaN:()=>ys,ZodNativeEnum:()=>cn,ZodNever:()=>ut,ZodNull:()=>dn,ZodNullable:()=>De,ZodNumber:()=>un,ZodObject:()=>Me,ZodOptional:()=>fe,ZodParsedType:()=>v,ZodPipeline:()=>pn,ZodPromise:()=>Ut,ZodReadonly:()=>Ft,ZodRecord:()=>hs,ZodRef:()=>ms,ZodSchema:()=>E,ZodSet:()=>vs,ZodString:()=>X,ZodSymbol:()=>Ss,ZodTransformer:()=>be,ZodTuple:()=>Ne,ZodType:()=>E,ZodUndefined:()=>zt,ZodUnion:()=>fn,ZodUnknown:()=>nt,ZodVoid:()=>Es,addIssueToContext:()=>m,agent:()=>cc,aimodel:()=>gc,any:()=>kc,array:()=>Zc,bigint:()=>Tc,boolean:()=>Bs,coerce:()=>ed,conversation:()=>ic,createZodEnum:()=>Kt,cuid2Regex:()=>Ts,cuidRegex:()=>_s,custom:()=>ds,datasource:()=>yc,date:()=>bc,default:()=>nh,discriminatedUnion:()=>Ac,effect:()=>Fn,emailRegex:()=>Ps,enum:()=>zc,errorUtil:()=>w,event:()=>dc,function:()=>Kc,getErrorMap:()=>at,getParsedType:()=>pe,instanceof:()=>vc,intent:()=>fc,intersection:()=>Rc,ipv4Regex:()=>xs,ipv6Regex:()=>ks,isAborted:()=>dr,isAsync:()=>Mt,isDirty:()=>ur,isEmojiRegex:()=>Ql,isValid:()=>it,knowledgebase:()=>hc,late:()=>mc,lazy:()=>Uc,literal:()=>Fc,makeIssue:()=>Dt,map:()=>$c,message:()=>lc,nan:()=>_c,nativeEnum:()=>Lc,never:()=>Ec,null:()=>xc,nullable:()=>Vc,number:()=>Zs,object:()=>Bc,objectUtil:()=>lr,oboolean:()=>Qc,onumber:()=>Yc,optional:()=>qc,ostring:()=>Xc,pipeline:()=>Jc,preprocess:()=>Gc,processCreateParams:()=>k,promise:()=>Wc,quotelessJson:()=>Zl,readonly:()=>Nc,record:()=>Dc,ref:()=>Mc,set:()=>jc,setErrorMap:()=>cs,strictObject:()=>Ic,string:()=>Os,symbol:()=>wc,table:()=>uc,tablerow:()=>pc,transformer:()=>Fn,tuple:()=>Hc,ulidRegex:()=>bs,undefined:()=>Pc,union:()=>Cc,unknown:()=>Sc,user:()=>oc,util:()=>Z,uuidRegex:()=>ws,variable:()=>ac,void:()=>Oc});var b="x-zui";function Ia(t){return typeof t=="symbol"?"symbol":typeof t=="bigint"?`${t.toString()}n`:T(t)}i(Ia,"primitiveToTypscriptLiteralType");function T(t){return typeof t>"u"?"undefined":typeof t=="symbol"?t.description?`Symbol(${T(t.description)})`:"Symbol()":typeof t=="bigint"?`BigInt(${t.toString()})`:JSON.stringify(t)}i(T,"primitiveToTypescriptValue");function tt(t){return typeof t>"u"?"undefined":JSON.stringify(t)}i(tt,"unknownToTypescriptValue");var Ca=i((t,e)=>{let r=Object.entries(t),n=e?" as const":"";return`{ ${r.map(([s,a])=>`${An(s)}: ${tt(a)}`).join(", ")} }${n}`},"recordOfUnknownToTypescriptRecord"),An=i(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:T(t),"toPropertyKey"),mu=i(t=>t.charAt(0).toUpperCase()+t.slice(1),"capitalize"),Aa=i(t=>{let e=/[^a-zA-Z0-9_]/g;return t.split(e).map(mu).filter(n=>!!n).join("")},"toTypeArgumentName"),F=i(t=>{let e=(t??"").split(`
1
+ "use strict";var uu=Object.create;var Xt=Object.defineProperty;var pu=Object.getOwnPropertyDescriptor;var fu=Object.getOwnPropertyNames;var gu=Object.getPrototypeOf,yu=Object.prototype.hasOwnProperty;var vt=(t,e)=>{for(var r in e)Xt(t,r,{get:e[r],enumerable:!0})},Ls=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of fu(e))!yu.call(t,s)&&s!==r&&Xt(t,s,{get:()=>e[s],enumerable:!(n=pu(e,s))||n.enumerable});return t};var Ws=(t,e,r)=>(r=t!=null?uu(gu(t)):{},Ls(e||!t||!t.__esModule?Xt(r,"default",{value:t,enumerable:!0}):r,t)),hu=t=>Ls(Xt({},"__esModule",{value:!0}),t);var Vm={};vt(Vm,{BRAND:()=>Kl,Bot:()=>Pn,BotDefinition:()=>wn,BotLogger:()=>Pe,BotSpecificClient:()=>ce,DIRTY:()=>Re,EMPTY_PATH:()=>Rl,INVALID:()=>P,Integration:()=>bn,IntegrationDefinition:()=>vn,IntegrationLogger:()=>we,IntegrationSpecificClient:()=>gt,InterfaceDefinition:()=>xn,NEVER:()=>nd,OK:()=>J,ParseInputLazyPath:()=>ie,ParseStatus:()=>te,Plugin:()=>Sn,PluginDefinition:()=>kn,RuntimeError:()=>En.RuntimeError,Schema:()=>E,WELL_KNOWN_ATTRIBUTES:()=>om,ZodAny:()=>lt,ZodArray:()=>ct,ZodBigInt:()=>rn,ZodBoolean:()=>nn,ZodBranded:()=>sn,ZodCatch:()=>an,ZodDate:()=>on,ZodDefault:()=>Ut,ZodDiscriminatedUnion:()=>ps,ZodEffects:()=>be,ZodEnum:()=>We,ZodError:()=>le,ZodFirstPartyTypeKind:()=>ls,ZodFunction:()=>gs,ZodIntersection:()=>ln,ZodIssueCode:()=>y,ZodLazy:()=>cn,ZodLiteral:()=>dn,ZodMap:()=>ys,ZodNaN:()=>hs,ZodNativeEnum:()=>un,ZodNever:()=>pt,ZodNull:()=>pn,ZodNullable:()=>Me,ZodNumber:()=>fn,ZodObject:()=>De,ZodOptional:()=>fe,ZodParsedType:()=>v,ZodPipeline:()=>gn,ZodPromise:()=>zt,ZodReadonly:()=>Lt,ZodRecord:()=>ms,ZodRef:()=>vs,ZodSchema:()=>E,ZodSet:()=>_s,ZodString:()=>X,ZodSymbol:()=>Es,ZodTransformer:()=>be,ZodTuple:()=>Ne,ZodType:()=>E,ZodUndefined:()=>Wt,ZodUnion:()=>yn,ZodUnknown:()=>st,ZodVoid:()=>Os,addIssueToContext:()=>m,agent:()=>uc,aimodel:()=>hc,any:()=>Ec,array:()=>Bc,bigint:()=>wc,boolean:()=>Bs,botIdHeader:()=>qt,botUserIdHeader:()=>Hs,coerce:()=>rd,configurationHeader:()=>Vt,configurationTypeHeader:()=>Ns,conversation:()=>lc,createZodEnum:()=>Ft,cuid2Regex:()=>bs,cuidRegex:()=>Ts,custom:()=>us,datasource:()=>mc,date:()=>Pc,discriminatedUnion:()=>Hc,effect:()=>zn,emailRegex:()=>xs,enum:()=>Wc,errorUtil:()=>w,event:()=>pc,function:()=>Fc,getErrorMap:()=>it,getParsedType:()=>pe,instanceof:()=>Tc,integrationIdHeader:()=>Ms,intent:()=>yc,intersection:()=>Mc,ipv4Regex:()=>ks,ipv6Regex:()=>Ss,isAborted:()=>pr,isApiError:()=>En.isApiError,isAsync:()=>$t,isDirty:()=>fr,isEmojiRegex:()=>tc,isValid:()=>ot,knowledgebase:()=>vc,late:()=>_c,lazy:()=>zc,literal:()=>Lc,makeIssue:()=>Nt,map:()=>Kc,mergeObjectSchemas:()=>ft,message:()=>dc,messages:()=>Rs,nan:()=>bc,nativeEnum:()=>qc,never:()=>Zc,null:()=>Sc,nullable:()=>Jc,number:()=>Is,object:()=>Cc,objectUtil:()=>dr,oboolean:()=>td,onumber:()=>ed,operationHeader:()=>Gt,optional:()=>Gc,ostring:()=>Qc,parseBody:()=>oe,pipeline:()=>Yc,preprocess:()=>Xc,processCreateParams:()=>k,promise:()=>Vc,quotelessJson:()=>Bl,readonly:()=>jc,record:()=>Nc,ref:()=>$c,serve:()=>Jt,set:()=>Uc,setErrorMap:()=>ds,strictObject:()=>Ac,string:()=>Zs,symbol:()=>xc,table:()=>fc,tablerow:()=>gc,transformer:()=>zn,transforms:()=>Ca,tuple:()=>Dc,typeHeader:()=>$s,ulidRegex:()=>ws,undefined:()=>kc,union:()=>Rc,unknown:()=>Oc,user:()=>cc,util:()=>Z,uuidRegex:()=>Ps,variable:()=>oc,void:()=>Ic,webhookIdHeader:()=>Ds,z:()=>_});module.exports=hu(Vm);var Rs={};vt(Rs,{defaults:()=>im,markdown:()=>am});var qn=Object.defineProperty,mu=Object.defineProperties,vu=Object.getOwnPropertyDescriptors,cr=Object.getOwnPropertySymbols,Za=Object.prototype.hasOwnProperty,Ia=Object.prototype.propertyIsEnumerable,qs=(t,e,r)=>e in t?qn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,c=(t,e)=>{for(var r in e||(e={}))Za.call(e,r)&&qs(t,r,e[r]);if(cr)for(var r of cr(e))Ia.call(e,r)&&qs(t,r,e[r]);return t},p=(t,e)=>mu(t,vu(e)),i=(t,e)=>qn(t,"name",{value:e,configurable:!0}),Ba=(t,e)=>{var r={};for(var n in t)Za.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&cr)for(var n of cr(t))e.indexOf(n)<0&&Ia.call(t,n)&&(r[n]=t[n]);return r},Lr=(t,e)=>{for(var r in e)qn(t,r,{get:e[r],enumerable:!0})},Ca={};Lr(Ca,{errors:()=>Ma,fromJSONSchema:()=>od,fromJSONSchemaLegacy:()=>Zh,fromObject:()=>Ln,toJSONSchema:()=>V,toJSONSchemaLegacy:()=>tm,toTypescriptSchema:()=>as,toTypescriptType:()=>Vn});var _={};Lr(_,{BRAND:()=>Kl,DIRTY:()=>Re,EMPTY_PATH:()=>Rl,INVALID:()=>P,NEVER:()=>nd,OK:()=>J,ParseInputLazyPath:()=>ie,ParseStatus:()=>te,Schema:()=>E,ZodAny:()=>lt,ZodArray:()=>ct,ZodBigInt:()=>rn,ZodBoolean:()=>nn,ZodBranded:()=>sn,ZodCatch:()=>an,ZodDate:()=>on,ZodDefault:()=>Ut,ZodDiscriminatedUnion:()=>ps,ZodEffects:()=>be,ZodEnum:()=>We,ZodError:()=>le,ZodFirstPartyTypeKind:()=>ls,ZodFunction:()=>gs,ZodIntersection:()=>ln,ZodIssueCode:()=>y,ZodLazy:()=>cn,ZodLiteral:()=>dn,ZodMap:()=>ys,ZodNaN:()=>hs,ZodNativeEnum:()=>un,ZodNever:()=>pt,ZodNull:()=>pn,ZodNullable:()=>Me,ZodNumber:()=>fn,ZodObject:()=>De,ZodOptional:()=>fe,ZodParsedType:()=>v,ZodPipeline:()=>gn,ZodPromise:()=>zt,ZodReadonly:()=>Lt,ZodRecord:()=>ms,ZodRef:()=>vs,ZodSchema:()=>E,ZodSet:()=>_s,ZodString:()=>X,ZodSymbol:()=>Es,ZodTransformer:()=>be,ZodTuple:()=>Ne,ZodType:()=>E,ZodUndefined:()=>Wt,ZodUnion:()=>yn,ZodUnknown:()=>st,ZodVoid:()=>Os,addIssueToContext:()=>m,agent:()=>uc,aimodel:()=>hc,any:()=>Ec,array:()=>Bc,bigint:()=>wc,boolean:()=>Bs,coerce:()=>rd,conversation:()=>lc,createZodEnum:()=>Ft,cuid2Regex:()=>bs,cuidRegex:()=>Ts,custom:()=>us,datasource:()=>mc,date:()=>Pc,default:()=>ah,discriminatedUnion:()=>Hc,effect:()=>zn,emailRegex:()=>xs,enum:()=>Wc,errorUtil:()=>w,event:()=>pc,function:()=>Fc,getErrorMap:()=>it,getParsedType:()=>pe,instanceof:()=>Tc,intent:()=>yc,intersection:()=>Mc,ipv4Regex:()=>ks,ipv6Regex:()=>Ss,isAborted:()=>pr,isAsync:()=>$t,isDirty:()=>fr,isEmojiRegex:()=>tc,isValid:()=>ot,knowledgebase:()=>vc,late:()=>_c,lazy:()=>zc,literal:()=>Lc,makeIssue:()=>Nt,map:()=>Kc,message:()=>dc,nan:()=>bc,nativeEnum:()=>qc,never:()=>Zc,null:()=>Sc,nullable:()=>Jc,number:()=>Is,object:()=>Cc,objectUtil:()=>dr,oboolean:()=>td,onumber:()=>ed,optional:()=>Gc,ostring:()=>Qc,pipeline:()=>Yc,preprocess:()=>Xc,processCreateParams:()=>k,promise:()=>Vc,quotelessJson:()=>Bl,readonly:()=>jc,record:()=>Nc,ref:()=>$c,set:()=>Uc,setErrorMap:()=>ds,strictObject:()=>Ac,string:()=>Zs,symbol:()=>xc,table:()=>fc,tablerow:()=>gc,transformer:()=>zn,tuple:()=>Dc,ulidRegex:()=>ws,undefined:()=>kc,union:()=>Rc,unknown:()=>Oc,user:()=>cc,util:()=>Z,uuidRegex:()=>Ps,variable:()=>oc,void:()=>Ic});var b="x-zui";function Aa(t){return typeof t=="symbol"?"symbol":typeof t=="bigint"?`${t.toString()}n`:T(t)}i(Aa,"primitiveToTypscriptLiteralType");function T(t){return typeof t>"u"?"undefined":typeof t=="symbol"?t.description?`Symbol(${T(t.description)})`:"Symbol()":typeof t=="bigint"?`BigInt(${t.toString()})`:JSON.stringify(t)}i(T,"primitiveToTypescriptValue");function rt(t){return typeof t>"u"?"undefined":JSON.stringify(t)}i(rt,"unknownToTypescriptValue");var Ra=i((t,e)=>{let r=Object.entries(t),n=e?" as const":"";return`{ ${r.map(([s,a])=>`${Rn(s)}: ${rt(a)}`).join(", ")} }${n}`},"recordOfUnknownToTypescriptRecord"),Rn=i(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:T(t),"toPropertyKey"),_u=i(t=>t.charAt(0).toUpperCase()+t.slice(1),"capitalize"),Ha=i(t=>{let e=/[^a-zA-Z0-9_]/g;return t.split(e).map(_u).filter(n=>!!n).join("")},"toTypeArgumentName"),F=i(t=>{let e=(t??"").split(`
2
2
  `).filter(r=>r.trim().length>0);return e.length===0?"":e.length===1?`/** ${e[0]} */`:`/**
3
3
  * ${e.join(`
4
4
  * `)}
5
- */`},"getMultilineComment"),Ra={};Fr(Ra,{JSONSchemaToZuiError:()=>zr,ObjectToZuiError:()=>Rn,UnrepresentableGenericError:()=>Hn,UnsupportedJSONSchemaToZuiError:()=>ve,UnsupportedZuiCheckToJSONSchemaError:()=>Ka,UnsupportedZuiToJSONSchemaError:()=>ee,UnsupportedZuiToTypescriptSchemaError:()=>Oe,UnsupportedZuiToTypescriptTypeError:()=>Va,UntitledDeclarationError:()=>Ja,ZuiToJSONSchemaError:()=>Lr,ZuiToTypescriptSchemaError:()=>za,ZuiToTypescriptTypeError:()=>Wr,ZuiTransformError:()=>dt});var Ha=class extends Error{constructor(e,r){super(r),this.transform=e}};i(Ha,"ZuiTransformError");var dt=Ha,Da=class extends dt{constructor(e){super("json-schema-to-zui",e)}};i(Da,"JSONSchemaToZuiError");var zr=Da,Ma=class extends dt{constructor(e){super("object-to-zui",e)}};i(Ma,"ObjectToZuiError");var Rn=Ma,Na=class extends dt{constructor(e){super("zui-to-json-schema",e)}};i(Na,"ZuiToJSONSchemaError");var Lr=Na,$a=class extends Lr{constructor(e,{suggestedAlternative:r}={}){super(`Zod type ${e} cannot be transformed to JSON Schema.`+(r?` Suggested alternative: ${r}`:""))}};i($a,"UnsupportedZuiToJSONSchemaError");var ee=$a,ja=class extends Lr{constructor({zodType:e,checkKind:r}){super(`Zod check .${r}() of type ${e} cannot be transformed to JSON Schema.`)}};i(ja,"UnsupportedZuiCheckToJSONSchemaError");var Ka=ja,Ua=class extends zr{constructor(e){super(`JSON Schema ${JSON.stringify(e)} cannot be transformed to ZUI type.`)}};i(Ua,"UnsupportedJSONSchemaToZuiError");var ve=Ua,Fa=class extends dt{constructor(e){super("zui-to-typescript-schema",e)}};i(Fa,"ZuiToTypescriptSchemaError");var za=Fa,La=class extends za{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript schema.`)}};i(La,"UnsupportedZuiToTypescriptSchemaError");var Oe=La,Wa=class extends dt{constructor(e){super("zui-to-typescript-type",e)}};i(Wa,"ZuiToTypescriptTypeError");var Wr=Wa,qa=class extends Wr{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript type.`)}};i(qa,"UnsupportedZuiToTypescriptTypeError");var Va=qa,Ga=class extends Wr{constructor(){super("Schema must have a title to be transformed to a TypeScript type with a declaration.")}};i(Ga,"UntitledDeclarationError");var Ja=Ga,Xa=class extends Wr{constructor(){super('ZodRef can only be transformed to a TypeScript type with a "type" declaration.')}};i(Xa,"UnrepresentableGenericError");var Hn=Xa,Ya=["string","number","boolean","unknown","void","any","null","undefined","never","bigint","symbol","object"],vu=i(t=>Ya.includes(t),"isPrimitive"),_u=i(t=>Ya.map(e=>`${e}[]`).includes(t),"isArrayOfPrimitives"),Ws=i(t=>t.replace(/ +/g," ").trim(),"stripSpaces"),Qa=class{constructor(e,r,n=!1){this.key=e,this.value=r,this.optional=n}};i(Qa,"KeyValue");var Jt=Qa,ei=class{constructor(e){this.schema=e}};i(ei,"FnParameters");var qs=ei,ti=class{constructor(e){this.schema=e}};i(ti,"FnReturn");var Vs=ti,ri=class{constructor(e){this.props=e}};i(ri,"Declaration");var Yt=ri;function qn(t,e={}){let r=wu(t,e),n=I(r,{});return e.formatter&&(n=e.formatter(n)),n}i(qn,"toTypescriptType");function I(t,e){var r,n,s;let a=p(c({},e),{parent:t});if(t===null)return"";if(t instanceof Yt)return Tu(t,a);if(t instanceof Jt){if(t.value instanceof u.ZodOptional){let O=t.value._def.innerType;return I(new Jt(t.key,O,!0),a)}let d=F(t.value.description),f=d?.trim().length>0?`
6
- `:"",g=t.value.describe(""),x=t.optional||t.value.isOptional()?"?":"";return`${f}${d}${f}${t.key}${x}: ${I(g,a)}${f}`}if(t instanceof qs){if(t.schema instanceof u.ZodTuple){let g="";for(let h=0;h<t.schema.items.length;h++){let x=(s=(n=(r=t.schema.items[h])==null?void 0:r.ui)==null?void 0:n.title)!=null?s:`arg${h}`,O=t.schema.items[h];g+=`${I(new Jt(An(x),O),a)}${h<t.schema.items.length-1?", ":""} `}return g}let d=I(t.schema,a);return d.startsWith("{")&&d.endsWith("}")||d.startsWith("[")&&d.endsWith("]")||d.startsWith("(")&&d.endsWith(")")||d.startsWith("Array<")&&d.endsWith(">")||d.startsWith("Record<")&&d.endsWith(">")||_u(d)?`args: ${d}`:d}if(t instanceof Vs)return t.schema instanceof u.ZodOptional?`${I(t.schema.unwrap(),a)} | undefined`:I(t.schema,a);let o=t,l=o._def;switch(l.typeName){case u.ZodFirstPartyTypeKind.ZodString:return`${F(o.description)} string`.trim();case u.ZodFirstPartyTypeKind.ZodNumber:case u.ZodFirstPartyTypeKind.ZodNaN:case u.ZodFirstPartyTypeKind.ZodBigInt:return`${F(o.description)} number`.trim();case u.ZodFirstPartyTypeKind.ZodBoolean:return`${F(o.description)} boolean`.trim();case u.ZodFirstPartyTypeKind.ZodDate:return`${F(o.description)} Date`.trim();case u.ZodFirstPartyTypeKind.ZodUndefined:return`${F(o.description)} undefined`.trim();case u.ZodFirstPartyTypeKind.ZodNull:return`${F(o.description)} null`.trim();case u.ZodFirstPartyTypeKind.ZodAny:return`${F(o.description)} any`.trim();case u.ZodFirstPartyTypeKind.ZodUnknown:return`${F(o.description)} unknown`.trim();case u.ZodFirstPartyTypeKind.ZodNever:return`${F(o.description)} never`.trim();case u.ZodFirstPartyTypeKind.ZodVoid:return`${F(o.description)} void`.trim();case u.ZodFirstPartyTypeKind.ZodArray:let d=I(l.type,a);return vu(d)?`${d}[]`:`Array<${d}>`;case u.ZodFirstPartyTypeKind.ZodObject:return`{ ${Object.entries(l.shape()).map(([q,se])=>I(new Jt(An(q),se),a)).join("; ")} }`;case u.ZodFirstPartyTypeKind.ZodUnion:let g=l.options.map(q=>I(q,a));return`${F(o.description)}
7
- ${g.join(" | ")}`;case u.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let h=l.options.map(q=>I(q,a));return`${F(o.description)}
8
- ${h.join(" | ")}`;case u.ZodFirstPartyTypeKind.ZodIntersection:return`${I(l.left,a)} & ${I(l.right,a)}`;case u.ZodFirstPartyTypeKind.ZodTuple:return l.items.length===0?"":`[${l.items.map(q=>I(q,a)).join(", ")}]`;case u.ZodFirstPartyTypeKind.ZodRecord:let O=I(l.keyType,a),B=I(l.valueType,a);return`${F(o.description)} { [key: ${O}]: ${B} }`;case u.ZodFirstPartyTypeKind.ZodMap:return`Map<${I(l.keyType,a)}, ${I(l.valueType,a)}>`;case u.ZodFirstPartyTypeKind.ZodSet:return`Set<${I(l.valueType,a)}>`;case u.ZodFirstPartyTypeKind.ZodFunction:let U=I(new qs(l.args),a),W=I(new Vs(l.returns),a);return`${F(o.description)}
9
- (${U}) => ${W}`;case u.ZodFirstPartyTypeKind.ZodLazy:return I(l.getter(),a);case u.ZodFirstPartyTypeKind.ZodLiteral:let Q=Ia(l.value);return`${F(o.description)}
10
- ${Q}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(T).join(" | ");case u.ZodFirstPartyTypeKind.ZodEffects:return I(l.schema,a);case u.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Va(u.ZodFirstPartyTypeKind.ZodNativeEnum);case u.ZodFirstPartyTypeKind.ZodOptional:return`${I(l.innerType,a)} | undefined`;case u.ZodFirstPartyTypeKind.ZodNullable:return`${I(l.innerType,a)} | null`;case u.ZodFirstPartyTypeKind.ZodDefault:return I(l.innerType,a);case u.ZodFirstPartyTypeKind.ZodCatch:return I(l.innerType,a);case u.ZodFirstPartyTypeKind.ZodPromise:return`Promise<${I(l.type,a)}>`;case u.ZodFirstPartyTypeKind.ZodBranded:return I(l.type,a);case u.ZodFirstPartyTypeKind.ZodPipeline:return I(l.in,a);case u.ZodFirstPartyTypeKind.ZodSymbol:return`${F(o.description)} symbol`.trim();case u.ZodFirstPartyTypeKind.ZodReadonly:return`Readonly<${I(l.innerType,a)}>`;case u.ZodFirstPartyTypeKind.ZodRef:return Aa(l.uri);default:Z.assertNever(l)}}i(I,"sUnwrapZod");var Tu=i((t,e)=>{if(t.props.type==="none")return I(t.props.schema,e);let r=F(t.props.schema.description),n=t.props.schema.describe(""),s=I(n,e);if(t.props.type==="variable")return Ws(`${r}declare const ${t.props.identifier}: ${s};`);let a=t.props.args.length>0?`<${t.props.args.map(Aa).join(", ")}>`:"";return Ws(`${r}type ${t.props.identifier}${a} = ${s};`)},"unwrapDeclaration"),bu=i(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),wu=i((t,e)=>{let r=bu(e),n=t.getReferences();if(r==="none"){if(n.length>0)throw new Hn;return new Yt({type:"none",schema:t})}let s="title"in t.ui?t.ui.title:null;if(!s)throw new Ja;if(r==="variable"){if(n.length>0)throw new Hn;return new Yt({type:"variable",identifier:s,schema:t})}return new Yt({type:"type",identifier:s,schema:t,args:n})},"getDeclarationProps"),Pu=typeof global=="object"&&global&&global.Object===Object&&global,ni=Pu,xu=typeof self=="object"&&self&&self.Object===Object&&self,ku=ni||xu||Function("return this")(),ye=ku,Su=ye.Symbol,_e=Su,si=Object.prototype,Eu=si.hasOwnProperty,Ou=si.toString,mt=_e?_e.toStringTag:void 0;function ai(t){var e=Eu.call(t,mt),r=t[mt];try{t[mt]=void 0;var n=!0}catch{}var s=Ou.call(t);return n&&(e?t[mt]=r:delete t[mt]),s}i(ai,"getRawTag");var Zu=ai,Bu=Object.prototype,Iu=Bu.toString;function ii(t){return Iu.call(t)}i(ii,"objectToString");var Cu=ii,Au="[object Null]",Ru="[object Undefined]",Gs=_e?_e.toStringTag:void 0;function oi(t){return t==null?t===void 0?Ru:Au:Gs&&Gs in Object(t)?Zu(t):Cu(t)}i(oi,"baseGetTag");var $e=oi;function li(t){return t!=null&&typeof t=="object"}i(li,"isObjectLike");var He=li,Hu="[object Symbol]";function ci(t){return typeof t=="symbol"||He(t)&&$e(t)==Hu}i(ci,"isSymbol");var Vn=ci;function di(t,e){for(var r=-1,n=t==null?0:t.length,s=Array(n);++r<n;)s[r]=e(t[r],r,t);return s}i(di,"arrayMap");var ui=di,Du=Array.isArray,ge=Du,Mu=1/0,Js=_e?_e.prototype:void 0,Xs=Js?Js.toString:void 0;function Gn(t){if(typeof t=="string")return t;if(ge(t))return ui(t,Gn)+"";if(Vn(t))return Xs?Xs.call(t):"";var e=t+"";return e=="0"&&1/t==-Mu?"-0":e}i(Gn,"baseToString");var Nu=Gn;function pi(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}i(pi,"isObject");var st=pi;function fi(t){return t}i(fi,"identity");var $u=fi,ju="[object AsyncFunction]",Ku="[object Function]",Uu="[object GeneratorFunction]",Fu="[object Proxy]";function gi(t){if(!st(t))return!1;var e=$e(t);return e==Ku||e==Uu||e==ju||e==Fu}i(gi,"isFunction");var yi=gi,zu=ye["__core-js_shared__"],En=zu,Ys=function(){var t=/[^.]+$/.exec(En&&En.keys&&En.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function hi(t){return!!Ys&&Ys in t}i(hi,"isMasked");var Lu=hi,Wu=Function.prototype,qu=Wu.toString;function mi(t){if(t!=null){try{return qu.call(t)}catch{}try{return t+""}catch{}}return""}i(mi,"toSource");var je=mi,Vu=/[\\^$.*+?()[\]{}|]/g,Gu=/^\[object .+?Constructor\]$/,Ju=Function.prototype,Xu=Object.prototype,Yu=Ju.toString,Qu=Xu.hasOwnProperty,ep=RegExp("^"+Yu.call(Qu).replace(Vu,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function vi(t){if(!st(t)||Lu(t))return!1;var e=yi(t)?ep:Gu;return e.test(je(t))}i(vi,"baseIsNative");var tp=vi;function _i(t,e){return t?.[e]}i(_i,"getValue");var rp=_i;function Ti(t,e){var r=rp(t,e);return tp(r)?r:void 0}i(Ti,"getNative");var Ke=Ti,np=Ke(ye,"WeakMap"),Dn=np,sp=function(){try{var t=Ke(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Qs=sp,ap=9007199254740991,ip=/^(?:0|[1-9]\d*)$/;function bi(t,e){var r=typeof t;return e=e??ap,!!e&&(r=="number"||r!="symbol"&&ip.test(t))&&t>-1&&t%1==0&&t<e}i(bi,"isIndex");var Jn=bi;function wi(t,e,r){e=="__proto__"&&Qs?Qs(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}i(wi,"baseAssignValue");var Pi=wi;function xi(t,e){return t===e||t!==t&&e!==e}i(xi,"eq");var Xn=xi,op=Object.prototype,lp=op.hasOwnProperty;function ki(t,e,r){var n=t[e];(!(lp.call(t,e)&&Xn(n,r))||r===void 0&&!(e in t))&&Pi(t,e,r)}i(ki,"assignValue");var cp=ki,dp=9007199254740991;function Si(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=dp}i(Si,"isLength");var Yn=Si;function Ei(t){return t!=null&&Yn(t.length)&&!yi(t)}i(Ei,"isArrayLike");var Oi=Ei,up=Object.prototype;function Zi(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||up;return t===r}i(Zi,"isPrototype");var Bi=Zi;function Ii(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}i(Ii,"baseTimes");var pp=Ii,fp="[object Arguments]";function Ci(t){return He(t)&&$e(t)==fp}i(Ci,"baseIsArguments");var ea=Ci,Ai=Object.prototype,gp=Ai.hasOwnProperty,yp=Ai.propertyIsEnumerable,hp=ea(function(){return arguments}())?ea:function(t){return He(t)&&gp.call(t,"callee")&&!yp.call(t,"callee")},Ri=hp;function Hi(){return!1}i(Hi,"stubFalse");var mp=Hi,Di=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ta=Di&&typeof module=="object"&&module&&!module.nodeType&&module,vp=ta&&ta.exports===Di,ra=vp?ye.Buffer:void 0,_p=ra?ra.isBuffer:void 0,Tp=_p||mp,Mn=Tp,bp="[object Arguments]",wp="[object Array]",Pp="[object Boolean]",xp="[object Date]",kp="[object Error]",Sp="[object Function]",Ep="[object Map]",Op="[object Number]",Zp="[object Object]",Bp="[object RegExp]",Ip="[object Set]",Cp="[object String]",Ap="[object WeakMap]",Rp="[object ArrayBuffer]",Hp="[object DataView]",Dp="[object Float32Array]",Mp="[object Float64Array]",Np="[object Int8Array]",$p="[object Int16Array]",jp="[object Int32Array]",Kp="[object Uint8Array]",Up="[object Uint8ClampedArray]",Fp="[object Uint16Array]",zp="[object Uint32Array]",D={};D[Dp]=D[Mp]=D[Np]=D[$p]=D[jp]=D[Kp]=D[Up]=D[Fp]=D[zp]=!0;D[bp]=D[wp]=D[Rp]=D[Pp]=D[Hp]=D[xp]=D[kp]=D[Sp]=D[Ep]=D[Op]=D[Zp]=D[Bp]=D[Ip]=D[Cp]=D[Ap]=!1;function Mi(t){return He(t)&&Yn(t.length)&&!!D[$e(t)]}i(Mi,"baseIsTypedArray");var Lp=Mi;function Ni(t){return function(e){return t(e)}}i(Ni,"baseUnary");var Wp=Ni,$i=typeof exports=="object"&&exports&&!exports.nodeType&&exports,It=$i&&typeof module=="object"&&module&&!module.nodeType&&module,qp=It&&It.exports===$i,On=qp&&ni.process,Vp=function(){try{var t=It&&It.require&&It.require("util").types;return t||On&&On.binding&&On.binding("util")}catch{}}(),na=Vp,sa=na&&na.isTypedArray,Gp=sa?Wp(sa):Lp,ji=Gp,Jp=Object.prototype,Xp=Jp.hasOwnProperty;function Ki(t,e){var r=ge(t),n=!r&&Ri(t),s=!r&&!n&&Mn(t),a=!r&&!n&&!s&&ji(t),o=r||n||s||a,l=o?pp(t.length,String):[],d=l.length;for(var f in t)(e||Xp.call(t,f))&&!(o&&(f=="length"||s&&(f=="offset"||f=="parent")||a&&(f=="buffer"||f=="byteLength"||f=="byteOffset")||Jn(f,d)))&&l.push(f);return l}i(Ki,"arrayLikeKeys");var Ui=Ki;function Fi(t,e){return function(r){return t(e(r))}}i(Fi,"overArg");var zi=Fi,Yp=zi(Object.keys,Object),Qp=Yp,ef=Object.prototype,tf=ef.hasOwnProperty;function Li(t){if(!Bi(t))return Qp(t);var e=[];for(var r in Object(t))tf.call(t,r)&&r!="constructor"&&e.push(r);return e}i(Li,"baseKeys");var rf=Li;function Wi(t){return Oi(t)?Ui(t):rf(t)}i(Wi,"keys");var Qn=Wi;function qi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}i(qi,"nativeKeysIn");var nf=qi,sf=Object.prototype,af=sf.hasOwnProperty;function Vi(t){if(!st(t))return nf(t);var e=Bi(t),r=[];for(var n in t)n=="constructor"&&(e||!af.call(t,n))||r.push(n);return r}i(Vi,"baseKeysIn");var of=Vi;function Gi(t){return Oi(t)?Ui(t,!0):of(t)}i(Gi,"keysIn");var lf=Gi,cf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,df=/^\w*$/;function Ji(t,e){if(ge(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||Vn(t)?!0:df.test(t)||!cf.test(t)||e!=null&&t in Object(e)}i(Ji,"isKey");var es=Ji,uf=Ke(Object,"create"),At=uf;function Xi(){this.__data__=At?At(null):{},this.size=0}i(Xi,"hashClear");var pf=Xi;function Yi(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}i(Yi,"hashDelete");var ff=Yi,gf="__lodash_hash_undefined__",yf=Object.prototype,hf=yf.hasOwnProperty;function Qi(t){var e=this.__data__;if(At){var r=e[t];return r===gf?void 0:r}return hf.call(e,t)?e[t]:void 0}i(Qi,"hashGet");var mf=Qi,vf=Object.prototype,_f=vf.hasOwnProperty;function eo(t){var e=this.__data__;return At?e[t]!==void 0:_f.call(e,t)}i(eo,"hashHas");var Tf=eo,bf="__lodash_hash_undefined__";function to(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=At&&e===void 0?bf:e,this}i(to,"hashSet");var wf=to;function Ue(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}i(Ue,"Hash");Ue.prototype.clear=pf;Ue.prototype.delete=ff;Ue.prototype.get=mf;Ue.prototype.has=Tf;Ue.prototype.set=wf;var aa=Ue;function ro(){this.__data__=[],this.size=0}i(ro,"listCacheClear");var Pf=ro;function no(t,e){for(var r=t.length;r--;)if(Xn(t[r][0],e))return r;return-1}i(no,"assocIndexOf");var qr=no,xf=Array.prototype,kf=xf.splice;function so(t){var e=this.__data__,r=qr(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():kf.call(e,r,1),--this.size,!0}i(so,"listCacheDelete");var Sf=so;function ao(t){var e=this.__data__,r=qr(e,t);return r<0?void 0:e[r][1]}i(ao,"listCacheGet");var Ef=ao;function io(t){return qr(this.__data__,t)>-1}i(io,"listCacheHas");var Of=io;function oo(t,e){var r=this.__data__,n=qr(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}i(oo,"listCacheSet");var Zf=oo;function Fe(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}i(Fe,"ListCache");Fe.prototype.clear=Pf;Fe.prototype.delete=Sf;Fe.prototype.get=Ef;Fe.prototype.has=Of;Fe.prototype.set=Zf;var Vr=Fe,Bf=Ke(ye,"Map"),Rt=Bf;function lo(){this.size=0,this.__data__={hash:new aa,map:new(Rt||Vr),string:new aa}}i(lo,"mapCacheClear");var If=lo;function co(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}i(co,"isKeyable");var Cf=co;function uo(t,e){var r=t.__data__;return Cf(e)?r[typeof e=="string"?"string":"hash"]:r.map}i(uo,"getMapData");var Gr=uo;function po(t){var e=Gr(this,t).delete(t);return this.size-=e?1:0,e}i(po,"mapCacheDelete");var Af=po;function fo(t){return Gr(this,t).get(t)}i(fo,"mapCacheGet");var Rf=fo;function go(t){return Gr(this,t).has(t)}i(go,"mapCacheHas");var Hf=go;function yo(t,e){var r=Gr(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}i(yo,"mapCacheSet");var Df=yo;function ze(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}i(ze,"MapCache");ze.prototype.clear=If;ze.prototype.delete=Af;ze.prototype.get=Rf;ze.prototype.has=Hf;ze.prototype.set=Df;var Jr=ze,Mf="Expected a function";function Xr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Mf);var r=i(function(){var n=arguments,s=e?e.apply(this,n):n[0],a=r.cache;if(a.has(s))return a.get(s);var o=t.apply(this,n);return r.cache=a.set(s,o)||a,o},"memoized");return r.cache=new(Xr.Cache||Jr),r}i(Xr,"memoize");Xr.Cache=Jr;var Nf=Xr,$f=500;function ho(t){var e=Nf(t,function(n){return r.size===$f&&r.clear(),n}),r=e.cache;return e}i(ho,"memoizeCapped");var jf=ho,Kf=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Uf=/\\(\\)?/g,Ff=jf(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Kf,function(r,n,s,a){e.push(s?a.replace(Uf,"$1"):n||r)}),e}),zf=Ff;function mo(t){return t==null?"":Nu(t)}i(mo,"toString");var Lf=mo;function vo(t,e){return ge(t)?t:es(t,e)?[t]:zf(Lf(t))}i(vo,"castPath");var Yr=vo,Wf=1/0;function _o(t){if(typeof t=="string"||Vn(t))return t;var e=t+"";return e=="0"&&1/t==-Wf?"-0":e}i(_o,"toKey");var $t=_o;function To(t,e){e=Yr(e,t);for(var r=0,n=e.length;t!=null&&r<n;)t=t[$t(e[r++])];return r&&r==n?t:void 0}i(To,"baseGet");var ts=To;function bo(t,e,r){var n=t==null?void 0:ts(t,e);return n===void 0?r:n}i(bo,"get");var qf=bo;function wo(t,e){for(var r=-1,n=e.length,s=t.length;++r<n;)t[s+r]=e[r];return t}i(wo,"arrayPush");var Po=wo,Vf=zi(Object.getPrototypeOf,Object),xo=Vf,Gf="[object Object]",Jf=Function.prototype,Xf=Object.prototype,ko=Jf.toString,Yf=Xf.hasOwnProperty,Qf=ko.call(Object);function So(t){if(!He(t)||$e(t)!=Gf)return!1;var e=xo(t);if(e===null)return!0;var r=Yf.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&ko.call(r)==Qf}i(So,"isPlainObject");var ia=So;function Eo(){this.__data__=new Vr,this.size=0}i(Eo,"stackClear");var eg=Eo;function Oo(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}i(Oo,"stackDelete");var tg=Oo;function Zo(t){return this.__data__.get(t)}i(Zo,"stackGet");var rg=Zo;function Bo(t){return this.__data__.has(t)}i(Bo,"stackHas");var ng=Bo,sg=200;function Io(t,e){var r=this.__data__;if(r instanceof Vr){var n=r.__data__;if(!Rt||n.length<sg-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Jr(n)}return r.set(t,e),this.size=r.size,this}i(Io,"stackSet");var ag=Io;function Le(t){var e=this.__data__=new Vr(t);this.size=e.size}i(Le,"Stack");Le.prototype.clear=eg;Le.prototype.delete=tg;Le.prototype.get=rg;Le.prototype.has=ng;Le.prototype.set=ag;var Qt=Le;function Co(t,e){for(var r=-1,n=t==null?0:t.length,s=0,a=[];++r<n;){var o=t[r];e(o,r,t)&&(a[s++]=o)}return a}i(Co,"arrayFilter");var ig=Co;function Ao(){return[]}i(Ao,"stubArray");var Ro=Ao,og=Object.prototype,lg=og.propertyIsEnumerable,oa=Object.getOwnPropertySymbols,cg=oa?function(t){return t==null?[]:(t=Object(t),ig(oa(t),function(e){return lg.call(t,e)}))}:Ro,Ho=cg,dg=Object.getOwnPropertySymbols,ug=dg?function(t){for(var e=[];t;)Po(e,Ho(t)),t=xo(t);return e}:Ro,pg=ug;function Do(t,e,r){var n=e(t);return ge(t)?n:Po(n,r(t))}i(Do,"baseGetAllKeys");var Mo=Do;function No(t){return Mo(t,Qn,Ho)}i(No,"getAllKeys");var la=No;function $o(t){return Mo(t,lf,pg)}i($o,"getAllKeysIn");var fg=$o,gg=Ke(ye,"DataView"),Nn=gg,yg=Ke(ye,"Promise"),$n=yg,hg=Ke(ye,"Set"),jn=hg,ca="[object Map]",mg="[object Object]",da="[object Promise]",ua="[object Set]",pa="[object WeakMap]",fa="[object DataView]",vg=je(Nn),_g=je(Rt),Tg=je($n),bg=je(jn),wg=je(Dn),Ze=$e;(Nn&&Ze(new Nn(new ArrayBuffer(1)))!=fa||Rt&&Ze(new Rt)!=ca||$n&&Ze($n.resolve())!=da||jn&&Ze(new jn)!=ua||Dn&&Ze(new Dn)!=pa)&&(Ze=i(function(t){var e=$e(t),r=e==mg?t.constructor:void 0,n=r?je(r):"";if(n)switch(n){case vg:return fa;case _g:return ca;case Tg:return da;case bg:return ua;case wg:return pa}return e},"getTag"));var ga=Ze,Pg=ye.Uint8Array,ya=Pg,xg="__lodash_hash_undefined__";function jo(t){return this.__data__.set(t,xg),this}i(jo,"setCacheAdd");var kg=jo;function Ko(t){return this.__data__.has(t)}i(Ko,"setCacheHas");var Sg=Ko;function Ht(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Jr;++e<r;)this.add(t[e])}i(Ht,"SetCache");Ht.prototype.add=Ht.prototype.push=kg;Ht.prototype.has=Sg;var Eg=Ht;function Uo(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}i(Uo,"arraySome");var Og=Uo;function Fo(t,e){return t.has(e)}i(Fo,"cacheHas");var Zg=Fo,Bg=1,Ig=2;function zo(t,e,r,n,s,a){var o=r&Bg,l=t.length,d=e.length;if(l!=d&&!(o&&d>l))return!1;var f=a.get(t),g=a.get(e);if(f&&g)return f==e&&g==t;var h=-1,x=!0,O=r&Ig?new Eg:void 0;for(a.set(t,e),a.set(e,t);++h<l;){var B=t[h],U=e[h];if(n)var W=o?n(U,B,h,e,t,a):n(B,U,h,t,e,a);if(W!==void 0){if(W)continue;x=!1;break}if(O){if(!Og(e,function(Q,ae){if(!Zg(O,ae)&&(B===Q||s(B,Q,r,n,a)))return O.push(ae)})){x=!1;break}}else if(!(B===U||s(B,U,r,n,a))){x=!1;break}}return a.delete(t),a.delete(e),x}i(zo,"equalArrays");var Lo=zo;function Wo(t){var e=-1,r=Array(t.size);return t.forEach(function(n,s){r[++e]=[s,n]}),r}i(Wo,"mapToArray");var Cg=Wo;function qo(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}i(qo,"setToArray");var Ag=qo,Rg=1,Hg=2,Dg="[object Boolean]",Mg="[object Date]",Ng="[object Error]",$g="[object Map]",jg="[object Number]",Kg="[object RegExp]",Ug="[object Set]",Fg="[object String]",zg="[object Symbol]",Lg="[object ArrayBuffer]",Wg="[object DataView]",ha=_e?_e.prototype:void 0,Zn=ha?ha.valueOf:void 0;function Vo(t,e,r,n,s,a,o){switch(r){case Wg:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Lg:return!(t.byteLength!=e.byteLength||!a(new ya(t),new ya(e)));case Dg:case Mg:case jg:return Xn(+t,+e);case Ng:return t.name==e.name&&t.message==e.message;case Kg:case Fg:return t==e+"";case $g:var l=Cg;case Ug:var d=n&Rg;if(l||(l=Ag),t.size!=e.size&&!d)return!1;var f=o.get(t);if(f)return f==e;n|=Hg,o.set(t,e);var g=Lo(l(t),l(e),n,s,a,o);return o.delete(t),g;case zg:if(Zn)return Zn.call(t)==Zn.call(e)}return!1}i(Vo,"equalByTag");var qg=Vo,Vg=1,Gg=Object.prototype,Jg=Gg.hasOwnProperty;function Go(t,e,r,n,s,a){var o=r&Vg,l=la(t),d=l.length,f=la(e),g=f.length;if(d!=g&&!o)return!1;for(var h=d;h--;){var x=l[h];if(!(o?x in e:Jg.call(e,x)))return!1}var O=a.get(t),B=a.get(e);if(O&&B)return O==e&&B==t;var U=!0;a.set(t,e),a.set(e,t);for(var W=o;++h<d;){x=l[h];var Q=t[x],ae=e[x];if(n)var q=o?n(ae,Q,x,e,t,a):n(Q,ae,x,t,e,a);if(!(q===void 0?Q===ae||s(Q,ae,r,n,a):q)){U=!1;break}W||(W=x=="constructor")}if(U&&!W){var se=t.constructor,Je=e.constructor;se!=Je&&"constructor"in t&&"constructor"in e&&!(typeof se=="function"&&se instanceof se&&typeof Je=="function"&&Je instanceof Je)&&(U=!1)}return a.delete(t),a.delete(e),U}i(Go,"equalObjects");var Xg=Go,Yg=1,ma="[object Arguments]",va="[object Array]",Xt="[object Object]",Qg=Object.prototype,_a=Qg.hasOwnProperty;function Jo(t,e,r,n,s,a){var o=ge(t),l=ge(e),d=o?va:ga(t),f=l?va:ga(e);d=d==ma?Xt:d,f=f==ma?Xt:f;var g=d==Xt,h=f==Xt,x=d==f;if(x&&Mn(t)){if(!Mn(e))return!1;o=!0,g=!1}if(x&&!g)return a||(a=new Qt),o||ji(t)?Lo(t,e,r,n,s,a):qg(t,e,d,r,n,s,a);if(!(r&Yg)){var O=g&&_a.call(t,"__wrapped__"),B=h&&_a.call(e,"__wrapped__");if(O||B){var U=O?t.value():t,W=B?e.value():e;return a||(a=new Qt),s(U,W,r,n,a)}}return x?(a||(a=new Qt),Xg(t,e,r,n,s,a)):!1}i(Jo,"baseIsEqualDeep");var ey=Jo;function rs(t,e,r,n,s){return t===e?!0:t==null||e==null||!He(t)&&!He(e)?t!==t&&e!==e:ey(t,e,r,n,rs,s)}i(rs,"baseIsEqual");var Qr=rs,ty=1,ry=2;function Xo(t,e,r,n){var s=r.length,a=s,o=!n;if(t==null)return!a;for(t=Object(t);s--;){var l=r[s];if(o&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++s<a;){l=r[s];var d=l[0],f=t[d],g=l[1];if(o&&l[2]){if(f===void 0&&!(d in t))return!1}else{var h=new Qt;if(n)var x=n(f,g,d,t,e,h);if(!(x===void 0?Qr(g,f,ty|ry,n,h):x))return!1}}return!0}i(Xo,"baseIsMatch");var ny=Xo;function Yo(t){return t===t&&!st(t)}i(Yo,"isStrictComparable");var Qo=Yo;function el(t){for(var e=Qn(t),r=e.length;r--;){var n=e[r],s=t[n];e[r]=[n,s,Qo(s)]}return e}i(el,"getMatchData");var sy=el;function tl(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}i(tl,"matchesStrictComparable");var rl=tl;function nl(t){var e=sy(t);return e.length==1&&e[0][2]?rl(e[0][0],e[0][1]):function(r){return r===t||ny(r,t,e)}}i(nl,"baseMatches");var ay=nl;function sl(t,e){return t!=null&&e in Object(t)}i(sl,"baseHasIn");var iy=sl;function al(t,e,r){e=Yr(e,t);for(var n=-1,s=e.length,a=!1;++n<s;){var o=$t(e[n]);if(!(a=t!=null&&r(t,o)))break;t=t[o]}return a||++n!=s?a:(s=t==null?0:t.length,!!s&&Yn(s)&&Jn(o,s)&&(ge(t)||Ri(t)))}i(al,"hasPath");var oy=al;function il(t,e){return t!=null&&oy(t,e,iy)}i(il,"hasIn");var ly=il,cy=1,dy=2;function ol(t,e){return es(t)&&Qo(e)?rl($t(t),e):function(r){var n=qf(r,t);return n===void 0&&n===e?ly(r,t):Qr(e,n,cy|dy)}}i(ol,"baseMatchesProperty");var uy=ol;function ll(t){return function(e){return e?.[t]}}i(ll,"baseProperty");var py=ll;function cl(t){return function(e){return ts(e,t)}}i(cl,"basePropertyDeep");var fy=cl;function dl(t){return es(t)?py($t(t)):fy(t)}i(dl,"property");var gy=dl;function ul(t){return typeof t=="function"?t:t==null?$u:typeof t=="object"?ge(t)?uy(t[0],t[1]):ay(t):gy(t)}i(ul,"baseIteratee");var ns=ul;function pl(t){return function(e,r,n){for(var s=-1,a=Object(e),o=n(e),l=o.length;l--;){var d=o[t?l:++s];if(r(a[d],d,a)===!1)break}return e}}i(pl,"createBaseFor");var yy=pl,hy=yy(),my=hy;function fl(t,e){return t&&my(t,e,Qn)}i(fl,"baseForOwn");var vy=fl;function gl(t,e){return Qr(t,e)}i(gl,"isEqual");var rt=gl;function yl(t,e,r){r=typeof r=="function"?r:void 0;var n=r?r(t,e):void 0;return n===void 0?Qr(t,e,void 0,r):!!n}i(yl,"isEqualWith");var _y=yl;function hl(t){return t===void 0}i(hl,"isUndefined");var Ta=hl;function ml(t,e){var r={};return e=ns(e,3),vy(t,function(n,s,a){Pi(r,s,e(n,s,a))}),r}i(ml,"mapValues");var Ty=ml,by="Expected a function";function vl(t){if(typeof t!="function")throw new TypeError(by);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}i(vl,"negate");var wy=vl;function _l(t,e,r,n){if(!st(t))return t;e=Yr(e,t);for(var s=-1,a=e.length,o=a-1,l=t;l!=null&&++s<a;){var d=$t(e[s]),f=r;if(d==="__proto__"||d==="constructor"||d==="prototype")return t;if(s!=o){var g=l[d];f=n?n(g,d,l):void 0,f===void 0&&(f=st(g)?g:Jn(e[s+1])?[]:{})}cp(l,d,f),l=l[d]}return t}i(_l,"baseSet");var Py=_l;function Tl(t,e,r){for(var n=-1,s=e.length,a={};++n<s;){var o=e[n],l=ts(t,o);r(l,o)&&Py(a,Yr(o,t),l)}return a}i(Tl,"basePickBy");var xy=Tl;function bl(t,e){if(t==null)return{};var r=ui(fg(t),function(n){return[n]});return e=ns(e),xy(t,r,function(n,s){return e(n,s[0])})}i(bl,"pickBy");var ky=bl;function wl(t,e){return ky(t,wy(ns(e)))}i(wl,"omitBy");var ba=wl,Sy=i(t=>{let e=t.checks;return e.length===0?"":e.map(Ey).join("")},"generateStringChecks"),Ey=i(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"length":return`.length(${T(t.value)}, ${T(t.message)})`;case"email":return`.email(${T(t.message)})`;case"url":return`.url(${T(t.message)})`;case"emoji":return`.emoji(${T(t.message)})`;case"uuid":return`.uuid(${T(t.message)})`;case"cuid":return`.cuid(${T(t.message)})`;case"cuid2":return`.cuid2(${T(t.message)})`;case"ulid":return`.ulid(${T(t.message)})`;case"includes":let e=tt({message:t.message,position:t.position});return`.includes(${T(t.value)}, ${e})`;case"startsWith":return`.startsWith(${T(t.value)}, ${T(t.message)})`;case"endsWith":return`.endsWith(${T(t.value)}, ${T(t.message)})`;case"regex":return`.regex(${String(t.regex)}, ${T(t.message)})`;case"trim":return".trim()";case"toLowerCase":return".toLowerCase()";case"toUpperCase":return".toUpperCase()";case"datetime":let n=t.precision===null?void 0:t.precision;return`.datetime(${tt({message:t.message,precision:n,offset:t.offset})})`;case"ip":return`.ip(${tt({message:t.message,version:t.version})})`;default:return""}},"_generateStringCheck"),Oy=i(t=>{let e=t.checks;return e.length===0?"":e.map(Zy).join("")},"generateNumberChecks"),Zy=i(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"int":return`.int(${T(t.message)})`;case"multipleOf":return`.multipleOf(${T(t.value)}, ${T(t.message)})`;case"finite":return`.finite(${T(t.message)})`;default:return""}},"_generateNumberCheck"),By=i(t=>{let e=t.checks;return e.length===0?"":e.map(Iy).join("")},"generateBigIntChecks"),Iy=i(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"multipleOf":return`.multipleOf(${T(t.value)}, ${T(t.message)})`;default:return""}},"_generateBigIntCheck"),Cy=i(t=>{let e=t.checks;return e.length===0?"":e.map(Ay).join("")},"generateDateChecks"),Ay=i(t=>{switch(t.kind){case"min":return`.min(${wa(t.value)}, ${T(t.message)})`;case"max":return`.max(${wa(t.value)}, ${T(t.message)})`;default:return""}},"_generateDateCheck"),wa=i(t=>`new Date(${t})`,"dateTs"),Ry=i(t=>{let e=[];if(t.exactLength){let{value:r,message:n}=t.exactLength;e.push(`.length(${T(r)}, ${T(n)})`)}if(t.minLength){let{value:r,message:n}=t.minLength;e.push(`.min(${T(r)}, ${T(n)})`)}if(t.maxLength){let{value:r,message:n}=t.maxLength;e.push(`.max(${T(r)}, ${T(n)})`)}return e.join("")},"generateArrayChecks"),Hy=i(t=>{let e=[];if(t.minSize){let{value:r,message:n}=t.minSize;e.push(`.min(${T(r)}, ${T(n)})`)}if(t.maxSize){let{value:r,message:n}=t.maxSize;e.push(`.max(${T(r)}, ${T(n)})`)}return e.join("")},"generateSetChecks");function ss(t){return N(t)}i(ss,"toTypescriptSchema");function N(t){let r=t._def;switch(r.typeName){case u.ZodFirstPartyTypeKind.ZodString:return`z.string()${Sy(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNumber:return`z.number()${Oy(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNaN:return`z.nan()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodBigInt:return`z.bigint()${By(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodBoolean:return`z.boolean()${R(r)}${A(t._def)}`.trim();case u.ZodFirstPartyTypeKind.ZodDate:return`z.date()${Cy(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodUndefined:return`z.undefined()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNull:return`z.null()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodAny:return`z.any()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodUnknown:return`z.unknown()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNever:return`z.never()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodVoid:return`z.void()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodArray:return`z.array(${N(r.type)})${Ry(r)}${R(r)}${A(r)}`;case u.ZodFirstPartyTypeKind.ZodObject:let n=Ty(r.shape(),N),s=t.additionalProperties(),a=s?`.catchall(${N(s)})`:"";return["z.object({",...Object.entries(n).map(([ou,lu])=>` ${ou}: ${lu},`),`})${a}${R(r)}${A(r)}`].join(`
11
- `).trim();case u.ZodFirstPartyTypeKind.ZodUnion:return`z.union([${r.options.map(N).join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let l=r.options.map(N);return`z.discriminatedUnion(${T(r.discriminator)}, [${l.join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodIntersection:let f=N(r.left),g=N(r.right);return`z.intersection(${f}, ${g})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodTuple:return`z.tuple([${r.items.map(N).join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodRecord:let x=N(r.keyType),O=N(r.valueType);return`z.record(${x}, ${O})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodMap:let B=N(r.keyType),U=N(r.valueType);return`z.map(${B}, ${U})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodSet:return`z.set(${N(r.valueType)})${Hy(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodFunction:let W=r.args.items.map(N),Q=W.length?`.args(${W.join(", ")})`:"",ae=N(r.returns);return`z.function()${Q}.returns(${ae})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodLazy:return`z.lazy(() => ${N(r.getter())})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodLiteral:return`z.literal(${T(r.value)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return`z.enum([${r.values.map(T).join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodEffects:throw new Oe(u.ZodFirstPartyTypeKind.ZodEffects);case u.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Oe(u.ZodFirstPartyTypeKind.ZodNativeEnum);case u.ZodFirstPartyTypeKind.ZodOptional:return`z.optional(${N(r.innerType)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNullable:return`z.nullable(${N(r.innerType)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodDefault:let Je=tt(r.defaultValue());return`z.default(${N(r.innerType)}, ${Je})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodCatch:throw new Oe(u.ZodFirstPartyTypeKind.ZodCatch);case u.ZodFirstPartyTypeKind.ZodPromise:return`z.promise(${N(r.type)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodBranded:throw new Oe(u.ZodFirstPartyTypeKind.ZodBranded);case u.ZodFirstPartyTypeKind.ZodPipeline:throw new Oe(u.ZodFirstPartyTypeKind.ZodPipeline);case u.ZodFirstPartyTypeKind.ZodSymbol:throw new Oe(u.ZodFirstPartyTypeKind.ZodSymbol);case u.ZodFirstPartyTypeKind.ZodReadonly:return`z.readonly(${N(r.innerType)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodRef:return`z.ref(${T(r.uri)})${R(r)}${A(r)}`.trim();default:Z.assertNever(r)}}i(N,"sUnwrapZod");var A=i(t=>t.description?`.describe(${T(t.description)})`:"","_maybeDescribe"),R=i(t=>`${Dy(t)}${My(t)}${Ny(t)}${$y(t)}${jy(t)}${Ky(t)}${Uy(t)}`,"_addZuiExtensions"),Dy=i(t=>{var e;return(e=t[b])!=null&&e.title?`.title(${T(t[b].title)})`:""},"_maybeTitle"),My=i(t=>{var e;return(e=t[b])!=null&&e.displayAs?`.displayAs(${Ca({id:t[b].displayAs[0],params:t[b].displayAs[1]})})`:""},"_maybeDisplayAs"),Ny=i(t=>{var e;return(e=t[b])!=null&&e.disabled?`.disabled(${t[b].disabled})`:""},"_maybeDisabled"),$y=i(t=>{var e;return(e=t[b])!=null&&e.hidden?`.hidden(${t[b].hidden})`:""},"_maybeHidden"),jy=i(t=>{var e;return(e=t[b])!=null&&e.placeholder?`.placeholder(${T(t[b].placeholder)})`:""},"_maybePlaceholder"),Ky=i(t=>{var e;return(e=t[b])!=null&&e.secret?".secret()":""},"_maybeSecret"),Uy=i(t=>{var e;let r=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],n=Object.entries((e=t[b])!=null?e:{}).filter(([s])=>!r.includes(s));return n.length>0?`.metadata(${Ca(Object.fromEntries(n))})`:""},"_maybeSetMetadata"),Fy=i(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[b]&&(e[b]=t._def[b]);for(let r of t._def.checks)switch(r.kind){case"min":{let n=r.inclusive?"minimum":"exclusiveMinimum",s=r.inclusive?"exclusiveMinimum":"minimum";e[n]=r.value,delete e[s];break}case"max":{let n=r.inclusive?"maximum":"exclusiveMaximum",s=r.inclusive?"exclusiveMaximum":"maximum";e[n]=r.value,delete e[s];break}case"int":e.type="integer";break;case"finite":{e.format="finite";break}case"multipleOf":e.multipleOf=r.value;break;default:}return e},"zodNumberToJsonNumber"),Pl="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",xl="(([+-]\\d{2}(:?\\d{2})?)|Z)",zy="Z",kl="(\\.\\d+)?",Kn="\\.\\d{",Ly="}",Sl=i(t=>{let e=t.precision?Kn+t.precision+Ly:t.precision===0?"":kl,r=t.offset?xl:zy;return new RegExp(`^${Pl}${e}${r}$`)},"generateDatetimeRegex"),Wy=i(t=>({precision:qy(t),offset:t.endsWith(`${xl}$`)}),"extractPrecisionAndOffset"),qy=i(t=>{let e=t.slice(1+Pl.length);return e.startsWith(kl)?null:e.startsWith(Kn)?parseInt(e.slice(Kn.length)):0},"_extractPrecision"),Ct={};Fr(Ct,{escapeSpecialChars:()=>Vy});var Vy=i(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function as(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage=p(c({},t.errorMessage),{[e]:r}))}i(as,"addErrorMessage");function H(t,e,r,n,s){t[e]=r,as(t,e,n,s)}i(H,"setResponseValueAndErrors");var j={cuid:"^[cC][^\\s-]{8,}$",cuid2:"^[a-z][a-z0-9]*$",ulid:"^[0-9A-HJKMNP-TV-Z]{26}$",email:"^(?!\\.)(?!.*\\.\\.)([a-zA-Z0-9_+-\\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\\-]*\\.)+[a-zA-Z]{2,}$",emoji:"^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",uuid:"^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$",ipv4:"^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$",ipv6:"^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$"};function is(t,e){let r=c({type:"string"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});function n(s){return e.patternStrategy==="escape"?Ct.escapeSpecialChars(s):s}if(i(n,"processPattern"),t.checks)for(let s of t.checks)switch(s.kind){case"min":H(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e);break;case"max":H(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Ee(r,"email",s.message,e);break;case"format:idn-email":Ee(r,"idn-email",s.message,e);break;case"pattern:zod":de(r,j.email,s.message,e);break}break;case"url":Ee(r,"uri",s.message,e);break;case"uuid":Ee(r,"uuid",s.message,e);break;case"regex":de(r,s.regex.source,s.message,e);break;case"cuid":de(r,j.cuid,s.message,e);break;case"cuid2":de(r,j.cuid2,s.message,e);break;case"startsWith":de(r,"^"+n(s.value),s.message,e);break;case"endsWith":de(r,n(s.value)+"$",s.message,e);break;case"datetime":Ee(r,"date-time",s.message,e);break;case"length":H(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e),H(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"includes":{de(r,n(s.value),s.message,e);break}case"ip":{s.version!=="v6"&&Ee(r,"ipv4",s.message,e),s.version!=="v4"&&Ee(r,"ipv6",s.message,e);break}case"emoji":de(r,j.emoji,s.message,e);break;case"ulid":{de(r,j.ulid,s.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}i(is,"parseStringDef");var Ee=i((t,e,r,n)=>{var s;t.format||(s=t.anyOf)!=null&&s.some(a=>a.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push(c({format:t.format},t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}})),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push(c({format:e},r&&n.errorMessages&&{errorMessage:{format:r}}))):H(t,"format",e,r,n)},"addFormat"),de=i((t,e,r,n)=>{var s;t.pattern||(s=t.allOf)!=null&&s.some(a=>a.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push(c({pattern:t.pattern},t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}})),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push(c({pattern:e},r&&n.errorMessages&&{errorMessage:{pattern:r}}))):H(t,"pattern",e,r,n)},"addPattern"),Gy=i(t=>{let e={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[b]&&(e[b]=t._def[b]);for(let r of t._def.checks)switch(r.kind){case"cuid":e.format="cuid",e.pattern=j.cuid;break;case"cuid2":e.format="cuid2",e.pattern=j.cuid2;break;case"ulid":e.format="ulid",e.pattern=j.ulid;break;case"uuid":e.format="uuid",e.pattern=j.uuid;break;case"emoji":e.format="emoji",e.pattern=j.emoji;break;case"email":e.format="email",e.pattern=j.email;break;case"ip":e.format=r.version==="v6"?"ipv6":"ipv4",e.pattern=r.version==="v6"?j.ipv6:j.ipv4;break;case"datetime":e.format="date-time",e.pattern=Sl(r).source,e[b]=p(c({},e[b]),{precision:r.precision,offset:r.offset});break;case"url":e.format="uri";break;case"endsWith":e.pattern=`${Ct.escapeSpecialChars(r.value)}$`;break;case"startsWith":e.pattern=`^${Ct.escapeSpecialChars(r.value)}`;break;case"includes":let n=r.position&&r.position>=1?`^(?:.{${r.position}}).*`:"";e.pattern=`${n}${Ct.escapeSpecialChars(r.value)}`;break;case"regex":e.pattern=r.regex.source;break;case"length":e.minLength=e.maxLength=Math.max(0,r.value);break;case"min":e.minLength=Math.max(0,r.value);break;case"max":e.maxLength=Math.max(0,r.value);break;default:throw new Ka({zodType:u.ZodFirstPartyTypeKind.ZodString,checkKind:r.kind})}return e},"zodStringToJsonString"),Jy=i((t,e)=>{let r={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[b]&&(r[b]=t._def[b]),t._def.minLength&&(r.minItems=t._def.minLength.value),t._def.maxLength&&(r.maxItems=t._def.maxLength.value),t._def.exactLength&&(r.minItems=t._def.exactLength.value,r.maxItems=t._def.exactLength.value),r},"zodArrayToJsonArray"),Xy=i((t,e)=>{let r={type:"array",description:t.description,uniqueItems:!0,items:e(t._def.valueType),"x-zui":t._def["x-zui"]};return t._def[b]&&(r[b]=t._def[b]),t._def.minSize&&(r.minItems=t._def.minSize.value),t._def.maxSize&&(r.maxItems=t._def.maxSize.value),r},"zodSetToJsonSet"),Yy=i((t,e)=>{let r={type:"array",description:t.description,items:t._def.items.map(n=>e(n))};return t._def[b]&&(r[b]=t._def[b]),t._def.rest&&(r.additionalItems=e(t._def.rest)),r},"zodTupleToJsonTuple");function V(t){let e=t,r=e._def;switch(r.typeName){case u.ZodFirstPartyTypeKind.ZodString:return Gy(e);case u.ZodFirstPartyTypeKind.ZodNumber:return Fy(e);case u.ZodFirstPartyTypeKind.ZodNaN:throw new ee(u.ZodFirstPartyTypeKind.ZodNaN);case u.ZodFirstPartyTypeKind.ZodBigInt:throw new ee(u.ZodFirstPartyTypeKind.ZodBigInt,{suggestedAlternative:"serialize bigint to string"});case u.ZodFirstPartyTypeKind.ZodBoolean:return{type:"boolean",description:r.description,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodDate:throw new ee(u.ZodFirstPartyTypeKind.ZodDate,{suggestedAlternative:"use z.string().datetime() instead"});case u.ZodFirstPartyTypeKind.ZodUndefined:return Bn(r);case u.ZodFirstPartyTypeKind.ZodNull:return In(r);case u.ZodFirstPartyTypeKind.ZodAny:return{description:r.description,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodUnknown:return{description:r.description,"x-zui":p(c({},r["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodUnknown}})};case u.ZodFirstPartyTypeKind.ZodNever:return{not:!0,description:r.description,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodVoid:throw new ee(u.ZodFirstPartyTypeKind.ZodVoid);case u.ZodFirstPartyTypeKind.ZodArray:return Jy(e,V);case u.ZodFirstPartyTypeKind.ZodObject:let n=Object.entries(r.shape()),s=n.filter(([g,h])=>!h.isOptional()),a=s.length?s.map(([g])=>g):void 0,o=n.map(([g,h])=>[g,h.mandatory()]).map(([g,h])=>[g,V(h)]),l=!1;return r.unknownKeys instanceof u.ZodType?l=V(r.unknownKeys):r.unknownKeys==="passthrough"&&(l=!0),{type:"object",description:r.description,properties:Object.fromEntries(o),required:a,additionalProperties:l,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodUnion:return{description:r.description,anyOf:r.options.map(g=>V(g)),"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return{description:r.description,anyOf:r.options.map(g=>V(g)),"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodIntersection:let d=V(r.left),f=V(r.right);return"additionalProperties"in d&&delete d.additionalProperties,"additionalProperties"in f&&delete f.additionalProperties,{description:r.description,allOf:[d,f],"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodTuple:return Yy(e,V);case u.ZodFirstPartyTypeKind.ZodRecord:return{type:"object",description:r.description,additionalProperties:V(r.valueType),"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodMap:throw new ee(u.ZodFirstPartyTypeKind.ZodMap);case u.ZodFirstPartyTypeKind.ZodSet:return Xy(e,V);case u.ZodFirstPartyTypeKind.ZodFunction:throw new ee(u.ZodFirstPartyTypeKind.ZodFunction);case u.ZodFirstPartyTypeKind.ZodLazy:throw new ee(u.ZodFirstPartyTypeKind.ZodLazy);case u.ZodFirstPartyTypeKind.ZodLiteral:if(typeof r.value=="string")return{type:"string",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="number")return{type:"number",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="boolean")return{type:"boolean",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(r.value===null)return In(r);if(r.value===void 0)return Bn(r);{u.util.assertEqual(!0);let g=typeof r.value;throw new Lr(`Unsupported literal type: "${g}"`)}case u.ZodFirstPartyTypeKind.ZodEnum:return{type:"string",description:r.description,enum:r.values,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodEffects:throw new ee(u.ZodFirstPartyTypeKind.ZodEffects);case u.ZodFirstPartyTypeKind.ZodNativeEnum:throw new ee(u.ZodFirstPartyTypeKind.ZodNativeEnum);case u.ZodFirstPartyTypeKind.ZodOptional:return{description:r.description,anyOf:[V(r.innerType),Bn()],"x-zui":p(c({},r["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodOptional}})};case u.ZodFirstPartyTypeKind.ZodNullable:return{anyOf:[V(r.innerType),In()],"x-zui":p(c({},r["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodNullable}})};case u.ZodFirstPartyTypeKind.ZodDefault:return p(c({},V(r.innerType)),{default:r.defaultValue()});case u.ZodFirstPartyTypeKind.ZodCatch:throw new ee(u.ZodFirstPartyTypeKind.ZodCatch);case u.ZodFirstPartyTypeKind.ZodPromise:throw new ee(u.ZodFirstPartyTypeKind.ZodPromise);case u.ZodFirstPartyTypeKind.ZodBranded:throw new ee(u.ZodFirstPartyTypeKind.ZodBranded);case u.ZodFirstPartyTypeKind.ZodPipeline:throw new ee(u.ZodFirstPartyTypeKind.ZodPipeline);case u.ZodFirstPartyTypeKind.ZodSymbol:throw new ee(u.ZodFirstPartyTypeKind.ZodPipeline);case u.ZodFirstPartyTypeKind.ZodReadonly:return p(c({},V(r.innerType)),{readOnly:!0});case u.ZodFirstPartyTypeKind.ZodRef:return{$ref:r.uri,description:r.description,"x-zui":r["x-zui"]};default:u.util.assertNever(r)}}i(V,"toJSONSchema");var Bn=i(t=>({not:!0,description:t?.description,"x-zui":p(c({},t?.["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodUndefined}})}),"undefinedSchema"),In=i(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),El=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};i(El,"ParseInputLazyPath");var ie=El,Pa=i((t,e)=>{if(it(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new le(t.common.issues);return this._error=r,this._error}}},"handleResult"),Ol=class{constructor(e){this.__type__="ZuiType",this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._metadataRoot._def.description}dereference(e){return this}getReferences(){return[]}clone(){let e=this.constructor;return new e(c({},this._def))}_getType(e){return pe(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:pe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new te,ctx:{common:e.parent.common,data:e.data,parsedType:pe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Mt(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;let s={common:{issues:[],async:(n=r?.async)!=null?n:!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pe(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Pa(s,a)}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pe(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Mt(s)?s:Promise.resolve(s));return Pa(n,a)}refine(e,r){let n=i(s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r,"getIssueProperties");return this._refinement((s,a)=>{let o=e(s),l=i(()=>a.addIssue(c({code:y.custom},n(s))),"setError");return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new be({schema:this,typeName:"ZodEffects",effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return fe.create(this,this._def)}nullable(){return De.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return lt.create(this,this._def)}promise(){return Ut.create(this,this._def)}mandatory(){return this}or(e){return fn.create([this,e],this._def)}and(e){return an.create(this,e,this._def)}transform(e){return new be(p(c({},k(this._def)),{schema:this,typeName:"ZodEffects",effect:{type:"transform",transform:e}}))}default(e){let r=typeof e=="function"?e:()=>e;return new jt(p(c({},k(this._def)),{innerType:this,defaultValue:r,typeName:"ZodDefault"}))}brand(){return new rn(c({typeName:"ZodBranded",type:this},k(this._def)))}catch(e){let r=typeof e=="function"?e:()=>e;return new nn(p(c({},k(this._def)),{innerType:this,catchValue:r,typeName:"ZodCatch"}))}describe(e){let r=this.clone();return r._metadataRoot._def.description=e,r}pipe(e){return pn.create(this,e)}readonly(){return Ft.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}metadata(e){var r,n,s;let a=this.clone(),o=a._metadataRoot;(s=(r=o._def)[n=b])!=null||(r[n]={});for(let[l,d]of Object.entries(e))o._def[b]=p(c({},o._def[b]),{[l]:d});return a}getMetadata(){return c({},this._metadataRoot._def[b])}setMetadata(e){this._metadataRoot._def[b]=c({},e)}get ui(){return c({},this._metadataRoot._def[b])}get _metadataRoot(){return this.naked()}displayAs(e){return this.metadata({displayAs:[e.id,e.params]})}title(e){return this.metadata({title:e})}hidden(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({hidden:r})}disabled(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({disabled:r})}placeholder(e){return this.metadata({placeholder:e})}toJSONSchema(){return V(this)}toTypescriptType(e){return qn(this,e)}toTypescriptSchema(){return ss(this)}naked(){return this}};i(Ol,"ZodType");var E=Ol,os=(t=>(t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodRef="ZodRef",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly",t))(os||{}),Z;(t=>{t.assertEqual=i(s=>s,"assertEqual");function e(s){}t.assertIs=e,i(e,"assertIs");function r(s){throw new Error("assertNever called")}t.assertNever=r,i(r,"assertNever"),t.arrayToEnum=i(s=>{let a={};for(let o of s)a[o]=o;return a},"arrayToEnum"),t.getValidEnumValues=i(s=>{let a=(0,t.objectKeys)(s).filter(l=>typeof s[s[l]]!="number"),o={};for(let l of a)o[l]=s[l];return(0,t.objectValues)(o)},"getValidEnumValues"),t.objectValues=i(s=>(0,t.objectKeys)(s).map(function(a){return s[a]}),"objectValues"),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let a=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&a.push(o);return a},t.find=i((s,a)=>{for(let o of s)if(a(o))return o},"find"),t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}t.joinValues=n,i(n,"joinValues"),t.jsonStringifyReplacer=i((s,a)=>typeof a=="bigint"?a.toString():a,"jsonStringifyReplacer"),t.compareFunctions=i((s,a)=>s.toString()===a.toString(),"compareFunctions"),t.mock=i(()=>({}),"mock")})(Z||(Z={}));var lr;(t=>{t.mergeShapes=i((e,r)=>c(c({},e),r),"mergeShapes")})(lr||(lr={}));var v=Z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),pe=i(t=>{switch(typeof t){case"undefined":return v.undefined;case"string":return v.string;case"number":return isNaN(t)?v.nan:v.number;case"boolean":return v.boolean;case"function":return v.function;case"bigint":return v.bigint;case"symbol":return v.symbol;case"object":return Array.isArray(t)?v.array:t===null?v.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?v.promise:typeof Map<"u"&&t instanceof Map?v.map:typeof Set<"u"&&t instanceof Set?v.set:typeof Date<"u"&&t instanceof Date?v.date:v.object;default:return v.unknown}},"getParsedType");function k(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s,[b]:t?.[b]}:{errorMap:i((o,l)=>o.code!=="invalid_type"?{message:l.defaultError}:typeof l.data>"u"?{message:n??l.defaultError}:{message:r??l.defaultError},"customMap"),description:s,[b]:t?.[b]}}i(k,"processCreateParams");var ls=i((t,e)=>{let r;switch(t.code){case y.invalid_type:t.received===v.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case y.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Z.jsonStringifyReplacer)}`;break;case y.unrecognized_keys:r=`Unrecognized key(s) in object: ${Z.joinValues(t.keys,", ")}`;break;case y.invalid_union:r="Invalid input";break;case y.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Z.joinValues(t.options)}`;break;case y.invalid_enum_value:r=`Invalid enum value. Expected ${Z.joinValues(t.options)}, received '${t.received}'`;break;case y.invalid_arguments:r="Invalid function arguments";break;case y.invalid_return_type:r="Invalid function return type";break;case y.invalid_date:r="Invalid date";break;case y.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Z.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case y.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case y.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case y.custom:r="Invalid input";break;case y.invalid_intersection_types:r="Intersection results could not be merged";break;case y.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case y.not_finite:r="Number must be finite";break;case y.unresolved_reference:r="Unresolved reference";break;default:r=e.defaultError,Z.assertNever(t)}return{message:r}},"errorMap"),xa=ls,y=Z.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite","unresolved_reference"]),Zl=i(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),cr=class Bl extends Error{constructor(e){super(),this.issues=[],this.addIssue=i(n=>{this.issues=[...this.issues,n]},"addIssue"),this.addIssues=i((n=[])=>{this.issues=[...this.issues,...n]},"addIssues");let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let r=e||function(a){return a.message},n={_errors:[]},s=i(a=>{for(let o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let l=n,d=0;for(;d<o.path.length;){let f=o.path[d];d===o.path.length-1?(l[f]=l[f]||{_errors:[]},l[f]._errors.push(r(o))):l[f]=l[f]||{_errors:[]},l=l[f],d++}}},"processError");return s(this),n}static assert(e){if(!(e instanceof Bl))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Z.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};i(cr,"ZodError");cr.create=i(t=>new cr(t),"create");var le=cr,Il=ls;function cs(t){Il=t}i(cs,"setErrorMap");function at(){return Il}i(at,"getErrorMap");var Dt=i(t=>{var e;let{data:r,path:n,errorMaps:s,issueData:a}=t,o=[...n,...a.path||[]],l=p(c({},a),{path:o}),d="",f=s.filter(g=>!!g).slice().reverse();for(let g of f)d=g(l,{data:r,defaultError:d}).message;return p(c({},a),{path:o,message:(e=a.message)!=null?e:d})},"makeIssue"),Cl=[];function m(t,e){let r=Dt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,at(),ls].filter(n=>!!n)});t.common.issues.push(r)}i(m,"addIssueToContext");var Al=class Rl{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return P;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r)n.push({key:await s.key,value:await s.value});return Rl.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:a,value:o}=s;if(a.status==="aborted"||o.status==="aborted")return P;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[a.value]=o.value)}return{status:e.value,value:n}}};i(Al,"ParseStatus");var te=Al,P=Object.freeze({status:"aborted"}),Re=i(t=>({status:"dirty",value:t}),"DIRTY"),J=i(t=>({status:"valid",value:t}),"OK"),dr=i(t=>t.status==="aborted","isAborted"),ur=i(t=>t.status==="dirty","isDirty"),it=i(t=>t.status==="valid","isValid"),Mt=i(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),w;(t=>{t.errToObj=i(e=>typeof e=="string"?{message:e}:e||{},"errToObj"),t.toString=i(e=>typeof e=="string"?e:e?.message,"toString")})(w||(w={}));var pr=class Hl extends E{constructor(){super(...arguments),this._any=!0}_parse(e){return J(e.data)}isEqual(e){return e instanceof Hl}};i(pr,"ZodAny");pr.create=i(t=>new pr(c({typeName:"ZodAny"},k(t))),"create");var ot=pr,fr=class Be extends E{dereference(e){return new Be(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Be(p(c({},this._def),{type:this._def.type.clone()}))}isEqual(e){var r,n,s,a,o,l;return e instanceof Be?rt((r=this._def.exactLength)==null?void 0:r.value,(n=e._def.exactLength)==null?void 0:n.value)&&rt((s=this._def.maxLength)==null?void 0:s.value,(a=e._def.maxLength)==null?void 0:a.value)&&rt((o=this._def.minLength)==null?void 0:o.value,(l=e._def.minLength)==null?void 0:l.value)&&this._def.type.isEqual(e._def.type):!1}_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==v.array)return m(r,{code:y.invalid_type,expected:v.array,received:r.parsedType}),P;if(s.exactLength!==null){let o=r.data.length>s.exactLength.value,l=r.data.length<s.exactLength.value;(o||l)&&(m(r,{code:o?y.too_big:y.too_small,minimum:l?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(m(r,{code:y.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(m(r,{code:y.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,l)=>s.type._parseAsync(new ie(r,o,r.path,l)))).then(o=>te.mergeArray(n,o));let a=[...r.data].map((o,l)=>s.type._parseSync(new ie(r,o,r.path,l)));return te.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new Be(p(c({},this._def),{minLength:{value:e,message:w.toString(r)}}))}max(e,r){return new Be(p(c({},this._def),{maxLength:{value:e,message:w.toString(r)}}))}length(e,r){return new Be(p(c({},this._def),{exactLength:{value:e,message:w.toString(r)}}))}nonempty(e){return this.min(1,e)}};i(fr,"ZodArray");fr.create=i((t,e)=>new fr(c({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},k(e))),"create");var lt=fr,Qy=i((t,e)=>Dl(t,e,new WeakSet),"isEqual"),Dl=i((t,e,r)=>_y(t,e,eh(r)),"_isEqualWithVisitedTracking"),eh=i(t=>(e,r)=>{if(ia(e)&&!t.has(e)&&ia(r)&&!t.has(r)){let n=ba(e,Ta),s=ba(r,Ta);return t.add(n).add(s).add(e).add(r),Dl(n,s,t)}},"_customizerWithVisitedTracking"),th={compare:Qy},Ml=class{constructor(e=[],r={}){this._options=c(c({},th),r),this._items=[];for(let n of e)this.add(n)}get items(){return[...this._items]}get size(){return this._items.length}has(e){return this._items.some(r=>this._options.compare(r,e))}add(e){this.has(e)||this._items.push(e)}isEqual(e){return this.size!==e.size?!1:this.isSubsetOf(e)&&e.isSubsetOf(this)}isSubsetOf(e){return this.size>e.size?!1:this._items.every(r=>e.has(r))}};i(Ml,"CustomSet");var K=Ml,gr=class er extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==v.bigint){let a=this._getOrReturnCtx(e);return m(a,{code:y.invalid_type,expected:v.bigint,received:a.parsedType}),P}let n,s=new te;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:y.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:y.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),m(n,{code:y.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):Z.assertNever(a);return{status:s.value,value:e.data}}isEqual(e){if(!(e instanceof er)||this._def.coerce!==e._def.coerce)return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}gte(e,r){return this.setLimit("min",e,!0,w.toString(r))}gt(e,r){return this.setLimit("min",e,!1,w.toString(r))}lte(e,r){return this.setLimit("max",e,!0,w.toString(r))}lt(e,r){return this.setLimit("max",e,!1,w.toString(r))}setLimit(e,r,n,s){return new er(p(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:w.toString(s)}]}))}_addCheck(e){return new er(p(c({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};i(gr,"ZodBigInt");gr.create=i(t=>{var e;return new gr(c({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},k(t)))},"create");var en=gr,yr=class Nl extends E{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==v.boolean){let n=this._getOrReturnCtx(e);return m(n,{code:y.invalid_type,expected:v.boolean,received:n.parsedType}),P}return J(e.data)}isEqual(e){return e instanceof Nl?this._def.coerce===e._def.coerce:!1}};i(yr,"ZodBoolean");yr.create=i(t=>new yr(c({typeName:"ZodBoolean",coerce:t?.coerce||!1},k(t))),"create");var tn=yr,$l=Symbol("zod_brand"),jl=class _t extends E{dereference(e){return new _t(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new _t(p(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}isEqual(e){return e instanceof _t?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new _t(p(c({},this._def),{type:this._def.type.mandatory()}))}};i(jl,"ZodBranded");var rn=jl,hr=class Tt extends E{_parse(e){let{ctx:r}=this._processInputParams(e),n=p(c({},r),{common:p(c({},r.common),{issues:[]})}),s=this._def.innerType._parse({data:n.data,path:n.path,parent:c({},n)});return Mt(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new le(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new le(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof Tt?this._def.innerType.isEqual(e._def.innerType)&&Z.compareFunctions(this._def.catchValue,e._def.catchValue):!1}dereference(e){return new Tt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Tt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}naked(){return this._def.innerType.naked()}mandatory(){return new Tt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};i(hr,"ZodCatch");hr.create=i((t,e)=>new hr(c({innerType:t,typeName:"ZodCatch",catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},k(e))),"create");var nn=hr,ds=i((t,e={},r)=>t?ot.create().superRefine((n,s)=>{var a,o;if(!t(n)){let l=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,d=(o=(a=l.fatal)!=null?a:r)!=null?o:!0,f=typeof l=="string"?{message:l}:l;s.addIssue(p(c({code:"custom"},f),{fatal:d}))}}):ot.create(),"custom"),mr=class Un extends E{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==v.date){let a=this._getOrReturnCtx(e);return m(a,{code:y.invalid_type,expected:v.date,received:a.parsedType}),P}if(isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return m(a,{code:y.invalid_date}),P}let n=new te,s;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:y.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:y.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):Z.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Un(p(c({},this._def),{checks:[...this._def.checks,e]}))}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}isEqual(e){if(!(e instanceof Un))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)&&this._def.coerce===e._def.coerce}};i(mr,"ZodDate");mr.create=i(t=>new mr(c({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},k(t))),"create");var sn=mr,vr=class bt extends E{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===v.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}dereference(e){return new bt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new bt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}isEqual(e){return e instanceof bt?this._def.innerType.isEqual(e._def.innerType)&&rt(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new bt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};i(vr,"ZodDefault");vr.create=i((t,e,r)=>new vr(c({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},k(r))),"create");var jt=vr,he=i(t=>Array.from(new Set(t)),"unique"),ue=i(t=>t instanceof on?ue(t.schema):t instanceof be?ue(t.innerType()):t instanceof ln?[t.value]:t instanceof We?t.options:t instanceof cn?Z.objectValues(t.enum):t instanceof jt?ue(t._def.innerType):t instanceof zt?[void 0]:t instanceof dn?[null]:t instanceof fe?[void 0,...ue(t.unwrap())]:t instanceof De?[null,...ue(t.unwrap())]:t instanceof rn||t instanceof Ft?ue(t.unwrap()):t instanceof nn?ue(t._def.innerType):[],"getDiscriminator"),Kl=class Ie extends E{dereference(e){let r=this.options.map(s=>s.dereference(e)),n=Ie._getOptionsMap(this.discriminator,r);return new Ie(p(c({},this._def),{options:r,optionsMap:n}))}getReferences(){return he(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(r=>r.clone());return new Ie(p(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==v.object)return m(r,{code:y.invalid_type,expected:v.object,received:r.parsedType}),P;let n=this.discriminator,s=r.data[n],a=this.optionsMap.get(s);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(m(r,{code:y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),P)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=Ie._getOptionsMap(e,r);return new Ie(c({typeName:"ZodDiscriminatedUnion",discriminator:e,options:r,optionsMap:s},k(n)))}static _getOptionsMap(e,r){let n=new Map;for(let s of r){let a=ue(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of a){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,s)}}return n}isEqual(e){if(!(e instanceof Ie)||this._def.discriminator!==e._def.discriminator)return!1;let r=i((a,o)=>a.isEqual(o),"compare"),n=new K(this._def.options,{compare:r}),s=new K(e._def.options,{compare:r});return n.isEqual(s)}};i(Kl,"ZodDiscriminatedUnion");var us=Kl;function Kt(t,e){return new We(c({values:t,typeName:"ZodEnum"},k(e)))}i(Kt,"createZodEnum");var ps=class tr extends E{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return m(r,{expected:Z.joinValues(n),received:r.parsedType,code:y.invalid_type}),P}if(this._def.values.indexOf(e.data)===-1){let r=this._getOrReturnCtx(e),n=this._def.values;return m(r,{received:r.data,code:y.invalid_enum_value,options:n}),P}return J(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return tr.create(e,c(c({},this._def),r))}exclude(e,r=this._def){return tr.create(this.options.filter(n=>!e.includes(n)),c(c({},this._def),r))}isEqual(e){if(!(e instanceof tr))return!1;let r=new K(this._def.values),n=new K(e._def.values);return r.isEqual(n)}};i(ps,"ZodEnum");ps.create=Kt;var We=ps,Ul=class Ce extends E{constructor(){super(...arguments),this.validate=this.implement}dereference(e){let r=this._def.args.dereference(e),n=this._def.returns.dereference(e);return new Ce(p(c({},this._def),{args:r,returns:n}))}getReferences(){return he([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new Ce(p(c({},this._def),{args:this._def.args.clone(),returns:this._def.returns.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==v.function)return m(r,{code:y.invalid_type,expected:v.function,received:r.parsedType}),P;function n(l,d){return Dt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,at(),xa].filter(f=>!!f),issueData:{code:y.invalid_arguments,argumentsError:d}})}i(n,"makeArgsIssue");function s(l,d){return Dt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,at(),xa].filter(f=>!!f),issueData:{code:y.invalid_return_type,returnTypeError:d}})}i(s,"makeReturnsIssue");let a={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof Ut){let l=this;return J(async function(...d){let f=new le([]),g=await l._def.args.parseAsync(d,a).catch(O=>{throw f.addIssue(n(d,O)),f}),h=await Reflect.apply(o,this,g);return await l._def.returns._def.type.parseAsync(h,a).catch(O=>{throw f.addIssue(s(h,O)),f})})}else{let l=this;return J(function(...d){let f=l._def.args.safeParse(d,a);if(!f.success)throw new le([n(d,f.error)]);let g=Reflect.apply(o,this,f.data),h=l._def.returns.safeParse(g,a);if(!h.success)throw new le([s(g,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ce(p(c({},this._def),{args:Ne.create(e).rest(nt.create())}))}returns(e){return new Ce(p(c({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Ce(c({args:e||Ne.create([]).rest(nt.create()),returns:r||nt.create(),typeName:"ZodFunction"},k(n)))}isEqual(e){return e instanceof Ce&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};i(Ul,"ZodFunction");var fs=Ul;function _r(t,e){let r=pe(t),n=pe(e);if(t===e)return{valid:!0,data:t};if(r===v.object&&n===v.object){let s=Z.objectKeys(e),a=Z.objectKeys(t).filter(l=>s.indexOf(l)!==-1),o=c(c({},t),e);for(let l of a){let d=_r(t[l],e[l]);if(!d.valid)return{valid:!1};o[l]=d.data}return{valid:!0,data:o}}else if(r===v.array&&n===v.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let a=0;a<t.length;a++){let o=t[a],l=e[a],d=_r(o,l);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return r===v.date&&n===v.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}i(_r,"mergeValues");var Tr=class rr extends E{dereference(e){return new rr(p(c({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return he([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new rr(p(c({},this._def),{left:this._def.left.clone(),right:this._def.right.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=i((a,o)=>{if(dr(a)||dr(o))return P;let l=_r(a.value,o.value);return l.valid?((ur(a)||ur(o))&&r.dirty(),{status:r.value,value:l.data}):(m(n,{code:y.invalid_intersection_types}),P)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,o])=>s(a,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}isEqual(e){if(!(e instanceof rr))return!1;let r=i((a,o)=>a.isEqual(o),"compare"),n=new K([this._def.left,this._def.right],{compare:r}),s=new K([e._def.left,e._def.right],{compare:r});return n.isEqual(s)}};i(Tr,"ZodIntersection");Tr.create=i((t,e,r)=>new Tr(c({left:t,right:e,typeName:"ZodIntersection"},k(r))),"create");var an=Tr,br=class wt extends E{get schema(){return this._def.getter()}dereference(e){return new wt(p(c({},this._def),{getter:i(()=>this._def.getter().dereference(e),"getter")}))}getReferences(){return this._def.getter().getReferences()}clone(){return new wt(p(c({},this._def),{getter:i(()=>this._def.getter().clone(),"getter")}))}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}isEqual(e){return e instanceof wt?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new wt(p(c({},this._def),{getter:i(()=>this._def.getter().mandatory(),"getter")}))}};i(br,"ZodLazy");br.create=i((t,e)=>new br(c({getter:t,typeName:"ZodLazy"},k(e))),"create");var on=br,wr=class Fl extends E{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return m(r,{received:r.data,code:y.invalid_literal,expected:this._def.value}),P}return{status:"valid",value:e.data}}get value(){return this._def.value}isEqual(e){return e instanceof Fl?rt(this._def.value,e._def.value):!1}};i(wr,"ZodLiteral");wr.create=i((t,e)=>new wr(c({value:t,typeName:"ZodLiteral"},k(e))),"create");var ln=wr,Pr=class nr extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new nr(p(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return he([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new nr(p(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.map)return m(n,{code:y.invalid_type,expected:v.map,received:n.parsedType}),P;let s=this._def.keyType,a=this._def.valueType,o=[...n.data.entries()].map(([l,d],f)=>({key:s._parse(new ie(n,l,n.path,[f,"key"])),value:a._parse(new ie(n,d,n.path,[f,"value"]))}));if(n.common.async){let l=new Map;return Promise.resolve().then(async()=>{for(let d of o){let f=await d.key,g=await d.value;if(f.status==="aborted"||g.status==="aborted")return P;(f.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(f.value,g.value)}return{status:r.value,value:l}})}else{let l=new Map;for(let d of o){let f=d.key,g=d.value;if(f.status==="aborted"||g.status==="aborted")return P;(f.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(f.value,g.value)}return{status:r.value,value:l}}}isEqual(e){return!(!(e instanceof nr)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};i(Pr,"ZodMap");Pr.create=i((t,e,r)=>new Pr(c({valueType:e,keyType:t,typeName:"ZodMap"},k(r))),"create");var gs=Pr,xr=class zl extends E{_parse(e){if(this._getType(e)!==v.nan){let n=this._getOrReturnCtx(e);return m(n,{code:y.invalid_type,expected:v.nan,received:n.parsedType}),P}return{status:"valid",value:e.data}}isEqual(e){return e instanceof zl}};i(xr,"ZodNaN");xr.create=i(t=>new xr(c({typeName:"ZodNaN"},k(t))),"create");var ys=xr,kr=class Ll extends E{_parse(e){let r=Z.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==v.string&&n.parsedType!==v.number){let s=Z.objectValues(r);return m(n,{expected:Z.joinValues(s),received:n.parsedType,code:y.invalid_type}),P}if(r.indexOf(e.data)===-1){let s=Z.objectValues(r);return m(n,{received:n.data,code:y.invalid_enum_value,options:s}),P}return J(e.data)}get enum(){return this._def.values}isEqual(e){return e instanceof Ll?rt(this._def.values,e._def.values):!1}};i(kr,"ZodNativeEnum");kr.create=i((t,e)=>new kr(c({values:t,typeName:"ZodNativeEnum"},k(e))),"create");var cn=kr,Sr=class Wl extends E{_parse(e){let r=this._getOrReturnCtx(e);return m(r,{code:y.invalid_type,expected:v.never,received:r.parsedType}),P}isEqual(e){return e instanceof Wl}};i(Sr,"ZodNever");Sr.create=i(t=>new Sr(c({typeName:"ZodNever"},k(t))),"create");var ut=Sr,Er=class ql extends E{_parse(e){if(this._getType(e)!==v.null){let n=this._getOrReturnCtx(e);return m(n,{code:y.invalid_type,expected:v.null,received:n.parsedType}),P}return J(e.data)}isEqual(e){return e instanceof ql}};i(Er,"ZodNull");Er.create=i(t=>new Er(c({typeName:"ZodNull"},k(t))),"create");var dn=Er,Or=class Pt extends E{dereference(e){return new Pt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Pt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===v.null?J(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof Pt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new Pt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};i(Or,"ZodNullable");Or.create=i((t,e)=>new Or(c({innerType:t,typeName:"ZodNullable"},k(e))),"create");var De=Or;function Vl(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,a=parseInt(t.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return a%o/Math.pow(10,s)}i(Vl,"floatSafeRemainder");var Zr=class sr extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==v.number){let a=this._getOrReturnCtx(e);return m(a,{code:y.invalid_type,expected:v.number,received:a.parsedType}),P}let n,s=new te;for(let a of this._def.checks)a.kind==="int"?Z.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:y.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:y.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:y.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Vl(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),m(n,{code:y.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:y.not_finite,message:a.message}),s.dirty()):Z.assertNever(a);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,w.toString(r))}gt(e,r){return this.setLimit("min",e,!1,w.toString(r))}lte(e,r){return this.setLimit("max",e,!0,w.toString(r))}lt(e,r){return this.setLimit("max",e,!1,w.toString(r))}setLimit(e,r,n,s){return new sr(p(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:w.toString(s)}]}))}_addCheck(e){return new sr(p(c({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Z.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}isEqual(e){if(!(e instanceof sr))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}};i(Zr,"ZodNumber");Zr.create=i(t=>new Zr(c({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},k(t))),"create");var un=Zr;function Ae(t){if(t instanceof Me){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=fe.create(Ae(n))}return new Me(p(c({},t._def),{shape:i(()=>e,"shape")}))}else return t instanceof lt?new lt(p(c({},t._def),{type:Ae(t.element)})):t instanceof fe?fe.create(Ae(t.unwrap())):t instanceof De?De.create(Ae(t.unwrap())):t instanceof Ne?Ne.create(t.items.map(e=>Ae(e))):t}i(Ae,"deepPartialify");var Te=class ne extends E{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Z.objectKeys(e);return this._cached={shape:e,keys:r}}dereference(e){let r=this._def.shape(),n={};for(let s in r)n[s]=r[s].dereference(e);return new ne(p(c({},this._def),{shape:i(()=>n,"shape")}))}getReferences(){let e=this._def.shape(),r=[];for(let n in e)r.push(...e[n].getReferences());return he(r)}clone(){let e={},r=this._def.shape();for(let[n,s]of Object.entries(r))e[n]=s.clone();return new ne(p(c({},this._def),{shape:i(()=>e,"shape")}))}_parse(e){if(this._getType(e)!==v.object){let g=this._getOrReturnCtx(e);return m(g,{code:y.invalid_type,expected:v.object,received:g.parsedType}),P}let{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),l=[];if(this._def.unknownKeys!=="strip")for(let g in s.data)o.includes(g)||l.push(g);let d=[];for(let g of o){let h=a[g],x=s.data[g];d.push({key:{status:"valid",value:g},value:h._parse(new ie(s,x,s.path,g)),alwaysSet:g in s.data})}let f=this._def.unknownKeys;if(f==="passthrough")for(let g of l)d.push({key:{status:"valid",value:g},value:{status:"valid",value:s.data[g]}});else if(f==="strict")l.length>0&&(m(s,{code:y.unrecognized_keys,keys:l}),n.dirty());else if(f!=="strip")for(let g of l){let h=s.data[g];d.push({key:{status:"valid",value:g},value:f._parse(new ie(s,h,s.path,g)),alwaysSet:g in s.data})}return s.common.async?Promise.resolve().then(async()=>{let g=[];for(let h of d){let x=await h.key;g.push({key:x,value:await h.value,alwaysSet:h.alwaysSet})}return g}).then(g=>te.mergeObjectSync(n,g)):te.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new ne(c(p(c({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:i((r,n)=>{var s,a,o,l;let d=(o=(a=(s=this._def).errorMap)==null?void 0:a.call(s,r,n).message)!=null?o:n.defaultError;return r.code==="unrecognized_keys"?{message:(l=w.errToObj(e).message)!=null?l:d}:{message:d}},"errorMap")}:{}))}strip(){return new ne(p(c({},this._def),{unknownKeys:"strip"}))}passthrough(){return new ne(p(c({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(this._def.unknownKeys instanceof E)return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return ot.create();if(this._def.unknownKeys==="strict")return ut.create()}extend(e){return new ne(p(c({},this._def),{shape:i(()=>c(c({},this._def.shape()),e),"shape")}))}merge(e){return new ne({unknownKeys:e._def.unknownKeys,shape:i(()=>c(c({},this._def.shape()),e._def.shape()),"shape"),typeName:"ZodObject"})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new ne(p(c({},this._def),{unknownKeys:e}))}pick(e){let r={};return Z.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new ne(p(c({},this._def),{shape:i(()=>r,"shape")}))}omit(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new ne(p(c({},this._def),{shape:i(()=>r,"shape")}))}deepPartial(){return Ae(this)}partial(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s?.optional()}),new ne(p(c({},this._def),{shape:i(()=>r,"shape")}))}required(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof fe;)a=a._def.innerType;r[n]=a}}),new ne(p(c({},this._def),{shape:i(()=>r,"shape")}))}keyof(){return Kt(Z.objectKeys(this.shape))}isEqual(e){if(!(e instanceof ne)||!this._unknownKeysEqual(e))return!1;let r=this._def.shape(),n=e._def.shape(),s=i((l,d)=>l[0]===d[0]&&l[1].isEqual(d[1]),"compare"),a=new K(Object.entries(r),{compare:s}),o=new K(Object.entries(n),{compare:s});return a.isEqual(o)}_unknownKeysEqual(e){let r=this.additionalProperties(),n=e.additionalProperties();return r===void 0||n===void 0?r===n:r.isEqual(n)}};i(Te,"ZodObject");Te.create=i((t,e)=>new Te(c({shape:i(()=>t,"shape"),unknownKeys:"strip",typeName:"ZodObject"},k(e))),"create");Te.strictCreate=i((t,e)=>new Te(c({shape:i(()=>t,"shape"),unknownKeys:"strict",typeName:"ZodObject"},k(e))),"strictCreate");Te.lazycreate=i((t,e)=>new Te(c({shape:t,unknownKeys:"strip",typeName:"ZodObject"},k(e))),"lazycreate");var Me=Te,Br=class ar extends E{dereference(e){return new ar(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new ar(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===v.undefined?J(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof ar?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return this._def.innerType.mandatory()}};i(Br,"ZodOptional");Br.create=i((t,e)=>new Br(c({innerType:t,typeName:"ZodOptional"},k(e))),"create");var fe=Br,Gl=class xt extends E{dereference(e){return new xt(p(c({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return he([...this._def.in.getReferences(),...this._def.out.getReferences()])}clone(){return new xt(p(c({},this._def),{in:this._def.in.clone(),out:this._def.out.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return i(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?P:a.status==="dirty"?(r.dirty(),Re(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})},"handleAsync")();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?P:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new xt({in:e,out:r,typeName:"ZodPipeline"})}isEqual(e){return!(!(e instanceof xt)||!this._def.in.isEqual(e._def.in)||!this._def.out.isEqual(e._def.out))}};i(Gl,"ZodPipeline");var pn=Gl,Ir=class ir extends E{unwrap(){return this._def.type}dereference(e){return new ir(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new ir(p(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==v.promise&&r.common.async===!1)return m(r,{code:y.invalid_type,expected:v.promise,received:r.parsedType}),P;let n=r.parsedType===v.promise?r.data:Promise.resolve(r.data);return J(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}isEqual(e){return e instanceof ir?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}};i(Ir,"ZodPromise");Ir.create=i((t,e)=>new Ir(c({type:t,typeName:"ZodPromise"},k(e))),"create");var Ut=Ir,Cr=class kt extends E{dereference(e){return new kt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new kt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){let r=this._def.innerType._parse(e);return it(r)&&(r.value=Object.freeze(r.value)),r}unwrap(){return this._def.innerType}isEqual(e){return e instanceof kt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new kt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};i(Cr,"ZodReadonly");Cr.create=i((t,e)=>new Cr(c({innerType:t,typeName:"ZodReadonly"},k(e))),"create");var Ft=Cr,Jl=class Ye extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new Ye(p(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return he([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new Ye(p(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.object)return m(n,{code:y.invalid_type,expected:v.object,received:n.parsedType}),P;let s=[],a=this._def.keyType,o=this._def.valueType;for(let l in n.data)s.push({key:a._parse(new ie(n,l,n.path,l)),value:o._parse(new ie(n,n.data[l],n.path,l))});return n.common.async?te.mergeObjectAsync(r,s):te.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof E?new Ye(c({keyType:e,valueType:r,typeName:"ZodRecord"},k(n))):new Ye(c({keyType:X.create(),valueType:e,typeName:"ZodRecord"},k(r)))}isEqual(e){return!(!(e instanceof Ye)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};i(Jl,"ZodRecord");var hs=Jl,Ar=class Xl extends E{dereference(e){let r=e[this._def.uri];return r||this}getReferences(){return[this._def.uri]}_parse(e){let r=this._getOrReturnCtx(e);return m(r,{code:y.unresolved_reference}),P}isOptional(){return!1}isNullable(){return!1}isEqual(e){return e instanceof Xl?this._def.uri===e._def.uri:!1}};i(Ar,"ZodRef");Ar.create=i(t=>new Ar({typeName:"ZodRef",uri:t}),"create");var ms=Ar,Rr=class Qe extends E{dereference(e){return new Qe(p(c({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new Qe(p(c({},this._def),{valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.set)return m(n,{code:y.invalid_type,expected:v.set,received:n.parsedType}),P;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(m(n,{code:y.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(m(n,{code:y.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let a=this._def.valueType;function o(d){let f=new Set;for(let g of d){if(g.status==="aborted")return P;g.status==="dirty"&&r.dirty(),f.add(g.value)}return{status:r.value,value:f}}i(o,"finalizeSet");let l=[...n.data.values()].map((d,f)=>a._parse(new ie(n,d,n.path,f)));return n.common.async?Promise.all(l).then(d=>o(d)):o(l)}min(e,r){return new Qe(p(c({},this._def),{minSize:{value:e,message:w.toString(r)}}))}max(e,r){return new Qe(p(c({},this._def),{maxSize:{value:e,message:w.toString(r)}}))}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}isEqual(e){var r,n,s,a;if(!(e instanceof Qe))return!1;let o=(r=this._def.minSize)==null?void 0:r.value,l=(n=e._def.minSize)==null?void 0:n.value;if(o!==l)return!1;let d=(s=this._def.maxSize)==null?void 0:s.value,f=(a=e._def.maxSize)==null?void 0:a.value;return d!==f?!1:this._def.valueType.isEqual(e._def.valueType)}};i(Rr,"ZodSet");Rr.create=i((t,e)=>new Rr(c({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},k(e))),"create");var vs=Rr,_s=/^c[^\s-]{8,}$/i,Ts=/^[a-z][a-z0-9]*$/,bs=/^[0-9A-HJKMNP-TV-Z]{26}$/,ws=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ps=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Yl="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ql=i(t=>t===Yl,"isEmojiRegex"),Cn,xs=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,ks=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;function ec(t,e){return!!((e==="v4"||!e)&&xs.test(t)||(e==="v6"||!e)&&ks.test(t))}i(ec,"isValidIP");var Hr=class et extends E{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==v.string){let a=this._getOrReturnCtx(e);return m(a,{code:y.invalid_type,expected:v.string,received:a.parsedType}),P}let n=new te,s;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:y.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:y.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let o=e.data.length>a.value,l=e.data.length<a.value;(o||l)&&(s=this._getOrReturnCtx(e,s),o?m(s,{code:y.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):l&&m(s,{code:y.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")Ps.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"email",code:y.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Cn||(Cn=new RegExp(Yl,"u")),Cn.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"emoji",code:y.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")ws.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"uuid",code:y.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")_s.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid",code:y.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")Ts.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid2",code:y.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")bs.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ulid",code:y.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),m(s,{validation:"url",code:y.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"regex",code:y.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),m(s,{code:y.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:y.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:y.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Sl(a).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:y.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="ip"?ec(e.data,a.version)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ip",code:y.invalid_string,message:a.message}),n.dirty()):Z.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),c({validation:r,code:y.invalid_string},w.errToObj(n)))}_addCheck(e){return new et(p(c({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(c({kind:"email"},w.errToObj(e)))}url(e){return this._addCheck(c({kind:"url"},w.errToObj(e)))}emoji(e){return this._addCheck(c({kind:"emoji"},w.errToObj(e)))}uuid(e){return this._addCheck(c({kind:"uuid"},w.errToObj(e)))}cuid(e){return this._addCheck(c({kind:"cuid"},w.errToObj(e)))}cuid2(e){return this._addCheck(c({kind:"cuid2"},w.errToObj(e)))}ulid(e){return this._addCheck(c({kind:"ulid"},w.errToObj(e)))}ip(e){return this._addCheck(c({kind:"ip"},w.errToObj(e)))}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck(c({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(r=e?.offset)!=null?r:!1},w.errToObj(e?.message)))}regex(e,r){return this._addCheck(c({kind:"regex",regex:e},w.errToObj(r)))}includes(e,r){return this._addCheck(c({kind:"includes",value:e,position:r?.position},w.errToObj(r?.message)))}startsWith(e,r){return this._addCheck(c({kind:"startsWith",value:e},w.errToObj(r)))}endsWith(e,r){return this._addCheck(c({kind:"endsWith",value:e},w.errToObj(r)))}min(e,r){return this._addCheck(c({kind:"min",value:e},w.errToObj(r)))}max(e,r){return this._addCheck(c({kind:"max",value:e},w.errToObj(r)))}length(e,r){return this._addCheck(c({kind:"length",value:e},w.errToObj(r)))}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new et(p(c({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}secret(){return this._def[b]=p(c({},this._def[b]),{secret:!0}),this}toLowerCase(){return new et(p(c({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new et(p(c({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}isEqual(e){if(!(e instanceof et))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}};i(Hr,"ZodString");Hr.create=i(t=>{var e;return new Hr(c({checks:[],typeName:"ZodString",coerce:(e=t?.coerce)!=null?e:!1},k(t)))},"create");var X=Hr,Dr=class tc extends E{_parse(e){if(this._getType(e)!==v.symbol){let n=this._getOrReturnCtx(e);return m(n,{code:y.invalid_type,expected:v.symbol,received:n.parsedType}),P}return J(e.data)}isEqual(e){return e instanceof tc}};i(Dr,"ZodSymbol");Dr.create=i(t=>new Dr(c({typeName:"ZodSymbol"},k(t))),"create");var Ss=Dr,ct=class St extends E{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName==="ZodEffects"?this._def.schema.sourceType():this._def.schema}dereference(e){return new St(p(c({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new St(p(c({},this._def),{schema:this._def.schema.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i(o=>{m(n,o),o.fatal?r.abort():r.dirty()},"addIssue"),get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){let o=s.transform(n.data,a);if(n.common.async)return Promise.resolve(o).then(async l=>{if(r.value==="aborted")return P;let d=await this._def.schema._parseAsync({data:l,path:n.path,parent:n});return d.status==="aborted"?P:d.status==="dirty"||r.value==="dirty"?Re(d.value):d});{if(r.value==="aborted")return P;let l=this._def.schema._parseSync({data:o,path:n.path,parent:n});return l.status==="aborted"?P:l.status==="dirty"||r.value==="dirty"?Re(l.value):l}}if(s.type==="refinement"){let o=i(l=>{let d=s.refinement(l,a);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l},"executeRefinement");if(n.common.async===!1){let l=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return l.status==="aborted"?P:(l.status==="dirty"&&r.dirty(),o(l.value),{status:r.value,value:l.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>l.status==="aborted"?P:(l.status==="dirty"&&r.dirty(),o(l.value).then(()=>({status:r.value,value:l.value}))))}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!it(o))return o;let l=s.transform(o.value,a);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:l}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>it(o)?Promise.resolve(s.transform(o.value,a)).then(l=>({status:r.value,value:l})):o);Z.assertNever(s)}isEqual(e){return!(e instanceof St)||!this._def.schema.isEqual(e._def.schema)?!1:this._def.effect.type==="refinement"?e._def.effect.type!=="refinement"?!1:Z.compareFunctions(this._def.effect.refinement,e._def.effect.refinement):this._def.effect.type==="transform"?e._def.effect.type!=="transform"?!1:Z.compareFunctions(this._def.effect.transform,e._def.effect.transform):this._def.effect.type==="preprocess"?e._def.effect.type!=="preprocess"?!1:Z.compareFunctions(this._def.effect.transform,e._def.effect.transform):!1}naked(){return this._def.schema.naked()}mandatory(){return new St(p(c({},this._def),{schema:this._def.schema.mandatory()}))}};i(ct,"ZodEffects");ct.create=i((t,e,r)=>new ct(c({schema:t,typeName:"ZodEffects",effect:e},k(r))),"create");ct.createWithPreprocess=i((t,e,r)=>new ct(c({schema:e,effect:{type:"preprocess",transform:t},typeName:"ZodEffects"},k(r))),"createWithPreprocess");var be=ct,Mr=class Et extends E{dereference(e){let r=this._def.items.map(s=>s.dereference(e)),n=this._def.rest?this._def.rest.dereference(e):null;return new Et(p(c({},this._def),{items:r,rest:n}))}getReferences(){return he([...this._def.items.flatMap(e=>e.getReferences()),...this._def.rest?this._def.rest.getReferences():[]])}clone(){let e=this._def.items.map(n=>n.clone()),r=this._def.rest?this._def.rest.clone():null;return new Et(p(c({},this._def),{items:e,rest:r}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.array)return m(n,{code:y.invalid_type,expected:v.array,received:n.parsedType}),P;if(n.data.length<this._def.items.length)return m(n,{code:y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),P;!this._def.rest&&n.data.length>this._def.items.length&&(m(n,{code:y.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...n.data].map((o,l)=>{let d=this._def.items[l]||this._def.rest;return d?d._parse(new ie(n,o,n.path,l)):null}).filter(o=>!!o);return n.common.async?Promise.all(a).then(o=>te.mergeArray(r,o)):te.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new Et(p(c({},this._def),{rest:e}))}isEqual(e){if(!(e instanceof Et)||!this._restEquals(e))return!1;let r=i((a,o)=>a.isEqual(o),"compare"),n=new K(this._def.items,{compare:r}),s=new K(e._def.items,{compare:r});return n.isEqual(s)}_restEquals(e){return this._def.rest===null?e._def.rest===null:e._def.rest!==null&&this._def.rest.isEqual(e._def.rest)}};i(Mr,"ZodTuple");Mr.create=i((t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Mr(c({items:t,typeName:"ZodTuple",rest:null},k(e)))},"create");var Ne=Mr,Nr=class rc extends E{_parse(e){if(this._getType(e)!==v.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:y.invalid_type,expected:v.undefined,received:n.parsedType}),P}return J(e.data)}isEqual(e){return e instanceof rc}mandatory(){return ut.create(c({},this._def))}};i(Nr,"ZodUndefined");Nr.create=i(t=>new Nr(c({typeName:"ZodUndefined"},k(t))),"create");var zt=Nr,$r=class Ot extends E{dereference(e){let r=this._def.options.map(n=>n.dereference(e));return new Ot(p(c({},this._def),{options:r}))}getReferences(){return he(this._def.options.reduce((e,r)=>[...e,...r.getReferences()],[]))}clone(){let e=this._def.options.map(r=>r.clone());return new Ot(p(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(a){for(let l of a)if(l.result.status==="valid")return l.result;for(let l of a)if(l.result.status==="dirty")return r.common.issues.push(...l.ctx.common.issues),l.result;let o=a.map(l=>new le(l.ctx.common.issues));return m(r,{code:y.invalid_union,unionErrors:o}),P}if(i(s,"handleResults"),r.common.async)return Promise.all(n.map(async a=>{let o=p(c({},r),{common:p(c({},r.common),{issues:[]}),parent:null});return{result:await a._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let a,o=[];for(let d of n){let f=p(c({},r),{common:p(c({},r.common),{issues:[]}),parent:null}),g=d._parseSync({data:r.data,path:r.path,parent:f});if(g.status==="valid")return g;g.status==="dirty"&&!a&&(a={result:g,ctx:f}),f.common.issues.length&&o.push(f.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let l=o.map(d=>new le(d));return m(r,{code:y.invalid_union,unionErrors:l}),P}}get options(){return this._def.options}isEqual(e){if(!(e instanceof Ot))return!1;let r=i((a,o)=>a.isEqual(o),"compare"),n=new K([...this._def.options],{compare:r}),s=new K([...e._def.options],{compare:r});return n.isEqual(s)}mandatory(){let e=this._def.options.filter(a=>!(a instanceof zt)).map(a=>a.mandatory()),[r,n,...s]=e;return r?n?new Ot(p(c({},this._def),{options:[r,n,...s]})):r:ut.create(c({},this._def))}};i($r,"ZodUnion");$r.create=i((t,e)=>new $r(c({options:t,typeName:"ZodUnion"},k(e))),"create");var fn=$r,jr=class nc extends E{constructor(){super(...arguments),this._unknown=!0}_parse(e){return J(e.data)}isEqual(e){return e instanceof nc}};i(jr,"ZodUnknown");jr.create=i(t=>new jr(c({typeName:"ZodUnknown"},k(t))),"create");var nt=jr,Kr=class sc extends E{_parse(e){if(this._getType(e)!==v.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:y.invalid_type,expected:v.void,received:n.parsedType}),P}return J(e.data)}isEqual(e){return e instanceof sc}};i(Kr,"ZodVoid");Kr.create=i(t=>new Kr(c({typeName:"ZodVoid"},k(t))),"create");var Es=Kr,rh=["gpt-3.5-turbo","gpt-3.5-turbo-16k","gpt-4","gpt-4-1106-preview","gpt-4-vision-preview","gpt-4-0125-preview","gpt-4-turbo-preview","gpt-4-turbo","gpt-4o","gpt-3.5-turbo-0125","gpt-3.5-turbo-1106"],gv=We.create(["any","string","number","boolean","object","pattern","date","array","target","time","enum"]),ac=i(t=>X.create().displayAs({id:"variable",params:c({type:t?.type||"any"},t?.params)}),"variable"),ic=i(t=>X.create().displayAs({id:"conversation",params:c({},t?.params)}),"conversation"),oc=i(t=>X.create().displayAs({id:"user",params:c({},t?.params)}),"user"),lc=i(t=>X.create().displayAs({id:"message",params:c({},t?.params)}),"message"),cc=i(t=>X.create().displayAs({id:"agent",params:c({},t?.params)}),"agent"),dc=i(t=>X.create().displayAs({id:"event",params:c({},t?.params)}),"event"),uc=i(t=>X.create().displayAs({id:"table",params:c({},t?.params)}),"table"),pc=i(t=>X.create().displayAs({id:"tablerow",params:c({},t?.params)}),"tablerow"),fc=i(t=>X.create().displayAs({id:"intent",params:c({},t?.params)}),"intent"),gc=i(()=>We.create(rh).displayAs({id:"dropdown",params:{}}),"aimodel"),yc=i(t=>X.create().displayAs({id:"datasource",params:c({},t)}),"datasource"),hc=i(t=>X.create().displayAs({id:"knowledgebase",params:c({},t)}),"knowledgebase"),mc={object:Me.lazycreate},vc=i((t,e={message:`Input not instance of ${t.name}`})=>ds(r=>r instanceof t,e),"instanceOfType"),Os=X.create,Zs=un.create,_c=ys.create,Tc=en.create,Bs=tn.create,bc=sn.create,wc=Ss.create,Pc=zt.create,xc=dn.create,kc=ot.create,Sc=nt.create,Ec=ut.create,Oc=Es.create,Zc=lt.create,Bc=Me.create,Ic=Me.strictCreate,Cc=fn.create,Ac=us.create,Rc=an.create,Hc=Ne.create,Dc=hs.create,Mc=ms.create,Nc=Ft.create,$c=gs.create,jc=vs.create,Kc=fs.create,Uc=on.create,Fc=ln.create,zc=We.create,Lc=cn.create,Wc=Ut.create,Fn=be.create,qc=fe.create,Vc=De.create,nh=jt.create,Gc=be.createWithPreprocess,Jc=pn.create,Xc=i(()=>Os().optional(),"ostring"),Yc=i(()=>Zs().optional(),"onumber"),Qc=i(()=>Bs().optional(),"oboolean"),ed={string:i(t=>X.create(p(c({},t),{coerce:!0})),"string"),number:i(t=>un.create(p(c({},t),{coerce:!0})),"number"),boolean:i(t=>tn.create(p(c({},t),{coerce:!0})),"boolean"),bigint:i(t=>en.create(p(c({},t),{coerce:!0})),"bigint"),date:i(t=>sn.create(p(c({},t),{coerce:!0})),"date")},td=P,u=_,rd=i((t,e)=>t.anyOf.length?t.anyOf.length===1?L(t.anyOf[0],p(c({},e),{path:[...e.path,"anyOf",0]})):`z.union([${t.anyOf.map((r,n)=>L(r,p(c({},e),{path:[...e.path,"anyOf",n]}))).join(", ")}])`:"z.any()","parseAnyOf"),sh=i(t=>{var e;return(e=t[b])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),ah=i(t=>"z.any()","parseDefault"),ih=i((t,e)=>`z.union([${t.type.map(r=>L(p(c({},t),{type:r}),e)).join(", ")}])`,"parseMultipleType"),oh=i((t,e)=>`z.any().refine((value) => !${L(t.not,p(c({},e),{path:[...e.path,"not"]}))}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`,"parseNot"),lh=i(t=>"z.null()","parseNull"),ch=i(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),dh=i((t,...e)=>Object.keys(t).reduce((r,n)=>(e.includes(n)||(r[n]=t[n]),r),{}),"omit");function G(t,e,r){var n;let s=t[e],a="";if(s!==void 0){let o=r({value:s,json:JSON.stringify(s)});if(o){let l=o[0],d=o.length===3?o[1]:"",f=o.length===3?o[2]:o[1];a+=l,((n=t.errorMessage)==null?void 0:n[e])!==void 0&&(a+=d+JSON.stringify(t.errorMessage[e])),a+=f}}return a}i(G,"withMessage");var Zt=Symbol("Original index"),uh=i(t=>{let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(typeof n=="boolean")e.push(n?{[Zt]:r}:{[Zt]:r,not:{}});else{if(Zt in n)return t;e.push(p(c({},n),{[Zt]:r}))}}return e},"ensureOriginalIndex");function Nt(t,e){if(t.allOf.length===0)return"z.never()";if(t.allOf.length===1){let r=t.allOf[0];return L(r,p(c({},e),{path:[...e.path,"allOf",r[Zt]]}))}else{let[r,n]=ch(uh(t.allOf));return`z.intersection(${Nt({allOf:r},e)}, ${Nt({allOf:n},e)})`}}i(Nt,"parseAllOf");var ph=i((t,e)=>{if(Array.isArray(t.items))return`z.tuple([${t.items.map((n,s)=>L(n,p(c({},e),{path:[...e.path,"items",s]})))}])`;let r=t.items?`z.array(${L(t.items,p(c({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return r+=G(t,"minItems",({json:n})=>[`.min(${n}`,", ",")"]),r+=G(t,"maxItems",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseArray"),fh=i(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),gh=i(t=>t.enum.length===0?"z.never()":t.enum.length===1?`z.literal(${JSON.stringify(t.enum[0])})`:t.enum.every(e=>typeof e=="string")?`z.enum([${t.enum.map(e=>JSON.stringify(e))}])`:`z.union([${t.enum.map(e=>`z.literal(${JSON.stringify(e)})`).join(", ")}])`,"parseEnum"),yh=i((t,e)=>{let r=L(t.if,p(c({},e),{path:[...e.path,"if"]})),n=L(t.then,p(c({},e),{path:[...e.path,"then"]})),s=L(t.else,p(c({},e),{path:[...e.path,"else"]}));return`z.union([${n}, ${s}]).superRefine((value,ctx) => {
5
+ */`},"getMultilineComment"),Ma={};Lr(Ma,{JSONSchemaToZuiError:()=>Wr,ObjectToZuiError:()=>Hn,UnrepresentableGenericError:()=>Mn,UnsupportedJSONSchemaToZuiError:()=>ve,UnsupportedZuiCheckToJSONSchemaError:()=>Fa,UnsupportedZuiToJSONSchemaError:()=>ee,UnsupportedZuiToTypescriptSchemaError:()=>Oe,UnsupportedZuiToTypescriptTypeError:()=>Ja,UntitledDeclarationError:()=>Ya,ZuiToJSONSchemaError:()=>qr,ZuiToTypescriptSchemaError:()=>Wa,ZuiToTypescriptTypeError:()=>Vr,ZuiTransformError:()=>ut});var Da=class extends Error{constructor(e,r){super(r),this.transform=e}};i(Da,"ZuiTransformError");var ut=Da,Na=class extends ut{constructor(e){super("json-schema-to-zui",e)}};i(Na,"JSONSchemaToZuiError");var Wr=Na,$a=class extends ut{constructor(e){super("object-to-zui",e)}};i($a,"ObjectToZuiError");var Hn=$a,ja=class extends ut{constructor(e){super("zui-to-json-schema",e)}};i(ja,"ZuiToJSONSchemaError");var qr=ja,Ka=class extends qr{constructor(e,{suggestedAlternative:r}={}){super(`Zod type ${e} cannot be transformed to JSON Schema.`+(r?` Suggested alternative: ${r}`:""))}};i(Ka,"UnsupportedZuiToJSONSchemaError");var ee=Ka,Ua=class extends qr{constructor({zodType:e,checkKind:r}){super(`Zod check .${r}() of type ${e} cannot be transformed to JSON Schema.`)}};i(Ua,"UnsupportedZuiCheckToJSONSchemaError");var Fa=Ua,za=class extends Wr{constructor(e){super(`JSON Schema ${JSON.stringify(e)} cannot be transformed to ZUI type.`)}};i(za,"UnsupportedJSONSchemaToZuiError");var ve=za,La=class extends ut{constructor(e){super("zui-to-typescript-schema",e)}};i(La,"ZuiToTypescriptSchemaError");var Wa=La,qa=class extends Wa{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript schema.`)}};i(qa,"UnsupportedZuiToTypescriptSchemaError");var Oe=qa,Va=class extends ut{constructor(e){super("zui-to-typescript-type",e)}};i(Va,"ZuiToTypescriptTypeError");var Vr=Va,Ga=class extends Vr{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript type.`)}};i(Ga,"UnsupportedZuiToTypescriptTypeError");var Ja=Ga,Xa=class extends Vr{constructor(){super("Schema must have a title to be transformed to a TypeScript type with a declaration.")}};i(Xa,"UntitledDeclarationError");var Ya=Xa,Qa=class extends Vr{constructor(){super('ZodRef can only be transformed to a TypeScript type with a "type" declaration.')}};i(Qa,"UnrepresentableGenericError");var Mn=Qa,ei=["string","number","boolean","unknown","void","any","null","undefined","never","bigint","symbol","object"],Tu=i(t=>ei.includes(t),"isPrimitive"),bu=i(t=>ei.map(e=>`${e}[]`).includes(t),"isArrayOfPrimitives"),Vs=i(t=>t.replace(/ +/g," ").trim(),"stripSpaces"),ti=class{constructor(e,r,n=!1){this.key=e,this.value=r,this.optional=n}};i(ti,"KeyValue");var Yt=ti,ri=class{constructor(e){this.schema=e}};i(ri,"FnParameters");var Gs=ri,ni=class{constructor(e){this.schema=e}};i(ni,"FnReturn");var Js=ni,si=class{constructor(e){this.props=e}};i(si,"Declaration");var er=si;function Vn(t,e={}){let r=xu(t,e),n=B(r,{});return e.formatter&&(n=e.formatter(n)),n}i(Vn,"toTypescriptType");function B(t,e){var r,n,s;let a=p(c({},e),{parent:t});if(t===null)return"";if(t instanceof er)return wu(t,a);if(t instanceof Yt){if(t.value instanceof u.ZodOptional){let O=t.value._def.innerType;return B(new Yt(t.key,O,!0),a)}let d=F(t.value.description),f=d?.trim().length>0?`
6
+ `:"",g=t.value.describe(""),x=t.optional||t.value.isOptional()?"?":"";return`${f}${d}${f}${t.key}${x}: ${B(g,a)}${f}`}if(t instanceof Gs){if(t.schema instanceof u.ZodTuple){let g="";for(let h=0;h<t.schema.items.length;h++){let x=(s=(n=(r=t.schema.items[h])==null?void 0:r.ui)==null?void 0:n.title)!=null?s:`arg${h}`,O=t.schema.items[h];g+=`${B(new Yt(Rn(x),O),a)}${h<t.schema.items.length-1?", ":""} `}return g}let d=B(t.schema,a);return d.startsWith("{")&&d.endsWith("}")||d.startsWith("[")&&d.endsWith("]")||d.startsWith("(")&&d.endsWith(")")||d.startsWith("Array<")&&d.endsWith(">")||d.startsWith("Record<")&&d.endsWith(">")||bu(d)?`args: ${d}`:d}if(t instanceof Js)return t.schema instanceof u.ZodOptional?`${B(t.schema.unwrap(),a)} | undefined`:B(t.schema,a);let o=t,l=o._def;switch(l.typeName){case u.ZodFirstPartyTypeKind.ZodString:return`${F(o.description)} string`.trim();case u.ZodFirstPartyTypeKind.ZodNumber:case u.ZodFirstPartyTypeKind.ZodNaN:case u.ZodFirstPartyTypeKind.ZodBigInt:return`${F(o.description)} number`.trim();case u.ZodFirstPartyTypeKind.ZodBoolean:return`${F(o.description)} boolean`.trim();case u.ZodFirstPartyTypeKind.ZodDate:return`${F(o.description)} Date`.trim();case u.ZodFirstPartyTypeKind.ZodUndefined:return`${F(o.description)} undefined`.trim();case u.ZodFirstPartyTypeKind.ZodNull:return`${F(o.description)} null`.trim();case u.ZodFirstPartyTypeKind.ZodAny:return`${F(o.description)} any`.trim();case u.ZodFirstPartyTypeKind.ZodUnknown:return`${F(o.description)} unknown`.trim();case u.ZodFirstPartyTypeKind.ZodNever:return`${F(o.description)} never`.trim();case u.ZodFirstPartyTypeKind.ZodVoid:return`${F(o.description)} void`.trim();case u.ZodFirstPartyTypeKind.ZodArray:let d=B(l.type,a);return Tu(d)?`${d}[]`:`Array<${d}>`;case u.ZodFirstPartyTypeKind.ZodObject:return`{ ${Object.entries(l.shape()).map(([q,se])=>B(new Yt(Rn(q),se),a)).join("; ")} }`;case u.ZodFirstPartyTypeKind.ZodUnion:let g=l.options.map(q=>B(q,a));return`${F(o.description)}
7
+ ${g.join(" | ")}`;case u.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let h=l.options.map(q=>B(q,a));return`${F(o.description)}
8
+ ${h.join(" | ")}`;case u.ZodFirstPartyTypeKind.ZodIntersection:return`${B(l.left,a)} & ${B(l.right,a)}`;case u.ZodFirstPartyTypeKind.ZodTuple:return l.items.length===0?"":`[${l.items.map(q=>B(q,a)).join(", ")}]`;case u.ZodFirstPartyTypeKind.ZodRecord:let O=B(l.keyType,a),I=B(l.valueType,a);return`${F(o.description)} { [key: ${O}]: ${I} }`;case u.ZodFirstPartyTypeKind.ZodMap:return`Map<${B(l.keyType,a)}, ${B(l.valueType,a)}>`;case u.ZodFirstPartyTypeKind.ZodSet:return`Set<${B(l.valueType,a)}>`;case u.ZodFirstPartyTypeKind.ZodFunction:let U=B(new Gs(l.args),a),W=B(new Js(l.returns),a);return`${F(o.description)}
9
+ (${U}) => ${W}`;case u.ZodFirstPartyTypeKind.ZodLazy:return B(l.getter(),a);case u.ZodFirstPartyTypeKind.ZodLiteral:let Q=Aa(l.value);return`${F(o.description)}
10
+ ${Q}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(T).join(" | ");case u.ZodFirstPartyTypeKind.ZodEffects:return B(l.schema,a);case u.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Ja(u.ZodFirstPartyTypeKind.ZodNativeEnum);case u.ZodFirstPartyTypeKind.ZodOptional:return`${B(l.innerType,a)} | undefined`;case u.ZodFirstPartyTypeKind.ZodNullable:return`${B(l.innerType,a)} | null`;case u.ZodFirstPartyTypeKind.ZodDefault:return B(l.innerType,a);case u.ZodFirstPartyTypeKind.ZodCatch:return B(l.innerType,a);case u.ZodFirstPartyTypeKind.ZodPromise:return`Promise<${B(l.type,a)}>`;case u.ZodFirstPartyTypeKind.ZodBranded:return B(l.type,a);case u.ZodFirstPartyTypeKind.ZodPipeline:return B(l.in,a);case u.ZodFirstPartyTypeKind.ZodSymbol:return`${F(o.description)} symbol`.trim();case u.ZodFirstPartyTypeKind.ZodReadonly:return`Readonly<${B(l.innerType,a)}>`;case u.ZodFirstPartyTypeKind.ZodRef:return Ha(l.uri);default:Z.assertNever(l)}}i(B,"sUnwrapZod");var wu=i((t,e)=>{if(t.props.type==="none")return B(t.props.schema,e);let r=F(t.props.schema.description),n=t.props.schema.describe(""),s=B(n,e);if(t.props.type==="variable")return Vs(`${r}declare const ${t.props.identifier}: ${s};`);let a=t.props.args.length>0?`<${t.props.args.map(Ha).join(", ")}>`:"";return Vs(`${r}type ${t.props.identifier}${a} = ${s};`)},"unwrapDeclaration"),Pu=i(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),xu=i((t,e)=>{let r=Pu(e),n=t.getReferences();if(r==="none"){if(n.length>0)throw new Mn;return new er({type:"none",schema:t})}let s="title"in t.ui?t.ui.title:null;if(!s)throw new Ya;if(r==="variable"){if(n.length>0)throw new Mn;return new er({type:"variable",identifier:s,schema:t})}return new er({type:"type",identifier:s,schema:t,args:n})},"getDeclarationProps"),ku=typeof global=="object"&&global&&global.Object===Object&&global,ai=ku,Su=typeof self=="object"&&self&&self.Object===Object&&self,Eu=ai||Su||Function("return this")(),ye=Eu,Ou=ye.Symbol,_e=Ou,ii=Object.prototype,Zu=ii.hasOwnProperty,Iu=ii.toString,_t=_e?_e.toStringTag:void 0;function oi(t){var e=Zu.call(t,_t),r=t[_t];try{t[_t]=void 0;var n=!0}catch{}var s=Iu.call(t);return n&&(e?t[_t]=r:delete t[_t]),s}i(oi,"getRawTag");var Bu=oi,Cu=Object.prototype,Au=Cu.toString;function li(t){return Au.call(t)}i(li,"objectToString");var Ru=li,Hu="[object Null]",Mu="[object Undefined]",Xs=_e?_e.toStringTag:void 0;function ci(t){return t==null?t===void 0?Mu:Hu:Xs&&Xs in Object(t)?Bu(t):Ru(t)}i(ci,"baseGetTag");var $e=ci;function di(t){return t!=null&&typeof t=="object"}i(di,"isObjectLike");var He=di,Du="[object Symbol]";function ui(t){return typeof t=="symbol"||He(t)&&$e(t)==Du}i(ui,"isSymbol");var Gn=ui;function pi(t,e){for(var r=-1,n=t==null?0:t.length,s=Array(n);++r<n;)s[r]=e(t[r],r,t);return s}i(pi,"arrayMap");var fi=pi,Nu=Array.isArray,ge=Nu,$u=1/0,Ys=_e?_e.prototype:void 0,Qs=Ys?Ys.toString:void 0;function Jn(t){if(typeof t=="string")return t;if(ge(t))return fi(t,Jn)+"";if(Gn(t))return Qs?Qs.call(t):"";var e=t+"";return e=="0"&&1/t==-$u?"-0":e}i(Jn,"baseToString");var ju=Jn;function gi(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}i(gi,"isObject");var at=gi;function yi(t){return t}i(yi,"identity");var Ku=yi,Uu="[object AsyncFunction]",Fu="[object Function]",zu="[object GeneratorFunction]",Lu="[object Proxy]";function hi(t){if(!at(t))return!1;var e=$e(t);return e==Fu||e==zu||e==Uu||e==Lu}i(hi,"isFunction");var mi=hi,Wu=ye["__core-js_shared__"],On=Wu,ea=function(){var t=/[^.]+$/.exec(On&&On.keys&&On.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function vi(t){return!!ea&&ea in t}i(vi,"isMasked");var qu=vi,Vu=Function.prototype,Gu=Vu.toString;function _i(t){if(t!=null){try{return Gu.call(t)}catch{}try{return t+""}catch{}}return""}i(_i,"toSource");var je=_i,Ju=/[\\^$.*+?()[\]{}|]/g,Xu=/^\[object .+?Constructor\]$/,Yu=Function.prototype,Qu=Object.prototype,ep=Yu.toString,tp=Qu.hasOwnProperty,rp=RegExp("^"+ep.call(tp).replace(Ju,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ti(t){if(!at(t)||qu(t))return!1;var e=mi(t)?rp:Xu;return e.test(je(t))}i(Ti,"baseIsNative");var np=Ti;function bi(t,e){return t?.[e]}i(bi,"getValue");var sp=bi;function wi(t,e){var r=sp(t,e);return np(r)?r:void 0}i(wi,"getNative");var Ke=wi,ap=Ke(ye,"WeakMap"),Dn=ap,ip=function(){try{var t=Ke(Object,"defineProperty");return t({},"",{}),t}catch{}}(),ta=ip,op=9007199254740991,lp=/^(?:0|[1-9]\d*)$/;function Pi(t,e){var r=typeof t;return e=e??op,!!e&&(r=="number"||r!="symbol"&&lp.test(t))&&t>-1&&t%1==0&&t<e}i(Pi,"isIndex");var Xn=Pi;function xi(t,e,r){e=="__proto__"&&ta?ta(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}i(xi,"baseAssignValue");var ki=xi;function Si(t,e){return t===e||t!==t&&e!==e}i(Si,"eq");var Yn=Si,cp=Object.prototype,dp=cp.hasOwnProperty;function Ei(t,e,r){var n=t[e];(!(dp.call(t,e)&&Yn(n,r))||r===void 0&&!(e in t))&&ki(t,e,r)}i(Ei,"assignValue");var up=Ei,pp=9007199254740991;function Oi(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=pp}i(Oi,"isLength");var Qn=Oi;function Zi(t){return t!=null&&Qn(t.length)&&!mi(t)}i(Zi,"isArrayLike");var Ii=Zi,fp=Object.prototype;function Bi(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||fp;return t===r}i(Bi,"isPrototype");var Ci=Bi;function Ai(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}i(Ai,"baseTimes");var gp=Ai,yp="[object Arguments]";function Ri(t){return He(t)&&$e(t)==yp}i(Ri,"baseIsArguments");var ra=Ri,Hi=Object.prototype,hp=Hi.hasOwnProperty,mp=Hi.propertyIsEnumerable,vp=ra(function(){return arguments}())?ra:function(t){return He(t)&&hp.call(t,"callee")&&!mp.call(t,"callee")},Mi=vp;function Di(){return!1}i(Di,"stubFalse");var _p=Di,Ni=typeof exports=="object"&&exports&&!exports.nodeType&&exports,na=Ni&&typeof module=="object"&&module&&!module.nodeType&&module,Tp=na&&na.exports===Ni,sa=Tp?ye.Buffer:void 0,bp=sa?sa.isBuffer:void 0,wp=bp||_p,Nn=wp,Pp="[object Arguments]",xp="[object Array]",kp="[object Boolean]",Sp="[object Date]",Ep="[object Error]",Op="[object Function]",Zp="[object Map]",Ip="[object Number]",Bp="[object Object]",Cp="[object RegExp]",Ap="[object Set]",Rp="[object String]",Hp="[object WeakMap]",Mp="[object ArrayBuffer]",Dp="[object DataView]",Np="[object Float32Array]",$p="[object Float64Array]",jp="[object Int8Array]",Kp="[object Int16Array]",Up="[object Int32Array]",Fp="[object Uint8Array]",zp="[object Uint8ClampedArray]",Lp="[object Uint16Array]",Wp="[object Uint32Array]",M={};M[Np]=M[$p]=M[jp]=M[Kp]=M[Up]=M[Fp]=M[zp]=M[Lp]=M[Wp]=!0;M[Pp]=M[xp]=M[Mp]=M[kp]=M[Dp]=M[Sp]=M[Ep]=M[Op]=M[Zp]=M[Ip]=M[Bp]=M[Cp]=M[Ap]=M[Rp]=M[Hp]=!1;function $i(t){return He(t)&&Qn(t.length)&&!!M[$e(t)]}i($i,"baseIsTypedArray");var qp=$i;function ji(t){return function(e){return t(e)}}i(ji,"baseUnary");var Vp=ji,Ki=typeof exports=="object"&&exports&&!exports.nodeType&&exports,At=Ki&&typeof module=="object"&&module&&!module.nodeType&&module,Gp=At&&At.exports===Ki,Zn=Gp&&ai.process,Jp=function(){try{var t=At&&At.require&&At.require("util").types;return t||Zn&&Zn.binding&&Zn.binding("util")}catch{}}(),aa=Jp,ia=aa&&aa.isTypedArray,Xp=ia?Vp(ia):qp,Ui=Xp,Yp=Object.prototype,Qp=Yp.hasOwnProperty;function Fi(t,e){var r=ge(t),n=!r&&Mi(t),s=!r&&!n&&Nn(t),a=!r&&!n&&!s&&Ui(t),o=r||n||s||a,l=o?gp(t.length,String):[],d=l.length;for(var f in t)(e||Qp.call(t,f))&&!(o&&(f=="length"||s&&(f=="offset"||f=="parent")||a&&(f=="buffer"||f=="byteLength"||f=="byteOffset")||Xn(f,d)))&&l.push(f);return l}i(Fi,"arrayLikeKeys");var zi=Fi;function Li(t,e){return function(r){return t(e(r))}}i(Li,"overArg");var Wi=Li,ef=Wi(Object.keys,Object),tf=ef,rf=Object.prototype,nf=rf.hasOwnProperty;function qi(t){if(!Ci(t))return tf(t);var e=[];for(var r in Object(t))nf.call(t,r)&&r!="constructor"&&e.push(r);return e}i(qi,"baseKeys");var sf=qi;function Vi(t){return Ii(t)?zi(t):sf(t)}i(Vi,"keys");var es=Vi;function Gi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}i(Gi,"nativeKeysIn");var af=Gi,of=Object.prototype,lf=of.hasOwnProperty;function Ji(t){if(!at(t))return af(t);var e=Ci(t),r=[];for(var n in t)n=="constructor"&&(e||!lf.call(t,n))||r.push(n);return r}i(Ji,"baseKeysIn");var cf=Ji;function Xi(t){return Ii(t)?zi(t,!0):cf(t)}i(Xi,"keysIn");var df=Xi,uf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,pf=/^\w*$/;function Yi(t,e){if(ge(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||Gn(t)?!0:pf.test(t)||!uf.test(t)||e!=null&&t in Object(e)}i(Yi,"isKey");var ts=Yi,ff=Ke(Object,"create"),Ht=ff;function Qi(){this.__data__=Ht?Ht(null):{},this.size=0}i(Qi,"hashClear");var gf=Qi;function eo(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}i(eo,"hashDelete");var yf=eo,hf="__lodash_hash_undefined__",mf=Object.prototype,vf=mf.hasOwnProperty;function to(t){var e=this.__data__;if(Ht){var r=e[t];return r===hf?void 0:r}return vf.call(e,t)?e[t]:void 0}i(to,"hashGet");var _f=to,Tf=Object.prototype,bf=Tf.hasOwnProperty;function ro(t){var e=this.__data__;return Ht?e[t]!==void 0:bf.call(e,t)}i(ro,"hashHas");var wf=ro,Pf="__lodash_hash_undefined__";function no(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Ht&&e===void 0?Pf:e,this}i(no,"hashSet");var xf=no;function Ue(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}i(Ue,"Hash");Ue.prototype.clear=gf;Ue.prototype.delete=yf;Ue.prototype.get=_f;Ue.prototype.has=wf;Ue.prototype.set=xf;var oa=Ue;function so(){this.__data__=[],this.size=0}i(so,"listCacheClear");var kf=so;function ao(t,e){for(var r=t.length;r--;)if(Yn(t[r][0],e))return r;return-1}i(ao,"assocIndexOf");var Gr=ao,Sf=Array.prototype,Ef=Sf.splice;function io(t){var e=this.__data__,r=Gr(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():Ef.call(e,r,1),--this.size,!0}i(io,"listCacheDelete");var Of=io;function oo(t){var e=this.__data__,r=Gr(e,t);return r<0?void 0:e[r][1]}i(oo,"listCacheGet");var Zf=oo;function lo(t){return Gr(this.__data__,t)>-1}i(lo,"listCacheHas");var If=lo;function co(t,e){var r=this.__data__,n=Gr(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}i(co,"listCacheSet");var Bf=co;function Fe(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}i(Fe,"ListCache");Fe.prototype.clear=kf;Fe.prototype.delete=Of;Fe.prototype.get=Zf;Fe.prototype.has=If;Fe.prototype.set=Bf;var Jr=Fe,Cf=Ke(ye,"Map"),Mt=Cf;function uo(){this.size=0,this.__data__={hash:new oa,map:new(Mt||Jr),string:new oa}}i(uo,"mapCacheClear");var Af=uo;function po(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}i(po,"isKeyable");var Rf=po;function fo(t,e){var r=t.__data__;return Rf(e)?r[typeof e=="string"?"string":"hash"]:r.map}i(fo,"getMapData");var Xr=fo;function go(t){var e=Xr(this,t).delete(t);return this.size-=e?1:0,e}i(go,"mapCacheDelete");var Hf=go;function yo(t){return Xr(this,t).get(t)}i(yo,"mapCacheGet");var Mf=yo;function ho(t){return Xr(this,t).has(t)}i(ho,"mapCacheHas");var Df=ho;function mo(t,e){var r=Xr(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}i(mo,"mapCacheSet");var Nf=mo;function ze(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}i(ze,"MapCache");ze.prototype.clear=Af;ze.prototype.delete=Hf;ze.prototype.get=Mf;ze.prototype.has=Df;ze.prototype.set=Nf;var Yr=ze,$f="Expected a function";function Qr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError($f);var r=i(function(){var n=arguments,s=e?e.apply(this,n):n[0],a=r.cache;if(a.has(s))return a.get(s);var o=t.apply(this,n);return r.cache=a.set(s,o)||a,o},"memoized");return r.cache=new(Qr.Cache||Yr),r}i(Qr,"memoize");Qr.Cache=Yr;var jf=Qr,Kf=500;function vo(t){var e=jf(t,function(n){return r.size===Kf&&r.clear(),n}),r=e.cache;return e}i(vo,"memoizeCapped");var Uf=vo,Ff=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,zf=/\\(\\)?/g,Lf=Uf(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Ff,function(r,n,s,a){e.push(s?a.replace(zf,"$1"):n||r)}),e}),Wf=Lf;function _o(t){return t==null?"":ju(t)}i(_o,"toString");var qf=_o;function To(t,e){return ge(t)?t:ts(t,e)?[t]:Wf(qf(t))}i(To,"castPath");var en=To,Vf=1/0;function bo(t){if(typeof t=="string"||Gn(t))return t;var e=t+"";return e=="0"&&1/t==-Vf?"-0":e}i(bo,"toKey");var Kt=bo;function wo(t,e){e=en(e,t);for(var r=0,n=e.length;t!=null&&r<n;)t=t[Kt(e[r++])];return r&&r==n?t:void 0}i(wo,"baseGet");var rs=wo;function Po(t,e,r){var n=t==null?void 0:rs(t,e);return n===void 0?r:n}i(Po,"get");var Gf=Po;function xo(t,e){for(var r=-1,n=e.length,s=t.length;++r<n;)t[s+r]=e[r];return t}i(xo,"arrayPush");var ko=xo,Jf=Wi(Object.getPrototypeOf,Object),So=Jf,Xf="[object Object]",Yf=Function.prototype,Qf=Object.prototype,Eo=Yf.toString,eg=Qf.hasOwnProperty,tg=Eo.call(Object);function Oo(t){if(!He(t)||$e(t)!=Xf)return!1;var e=So(t);if(e===null)return!0;var r=eg.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&Eo.call(r)==tg}i(Oo,"isPlainObject");var la=Oo;function Zo(){this.__data__=new Jr,this.size=0}i(Zo,"stackClear");var rg=Zo;function Io(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}i(Io,"stackDelete");var ng=Io;function Bo(t){return this.__data__.get(t)}i(Bo,"stackGet");var sg=Bo;function Co(t){return this.__data__.has(t)}i(Co,"stackHas");var ag=Co,ig=200;function Ao(t,e){var r=this.__data__;if(r instanceof Jr){var n=r.__data__;if(!Mt||n.length<ig-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Yr(n)}return r.set(t,e),this.size=r.size,this}i(Ao,"stackSet");var og=Ao;function Le(t){var e=this.__data__=new Jr(t);this.size=e.size}i(Le,"Stack");Le.prototype.clear=rg;Le.prototype.delete=ng;Le.prototype.get=sg;Le.prototype.has=ag;Le.prototype.set=og;var tr=Le;function Ro(t,e){for(var r=-1,n=t==null?0:t.length,s=0,a=[];++r<n;){var o=t[r];e(o,r,t)&&(a[s++]=o)}return a}i(Ro,"arrayFilter");var lg=Ro;function Ho(){return[]}i(Ho,"stubArray");var Mo=Ho,cg=Object.prototype,dg=cg.propertyIsEnumerable,ca=Object.getOwnPropertySymbols,ug=ca?function(t){return t==null?[]:(t=Object(t),lg(ca(t),function(e){return dg.call(t,e)}))}:Mo,Do=ug,pg=Object.getOwnPropertySymbols,fg=pg?function(t){for(var e=[];t;)ko(e,Do(t)),t=So(t);return e}:Mo,gg=fg;function No(t,e,r){var n=e(t);return ge(t)?n:ko(n,r(t))}i(No,"baseGetAllKeys");var $o=No;function jo(t){return $o(t,es,Do)}i(jo,"getAllKeys");var da=jo;function Ko(t){return $o(t,df,gg)}i(Ko,"getAllKeysIn");var yg=Ko,hg=Ke(ye,"DataView"),$n=hg,mg=Ke(ye,"Promise"),jn=mg,vg=Ke(ye,"Set"),Kn=vg,ua="[object Map]",_g="[object Object]",pa="[object Promise]",fa="[object Set]",ga="[object WeakMap]",ya="[object DataView]",Tg=je($n),bg=je(Mt),wg=je(jn),Pg=je(Kn),xg=je(Dn),Ze=$e;($n&&Ze(new $n(new ArrayBuffer(1)))!=ya||Mt&&Ze(new Mt)!=ua||jn&&Ze(jn.resolve())!=pa||Kn&&Ze(new Kn)!=fa||Dn&&Ze(new Dn)!=ga)&&(Ze=i(function(t){var e=$e(t),r=e==_g?t.constructor:void 0,n=r?je(r):"";if(n)switch(n){case Tg:return ya;case bg:return ua;case wg:return pa;case Pg:return fa;case xg:return ga}return e},"getTag"));var ha=Ze,kg=ye.Uint8Array,ma=kg,Sg="__lodash_hash_undefined__";function Uo(t){return this.__data__.set(t,Sg),this}i(Uo,"setCacheAdd");var Eg=Uo;function Fo(t){return this.__data__.has(t)}i(Fo,"setCacheHas");var Og=Fo;function Dt(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Yr;++e<r;)this.add(t[e])}i(Dt,"SetCache");Dt.prototype.add=Dt.prototype.push=Eg;Dt.prototype.has=Og;var Zg=Dt;function zo(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}i(zo,"arraySome");var Ig=zo;function Lo(t,e){return t.has(e)}i(Lo,"cacheHas");var Bg=Lo,Cg=1,Ag=2;function Wo(t,e,r,n,s,a){var o=r&Cg,l=t.length,d=e.length;if(l!=d&&!(o&&d>l))return!1;var f=a.get(t),g=a.get(e);if(f&&g)return f==e&&g==t;var h=-1,x=!0,O=r&Ag?new Zg:void 0;for(a.set(t,e),a.set(e,t);++h<l;){var I=t[h],U=e[h];if(n)var W=o?n(U,I,h,e,t,a):n(I,U,h,t,e,a);if(W!==void 0){if(W)continue;x=!1;break}if(O){if(!Ig(e,function(Q,ae){if(!Bg(O,ae)&&(I===Q||s(I,Q,r,n,a)))return O.push(ae)})){x=!1;break}}else if(!(I===U||s(I,U,r,n,a))){x=!1;break}}return a.delete(t),a.delete(e),x}i(Wo,"equalArrays");var qo=Wo;function Vo(t){var e=-1,r=Array(t.size);return t.forEach(function(n,s){r[++e]=[s,n]}),r}i(Vo,"mapToArray");var Rg=Vo;function Go(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}i(Go,"setToArray");var Hg=Go,Mg=1,Dg=2,Ng="[object Boolean]",$g="[object Date]",jg="[object Error]",Kg="[object Map]",Ug="[object Number]",Fg="[object RegExp]",zg="[object Set]",Lg="[object String]",Wg="[object Symbol]",qg="[object ArrayBuffer]",Vg="[object DataView]",va=_e?_e.prototype:void 0,In=va?va.valueOf:void 0;function Jo(t,e,r,n,s,a,o){switch(r){case Vg:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case qg:return!(t.byteLength!=e.byteLength||!a(new ma(t),new ma(e)));case Ng:case $g:case Ug:return Yn(+t,+e);case jg:return t.name==e.name&&t.message==e.message;case Fg:case Lg:return t==e+"";case Kg:var l=Rg;case zg:var d=n&Mg;if(l||(l=Hg),t.size!=e.size&&!d)return!1;var f=o.get(t);if(f)return f==e;n|=Dg,o.set(t,e);var g=qo(l(t),l(e),n,s,a,o);return o.delete(t),g;case Wg:if(In)return In.call(t)==In.call(e)}return!1}i(Jo,"equalByTag");var Gg=Jo,Jg=1,Xg=Object.prototype,Yg=Xg.hasOwnProperty;function Xo(t,e,r,n,s,a){var o=r&Jg,l=da(t),d=l.length,f=da(e),g=f.length;if(d!=g&&!o)return!1;for(var h=d;h--;){var x=l[h];if(!(o?x in e:Yg.call(e,x)))return!1}var O=a.get(t),I=a.get(e);if(O&&I)return O==e&&I==t;var U=!0;a.set(t,e),a.set(e,t);for(var W=o;++h<d;){x=l[h];var Q=t[x],ae=e[x];if(n)var q=o?n(ae,Q,x,e,t,a):n(Q,ae,x,t,e,a);if(!(q===void 0?Q===ae||s(Q,ae,r,n,a):q)){U=!1;break}W||(W=x=="constructor")}if(U&&!W){var se=t.constructor,Xe=e.constructor;se!=Xe&&"constructor"in t&&"constructor"in e&&!(typeof se=="function"&&se instanceof se&&typeof Xe=="function"&&Xe instanceof Xe)&&(U=!1)}return a.delete(t),a.delete(e),U}i(Xo,"equalObjects");var Qg=Xo,ey=1,_a="[object Arguments]",Ta="[object Array]",Qt="[object Object]",ty=Object.prototype,ba=ty.hasOwnProperty;function Yo(t,e,r,n,s,a){var o=ge(t),l=ge(e),d=o?Ta:ha(t),f=l?Ta:ha(e);d=d==_a?Qt:d,f=f==_a?Qt:f;var g=d==Qt,h=f==Qt,x=d==f;if(x&&Nn(t)){if(!Nn(e))return!1;o=!0,g=!1}if(x&&!g)return a||(a=new tr),o||Ui(t)?qo(t,e,r,n,s,a):Gg(t,e,d,r,n,s,a);if(!(r&ey)){var O=g&&ba.call(t,"__wrapped__"),I=h&&ba.call(e,"__wrapped__");if(O||I){var U=O?t.value():t,W=I?e.value():e;return a||(a=new tr),s(U,W,r,n,a)}}return x?(a||(a=new tr),Qg(t,e,r,n,s,a)):!1}i(Yo,"baseIsEqualDeep");var ry=Yo;function ns(t,e,r,n,s){return t===e?!0:t==null||e==null||!He(t)&&!He(e)?t!==t&&e!==e:ry(t,e,r,n,ns,s)}i(ns,"baseIsEqual");var tn=ns,ny=1,sy=2;function Qo(t,e,r,n){var s=r.length,a=s,o=!n;if(t==null)return!a;for(t=Object(t);s--;){var l=r[s];if(o&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++s<a;){l=r[s];var d=l[0],f=t[d],g=l[1];if(o&&l[2]){if(f===void 0&&!(d in t))return!1}else{var h=new tr;if(n)var x=n(f,g,d,t,e,h);if(!(x===void 0?tn(g,f,ny|sy,n,h):x))return!1}}return!0}i(Qo,"baseIsMatch");var ay=Qo;function el(t){return t===t&&!at(t)}i(el,"isStrictComparable");var tl=el;function rl(t){for(var e=es(t),r=e.length;r--;){var n=e[r],s=t[n];e[r]=[n,s,tl(s)]}return e}i(rl,"getMatchData");var iy=rl;function nl(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}i(nl,"matchesStrictComparable");var sl=nl;function al(t){var e=iy(t);return e.length==1&&e[0][2]?sl(e[0][0],e[0][1]):function(r){return r===t||ay(r,t,e)}}i(al,"baseMatches");var oy=al;function il(t,e){return t!=null&&e in Object(t)}i(il,"baseHasIn");var ly=il;function ol(t,e,r){e=en(e,t);for(var n=-1,s=e.length,a=!1;++n<s;){var o=Kt(e[n]);if(!(a=t!=null&&r(t,o)))break;t=t[o]}return a||++n!=s?a:(s=t==null?0:t.length,!!s&&Qn(s)&&Xn(o,s)&&(ge(t)||Mi(t)))}i(ol,"hasPath");var cy=ol;function ll(t,e){return t!=null&&cy(t,e,ly)}i(ll,"hasIn");var dy=ll,uy=1,py=2;function cl(t,e){return ts(t)&&tl(e)?sl(Kt(t),e):function(r){var n=Gf(r,t);return n===void 0&&n===e?dy(r,t):tn(e,n,uy|py)}}i(cl,"baseMatchesProperty");var fy=cl;function dl(t){return function(e){return e?.[t]}}i(dl,"baseProperty");var gy=dl;function ul(t){return function(e){return rs(e,t)}}i(ul,"basePropertyDeep");var yy=ul;function pl(t){return ts(t)?gy(Kt(t)):yy(t)}i(pl,"property");var hy=pl;function fl(t){return typeof t=="function"?t:t==null?Ku:typeof t=="object"?ge(t)?fy(t[0],t[1]):oy(t):hy(t)}i(fl,"baseIteratee");var ss=fl;function gl(t){return function(e,r,n){for(var s=-1,a=Object(e),o=n(e),l=o.length;l--;){var d=o[t?l:++s];if(r(a[d],d,a)===!1)break}return e}}i(gl,"createBaseFor");var my=gl,vy=my(),_y=vy;function yl(t,e){return t&&_y(t,e,es)}i(yl,"baseForOwn");var Ty=yl;function hl(t,e){return tn(t,e)}i(hl,"isEqual");var nt=hl;function ml(t,e,r){r=typeof r=="function"?r:void 0;var n=r?r(t,e):void 0;return n===void 0?tn(t,e,void 0,r):!!n}i(ml,"isEqualWith");var by=ml;function vl(t){return t===void 0}i(vl,"isUndefined");var wa=vl;function _l(t,e){var r={};return e=ss(e,3),Ty(t,function(n,s,a){ki(r,s,e(n,s,a))}),r}i(_l,"mapValues");var wy=_l,Py="Expected a function";function Tl(t){if(typeof t!="function")throw new TypeError(Py);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}i(Tl,"negate");var xy=Tl;function bl(t,e,r,n){if(!at(t))return t;e=en(e,t);for(var s=-1,a=e.length,o=a-1,l=t;l!=null&&++s<a;){var d=Kt(e[s]),f=r;if(d==="__proto__"||d==="constructor"||d==="prototype")return t;if(s!=o){var g=l[d];f=n?n(g,d,l):void 0,f===void 0&&(f=at(g)?g:Xn(e[s+1])?[]:{})}up(l,d,f),l=l[d]}return t}i(bl,"baseSet");var ky=bl;function wl(t,e,r){for(var n=-1,s=e.length,a={};++n<s;){var o=e[n],l=rs(t,o);r(l,o)&&ky(a,en(o,t),l)}return a}i(wl,"basePickBy");var Sy=wl;function Pl(t,e){if(t==null)return{};var r=fi(yg(t),function(n){return[n]});return e=ss(e),Sy(t,r,function(n,s){return e(n,s[0])})}i(Pl,"pickBy");var Ey=Pl;function xl(t,e){return Ey(t,xy(ss(e)))}i(xl,"omitBy");var Pa=xl,Oy=i(t=>{let e=t.checks;return e.length===0?"":e.map(Zy).join("")},"generateStringChecks"),Zy=i(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"length":return`.length(${T(t.value)}, ${T(t.message)})`;case"email":return`.email(${T(t.message)})`;case"url":return`.url(${T(t.message)})`;case"emoji":return`.emoji(${T(t.message)})`;case"uuid":return`.uuid(${T(t.message)})`;case"cuid":return`.cuid(${T(t.message)})`;case"cuid2":return`.cuid2(${T(t.message)})`;case"ulid":return`.ulid(${T(t.message)})`;case"includes":let e=rt({message:t.message,position:t.position});return`.includes(${T(t.value)}, ${e})`;case"startsWith":return`.startsWith(${T(t.value)}, ${T(t.message)})`;case"endsWith":return`.endsWith(${T(t.value)}, ${T(t.message)})`;case"regex":return`.regex(${String(t.regex)}, ${T(t.message)})`;case"trim":return".trim()";case"toLowerCase":return".toLowerCase()";case"toUpperCase":return".toUpperCase()";case"datetime":let n=t.precision===null?void 0:t.precision;return`.datetime(${rt({message:t.message,precision:n,offset:t.offset})})`;case"ip":return`.ip(${rt({message:t.message,version:t.version})})`;default:return""}},"_generateStringCheck"),Iy=i(t=>{let e=t.checks;return e.length===0?"":e.map(By).join("")},"generateNumberChecks"),By=i(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"int":return`.int(${T(t.message)})`;case"multipleOf":return`.multipleOf(${T(t.value)}, ${T(t.message)})`;case"finite":return`.finite(${T(t.message)})`;default:return""}},"_generateNumberCheck"),Cy=i(t=>{let e=t.checks;return e.length===0?"":e.map(Ay).join("")},"generateBigIntChecks"),Ay=i(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"multipleOf":return`.multipleOf(${T(t.value)}, ${T(t.message)})`;default:return""}},"_generateBigIntCheck"),Ry=i(t=>{let e=t.checks;return e.length===0?"":e.map(Hy).join("")},"generateDateChecks"),Hy=i(t=>{switch(t.kind){case"min":return`.min(${xa(t.value)}, ${T(t.message)})`;case"max":return`.max(${xa(t.value)}, ${T(t.message)})`;default:return""}},"_generateDateCheck"),xa=i(t=>`new Date(${t})`,"dateTs"),My=i(t=>{let e=[];if(t.exactLength){let{value:r,message:n}=t.exactLength;e.push(`.length(${T(r)}, ${T(n)})`)}if(t.minLength){let{value:r,message:n}=t.minLength;e.push(`.min(${T(r)}, ${T(n)})`)}if(t.maxLength){let{value:r,message:n}=t.maxLength;e.push(`.max(${T(r)}, ${T(n)})`)}return e.join("")},"generateArrayChecks"),Dy=i(t=>{let e=[];if(t.minSize){let{value:r,message:n}=t.minSize;e.push(`.min(${T(r)}, ${T(n)})`)}if(t.maxSize){let{value:r,message:n}=t.maxSize;e.push(`.max(${T(r)}, ${T(n)})`)}return e.join("")},"generateSetChecks");function as(t){return N(t)}i(as,"toTypescriptSchema");function N(t){let r=t._def;switch(r.typeName){case u.ZodFirstPartyTypeKind.ZodString:return`z.string()${Oy(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNumber:return`z.number()${Iy(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNaN:return`z.nan()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodBigInt:return`z.bigint()${Cy(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodBoolean:return`z.boolean()${R(r)}${A(t._def)}`.trim();case u.ZodFirstPartyTypeKind.ZodDate:return`z.date()${Ry(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodUndefined:return`z.undefined()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNull:return`z.null()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodAny:return`z.any()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodUnknown:return`z.unknown()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNever:return`z.never()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodVoid:return`z.void()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodArray:return`z.array(${N(r.type)})${My(r)}${R(r)}${A(r)}`;case u.ZodFirstPartyTypeKind.ZodObject:let n=wy(r.shape(),N),s=t.additionalProperties(),a=s?`.catchall(${N(s)})`:"";return["z.object({",...Object.entries(n).map(([cu,du])=>` ${cu}: ${du},`),`})${a}${R(r)}${A(r)}`].join(`
11
+ `).trim();case u.ZodFirstPartyTypeKind.ZodUnion:return`z.union([${r.options.map(N).join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let l=r.options.map(N);return`z.discriminatedUnion(${T(r.discriminator)}, [${l.join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodIntersection:let f=N(r.left),g=N(r.right);return`z.intersection(${f}, ${g})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodTuple:return`z.tuple([${r.items.map(N).join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodRecord:let x=N(r.keyType),O=N(r.valueType);return`z.record(${x}, ${O})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodMap:let I=N(r.keyType),U=N(r.valueType);return`z.map(${I}, ${U})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodSet:return`z.set(${N(r.valueType)})${Dy(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodFunction:let W=r.args.items.map(N),Q=W.length?`.args(${W.join(", ")})`:"",ae=N(r.returns);return`z.function()${Q}.returns(${ae})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodLazy:return`z.lazy(() => ${N(r.getter())})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodLiteral:return`z.literal(${T(r.value)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return`z.enum([${r.values.map(T).join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodEffects:throw new Oe(u.ZodFirstPartyTypeKind.ZodEffects);case u.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Oe(u.ZodFirstPartyTypeKind.ZodNativeEnum);case u.ZodFirstPartyTypeKind.ZodOptional:return`z.optional(${N(r.innerType)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNullable:return`z.nullable(${N(r.innerType)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodDefault:let Xe=rt(r.defaultValue());return`z.default(${N(r.innerType)}, ${Xe})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodCatch:throw new Oe(u.ZodFirstPartyTypeKind.ZodCatch);case u.ZodFirstPartyTypeKind.ZodPromise:return`z.promise(${N(r.type)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodBranded:throw new Oe(u.ZodFirstPartyTypeKind.ZodBranded);case u.ZodFirstPartyTypeKind.ZodPipeline:throw new Oe(u.ZodFirstPartyTypeKind.ZodPipeline);case u.ZodFirstPartyTypeKind.ZodSymbol:throw new Oe(u.ZodFirstPartyTypeKind.ZodSymbol);case u.ZodFirstPartyTypeKind.ZodReadonly:return`z.readonly(${N(r.innerType)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodRef:return`z.ref(${T(r.uri)})${R(r)}${A(r)}`.trim();default:Z.assertNever(r)}}i(N,"sUnwrapZod");var A=i(t=>t.description?`.describe(${T(t.description)})`:"","_maybeDescribe"),R=i(t=>`${Ny(t)}${$y(t)}${jy(t)}${Ky(t)}${Uy(t)}${Fy(t)}${zy(t)}`,"_addZuiExtensions"),Ny=i(t=>{var e;return(e=t[b])!=null&&e.title?`.title(${T(t[b].title)})`:""},"_maybeTitle"),$y=i(t=>{var e;return(e=t[b])!=null&&e.displayAs?`.displayAs(${Ra({id:t[b].displayAs[0],params:t[b].displayAs[1]})})`:""},"_maybeDisplayAs"),jy=i(t=>{var e;return(e=t[b])!=null&&e.disabled?`.disabled(${t[b].disabled})`:""},"_maybeDisabled"),Ky=i(t=>{var e;return(e=t[b])!=null&&e.hidden?`.hidden(${t[b].hidden})`:""},"_maybeHidden"),Uy=i(t=>{var e;return(e=t[b])!=null&&e.placeholder?`.placeholder(${T(t[b].placeholder)})`:""},"_maybePlaceholder"),Fy=i(t=>{var e;return(e=t[b])!=null&&e.secret?".secret()":""},"_maybeSecret"),zy=i(t=>{var e;let r=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],n=Object.entries((e=t[b])!=null?e:{}).filter(([s])=>!r.includes(s));return n.length>0?`.metadata(${Ra(Object.fromEntries(n))})`:""},"_maybeSetMetadata"),Ly=i(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[b]&&(e[b]=t._def[b]);for(let r of t._def.checks)switch(r.kind){case"min":{let n=r.inclusive?"minimum":"exclusiveMinimum",s=r.inclusive?"exclusiveMinimum":"minimum";e[n]=r.value,delete e[s];break}case"max":{let n=r.inclusive?"maximum":"exclusiveMaximum",s=r.inclusive?"exclusiveMaximum":"maximum";e[n]=r.value,delete e[s];break}case"int":e.type="integer";break;case"finite":{e.format="finite";break}case"multipleOf":e.multipleOf=r.value;break;default:}return e},"zodNumberToJsonNumber"),kl="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",Sl="(([+-]\\d{2}(:?\\d{2})?)|Z)",Wy="Z",El="(\\.\\d+)?",Un="\\.\\d{",qy="}",Ol=i(t=>{let e=t.precision?Un+t.precision+qy:t.precision===0?"":El,r=t.offset?Sl:Wy;return new RegExp(`^${kl}${e}${r}$`)},"generateDatetimeRegex"),Vy=i(t=>({precision:Gy(t),offset:t.endsWith(`${Sl}$`)}),"extractPrecisionAndOffset"),Gy=i(t=>{let e=t.slice(1+kl.length);return e.startsWith(El)?null:e.startsWith(Un)?parseInt(e.slice(Un.length)):0},"_extractPrecision"),Rt={};Lr(Rt,{escapeSpecialChars:()=>Jy});var Jy=i(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function is(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage=p(c({},t.errorMessage),{[e]:r}))}i(is,"addErrorMessage");function H(t,e,r,n,s){t[e]=r,is(t,e,n,s)}i(H,"setResponseValueAndErrors");var j={cuid:"^[cC][^\\s-]{8,}$",cuid2:"^[a-z][a-z0-9]*$",ulid:"^[0-9A-HJKMNP-TV-Z]{26}$",email:"^(?!\\.)(?!.*\\.\\.)([a-zA-Z0-9_+-\\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\\-]*\\.)+[a-zA-Z]{2,}$",emoji:"^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",uuid:"^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$",ipv4:"^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$",ipv6:"^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$"};function os(t,e){let r=c({type:"string"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});function n(s){return e.patternStrategy==="escape"?Rt.escapeSpecialChars(s):s}if(i(n,"processPattern"),t.checks)for(let s of t.checks)switch(s.kind){case"min":H(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e);break;case"max":H(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Ee(r,"email",s.message,e);break;case"format:idn-email":Ee(r,"idn-email",s.message,e);break;case"pattern:zod":de(r,j.email,s.message,e);break}break;case"url":Ee(r,"uri",s.message,e);break;case"uuid":Ee(r,"uuid",s.message,e);break;case"regex":de(r,s.regex.source,s.message,e);break;case"cuid":de(r,j.cuid,s.message,e);break;case"cuid2":de(r,j.cuid2,s.message,e);break;case"startsWith":de(r,"^"+n(s.value),s.message,e);break;case"endsWith":de(r,n(s.value)+"$",s.message,e);break;case"datetime":Ee(r,"date-time",s.message,e);break;case"length":H(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e),H(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"includes":{de(r,n(s.value),s.message,e);break}case"ip":{s.version!=="v6"&&Ee(r,"ipv4",s.message,e),s.version!=="v4"&&Ee(r,"ipv6",s.message,e);break}case"emoji":de(r,j.emoji,s.message,e);break;case"ulid":{de(r,j.ulid,s.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}i(os,"parseStringDef");var Ee=i((t,e,r,n)=>{var s;t.format||(s=t.anyOf)!=null&&s.some(a=>a.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push(c({format:t.format},t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}})),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push(c({format:e},r&&n.errorMessages&&{errorMessage:{format:r}}))):H(t,"format",e,r,n)},"addFormat"),de=i((t,e,r,n)=>{var s;t.pattern||(s=t.allOf)!=null&&s.some(a=>a.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push(c({pattern:t.pattern},t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}})),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push(c({pattern:e},r&&n.errorMessages&&{errorMessage:{pattern:r}}))):H(t,"pattern",e,r,n)},"addPattern"),Xy=i(t=>{let e={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[b]&&(e[b]=t._def[b]);for(let r of t._def.checks)switch(r.kind){case"cuid":e.format="cuid",e.pattern=j.cuid;break;case"cuid2":e.format="cuid2",e.pattern=j.cuid2;break;case"ulid":e.format="ulid",e.pattern=j.ulid;break;case"uuid":e.format="uuid",e.pattern=j.uuid;break;case"emoji":e.format="emoji",e.pattern=j.emoji;break;case"email":e.format="email",e.pattern=j.email;break;case"ip":e.format=r.version==="v6"?"ipv6":"ipv4",e.pattern=r.version==="v6"?j.ipv6:j.ipv4;break;case"datetime":e.format="date-time",e.pattern=Ol(r).source,e[b]=p(c({},e[b]),{precision:r.precision,offset:r.offset});break;case"url":e.format="uri";break;case"endsWith":e.pattern=`${Rt.escapeSpecialChars(r.value)}$`;break;case"startsWith":e.pattern=`^${Rt.escapeSpecialChars(r.value)}`;break;case"includes":let n=r.position&&r.position>=1?`^(?:.{${r.position}}).*`:"";e.pattern=`${n}${Rt.escapeSpecialChars(r.value)}`;break;case"regex":e.pattern=r.regex.source;break;case"length":e.minLength=e.maxLength=Math.max(0,r.value);break;case"min":e.minLength=Math.max(0,r.value);break;case"max":e.maxLength=Math.max(0,r.value);break;default:throw new Fa({zodType:u.ZodFirstPartyTypeKind.ZodString,checkKind:r.kind})}return e},"zodStringToJsonString"),Yy=i((t,e)=>{let r={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[b]&&(r[b]=t._def[b]),t._def.minLength&&(r.minItems=t._def.minLength.value),t._def.maxLength&&(r.maxItems=t._def.maxLength.value),t._def.exactLength&&(r.minItems=t._def.exactLength.value,r.maxItems=t._def.exactLength.value),r},"zodArrayToJsonArray"),Qy=i((t,e)=>{let r={type:"array",description:t.description,uniqueItems:!0,items:e(t._def.valueType),"x-zui":t._def["x-zui"]};return t._def[b]&&(r[b]=t._def[b]),t._def.minSize&&(r.minItems=t._def.minSize.value),t._def.maxSize&&(r.maxItems=t._def.maxSize.value),r},"zodSetToJsonSet"),eh=i((t,e)=>{let r={type:"array",description:t.description,items:t._def.items.map(n=>e(n))};return t._def[b]&&(r[b]=t._def[b]),t._def.rest&&(r.additionalItems=e(t._def.rest)),r},"zodTupleToJsonTuple");function V(t){let e=t,r=e._def;switch(r.typeName){case u.ZodFirstPartyTypeKind.ZodString:return Xy(e);case u.ZodFirstPartyTypeKind.ZodNumber:return Ly(e);case u.ZodFirstPartyTypeKind.ZodNaN:throw new ee(u.ZodFirstPartyTypeKind.ZodNaN);case u.ZodFirstPartyTypeKind.ZodBigInt:throw new ee(u.ZodFirstPartyTypeKind.ZodBigInt,{suggestedAlternative:"serialize bigint to string"});case u.ZodFirstPartyTypeKind.ZodBoolean:return{type:"boolean",description:r.description,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodDate:throw new ee(u.ZodFirstPartyTypeKind.ZodDate,{suggestedAlternative:"use z.string().datetime() instead"});case u.ZodFirstPartyTypeKind.ZodUndefined:return Bn(r);case u.ZodFirstPartyTypeKind.ZodNull:return Cn(r);case u.ZodFirstPartyTypeKind.ZodAny:return{description:r.description,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodUnknown:return{description:r.description,"x-zui":p(c({},r["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodUnknown}})};case u.ZodFirstPartyTypeKind.ZodNever:return{not:!0,description:r.description,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodVoid:throw new ee(u.ZodFirstPartyTypeKind.ZodVoid);case u.ZodFirstPartyTypeKind.ZodArray:return Yy(e,V);case u.ZodFirstPartyTypeKind.ZodObject:let n=Object.entries(r.shape()),s=n.filter(([g,h])=>!h.isOptional()),a=s.length?s.map(([g])=>g):void 0,o=n.map(([g,h])=>[g,h.mandatory()]).map(([g,h])=>[g,V(h)]),l=!1;return r.unknownKeys instanceof u.ZodType?l=V(r.unknownKeys):r.unknownKeys==="passthrough"&&(l=!0),{type:"object",description:r.description,properties:Object.fromEntries(o),required:a,additionalProperties:l,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodUnion:return{description:r.description,anyOf:r.options.map(g=>V(g)),"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return{description:r.description,anyOf:r.options.map(g=>V(g)),"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodIntersection:let d=V(r.left),f=V(r.right);return"additionalProperties"in d&&delete d.additionalProperties,"additionalProperties"in f&&delete f.additionalProperties,{description:r.description,allOf:[d,f],"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodTuple:return eh(e,V);case u.ZodFirstPartyTypeKind.ZodRecord:return{type:"object",description:r.description,additionalProperties:V(r.valueType),"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodMap:throw new ee(u.ZodFirstPartyTypeKind.ZodMap);case u.ZodFirstPartyTypeKind.ZodSet:return Qy(e,V);case u.ZodFirstPartyTypeKind.ZodFunction:throw new ee(u.ZodFirstPartyTypeKind.ZodFunction);case u.ZodFirstPartyTypeKind.ZodLazy:throw new ee(u.ZodFirstPartyTypeKind.ZodLazy);case u.ZodFirstPartyTypeKind.ZodLiteral:if(typeof r.value=="string")return{type:"string",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="number")return{type:"number",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="boolean")return{type:"boolean",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(r.value===null)return Cn(r);if(r.value===void 0)return Bn(r);{u.util.assertEqual(!0);let g=typeof r.value;throw new qr(`Unsupported literal type: "${g}"`)}case u.ZodFirstPartyTypeKind.ZodEnum:return{type:"string",description:r.description,enum:r.values,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodEffects:throw new ee(u.ZodFirstPartyTypeKind.ZodEffects);case u.ZodFirstPartyTypeKind.ZodNativeEnum:throw new ee(u.ZodFirstPartyTypeKind.ZodNativeEnum);case u.ZodFirstPartyTypeKind.ZodOptional:return{description:r.description,anyOf:[V(r.innerType),Bn()],"x-zui":p(c({},r["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodOptional}})};case u.ZodFirstPartyTypeKind.ZodNullable:return{anyOf:[V(r.innerType),Cn()],"x-zui":p(c({},r["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodNullable}})};case u.ZodFirstPartyTypeKind.ZodDefault:return p(c({},V(r.innerType)),{default:r.defaultValue()});case u.ZodFirstPartyTypeKind.ZodCatch:throw new ee(u.ZodFirstPartyTypeKind.ZodCatch);case u.ZodFirstPartyTypeKind.ZodPromise:throw new ee(u.ZodFirstPartyTypeKind.ZodPromise);case u.ZodFirstPartyTypeKind.ZodBranded:throw new ee(u.ZodFirstPartyTypeKind.ZodBranded);case u.ZodFirstPartyTypeKind.ZodPipeline:throw new ee(u.ZodFirstPartyTypeKind.ZodPipeline);case u.ZodFirstPartyTypeKind.ZodSymbol:throw new ee(u.ZodFirstPartyTypeKind.ZodPipeline);case u.ZodFirstPartyTypeKind.ZodReadonly:return p(c({},V(r.innerType)),{readOnly:!0});case u.ZodFirstPartyTypeKind.ZodRef:return{$ref:r.uri,description:r.description,"x-zui":r["x-zui"]};default:u.util.assertNever(r)}}i(V,"toJSONSchema");var Bn=i(t=>({not:!0,description:t?.description,"x-zui":p(c({},t?.["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodUndefined}})}),"undefinedSchema"),Cn=i(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),Zl=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};i(Zl,"ParseInputLazyPath");var ie=Zl,ka=i((t,e)=>{if(ot(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new le(t.common.issues);return this._error=r,this._error}}},"handleResult"),Il=class{constructor(e){this.__type__="ZuiType",this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._metadataRoot._def.description}dereference(e){return this}getReferences(){return[]}clone(){let e=this.constructor;return new e(c({},this._def))}_getType(e){return pe(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:pe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new te,ctx:{common:e.parent.common,data:e.data,parsedType:pe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if($t(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;let s={common:{issues:[],async:(n=r?.async)!=null?n:!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pe(e)},a=this._parseSync({data:e,path:s.path,parent:s});return ka(s,a)}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pe(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await($t(s)?s:Promise.resolve(s));return ka(n,a)}refine(e,r){let n=i(s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r,"getIssueProperties");return this._refinement((s,a)=>{let o=e(s),l=i(()=>a.addIssue(c({code:y.custom},n(s))),"setError");return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new be({schema:this,typeName:"ZodEffects",effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return fe.create(this,this._def)}nullable(){return Me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ct.create(this,this._def)}promise(){return zt.create(this,this._def)}mandatory(){return this}or(e){return yn.create([this,e],this._def)}and(e){return ln.create(this,e,this._def)}transform(e){return new be(p(c({},k(this._def)),{schema:this,typeName:"ZodEffects",effect:{type:"transform",transform:e}}))}default(e){let r=typeof e=="function"?e:()=>e;return new Ut(p(c({},k(this._def)),{innerType:this,defaultValue:r,typeName:"ZodDefault"}))}brand(){return new sn(c({typeName:"ZodBranded",type:this},k(this._def)))}catch(e){let r=typeof e=="function"?e:()=>e;return new an(p(c({},k(this._def)),{innerType:this,catchValue:r,typeName:"ZodCatch"}))}describe(e){let r=this.clone();return r._metadataRoot._def.description=e,r}pipe(e){return gn.create(this,e)}readonly(){return Lt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}metadata(e){var r,n,s;let a=this.clone(),o=a._metadataRoot;(s=(r=o._def)[n=b])!=null||(r[n]={});for(let[l,d]of Object.entries(e))o._def[b]=p(c({},o._def[b]),{[l]:d});return a}getMetadata(){return c({},this._metadataRoot._def[b])}setMetadata(e){this._metadataRoot._def[b]=c({},e)}get ui(){return c({},this._metadataRoot._def[b])}get _metadataRoot(){return this.naked()}displayAs(e){return this.metadata({displayAs:[e.id,e.params]})}title(e){return this.metadata({title:e})}hidden(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({hidden:r})}disabled(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({disabled:r})}placeholder(e){return this.metadata({placeholder:e})}toJSONSchema(){return V(this)}toTypescriptType(e){return Vn(this,e)}toTypescriptSchema(){return as(this)}naked(){return this}};i(Il,"ZodType");var E=Il,ls=(t=>(t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodRef="ZodRef",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly",t))(ls||{}),Z;(t=>{t.assertEqual=i(s=>s,"assertEqual");function e(s){}t.assertIs=e,i(e,"assertIs");function r(s){throw new Error("assertNever called")}t.assertNever=r,i(r,"assertNever"),t.arrayToEnum=i(s=>{let a={};for(let o of s)a[o]=o;return a},"arrayToEnum"),t.getValidEnumValues=i(s=>{let a=(0,t.objectKeys)(s).filter(l=>typeof s[s[l]]!="number"),o={};for(let l of a)o[l]=s[l];return(0,t.objectValues)(o)},"getValidEnumValues"),t.objectValues=i(s=>(0,t.objectKeys)(s).map(function(a){return s[a]}),"objectValues"),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let a=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&a.push(o);return a},t.find=i((s,a)=>{for(let o of s)if(a(o))return o},"find"),t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}t.joinValues=n,i(n,"joinValues"),t.jsonStringifyReplacer=i((s,a)=>typeof a=="bigint"?a.toString():a,"jsonStringifyReplacer"),t.compareFunctions=i((s,a)=>s.toString()===a.toString(),"compareFunctions"),t.mock=i(()=>({}),"mock")})(Z||(Z={}));var dr;(t=>{t.mergeShapes=i((e,r)=>c(c({},e),r),"mergeShapes")})(dr||(dr={}));var v=Z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),pe=i(t=>{switch(typeof t){case"undefined":return v.undefined;case"string":return v.string;case"number":return isNaN(t)?v.nan:v.number;case"boolean":return v.boolean;case"function":return v.function;case"bigint":return v.bigint;case"symbol":return v.symbol;case"object":return Array.isArray(t)?v.array:t===null?v.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?v.promise:typeof Map<"u"&&t instanceof Map?v.map:typeof Set<"u"&&t instanceof Set?v.set:typeof Date<"u"&&t instanceof Date?v.date:v.object;default:return v.unknown}},"getParsedType");function k(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s,[b]:t?.[b]}:{errorMap:i((o,l)=>o.code!=="invalid_type"?{message:l.defaultError}:typeof l.data>"u"?{message:n??l.defaultError}:{message:r??l.defaultError},"customMap"),description:s,[b]:t?.[b]}}i(k,"processCreateParams");var cs=i((t,e)=>{let r;switch(t.code){case y.invalid_type:t.received===v.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case y.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Z.jsonStringifyReplacer)}`;break;case y.unrecognized_keys:r=`Unrecognized key(s) in object: ${Z.joinValues(t.keys,", ")}`;break;case y.invalid_union:r="Invalid input";break;case y.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Z.joinValues(t.options)}`;break;case y.invalid_enum_value:r=`Invalid enum value. Expected ${Z.joinValues(t.options)}, received '${t.received}'`;break;case y.invalid_arguments:r="Invalid function arguments";break;case y.invalid_return_type:r="Invalid function return type";break;case y.invalid_date:r="Invalid date";break;case y.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Z.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case y.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case y.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case y.custom:r="Invalid input";break;case y.invalid_intersection_types:r="Intersection results could not be merged";break;case y.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case y.not_finite:r="Number must be finite";break;case y.unresolved_reference:r="Unresolved reference";break;default:r=e.defaultError,Z.assertNever(t)}return{message:r}},"errorMap"),Sa=cs,y=Z.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite","unresolved_reference"]),Bl=i(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),ur=class Cl extends Error{constructor(e){super(),this.issues=[],this.addIssue=i(n=>{this.issues=[...this.issues,n]},"addIssue"),this.addIssues=i((n=[])=>{this.issues=[...this.issues,...n]},"addIssues");let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let r=e||function(a){return a.message},n={_errors:[]},s=i(a=>{for(let o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let l=n,d=0;for(;d<o.path.length;){let f=o.path[d];d===o.path.length-1?(l[f]=l[f]||{_errors:[]},l[f]._errors.push(r(o))):l[f]=l[f]||{_errors:[]},l=l[f],d++}}},"processError");return s(this),n}static assert(e){if(!(e instanceof Cl))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Z.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};i(ur,"ZodError");ur.create=i(t=>new ur(t),"create");var le=ur,Al=cs;function ds(t){Al=t}i(ds,"setErrorMap");function it(){return Al}i(it,"getErrorMap");var Nt=i(t=>{var e;let{data:r,path:n,errorMaps:s,issueData:a}=t,o=[...n,...a.path||[]],l=p(c({},a),{path:o}),d="",f=s.filter(g=>!!g).slice().reverse();for(let g of f)d=g(l,{data:r,defaultError:d}).message;return p(c({},a),{path:o,message:(e=a.message)!=null?e:d})},"makeIssue"),Rl=[];function m(t,e){let r=Nt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,it(),cs].filter(n=>!!n)});t.common.issues.push(r)}i(m,"addIssueToContext");var Hl=class Ml{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return P;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r)n.push({key:await s.key,value:await s.value});return Ml.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:a,value:o}=s;if(a.status==="aborted"||o.status==="aborted")return P;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[a.value]=o.value)}return{status:e.value,value:n}}};i(Hl,"ParseStatus");var te=Hl,P=Object.freeze({status:"aborted"}),Re=i(t=>({status:"dirty",value:t}),"DIRTY"),J=i(t=>({status:"valid",value:t}),"OK"),pr=i(t=>t.status==="aborted","isAborted"),fr=i(t=>t.status==="dirty","isDirty"),ot=i(t=>t.status==="valid","isValid"),$t=i(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),w;(t=>{t.errToObj=i(e=>typeof e=="string"?{message:e}:e||{},"errToObj"),t.toString=i(e=>typeof e=="string"?e:e?.message,"toString")})(w||(w={}));var gr=class Dl extends E{constructor(){super(...arguments),this._any=!0}_parse(e){return J(e.data)}isEqual(e){return e instanceof Dl}};i(gr,"ZodAny");gr.create=i(t=>new gr(c({typeName:"ZodAny"},k(t))),"create");var lt=gr,yr=class Ie extends E{dereference(e){return new Ie(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Ie(p(c({},this._def),{type:this._def.type.clone()}))}isEqual(e){var r,n,s,a,o,l;return e instanceof Ie?nt((r=this._def.exactLength)==null?void 0:r.value,(n=e._def.exactLength)==null?void 0:n.value)&&nt((s=this._def.maxLength)==null?void 0:s.value,(a=e._def.maxLength)==null?void 0:a.value)&&nt((o=this._def.minLength)==null?void 0:o.value,(l=e._def.minLength)==null?void 0:l.value)&&this._def.type.isEqual(e._def.type):!1}_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==v.array)return m(r,{code:y.invalid_type,expected:v.array,received:r.parsedType}),P;if(s.exactLength!==null){let o=r.data.length>s.exactLength.value,l=r.data.length<s.exactLength.value;(o||l)&&(m(r,{code:o?y.too_big:y.too_small,minimum:l?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(m(r,{code:y.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(m(r,{code:y.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,l)=>s.type._parseAsync(new ie(r,o,r.path,l)))).then(o=>te.mergeArray(n,o));let a=[...r.data].map((o,l)=>s.type._parseSync(new ie(r,o,r.path,l)));return te.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new Ie(p(c({},this._def),{minLength:{value:e,message:w.toString(r)}}))}max(e,r){return new Ie(p(c({},this._def),{maxLength:{value:e,message:w.toString(r)}}))}length(e,r){return new Ie(p(c({},this._def),{exactLength:{value:e,message:w.toString(r)}}))}nonempty(e){return this.min(1,e)}};i(yr,"ZodArray");yr.create=i((t,e)=>new yr(c({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},k(e))),"create");var ct=yr,th=i((t,e)=>Nl(t,e,new WeakSet),"isEqual"),Nl=i((t,e,r)=>by(t,e,rh(r)),"_isEqualWithVisitedTracking"),rh=i(t=>(e,r)=>{if(la(e)&&!t.has(e)&&la(r)&&!t.has(r)){let n=Pa(e,wa),s=Pa(r,wa);return t.add(n).add(s).add(e).add(r),Nl(n,s,t)}},"_customizerWithVisitedTracking"),nh={compare:th},$l=class{constructor(e=[],r={}){this._options=c(c({},nh),r),this._items=[];for(let n of e)this.add(n)}get items(){return[...this._items]}get size(){return this._items.length}has(e){return this._items.some(r=>this._options.compare(r,e))}add(e){this.has(e)||this._items.push(e)}isEqual(e){return this.size!==e.size?!1:this.isSubsetOf(e)&&e.isSubsetOf(this)}isSubsetOf(e){return this.size>e.size?!1:this._items.every(r=>e.has(r))}};i($l,"CustomSet");var K=$l,hr=class rr extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==v.bigint){let a=this._getOrReturnCtx(e);return m(a,{code:y.invalid_type,expected:v.bigint,received:a.parsedType}),P}let n,s=new te;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:y.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:y.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),m(n,{code:y.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):Z.assertNever(a);return{status:s.value,value:e.data}}isEqual(e){if(!(e instanceof rr)||this._def.coerce!==e._def.coerce)return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}gte(e,r){return this.setLimit("min",e,!0,w.toString(r))}gt(e,r){return this.setLimit("min",e,!1,w.toString(r))}lte(e,r){return this.setLimit("max",e,!0,w.toString(r))}lt(e,r){return this.setLimit("max",e,!1,w.toString(r))}setLimit(e,r,n,s){return new rr(p(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:w.toString(s)}]}))}_addCheck(e){return new rr(p(c({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};i(hr,"ZodBigInt");hr.create=i(t=>{var e;return new hr(c({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},k(t)))},"create");var rn=hr,mr=class jl extends E{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==v.boolean){let n=this._getOrReturnCtx(e);return m(n,{code:y.invalid_type,expected:v.boolean,received:n.parsedType}),P}return J(e.data)}isEqual(e){return e instanceof jl?this._def.coerce===e._def.coerce:!1}};i(mr,"ZodBoolean");mr.create=i(t=>new mr(c({typeName:"ZodBoolean",coerce:t?.coerce||!1},k(t))),"create");var nn=mr,Kl=Symbol("zod_brand"),Ul=class bt extends E{dereference(e){return new bt(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new bt(p(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}isEqual(e){return e instanceof bt?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new bt(p(c({},this._def),{type:this._def.type.mandatory()}))}};i(Ul,"ZodBranded");var sn=Ul,vr=class wt extends E{_parse(e){let{ctx:r}=this._processInputParams(e),n=p(c({},r),{common:p(c({},r.common),{issues:[]})}),s=this._def.innerType._parse({data:n.data,path:n.path,parent:c({},n)});return $t(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new le(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new le(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof wt?this._def.innerType.isEqual(e._def.innerType)&&Z.compareFunctions(this._def.catchValue,e._def.catchValue):!1}dereference(e){return new wt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new wt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}naked(){return this._def.innerType.naked()}mandatory(){return new wt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};i(vr,"ZodCatch");vr.create=i((t,e)=>new vr(c({innerType:t,typeName:"ZodCatch",catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},k(e))),"create");var an=vr,us=i((t,e={},r)=>t?lt.create().superRefine((n,s)=>{var a,o;if(!t(n)){let l=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,d=(o=(a=l.fatal)!=null?a:r)!=null?o:!0,f=typeof l=="string"?{message:l}:l;s.addIssue(p(c({code:"custom"},f),{fatal:d}))}}):lt.create(),"custom"),_r=class Fn extends E{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==v.date){let a=this._getOrReturnCtx(e);return m(a,{code:y.invalid_type,expected:v.date,received:a.parsedType}),P}if(isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return m(a,{code:y.invalid_date}),P}let n=new te,s;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:y.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:y.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):Z.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Fn(p(c({},this._def),{checks:[...this._def.checks,e]}))}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}isEqual(e){if(!(e instanceof Fn))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)&&this._def.coerce===e._def.coerce}};i(_r,"ZodDate");_r.create=i(t=>new _r(c({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},k(t))),"create");var on=_r,Tr=class Pt extends E{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===v.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}dereference(e){return new Pt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Pt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}isEqual(e){return e instanceof Pt?this._def.innerType.isEqual(e._def.innerType)&&nt(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new Pt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};i(Tr,"ZodDefault");Tr.create=i((t,e,r)=>new Tr(c({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},k(r))),"create");var Ut=Tr,he=i(t=>Array.from(new Set(t)),"unique"),ue=i(t=>t instanceof cn?ue(t.schema):t instanceof be?ue(t.innerType()):t instanceof dn?[t.value]:t instanceof We?t.options:t instanceof un?Z.objectValues(t.enum):t instanceof Ut?ue(t._def.innerType):t instanceof Wt?[void 0]:t instanceof pn?[null]:t instanceof fe?[void 0,...ue(t.unwrap())]:t instanceof Me?[null,...ue(t.unwrap())]:t instanceof sn||t instanceof Lt?ue(t.unwrap()):t instanceof an?ue(t._def.innerType):[],"getDiscriminator"),Fl=class Be extends E{dereference(e){let r=this.options.map(s=>s.dereference(e)),n=Be._getOptionsMap(this.discriminator,r);return new Be(p(c({},this._def),{options:r,optionsMap:n}))}getReferences(){return he(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(r=>r.clone());return new Be(p(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==v.object)return m(r,{code:y.invalid_type,expected:v.object,received:r.parsedType}),P;let n=this.discriminator,s=r.data[n],a=this.optionsMap.get(s);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(m(r,{code:y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),P)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=Be._getOptionsMap(e,r);return new Be(c({typeName:"ZodDiscriminatedUnion",discriminator:e,options:r,optionsMap:s},k(n)))}static _getOptionsMap(e,r){let n=new Map;for(let s of r){let a=ue(s.shape[e]);if(!a.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of a){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,s)}}return n}isEqual(e){if(!(e instanceof Be)||this._def.discriminator!==e._def.discriminator)return!1;let r=i((a,o)=>a.isEqual(o),"compare"),n=new K(this._def.options,{compare:r}),s=new K(e._def.options,{compare:r});return n.isEqual(s)}};i(Fl,"ZodDiscriminatedUnion");var ps=Fl;function Ft(t,e){return new We(c({values:t,typeName:"ZodEnum"},k(e)))}i(Ft,"createZodEnum");var fs=class nr extends E{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return m(r,{expected:Z.joinValues(n),received:r.parsedType,code:y.invalid_type}),P}if(this._def.values.indexOf(e.data)===-1){let r=this._getOrReturnCtx(e),n=this._def.values;return m(r,{received:r.data,code:y.invalid_enum_value,options:n}),P}return J(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return nr.create(e,c(c({},this._def),r))}exclude(e,r=this._def){return nr.create(this.options.filter(n=>!e.includes(n)),c(c({},this._def),r))}isEqual(e){if(!(e instanceof nr))return!1;let r=new K(this._def.values),n=new K(e._def.values);return r.isEqual(n)}};i(fs,"ZodEnum");fs.create=Ft;var We=fs,zl=class Ce extends E{constructor(){super(...arguments),this.validate=this.implement}dereference(e){let r=this._def.args.dereference(e),n=this._def.returns.dereference(e);return new Ce(p(c({},this._def),{args:r,returns:n}))}getReferences(){return he([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new Ce(p(c({},this._def),{args:this._def.args.clone(),returns:this._def.returns.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==v.function)return m(r,{code:y.invalid_type,expected:v.function,received:r.parsedType}),P;function n(l,d){return Nt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,it(),Sa].filter(f=>!!f),issueData:{code:y.invalid_arguments,argumentsError:d}})}i(n,"makeArgsIssue");function s(l,d){return Nt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,it(),Sa].filter(f=>!!f),issueData:{code:y.invalid_return_type,returnTypeError:d}})}i(s,"makeReturnsIssue");let a={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof zt){let l=this;return J(async function(...d){let f=new le([]),g=await l._def.args.parseAsync(d,a).catch(O=>{throw f.addIssue(n(d,O)),f}),h=await Reflect.apply(o,this,g);return await l._def.returns._def.type.parseAsync(h,a).catch(O=>{throw f.addIssue(s(h,O)),f})})}else{let l=this;return J(function(...d){let f=l._def.args.safeParse(d,a);if(!f.success)throw new le([n(d,f.error)]);let g=Reflect.apply(o,this,f.data),h=l._def.returns.safeParse(g,a);if(!h.success)throw new le([s(g,h.error)]);return h.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ce(p(c({},this._def),{args:Ne.create(e).rest(st.create())}))}returns(e){return new Ce(p(c({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Ce(c({args:e||Ne.create([]).rest(st.create()),returns:r||st.create(),typeName:"ZodFunction"},k(n)))}isEqual(e){return e instanceof Ce&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};i(zl,"ZodFunction");var gs=zl;function br(t,e){let r=pe(t),n=pe(e);if(t===e)return{valid:!0,data:t};if(r===v.object&&n===v.object){let s=Z.objectKeys(e),a=Z.objectKeys(t).filter(l=>s.indexOf(l)!==-1),o=c(c({},t),e);for(let l of a){let d=br(t[l],e[l]);if(!d.valid)return{valid:!1};o[l]=d.data}return{valid:!0,data:o}}else if(r===v.array&&n===v.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let a=0;a<t.length;a++){let o=t[a],l=e[a],d=br(o,l);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return r===v.date&&n===v.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}i(br,"mergeValues");var wr=class sr extends E{dereference(e){return new sr(p(c({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return he([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new sr(p(c({},this._def),{left:this._def.left.clone(),right:this._def.right.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=i((a,o)=>{if(pr(a)||pr(o))return P;let l=br(a.value,o.value);return l.valid?((fr(a)||fr(o))&&r.dirty(),{status:r.value,value:l.data}):(m(n,{code:y.invalid_intersection_types}),P)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,o])=>s(a,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}isEqual(e){if(!(e instanceof sr))return!1;let r=i((a,o)=>a.isEqual(o),"compare"),n=new K([this._def.left,this._def.right],{compare:r}),s=new K([e._def.left,e._def.right],{compare:r});return n.isEqual(s)}};i(wr,"ZodIntersection");wr.create=i((t,e,r)=>new wr(c({left:t,right:e,typeName:"ZodIntersection"},k(r))),"create");var ln=wr,Pr=class xt extends E{get schema(){return this._def.getter()}dereference(e){return new xt(p(c({},this._def),{getter:i(()=>this._def.getter().dereference(e),"getter")}))}getReferences(){return this._def.getter().getReferences()}clone(){return new xt(p(c({},this._def),{getter:i(()=>this._def.getter().clone(),"getter")}))}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}isEqual(e){return e instanceof xt?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new xt(p(c({},this._def),{getter:i(()=>this._def.getter().mandatory(),"getter")}))}};i(Pr,"ZodLazy");Pr.create=i((t,e)=>new Pr(c({getter:t,typeName:"ZodLazy"},k(e))),"create");var cn=Pr,xr=class Ll extends E{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return m(r,{received:r.data,code:y.invalid_literal,expected:this._def.value}),P}return{status:"valid",value:e.data}}get value(){return this._def.value}isEqual(e){return e instanceof Ll?nt(this._def.value,e._def.value):!1}};i(xr,"ZodLiteral");xr.create=i((t,e)=>new xr(c({value:t,typeName:"ZodLiteral"},k(e))),"create");var dn=xr,kr=class ar extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new ar(p(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return he([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new ar(p(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.map)return m(n,{code:y.invalid_type,expected:v.map,received:n.parsedType}),P;let s=this._def.keyType,a=this._def.valueType,o=[...n.data.entries()].map(([l,d],f)=>({key:s._parse(new ie(n,l,n.path,[f,"key"])),value:a._parse(new ie(n,d,n.path,[f,"value"]))}));if(n.common.async){let l=new Map;return Promise.resolve().then(async()=>{for(let d of o){let f=await d.key,g=await d.value;if(f.status==="aborted"||g.status==="aborted")return P;(f.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(f.value,g.value)}return{status:r.value,value:l}})}else{let l=new Map;for(let d of o){let f=d.key,g=d.value;if(f.status==="aborted"||g.status==="aborted")return P;(f.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(f.value,g.value)}return{status:r.value,value:l}}}isEqual(e){return!(!(e instanceof ar)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};i(kr,"ZodMap");kr.create=i((t,e,r)=>new kr(c({valueType:e,keyType:t,typeName:"ZodMap"},k(r))),"create");var ys=kr,Sr=class Wl extends E{_parse(e){if(this._getType(e)!==v.nan){let n=this._getOrReturnCtx(e);return m(n,{code:y.invalid_type,expected:v.nan,received:n.parsedType}),P}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Wl}};i(Sr,"ZodNaN");Sr.create=i(t=>new Sr(c({typeName:"ZodNaN"},k(t))),"create");var hs=Sr,Er=class ql extends E{_parse(e){let r=Z.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==v.string&&n.parsedType!==v.number){let s=Z.objectValues(r);return m(n,{expected:Z.joinValues(s),received:n.parsedType,code:y.invalid_type}),P}if(r.indexOf(e.data)===-1){let s=Z.objectValues(r);return m(n,{received:n.data,code:y.invalid_enum_value,options:s}),P}return J(e.data)}get enum(){return this._def.values}isEqual(e){return e instanceof ql?nt(this._def.values,e._def.values):!1}};i(Er,"ZodNativeEnum");Er.create=i((t,e)=>new Er(c({values:t,typeName:"ZodNativeEnum"},k(e))),"create");var un=Er,Or=class Vl extends E{_parse(e){let r=this._getOrReturnCtx(e);return m(r,{code:y.invalid_type,expected:v.never,received:r.parsedType}),P}isEqual(e){return e instanceof Vl}};i(Or,"ZodNever");Or.create=i(t=>new Or(c({typeName:"ZodNever"},k(t))),"create");var pt=Or,Zr=class Gl extends E{_parse(e){if(this._getType(e)!==v.null){let n=this._getOrReturnCtx(e);return m(n,{code:y.invalid_type,expected:v.null,received:n.parsedType}),P}return J(e.data)}isEqual(e){return e instanceof Gl}};i(Zr,"ZodNull");Zr.create=i(t=>new Zr(c({typeName:"ZodNull"},k(t))),"create");var pn=Zr,Ir=class kt extends E{dereference(e){return new kt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new kt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===v.null?J(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof kt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new kt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};i(Ir,"ZodNullable");Ir.create=i((t,e)=>new Ir(c({innerType:t,typeName:"ZodNullable"},k(e))),"create");var Me=Ir;function Jl(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,a=parseInt(t.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return a%o/Math.pow(10,s)}i(Jl,"floatSafeRemainder");var Br=class ir extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==v.number){let a=this._getOrReturnCtx(e);return m(a,{code:y.invalid_type,expected:v.number,received:a.parsedType}),P}let n,s=new te;for(let a of this._def.checks)a.kind==="int"?Z.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:y.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:y.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:y.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Jl(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),m(n,{code:y.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:y.not_finite,message:a.message}),s.dirty()):Z.assertNever(a);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,w.toString(r))}gt(e,r){return this.setLimit("min",e,!1,w.toString(r))}lte(e,r){return this.setLimit("max",e,!0,w.toString(r))}lt(e,r){return this.setLimit("max",e,!1,w.toString(r))}setLimit(e,r,n,s){return new ir(p(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:w.toString(s)}]}))}_addCheck(e){return new ir(p(c({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Z.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}isEqual(e){if(!(e instanceof ir))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}};i(Br,"ZodNumber");Br.create=i(t=>new Br(c({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},k(t))),"create");var fn=Br;function Ae(t){if(t instanceof De){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=fe.create(Ae(n))}return new De(p(c({},t._def),{shape:i(()=>e,"shape")}))}else return t instanceof ct?new ct(p(c({},t._def),{type:Ae(t.element)})):t instanceof fe?fe.create(Ae(t.unwrap())):t instanceof Me?Me.create(Ae(t.unwrap())):t instanceof Ne?Ne.create(t.items.map(e=>Ae(e))):t}i(Ae,"deepPartialify");var Te=class ne extends E{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Z.objectKeys(e);return this._cached={shape:e,keys:r}}dereference(e){let r=this._def.shape(),n={};for(let s in r)n[s]=r[s].dereference(e);return new ne(p(c({},this._def),{shape:i(()=>n,"shape")}))}getReferences(){let e=this._def.shape(),r=[];for(let n in e)r.push(...e[n].getReferences());return he(r)}clone(){let e={},r=this._def.shape();for(let[n,s]of Object.entries(r))e[n]=s.clone();return new ne(p(c({},this._def),{shape:i(()=>e,"shape")}))}_parse(e){if(this._getType(e)!==v.object){let g=this._getOrReturnCtx(e);return m(g,{code:y.invalid_type,expected:v.object,received:g.parsedType}),P}let{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),l=[];if(this._def.unknownKeys!=="strip")for(let g in s.data)o.includes(g)||l.push(g);let d=[];for(let g of o){let h=a[g],x=s.data[g];d.push({key:{status:"valid",value:g},value:h._parse(new ie(s,x,s.path,g)),alwaysSet:g in s.data})}let f=this._def.unknownKeys;if(f==="passthrough")for(let g of l)d.push({key:{status:"valid",value:g},value:{status:"valid",value:s.data[g]}});else if(f==="strict")l.length>0&&(m(s,{code:y.unrecognized_keys,keys:l}),n.dirty());else if(f!=="strip")for(let g of l){let h=s.data[g];d.push({key:{status:"valid",value:g},value:f._parse(new ie(s,h,s.path,g)),alwaysSet:g in s.data})}return s.common.async?Promise.resolve().then(async()=>{let g=[];for(let h of d){let x=await h.key;g.push({key:x,value:await h.value,alwaysSet:h.alwaysSet})}return g}).then(g=>te.mergeObjectSync(n,g)):te.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new ne(c(p(c({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:i((r,n)=>{var s,a,o,l;let d=(o=(a=(s=this._def).errorMap)==null?void 0:a.call(s,r,n).message)!=null?o:n.defaultError;return r.code==="unrecognized_keys"?{message:(l=w.errToObj(e).message)!=null?l:d}:{message:d}},"errorMap")}:{}))}strip(){return new ne(p(c({},this._def),{unknownKeys:"strip"}))}passthrough(){return new ne(p(c({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(this._def.unknownKeys instanceof E)return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return lt.create();if(this._def.unknownKeys==="strict")return pt.create()}extend(e){return new ne(p(c({},this._def),{shape:i(()=>c(c({},this._def.shape()),e),"shape")}))}merge(e){return new ne({unknownKeys:e._def.unknownKeys,shape:i(()=>c(c({},this._def.shape()),e._def.shape()),"shape"),typeName:"ZodObject"})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new ne(p(c({},this._def),{unknownKeys:e}))}pick(e){let r={};return Z.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new ne(p(c({},this._def),{shape:i(()=>r,"shape")}))}omit(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new ne(p(c({},this._def),{shape:i(()=>r,"shape")}))}deepPartial(){return Ae(this)}partial(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s?.optional()}),new ne(p(c({},this._def),{shape:i(()=>r,"shape")}))}required(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof fe;)a=a._def.innerType;r[n]=a}}),new ne(p(c({},this._def),{shape:i(()=>r,"shape")}))}keyof(){return Ft(Z.objectKeys(this.shape))}isEqual(e){if(!(e instanceof ne)||!this._unknownKeysEqual(e))return!1;let r=this._def.shape(),n=e._def.shape(),s=i((l,d)=>l[0]===d[0]&&l[1].isEqual(d[1]),"compare"),a=new K(Object.entries(r),{compare:s}),o=new K(Object.entries(n),{compare:s});return a.isEqual(o)}_unknownKeysEqual(e){let r=this.additionalProperties(),n=e.additionalProperties();return r===void 0||n===void 0?r===n:r.isEqual(n)}};i(Te,"ZodObject");Te.create=i((t,e)=>new Te(c({shape:i(()=>t,"shape"),unknownKeys:"strip",typeName:"ZodObject"},k(e))),"create");Te.strictCreate=i((t,e)=>new Te(c({shape:i(()=>t,"shape"),unknownKeys:"strict",typeName:"ZodObject"},k(e))),"strictCreate");Te.lazycreate=i((t,e)=>new Te(c({shape:t,unknownKeys:"strip",typeName:"ZodObject"},k(e))),"lazycreate");var De=Te,Cr=class or extends E{dereference(e){return new or(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new or(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===v.undefined?J(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof or?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return this._def.innerType.mandatory()}};i(Cr,"ZodOptional");Cr.create=i((t,e)=>new Cr(c({innerType:t,typeName:"ZodOptional"},k(e))),"create");var fe=Cr,Xl=class St extends E{dereference(e){return new St(p(c({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return he([...this._def.in.getReferences(),...this._def.out.getReferences()])}clone(){return new St(p(c({},this._def),{in:this._def.in.clone(),out:this._def.out.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return i(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?P:a.status==="dirty"?(r.dirty(),Re(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})},"handleAsync")();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?P:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new St({in:e,out:r,typeName:"ZodPipeline"})}isEqual(e){return!(!(e instanceof St)||!this._def.in.isEqual(e._def.in)||!this._def.out.isEqual(e._def.out))}};i(Xl,"ZodPipeline");var gn=Xl,Ar=class lr extends E{unwrap(){return this._def.type}dereference(e){return new lr(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new lr(p(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==v.promise&&r.common.async===!1)return m(r,{code:y.invalid_type,expected:v.promise,received:r.parsedType}),P;let n=r.parsedType===v.promise?r.data:Promise.resolve(r.data);return J(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}isEqual(e){return e instanceof lr?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}};i(Ar,"ZodPromise");Ar.create=i((t,e)=>new Ar(c({type:t,typeName:"ZodPromise"},k(e))),"create");var zt=Ar,Rr=class Et extends E{dereference(e){return new Et(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Et(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){let r=this._def.innerType._parse(e);return ot(r)&&(r.value=Object.freeze(r.value)),r}unwrap(){return this._def.innerType}isEqual(e){return e instanceof Et?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new Et(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};i(Rr,"ZodReadonly");Rr.create=i((t,e)=>new Rr(c({innerType:t,typeName:"ZodReadonly"},k(e))),"create");var Lt=Rr,Yl=class Qe extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new Qe(p(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return he([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new Qe(p(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.object)return m(n,{code:y.invalid_type,expected:v.object,received:n.parsedType}),P;let s=[],a=this._def.keyType,o=this._def.valueType;for(let l in n.data)s.push({key:a._parse(new ie(n,l,n.path,l)),value:o._parse(new ie(n,n.data[l],n.path,l))});return n.common.async?te.mergeObjectAsync(r,s):te.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof E?new Qe(c({keyType:e,valueType:r,typeName:"ZodRecord"},k(n))):new Qe(c({keyType:X.create(),valueType:e,typeName:"ZodRecord"},k(r)))}isEqual(e){return!(!(e instanceof Qe)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};i(Yl,"ZodRecord");var ms=Yl,Hr=class Ql extends E{dereference(e){let r=e[this._def.uri];return r||this}getReferences(){return[this._def.uri]}_parse(e){let r=this._getOrReturnCtx(e);return m(r,{code:y.unresolved_reference}),P}isOptional(){return!1}isNullable(){return!1}isEqual(e){return e instanceof Ql?this._def.uri===e._def.uri:!1}};i(Hr,"ZodRef");Hr.create=i(t=>new Hr({typeName:"ZodRef",uri:t}),"create");var vs=Hr,Mr=class et extends E{dereference(e){return new et(p(c({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new et(p(c({},this._def),{valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.set)return m(n,{code:y.invalid_type,expected:v.set,received:n.parsedType}),P;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(m(n,{code:y.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(m(n,{code:y.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let a=this._def.valueType;function o(d){let f=new Set;for(let g of d){if(g.status==="aborted")return P;g.status==="dirty"&&r.dirty(),f.add(g.value)}return{status:r.value,value:f}}i(o,"finalizeSet");let l=[...n.data.values()].map((d,f)=>a._parse(new ie(n,d,n.path,f)));return n.common.async?Promise.all(l).then(d=>o(d)):o(l)}min(e,r){return new et(p(c({},this._def),{minSize:{value:e,message:w.toString(r)}}))}max(e,r){return new et(p(c({},this._def),{maxSize:{value:e,message:w.toString(r)}}))}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}isEqual(e){var r,n,s,a;if(!(e instanceof et))return!1;let o=(r=this._def.minSize)==null?void 0:r.value,l=(n=e._def.minSize)==null?void 0:n.value;if(o!==l)return!1;let d=(s=this._def.maxSize)==null?void 0:s.value,f=(a=e._def.maxSize)==null?void 0:a.value;return d!==f?!1:this._def.valueType.isEqual(e._def.valueType)}};i(Mr,"ZodSet");Mr.create=i((t,e)=>new Mr(c({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},k(e))),"create");var _s=Mr,Ts=/^c[^\s-]{8,}$/i,bs=/^[a-z][a-z0-9]*$/,ws=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ps=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,xs=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ec="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",tc=i(t=>t===ec,"isEmojiRegex"),An,ks=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Ss=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;function rc(t,e){return!!((e==="v4"||!e)&&ks.test(t)||(e==="v6"||!e)&&Ss.test(t))}i(rc,"isValidIP");var Dr=class tt extends E{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==v.string){let a=this._getOrReturnCtx(e);return m(a,{code:y.invalid_type,expected:v.string,received:a.parsedType}),P}let n=new te,s;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:y.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:y.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let o=e.data.length>a.value,l=e.data.length<a.value;(o||l)&&(s=this._getOrReturnCtx(e,s),o?m(s,{code:y.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):l&&m(s,{code:y.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")xs.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"email",code:y.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")An||(An=new RegExp(ec,"u")),An.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"emoji",code:y.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Ps.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"uuid",code:y.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")Ts.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid",code:y.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")bs.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid2",code:y.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")ws.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ulid",code:y.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),m(s,{validation:"url",code:y.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"regex",code:y.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),m(s,{code:y.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:y.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:y.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Ol(a).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:y.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="ip"?rc(e.data,a.version)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ip",code:y.invalid_string,message:a.message}),n.dirty()):Z.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),c({validation:r,code:y.invalid_string},w.errToObj(n)))}_addCheck(e){return new tt(p(c({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(c({kind:"email"},w.errToObj(e)))}url(e){return this._addCheck(c({kind:"url"},w.errToObj(e)))}emoji(e){return this._addCheck(c({kind:"emoji"},w.errToObj(e)))}uuid(e){return this._addCheck(c({kind:"uuid"},w.errToObj(e)))}cuid(e){return this._addCheck(c({kind:"cuid"},w.errToObj(e)))}cuid2(e){return this._addCheck(c({kind:"cuid2"},w.errToObj(e)))}ulid(e){return this._addCheck(c({kind:"ulid"},w.errToObj(e)))}ip(e){return this._addCheck(c({kind:"ip"},w.errToObj(e)))}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck(c({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(r=e?.offset)!=null?r:!1},w.errToObj(e?.message)))}regex(e,r){return this._addCheck(c({kind:"regex",regex:e},w.errToObj(r)))}includes(e,r){return this._addCheck(c({kind:"includes",value:e,position:r?.position},w.errToObj(r?.message)))}startsWith(e,r){return this._addCheck(c({kind:"startsWith",value:e},w.errToObj(r)))}endsWith(e,r){return this._addCheck(c({kind:"endsWith",value:e},w.errToObj(r)))}min(e,r){return this._addCheck(c({kind:"min",value:e},w.errToObj(r)))}max(e,r){return this._addCheck(c({kind:"max",value:e},w.errToObj(r)))}length(e,r){return this._addCheck(c({kind:"length",value:e},w.errToObj(r)))}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new tt(p(c({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}secret(){return this._def[b]=p(c({},this._def[b]),{secret:!0}),this}toLowerCase(){return new tt(p(c({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new tt(p(c({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}isEqual(e){if(!(e instanceof tt))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}};i(Dr,"ZodString");Dr.create=i(t=>{var e;return new Dr(c({checks:[],typeName:"ZodString",coerce:(e=t?.coerce)!=null?e:!1},k(t)))},"create");var X=Dr,Nr=class nc extends E{_parse(e){if(this._getType(e)!==v.symbol){let n=this._getOrReturnCtx(e);return m(n,{code:y.invalid_type,expected:v.symbol,received:n.parsedType}),P}return J(e.data)}isEqual(e){return e instanceof nc}};i(Nr,"ZodSymbol");Nr.create=i(t=>new Nr(c({typeName:"ZodSymbol"},k(t))),"create");var Es=Nr,dt=class Ot extends E{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName==="ZodEffects"?this._def.schema.sourceType():this._def.schema}dereference(e){return new Ot(p(c({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new Ot(p(c({},this._def),{schema:this._def.schema.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i(o=>{m(n,o),o.fatal?r.abort():r.dirty()},"addIssue"),get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){let o=s.transform(n.data,a);if(n.common.async)return Promise.resolve(o).then(async l=>{if(r.value==="aborted")return P;let d=await this._def.schema._parseAsync({data:l,path:n.path,parent:n});return d.status==="aborted"?P:d.status==="dirty"||r.value==="dirty"?Re(d.value):d});{if(r.value==="aborted")return P;let l=this._def.schema._parseSync({data:o,path:n.path,parent:n});return l.status==="aborted"?P:l.status==="dirty"||r.value==="dirty"?Re(l.value):l}}if(s.type==="refinement"){let o=i(l=>{let d=s.refinement(l,a);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l},"executeRefinement");if(n.common.async===!1){let l=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return l.status==="aborted"?P:(l.status==="dirty"&&r.dirty(),o(l.value),{status:r.value,value:l.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>l.status==="aborted"?P:(l.status==="dirty"&&r.dirty(),o(l.value).then(()=>({status:r.value,value:l.value}))))}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ot(o))return o;let l=s.transform(o.value,a);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:l}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>ot(o)?Promise.resolve(s.transform(o.value,a)).then(l=>({status:r.value,value:l})):o);Z.assertNever(s)}isEqual(e){return!(e instanceof Ot)||!this._def.schema.isEqual(e._def.schema)?!1:this._def.effect.type==="refinement"?e._def.effect.type!=="refinement"?!1:Z.compareFunctions(this._def.effect.refinement,e._def.effect.refinement):this._def.effect.type==="transform"?e._def.effect.type!=="transform"?!1:Z.compareFunctions(this._def.effect.transform,e._def.effect.transform):this._def.effect.type==="preprocess"?e._def.effect.type!=="preprocess"?!1:Z.compareFunctions(this._def.effect.transform,e._def.effect.transform):!1}naked(){return this._def.schema.naked()}mandatory(){return new Ot(p(c({},this._def),{schema:this._def.schema.mandatory()}))}};i(dt,"ZodEffects");dt.create=i((t,e,r)=>new dt(c({schema:t,typeName:"ZodEffects",effect:e},k(r))),"create");dt.createWithPreprocess=i((t,e,r)=>new dt(c({schema:e,effect:{type:"preprocess",transform:t},typeName:"ZodEffects"},k(r))),"createWithPreprocess");var be=dt,$r=class Zt extends E{dereference(e){let r=this._def.items.map(s=>s.dereference(e)),n=this._def.rest?this._def.rest.dereference(e):null;return new Zt(p(c({},this._def),{items:r,rest:n}))}getReferences(){return he([...this._def.items.flatMap(e=>e.getReferences()),...this._def.rest?this._def.rest.getReferences():[]])}clone(){let e=this._def.items.map(n=>n.clone()),r=this._def.rest?this._def.rest.clone():null;return new Zt(p(c({},this._def),{items:e,rest:r}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.array)return m(n,{code:y.invalid_type,expected:v.array,received:n.parsedType}),P;if(n.data.length<this._def.items.length)return m(n,{code:y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),P;!this._def.rest&&n.data.length>this._def.items.length&&(m(n,{code:y.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let a=[...n.data].map((o,l)=>{let d=this._def.items[l]||this._def.rest;return d?d._parse(new ie(n,o,n.path,l)):null}).filter(o=>!!o);return n.common.async?Promise.all(a).then(o=>te.mergeArray(r,o)):te.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new Zt(p(c({},this._def),{rest:e}))}isEqual(e){if(!(e instanceof Zt)||!this._restEquals(e))return!1;let r=i((a,o)=>a.isEqual(o),"compare"),n=new K(this._def.items,{compare:r}),s=new K(e._def.items,{compare:r});return n.isEqual(s)}_restEquals(e){return this._def.rest===null?e._def.rest===null:e._def.rest!==null&&this._def.rest.isEqual(e._def.rest)}};i($r,"ZodTuple");$r.create=i((t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new $r(c({items:t,typeName:"ZodTuple",rest:null},k(e)))},"create");var Ne=$r,jr=class sc extends E{_parse(e){if(this._getType(e)!==v.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:y.invalid_type,expected:v.undefined,received:n.parsedType}),P}return J(e.data)}isEqual(e){return e instanceof sc}mandatory(){return pt.create(c({},this._def))}};i(jr,"ZodUndefined");jr.create=i(t=>new jr(c({typeName:"ZodUndefined"},k(t))),"create");var Wt=jr,Kr=class It extends E{dereference(e){let r=this._def.options.map(n=>n.dereference(e));return new It(p(c({},this._def),{options:r}))}getReferences(){return he(this._def.options.reduce((e,r)=>[...e,...r.getReferences()],[]))}clone(){let e=this._def.options.map(r=>r.clone());return new It(p(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(a){for(let l of a)if(l.result.status==="valid")return l.result;for(let l of a)if(l.result.status==="dirty")return r.common.issues.push(...l.ctx.common.issues),l.result;let o=a.map(l=>new le(l.ctx.common.issues));return m(r,{code:y.invalid_union,unionErrors:o}),P}if(i(s,"handleResults"),r.common.async)return Promise.all(n.map(async a=>{let o=p(c({},r),{common:p(c({},r.common),{issues:[]}),parent:null});return{result:await a._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let a,o=[];for(let d of n){let f=p(c({},r),{common:p(c({},r.common),{issues:[]}),parent:null}),g=d._parseSync({data:r.data,path:r.path,parent:f});if(g.status==="valid")return g;g.status==="dirty"&&!a&&(a={result:g,ctx:f}),f.common.issues.length&&o.push(f.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let l=o.map(d=>new le(d));return m(r,{code:y.invalid_union,unionErrors:l}),P}}get options(){return this._def.options}isEqual(e){if(!(e instanceof It))return!1;let r=i((a,o)=>a.isEqual(o),"compare"),n=new K([...this._def.options],{compare:r}),s=new K([...e._def.options],{compare:r});return n.isEqual(s)}mandatory(){let e=this._def.options.filter(a=>!(a instanceof Wt)).map(a=>a.mandatory()),[r,n,...s]=e;return r?n?new It(p(c({},this._def),{options:[r,n,...s]})):r:pt.create(c({},this._def))}};i(Kr,"ZodUnion");Kr.create=i((t,e)=>new Kr(c({options:t,typeName:"ZodUnion"},k(e))),"create");var yn=Kr,Ur=class ac extends E{constructor(){super(...arguments),this._unknown=!0}_parse(e){return J(e.data)}isEqual(e){return e instanceof ac}};i(Ur,"ZodUnknown");Ur.create=i(t=>new Ur(c({typeName:"ZodUnknown"},k(t))),"create");var st=Ur,Fr=class ic extends E{_parse(e){if(this._getType(e)!==v.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:y.invalid_type,expected:v.void,received:n.parsedType}),P}return J(e.data)}isEqual(e){return e instanceof ic}};i(Fr,"ZodVoid");Fr.create=i(t=>new Fr(c({typeName:"ZodVoid"},k(t))),"create");var Os=Fr,sh=["gpt-3.5-turbo","gpt-3.5-turbo-16k","gpt-4","gpt-4-1106-preview","gpt-4-vision-preview","gpt-4-0125-preview","gpt-4-turbo-preview","gpt-4-turbo","gpt-4o","gpt-3.5-turbo-0125","gpt-3.5-turbo-1106"],mv=We.create(["any","string","number","boolean","object","pattern","date","array","target","time","enum"]),oc=i(t=>X.create().displayAs({id:"variable",params:c({type:t?.type||"any"},t?.params)}),"variable"),lc=i(t=>X.create().displayAs({id:"conversation",params:c({},t?.params)}),"conversation"),cc=i(t=>X.create().displayAs({id:"user",params:c({},t?.params)}),"user"),dc=i(t=>X.create().displayAs({id:"message",params:c({},t?.params)}),"message"),uc=i(t=>X.create().displayAs({id:"agent",params:c({},t?.params)}),"agent"),pc=i(t=>X.create().displayAs({id:"event",params:c({},t?.params)}),"event"),fc=i(t=>X.create().displayAs({id:"table",params:c({},t?.params)}),"table"),gc=i(t=>X.create().displayAs({id:"tablerow",params:c({},t?.params)}),"tablerow"),yc=i(t=>X.create().displayAs({id:"intent",params:c({},t?.params)}),"intent"),hc=i(()=>We.create(sh).displayAs({id:"dropdown",params:{}}),"aimodel"),mc=i(t=>X.create().displayAs({id:"datasource",params:c({},t)}),"datasource"),vc=i(t=>X.create().displayAs({id:"knowledgebase",params:c({},t)}),"knowledgebase"),_c={object:De.lazycreate},Tc=i((t,e={message:`Input not instance of ${t.name}`})=>us(r=>r instanceof t,e),"instanceOfType"),Zs=X.create,Is=fn.create,bc=hs.create,wc=rn.create,Bs=nn.create,Pc=on.create,xc=Es.create,kc=Wt.create,Sc=pn.create,Ec=lt.create,Oc=st.create,Zc=pt.create,Ic=Os.create,Bc=ct.create,Cc=De.create,Ac=De.strictCreate,Rc=yn.create,Hc=ps.create,Mc=ln.create,Dc=Ne.create,Nc=ms.create,$c=vs.create,jc=Lt.create,Kc=ys.create,Uc=_s.create,Fc=gs.create,zc=cn.create,Lc=dn.create,Wc=We.create,qc=un.create,Vc=zt.create,zn=be.create,Gc=fe.create,Jc=Me.create,ah=Ut.create,Xc=be.createWithPreprocess,Yc=gn.create,Qc=i(()=>Zs().optional(),"ostring"),ed=i(()=>Is().optional(),"onumber"),td=i(()=>Bs().optional(),"oboolean"),rd={string:i(t=>X.create(p(c({},t),{coerce:!0})),"string"),number:i(t=>fn.create(p(c({},t),{coerce:!0})),"number"),boolean:i(t=>nn.create(p(c({},t),{coerce:!0})),"boolean"),bigint:i(t=>rn.create(p(c({},t),{coerce:!0})),"bigint"),date:i(t=>on.create(p(c({},t),{coerce:!0})),"date")},nd=P,u=_,sd=i((t,e)=>t.anyOf.length?t.anyOf.length===1?L(t.anyOf[0],p(c({},e),{path:[...e.path,"anyOf",0]})):`z.union([${t.anyOf.map((r,n)=>L(r,p(c({},e),{path:[...e.path,"anyOf",n]}))).join(", ")}])`:"z.any()","parseAnyOf"),ih=i(t=>{var e;return(e=t[b])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),oh=i(t=>"z.any()","parseDefault"),lh=i((t,e)=>`z.union([${t.type.map(r=>L(p(c({},t),{type:r}),e)).join(", ")}])`,"parseMultipleType"),ch=i((t,e)=>`z.any().refine((value) => !${L(t.not,p(c({},e),{path:[...e.path,"not"]}))}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`,"parseNot"),dh=i(t=>"z.null()","parseNull"),uh=i(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),ph=i((t,...e)=>Object.keys(t).reduce((r,n)=>(e.includes(n)||(r[n]=t[n]),r),{}),"omit");function G(t,e,r){var n;let s=t[e],a="";if(s!==void 0){let o=r({value:s,json:JSON.stringify(s)});if(o){let l=o[0],d=o.length===3?o[1]:"",f=o.length===3?o[2]:o[1];a+=l,((n=t.errorMessage)==null?void 0:n[e])!==void 0&&(a+=d+JSON.stringify(t.errorMessage[e])),a+=f}}return a}i(G,"withMessage");var Bt=Symbol("Original index"),fh=i(t=>{let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(typeof n=="boolean")e.push(n?{[Bt]:r}:{[Bt]:r,not:{}});else{if(Bt in n)return t;e.push(p(c({},n),{[Bt]:r}))}}return e},"ensureOriginalIndex");function jt(t,e){if(t.allOf.length===0)return"z.never()";if(t.allOf.length===1){let r=t.allOf[0];return L(r,p(c({},e),{path:[...e.path,"allOf",r[Bt]]}))}else{let[r,n]=uh(fh(t.allOf));return`z.intersection(${jt({allOf:r},e)}, ${jt({allOf:n},e)})`}}i(jt,"parseAllOf");var gh=i((t,e)=>{if(Array.isArray(t.items))return`z.tuple([${t.items.map((n,s)=>L(n,p(c({},e),{path:[...e.path,"items",s]})))}])`;let r=t.items?`z.array(${L(t.items,p(c({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return r+=G(t,"minItems",({json:n})=>[`.min(${n}`,", ",")"]),r+=G(t,"maxItems",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseArray"),yh=i(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),hh=i(t=>t.enum.length===0?"z.never()":t.enum.length===1?`z.literal(${JSON.stringify(t.enum[0])})`:t.enum.every(e=>typeof e=="string")?`z.enum([${t.enum.map(e=>JSON.stringify(e))}])`:`z.union([${t.enum.map(e=>`z.literal(${JSON.stringify(e)})`).join(", ")}])`,"parseEnum"),mh=i((t,e)=>{let r=L(t.if,p(c({},e),{path:[...e.path,"if"]})),n=L(t.then,p(c({},e),{path:[...e.path,"then"]})),s=L(t.else,p(c({},e),{path:[...e.path,"else"]}));return`z.union([${n}, ${s}]).superRefine((value,ctx) => {
12
12
  const result = ${r}.safeParse(value).success
13
13
  ? ${n}.safeParse(value)
14
14
  : ${s}.safeParse(value);
15
15
  if (!result.success) {
16
16
  result.error.errors.forEach((error) => ctx.addIssue(error))
17
17
  }
18
- })`},"parseIfThenElse"),hh=i(t=>{var e;let r="z.number()";return(e=t[b])!=null&&e.coerce&&(r="z.coerce.number()"),t.type==="integer"?r+=G(t,"type",()=>[".int(",")"]):r+=G(t,"format",({value:n})=>{if(n==="int64")return[".int(",")"]}),r+=G(t,"multipleOf",({value:n,json:s})=>n===1?r.startsWith("z.number().int(")?void 0:[".int(",")"]:[`.multipleOf(${s}`,", ",")"]),typeof t.minimum=="number"?t.exclusiveMinimum===!0?r+=G(t,"minimum",({json:n})=>[`.gt(${n}`,", ",")"]):r+=G(t,"minimum",({json:n})=>[`.gte(${n}`,", ",")"]):typeof t.exclusiveMinimum=="number"&&(r+=G(t,"exclusiveMinimum",({json:n})=>[`.gt(${n}`,", ",")"])),typeof t.maximum=="number"?t.exclusiveMaximum===!0?r+=G(t,"maximum",({json:n})=>[`.lt(${n}`,", ",")"]):r+=G(t,"maximum",({json:n})=>[`.lte(${n}`,", ",")"]):typeof t.exclusiveMaximum=="number"&&(r+=G(t,"exclusiveMaximum",({json:n})=>[`.lt(${n}`,", ",")"])),r},"parseNumber"),Is=i((t,e)=>t.oneOf.length?t.oneOf.length===1?L(t.oneOf[0],p(c({},e),{path:[...e.path,"oneOf",0]})):`z.any().superRefine((x, ctx) => {
18
+ })`},"parseIfThenElse"),vh=i(t=>{var e;let r="z.number()";return(e=t[b])!=null&&e.coerce&&(r="z.coerce.number()"),t.type==="integer"?r+=G(t,"type",()=>[".int(",")"]):r+=G(t,"format",({value:n})=>{if(n==="int64")return[".int(",")"]}),r+=G(t,"multipleOf",({value:n,json:s})=>n===1?r.startsWith("z.number().int(")?void 0:[".int(",")"]:[`.multipleOf(${s}`,", ",")"]),typeof t.minimum=="number"?t.exclusiveMinimum===!0?r+=G(t,"minimum",({json:n})=>[`.gt(${n}`,", ",")"]):r+=G(t,"minimum",({json:n})=>[`.gte(${n}`,", ",")"]):typeof t.exclusiveMinimum=="number"&&(r+=G(t,"exclusiveMinimum",({json:n})=>[`.gt(${n}`,", ",")"])),typeof t.maximum=="number"?t.exclusiveMaximum===!0?r+=G(t,"maximum",({json:n})=>[`.lt(${n}`,", ",")"]):r+=G(t,"maximum",({json:n})=>[`.lte(${n}`,", ",")"]):typeof t.exclusiveMaximum=="number"&&(r+=G(t,"exclusiveMaximum",({json:n})=>[`.lt(${n}`,", ",")"])),r},"parseNumber"),Cs=i((t,e)=>t.oneOf.length?t.oneOf.length===1?L(t.oneOf[0],p(c({},e),{path:[...e.path,"oneOf",0]})):`z.any().superRefine((x, ctx) => {
19
19
  const schemas = [${t.oneOf.map((r,n)=>L(r,p(c({},e),{path:[...e.path,"oneOf",n]}))).join(", ")}];
20
20
  const errors = schemas.reduce(
21
21
  (errors: z.ZodError[], schema) =>
@@ -32,7 +32,7 @@ ${Q}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(T).join("
32
32
  message: "Invalid input: Should pass single schema",
33
33
  });
34
34
  }
35
- })`:"z.any()","parseOneOf");function nd(t,e){let r;t.properties&&(Object.keys(t.properties).length?(r="z.object({ ",r+=Object.keys(t.properties).map(o=>{let l=t.properties[o],d=`${JSON.stringify(o)}: ${L(l,p(c({},e),{path:[...e.path,"properties",o]}))}`,f=typeof l=="object"&&l.default!==void 0||typeof t.default=="object"&&t.default!==null&&o in t.default,g=Array.isArray(t.required)?t.required.includes(o):typeof l=="object"&&l.required===!0;return!f&&!g?`${d}.optional()`:d}).join(", "),r+=" })"):r="z.object({})");let n=t.additionalProperties!==void 0?L(t.additionalProperties,p(c({},e),{path:[...e.path,"additionalProperties"]})):void 0,s;if(t.patternProperties){let o=Object.fromEntries(Object.entries(t.patternProperties).map(([l,d])=>[l,L(d,p(c({},e),{path:[...e.path,"patternProperties",l]}))],{}));s="",r?n?s+=`.catchall(z.union([${[...Object.values(o),n].join(", ")}]))`:Object.keys(o).length>1?s+=`.catchall(z.union([${Object.values(o).join(", ")}]))`:s+=`.catchall(${Object.values(o)})`:n?s+=`z.record(z.union([${[...Object.values(o),n].join(", ")}]))`:Object.keys(o).length>1?s+=`z.record(z.union([${Object.values(o).join(", ")}]))`:s+=`z.record(${Object.values(o)})`,s+=`.superRefine((value, ctx) => {
35
+ })`:"z.any()","parseOneOf");function ad(t,e){let r;t.properties&&(Object.keys(t.properties).length?(r="z.object({ ",r+=Object.keys(t.properties).map(o=>{let l=t.properties[o],d=`${JSON.stringify(o)}: ${L(l,p(c({},e),{path:[...e.path,"properties",o]}))}`,f=typeof l=="object"&&l.default!==void 0||typeof t.default=="object"&&t.default!==null&&o in t.default,g=Array.isArray(t.required)?t.required.includes(o):typeof l=="object"&&l.required===!0;return!f&&!g?`${d}.optional()`:d}).join(", "),r+=" })"):r="z.object({})");let n=t.additionalProperties!==void 0?L(t.additionalProperties,p(c({},e),{path:[...e.path,"additionalProperties"]})):void 0,s;if(t.patternProperties){let o=Object.fromEntries(Object.entries(t.patternProperties).map(([l,d])=>[l,L(d,p(c({},e),{path:[...e.path,"patternProperties",l]}))],{}));s="",r?n?s+=`.catchall(z.union([${[...Object.values(o),n].join(", ")}]))`:Object.keys(o).length>1?s+=`.catchall(z.union([${Object.values(o).join(", ")}]))`:s+=`.catchall(${Object.values(o)})`:n?s+=`z.record(z.union([${[...Object.values(o),n].join(", ")}]))`:Object.keys(o).length>1?s+=`z.record(z.union([${Object.values(o).join(", ")}]))`:s+=`z.record(${Object.values(o)})`,s+=`.superRefine((value, ctx) => {
36
36
  `,s+=`for (const key in value) {
37
37
  `,n&&(t.properties?s+=`let evaluated = [${Object.keys(t.properties).map(l=>JSON.stringify(l)).join(", ")}].includes(key)
38
38
  `:s+=`let evaluated = false
@@ -64,7 +64,7 @@ ${Q}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(T).join("
64
64
  `,s+=`}
65
65
  `,s+=`}
66
66
  `),s+=`}
67
- `,s+="})"}let a=r?s?r+s:n?n==="z.never()"?r+".strict()":r+`.catchall(${n})`:r:s||(n?`z.record(${n})`:"z.record(z.any())");return $.an.anyOf(t)&&(a+=`.and(${rd(p(c({},t),{anyOf:t.anyOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),$.a.oneOf(t)&&(a+=`.and(${Is(p(c({},t),{oneOf:t.oneOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),$.an.allOf(t)&&(a+=`.and(${Nt(p(c({},t),{allOf:t.allOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),a}i(nd,"parseObject");var mh=i(t=>{var e;let r="z.string()";if((e=t[b])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";r="z.coerce.string()"}return r+=G(t,"format",({value:n})=>{switch(n){case"email":return[".email(",")"];case"ip":return[".ip(",")"];case"ipv4":return['.ip({ version: "v4"',", message: "," })"];case"ipv6":return['.ip({ version: "v6"',", message: "," })"];case"uri":return[".url(",")"];case"uuid":return[".uuid(",")"];case"date-time":return[".datetime(",")"]}}),r+=G(t,"pattern",({json:n})=>[`.regex(new RegExp(${n})`,", ",")"]),r+=G(t,"minLength",({json:n})=>[`.min(${n}`,", ",")"]),r+=G(t,"maxLength",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseString"),vh=i((t,e)=>`${L(dh(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),_h=i(t=>`z.ref('${t.$ref}')`,"parseRef"),Th=i((t,e)=>{var r,n;if(t.oneOf.length<=1||!((r=t.discriminator)!=null&&r.propertyName))return Is(t,e);let s=t.oneOf.map((a,o)=>L(a,p(c({},e),{path:[...e.path,"oneOf",o]})));return`z.discriminatedUnion("${(n=t.discriminator)==null?void 0:n.propertyName}", [${s.join(", ")}])`},"parseDiscriminator"),L=i((t,e={seen:new Map,path:[]},r)=>{if(typeof t!="object")return t?"z.any()":"z.never()";if(e.parserOverride){let a=e.parserOverride(t,e);if(typeof a=="string")return a}let n=e.seen.get(t);if(n){if(n.r!==void 0)return n.r;if(e.depth===void 0||n.n>=e.depth)return"z.any()";n.n+=1}else n={r:void 0,n:0},e.seen.set(t,n);let s=Ph(t,e);return r||(s=bh(t,s),e.withoutDefaults||(s=wh(t,s))),n.r=s,s},"parseSchema"),bh=i((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),wh=i((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),Ph=i((t,e)=>$.a.nullable(t)?vh(t,e):$.an.object(t)?nd(t,e):$.an.array(t)?ph(t,e):$.an.anyOf(t)?rd(t,e):$.an.allOf(t)?Nt(t,e):$.a.discriminator(t)?Th(t,e):$.a.oneOf(t)?Is(t,e):$.a.not(t)?oh(t,e):$.an.enum(t)?gh(t):$.a.const(t)?fh(t):$.a.multipleType(t)?ih(t,e):$.a.primitive(t,"string")?mh(t):$.a.primitive(t,"number")||$.a.primitive(t,"integer")?hh(t):$.a.primitive(t,"boolean")?sh(t):$.a.primitive(t,"null")?lh(t):$.a.conditional(t)?yh(t,e):$.a.ref(t)?_h(t):ah(t),"selectParser"),$={an:{object:i(t=>t.type==="object","object"),array:i(t=>t.type==="array","array"),anyOf:i(t=>t.anyOf!==void 0,"anyOf"),allOf:i(t=>t.allOf!==void 0,"allOf"),enum:i(t=>t.enum!==void 0,"enum")},a:{nullable:i(t=>t.nullable===!0,"nullable"),multipleType:i(t=>Array.isArray(t.type),"multipleType"),not:i(t=>t.not!==void 0,"not"),const:i(t=>t.const!==void 0,"const"),primitive:i((t,e)=>t.type===e,"primitive"),conditional:i(t=>Boolean("if"in t&&t.if&&"then"in t&&"else"in t&&t.then&&t.else),"conditional"),discriminator:i(t=>{var e;return t.oneOf!==void 0&&((e=t.discriminator)==null?void 0:e.propertyName)!==void 0},"discriminator"),oneOf:i(t=>t.oneOf!==void 0,"oneOf"),ref:i(t=>t.$ref!==void 0,"ref")}},xh=i(t=>{let e;try{e=new Function("z",`return ${t}`)(u)}catch(r){return{sucess:!1,error:`Failed to evaluate schema: ${(r instanceof Error?r:new Error(String(r))).message}`}}return e instanceof u.ZodType?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),kh=i(t=>L(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),Sh=i(t=>{let e=kh(t);e=e.replaceAll("errors: z.ZodError[]","errors");let r=xh(e);if(!r.sucess)throw new zr(r.error);return r.value},"jsonSchemaToZod"),Bt=i((t,e)=>{var r,n;if(e[b]&&t._def&&(t._def[b]=e[b]),((r=t._def)==null?void 0:r.typeName)==="ZodObject"&&e.type==="object"&&e.properties&&Object.entries(e.properties).forEach(([s,a])=>{let o=typeof t._def.shape=="function"?t._def.shape():t._def.shape;o[s]&&Bt(o[s],a)}),((n=t._def)==null?void 0:n.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&Bt(t._def.valueType,e.additionalProperties),e.type==="array"&&e.items){let s=e.items;if(typeof s=="object"&&!Array.isArray(s)){let a=t._def.type;a&&Bt(a,s)}else Array.isArray(s)&&s.forEach((a,o)=>{let l=t._def;l.typeName===_.ZodFirstPartyTypeKind.ZodTuple&&Bt(l.items[o],a)})}},"applyZuiPropsRecursively"),Eh=i(t=>{let e=Sh(t);return Bt(e,t),e},"fromJSONSchemaLegacy"),Oh=i(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&sd(n))&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodOptional},"isOptionalSchema"),Zh=i(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&n.type==="null")&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodNullable},"isNullableSchema"),sd=i(t=>{var e,r;return t.not===!0&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodUndefined},"isUndefinedSchema"),Bh=i(t=>{var e,r;return!t.not&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodUnknown},"isUnknownSchema"),Ih=i(({type:t,minimum:e,exclusiveMinimum:r,maximum:n,exclusiveMaximum:s,multipleOf:a,format:o})=>{let l=u.number();return t==="integer"&&(l=l.int()),o==="finite"&&(l=l.finite()),r!==void 0?l=l.gt(r):e!==void 0&&(l=l.gte(e)),s!==void 0?l=l.lt(s):n!==void 0&&(l=l.lte(n)),a!==void 0&&(l=l.multipleOf(a)),l},"numberJSONSchemaToZuiNumber"),Ch=i(({format:t,pattern:e,minLength:r,maxLength:n})=>{let s=u.string();if(r&&n&&r===n?s=s.length(r):(r&&(s=s.min(r)),n&&(s=s.max(n))),t==="cuid"||e===j.cuid)s=s.cuid();else if(t==="cuid2"||e===j.cuid2)s=s.cuid2();else if(t==="emoji"||e===j.emoji)s=s.emoji();else if(t==="ulid"||e===j.ulid)s=s.ulid();else if(t==="date-time"){let{precision:a,offset:o}=e?Wy(e):{};s=s.datetime({precision:a,offset:o})}else t==="email"||e===j.email?s=s.email():t==="ipv4"||e===j.ipv4?s=s.ip():t==="ipv6"||e===j.ipv6?s=s.ip("v6"):t==="uri"?s=s.url():t==="uuid"||e===j.uuid?s=s.uuid():e&&(s=s.regex(new RegExp(e)));return s},"stringJSONSchemaToZuiString"),vt=i((t,e)=>{let r=[];e.enum!==void 0&&r.push(...e.enum),e.const!==void 0&&r.push(e.const);let n=r.filter(o=>typeof o===t),[s]=n;if(!s){if(t==="string"&&e.type==="string")return Ch(e);if(t==="number"&&(e.type==="number"||e.type==="integer"))return Ih(e);if(t==="boolean")return u.boolean();if(t==="null")return u.null();throw new zr(`Unknown primitive type: "${t}"`)}if(n.length===1)return u.literal(s);let a=n.map(o=>u.literal(o));return u.union(a)},"toZuiPrimitive"),Ah=i((t,e)=>Rh(t)?Dh(t,e):Hh(t)?Mh(t,e):Nh(t,e),"arrayJSONSchemaToZuiArray"),Rh=i(t=>Array.isArray(t.items),"_isTuple"),Hh=i(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),Dh=i(({items:t,additionalItems:e},r)=>{let n=t.map(r),s=u.tuple(n);return e!==void 0&&(s=s.rest(r(e))),s},"_handleTuple"),Mh=i(({items:t,minItems:e,maxItems:r},n)=>{let s=u.set(n(t));return e&&(s=s.min(e)),r&&(s=s.max(r)),s},"_handleSet"),Nh=i(({minItems:t,maxItems:e,items:r},n)=>{let s=u.array(n(r));return t&&t===e?s.length(t):(t&&(s=s.min(t)),e&&(s=s.max(e)),s)},"_handleArray"),Xe=u.any();function ad(t){return z(t)}i(ad,"fromJSONSchema");function z(t){var e;if(t===void 0)return Xe;if(t===!0)return u.any();if(t===!1)return u.never();if(t.default!==void 0)return z(p(c({},t),{default:void 0})).default(t.default);if(t.readOnly)return z(p(c({},t),{readOnly:void 0})).readonly();if(t.oneOf!==void 0)throw new ve({oneOf:t.oneOf});if(t.patternProperties!==void 0)throw new ve({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new ve({propertyNames:t.propertyNames});if(t.if!==void 0)throw new ve({if:t.if});if(t.then!==void 0)throw new ve({then:t.then});if(t.else!==void 0)throw new ve({else:t.else});if(t.$ref!==void 0)return u.ref(t.$ref);if(t.not!==void 0){if(sd(t))return u.undefined();if(t.not===!0)return u.never();throw new ve({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return Xe;if(t.type.length===1)return z(p(c({},t),{type:t.type[0]}));let r=t,{type:n}=r,s=Za(r,["type"]),a=t.type.map(o=>z(p(c({},s),{type:o})));return u.union(a)}if(t.type==="string")return t.enum&&t.enum.length>0?u.enum(t.enum):vt("string",t);if(t.type==="integer"){let r=vt("number",t);return r instanceof u.ZodNumber?r.int():r}if(t.type==="number")return vt("number",t);if(t.type==="boolean")return vt("boolean",t);if(t.type==="null")return vt("null",t);if(t.type==="array")return Ah(t,z);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let r=z(t.additionalProperties);return z(p(c({},t),{additionalProperties:void 0})).catchall(r)}if(t.properties!==void 0){let r={};for(let[n,s]of Object.entries(t.properties)){let a=z(s),o=(e=t.required)!=null?e:[];r[n]=o.includes(n)?a:a.optional()}return u.object(r)}if(t.additionalProperties!==void 0){let r=z(t.additionalProperties);return u.record(r)}return u.record(Xe)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return Xe;if(t.anyOf.length===1)return z(t.anyOf[0]);if(Oh(t))return z(t.anyOf[0]).optional();if(Zh(t))return z(t.anyOf[0]).nullable();let r=t.anyOf.map(z);return u.union(r)}if(t.allOf!==void 0){if(t.allOf.length===0)return Xe;if(t.allOf.length===1)return z(t.allOf[0]);let[r,...n]=t.allOf,s=z(r),a=z({allOf:n});return u.intersection(s,a)}return Bh(t)?u.unknown():Xe}i(z,"_fromJSONSchema");var $h=/^\d{4}-\d{2}-\d{2}(T|\s)?((\d{2}:\d{2}:\d{2}(\.\d{1,3})?)|(\d{2}:\d{2}))?(\s?([+-]\d{2}:\d{2}|Z))?$/,zn=i((t,e,r=!0)=>{if(typeof t!="object")throw new Rn("Input must be an object");let n=i(o=>{let l=o;return e?.nullable&&(l=l.nullable()),e?.optional&&(l=l.optional()),e?.passtrough&&typeof l.passthrough=="function"&&(l=l.passthrough()),l},"applyOptions"),s=Object.entries(t).reduce((o,[l,d])=>{if(d===null)o[l]=n(_.null());else switch(typeof d){case"string":o[l]=$h.test(d)?n(_.string().datetime()):n(_.string());break;case"number":o[l]=n(_.number());break;case"boolean":o[l]=n(_.boolean());break;case"object":Array.isArray(d)?d.length===0?o[l]=n(_.array(_.unknown())):typeof d[0]=="object"?o[l]=n(_.array(zn(d[0],e,!1))):["string","number","boolean"].includes(typeof d[0])&&(o[l]=n(_.array(_[typeof d[0]]()))):o[l]=n(zn(d,e,!1));break;default:throw new Rn(`Unsupported type for key ${l}`)}return o},{}),a=Object.keys(s).length>0;return e?.passtrough||!r&&!a?_.object(s).passthrough():_.object(s)},"fromObject");function id(){return{}}i(id,"parseAnyDef");function od(t,e){var r,n;let s={type:"array"};return((n=(r=t.type)==null?void 0:r._def)==null?void 0:n.typeName)!=="ZodAny"&&(s.items=C(t.type._def,p(c({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&H(s,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&H(s,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(H(s,"minItems",t.exactLength.value,t.exactLength.message,e),H(s,"maxItems",t.exactLength.value,t.exactLength.message,e)),s}i(od,"parseArrayDef");function ld(t,e){let r=c({type:"integer",format:"int64"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?H(r,"minimum",n.value,n.message,e):H(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),H(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?H(r,"maximum",n.value,n.message,e):H(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),H(r,"maximum",n.value,n.message,e));break;case"multipleOf":H(r,"multipleOf",n.value,n.message,e);break}return r}i(ld,"parseBigintDef");function cd(t){return c({type:"boolean"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{})}i(cd,"parseBooleanDef");function dd(t,e){return C(t.type._def,e)}i(dd,"parseBrandedDef");var jh=i((t,e)=>C(t.innerType._def,e),"parseCatchDef");function ud(t,e){return e.dateStrategy=="integer"?Kh(t,e):c({type:"string",format:"date-time"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{})}i(ud,"parseDateDef");var Kh=i((t,e)=>{let r=c({type:"integer",format:"unix-time"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"&&H(r,"minimum",n.value,n.message,e);break;case"max":e.target==="jsonSchema7"&&H(r,"maximum",n.value,n.message,e);break}return r},"integerDateParser");function pd(t,e){return p(c({},C(t.innerType._def,e)),{default:t.defaultValue()})}i(pd,"parseDefaultDef");function fd(t,e){return e.effectStrategy==="input"?C(t.schema._def,e):{}}i(fd,"parseEffectsDef");function gd(t){return{type:"string",enum:t.values}}i(gd,"parseEnumDef");var Uh=i(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function yd(t,e){let r=[C(t.left._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),C(t.right._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(a=>!!a),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return r.forEach(a=>{if(Uh(a))s.push(...a.allOf),a.unevaluatedProperties===void 0&&(n=void 0);else{let o=a;if("additionalProperties"in a&&a.additionalProperties===!1){let l=a,{additionalProperties:d}=l;o=Za(l,["additionalProperties"])}else n=void 0;s.push(o)}}),s.length?c({allOf:s},n):void 0}i(yd,"parseIntersectionDef");function hd(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}i(hd,"parseLiteralDef");function Cs(t,e){var r,n,s,a,o;if(e.target==="openApi3"&&((r=t.keyType)==null?void 0:r._def.typeName)==="ZodEnum")return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((d,f)=>{var g;return p(c({},d),{[f]:(g=C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"properties",f]})))!=null?g:{}})},{}),additionalProperties:!1};let l={type:"object",additionalProperties:(n=C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:{}};if(e.target==="openApi3")return l;if(((s=t.keyType)==null?void 0:s._def.typeName)==="ZodString"&&((a=t.keyType._def.checks)!=null&&a.length)){let d=Object.entries(is(t.keyType._def,e)).reduce((f,[g,h])=>g==="type"?f:p(c({},f),{[g]:h}),{});return p(c({},l),{propertyNames:d})}else if(((o=t.keyType)==null?void 0:o._def.typeName)==="ZodEnum")return p(c({},l),{propertyNames:{enum:t.keyType._def.values}});return l}i(Cs,"parseRecordDef");function md(t,e){if(e.mapStrategy==="record")return Cs(t,e);let r=C(t.keyType._def,p(c({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},n=C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}i(md,"parseMapDef");function vd(t){let e=t.values,n=Object.keys(t.values).filter(a=>typeof e[e[a]]!="number").map(a=>e[a]),s=Array.from(new Set(n.map(a=>typeof a)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n.filter(a=>typeof a=="string"||typeof a=="number")}}i(vd,"parseNativeEnumDef");function _d(){return{not:{}}}i(_d,"parseNeverDef");function Td(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}i(Td,"parseNullDef");var Ur={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function bd(t,e){if(e.target==="openApi3")return ka(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in Ur&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,a)=>{let o=Ur[a._def.typeName];return o&&!s.includes(o)?[...s,o]:s},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((s,a)=>{let o=typeof a._def.value;switch(o){case"string":case"number":case"boolean":return[...s,o];case"bigint":return[...s,"integer"];case"object":if(a._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===r.length){let s=n.filter((a,o,l)=>l.indexOf(a)===o);return{type:s.length>1?s:s[0],enum:r.reduce((a,o)=>a.includes(o._def.value)?a:[...a,o._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,s)=>[...n,...s._def.values.filter(a=>!n.includes(a))],[])};return ka(t,e)}i(bd,"parseUnionDef");var ka=i((t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((s,a)=>C(s._def,p(c({},e),{currentPath:[...e.currentPath,e.unionStrategy,`${a}`]}))).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0)),n=e.discriminator&&t.typeName==="ZodDiscriminatedUnion"&&typeof t.discriminator=="string"?{discriminator:{propertyName:t.discriminator}}:{};if(r.length)return e.unionStrategy==="anyOf"?c({anyOf:r},n):c({oneOf:r},n)},"asUnionOf");function wd(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length)){let n=t.innerType;if(e.target==="openApi3"){let a={type:Ur[n._def.typeName],nullable:!0};return Ln(n._def,e,a)}let s={type:[Ur[n._def.typeName],"null"]};return Ln(n._def,e,s)}if(e.target==="openApi3"){let n=C(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath]}));return n&&p(c({},n),{nullable:!0})}let r=C(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return r&&{anyOf:[r,{type:"null"}]}}i(wd,"parseNullableDef");function Pd(t,e){let r=c({type:"number"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",as(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?H(r,"minimum",n.value,n.message,e):H(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),H(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?H(r,"maximum",n.value,n.message,e):H(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),H(r,"maximum",n.value,n.message,e));break;case"multipleOf":H(r,"multipleOf",n.value,n.message,e);break}return r}i(Pd,"parseNumberDef");var Fh=i((t,e)=>{var r;return t.unknownKeys instanceof E?(r=C(t.unknownKeys._def,p(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function xd(t,e){let r=p(c({type:"object"},Object.entries(t.shape()).reduce((n,[s,a])=>{if(a===void 0||a._def===void 0)return n;let o=C(a._def,p(c({},e),{currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]}));return o===void 0?n:{properties:p(c({},n.properties),{[s]:o}),required:a.isOptional()?n.required:[...n.required,s]}},{properties:{},required:[]})),{additionalProperties:Fh(t,e)});return r.required.length||delete r.required,r}i(xd,"parseObjectDef");var zh=i((t,e)=>{var r;if(e.currentPath.toString()===((r=e.propertyPath)==null?void 0:r.toString()))return C(t.innerType._def,e);let n=C(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return n?{anyOf:[{not:{}},n]}:{}},"parseOptionalDef"),Lh=i((t,e)=>{if(e.pipeStrategy==="input")return C(t.in._def,e);if(e.pipeStrategy==="output")return C(t.out._def,e);let r=C(t.in._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),n=C(t.out._def,p(c({},e),{currentPath:[...e.currentPath,"allOf",r?"1":"0"]}));return{allOf:[r,n].filter(s=>s!==void 0)}},"parsePipelineDef");function kd(t,e){return C(t.type._def,e)}i(kd,"parsePromiseDef");function Sd(t,e){let n={type:"array",uniqueItems:!0,items:C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&H(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&H(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}i(Sd,"parseSetDef");function Ed(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>C(r._def,p(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:C(t.rest._def,p(c({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>C(r._def,p(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[])}}i(Ed,"parseTupleDef");function Od(){return{not:{}}}i(Od,"parseUndefinedDef");function Zd(){return{}}i(Zd,"parseUnknownDef");var Wh=i((t,e)=>C(t.innerType._def,e),"parseReadonlyDef");function Bd(t){return{$ref:t.uri}}i(Bd,"parseRefDef");function C(t,e,r=!1){let n=e.seen.get(t);if(n&&!r){let o=qh(n,e);if(o!==void 0)return o}let s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);let a=Gh(t,t.typeName,e);return a&&Ln(t,e,a),s.jsonSchema=a,a}i(C,"parseDef");var qh=i((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Vh(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},"get$ref"),Vh=i((t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")},"getRelativePath"),Gh=i((t,e,r)=>{switch(e){case"ZodString":return is(t,r);case"ZodNumber":return Pd(t,r);case"ZodObject":return xd(t,r);case"ZodBigInt":return ld(t,r);case"ZodBoolean":return cd(t);case"ZodDate":return ud(t,r);case"ZodUndefined":return Od();case"ZodNull":return Td(r);case"ZodArray":return od(t,r);case"ZodUnion":case"ZodDiscriminatedUnion":return bd(t,r);case"ZodIntersection":return yd(t,r);case"ZodTuple":return Ed(t,r);case"ZodRecord":return Cs(t,r);case"ZodRef":return Bd(t);case"ZodLiteral":return hd(t,r);case"ZodEnum":return gd(t);case"ZodNativeEnum":return vd(t);case"ZodNullable":return wd(t,r);case"ZodOptional":return zh(t,r);case"ZodMap":return md(t,r);case"ZodSet":return Sd(t,r);case"ZodLazy":return C(t.getter()._def,r);case"ZodPromise":return kd(t,r);case"ZodNaN":case"ZodNever":return _d();case"ZodEffects":return fd(t,r);case"ZodAny":return id();case"ZodUnknown":return Zd();case"ZodDefault":return pd(t,r);case"ZodBranded":return dd(t,r);case"ZodReadonly":return Wh(t,r);case"ZodCatch":return jh(t,r);case"ZodPipeline":return Lh(t,r);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return(n=>{})(e)}},"selectParser"),Ln=i((t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),Object.assign(r,{[b]:c(c({},t[b]),r[b])}),r),"addMeta"),Sa={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"string",mapStrategy:"entries",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",emailStrategy:"format:email",discriminator:!1,unionStrategy:"anyOf"},Jh=i(t=>typeof t=="string"?p(c({},Sa),{name:t}):c(c({},Sa),t),"getDefaultOptions"),Xh=i(t=>{let e=Jh(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return p(c({},e),{currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))})},"getRefs"),Yh=i((t,e)=>{var r;let n=Xh(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((d,[f,g])=>{var h;return p(c({},d),{[f]:(h=C(g._def,p(c({},n),{currentPath:[...n.basePath,n.definitionPath,f]}),!0))!=null?h:{}})},{}):void 0,a=typeof e=="string"?e:e?.name,o=(r=C(t._def,a===void 0?n:p(c({},n),{currentPath:[...n.basePath,n.definitionPath,a]}),!1))!=null?r:{},l=a===void 0?s?p(c({},o),{[n.definitionPath]:s}):o:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,a].join("/"),[n.definitionPath]:p(c({},s),{[a]:o})};return n.target==="jsonSchema7"?l.$schema="http://json-schema.org/draft-07/schema#":n.target==="jsonSchema2019-09"&&(l.$schema="https://json-schema.org/draft/2019-09/schema#"),l},"zodToJsonSchema"),Qh=i((t,e={target:"openApi3"})=>{let r=Yh(t,e);return e.$schemaUrl===!1?delete r.$schema:typeof e.$schemaUrl=="string"&&(r.$schema=e.$schemaUrl),r},"toJSONSchemaLegacy");var pt=(t,e)=>{let r=t._def,n=e._def;if(r.typeName===_.ZodFirstPartyTypeKind.ZodObject&&n.typeName===_.ZodFirstPartyTypeKind.ZodObject){let s=r.shape(),a=n.shape();return _.object({...s,...a})}if(r.typeName===_.ZodFirstPartyTypeKind.ZodRecord&&n.typeName===_.ZodFirstPartyTypeKind.ZodRecord)return _.record(_.intersection(r.valueType,n.valueType));throw new Error("Cannot merge object schemas with record schemas")},Id=_;var re=_.string().min(1),Ad=_.object({text:re}),Rd=_.object({markdown:re}),Hd=_.object({imageUrl:re}),Dd=_.object({audioUrl:re}),Md=_.object({videoUrl:re}),Nd=_.object({fileUrl:re,title:re.optional()}),$d=_.object({latitude:_.number(),longitude:_.number(),address:_.string().optional(),title:_.string().optional()}),jd=_.object({title:re,subtitle:re.optional(),imageUrl:re.optional(),actions:_.array(_.object({action:_.enum(["postback","url","say"]),label:re,value:re}))}),Cd=_.object({text:re,options:_.array(_.object({label:re,value:re}))}),em=_.object({items:_.array(jd)}),tm=_.union([_.object({type:_.literal("text"),payload:Ad}),_.object({type:_.literal("markdown"),payload:Rd}),_.object({type:_.literal("image"),payload:Hd}),_.object({type:_.literal("audio"),payload:Dd}),_.object({type:_.literal("video"),payload:Md}),_.object({type:_.literal("file"),payload:Nd}),_.object({type:_.literal("location"),payload:$d})]),rm=_.object({items:_.array(tm)}),nm={schema:Rd},sm={text:{schema:Ad},image:{schema:Hd},audio:{schema:Dd},video:{schema:Md},file:{schema:Nd},location:{schema:$d},carousel:{schema:em},card:{schema:jd},dropdown:{schema:Cd},choice:{schema:Cd},bloc:{schema:rm}};var Lt="x-bot-id",Rs="x-bot-user-id",Hs="x-integration-id",Ds="x-webhook-id",Ms="x-bp-configuration-type",Wt="x-bp-configuration",qt="x-bp-operation",Ns="x-bp-type",am={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};var Kd=require("browser-or-node");var $s=console;function oe(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function Vt(t,e=8072,r=cm){if(!Kd.isNode)throw new Error("This function can only be called in Node.js");let s=require("http").createServer(async(a,o)=>{try{let l=await im(a);if(l.path==="/health"){o.writeHead(200).end("ok");return}let d=await t(l);o.writeHead(d?.status??200,d?.headers??{}).end(d?.body??"{}")}catch(l){$s.error("Error while handling request",{error:l?.message??"Internal error occured"}),o.writeHead(500).end(JSON.stringify({error:l?.message??"Internal error occured"}))}});return s.listen(e,()=>r(e)),s}async function im(t){let e=await lm(t),r={};for(let s=0;s<t.rawHeaders.length;s+=2){let a=t.rawHeaders[s].toLowerCase(),o=t.rawHeaders[s+1];r[a]=o}let n=new URL(t.url??"",t.headers.host?`http://${t.headers.host}`:"http://botpress.cloud");return{body:e,path:n.pathname,query:om(n.search,"?"),headers:r,method:t.method?.toUpperCase()??"GET"}}function om(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function lm(t){return new Promise((e,r)=>{if(t.method!=="POST"&&t.method!=="PUT"&&t.method!=="PATCH")return e(void 0);let n="";t.on("data",s=>n+=s.toString()),t.on("error",s=>r(s)),t.on("end",()=>e(n))})}function cm(t){$s.info(`Listening on port ${t}`)}var Sn=require("@botpress/client");var M={};ht(M,{mapKeys:()=>pm,mapValues:()=>um,mergeRecords:()=>gm,pairs:()=>gn,stripUndefinedProps:()=>fm,values:()=>dm});var gn=t=>Object.entries(t),dm=t=>Object.values(t),um=(t,e)=>Object.fromEntries(gn(t).map(([r,n])=>[r,e(n,r)])),pm=(t,e)=>Object.fromEntries(gn(t).map(([r,n])=>[e(r),n])),fm=t=>Object.fromEntries(gn(t).filter(([,e])=>e!==void 0)),gm=(t,e,r)=>{let n=[...Object.keys(t),...Object.keys(e)],s=[...new Set(n)],a={};for(let o of s){let l=t[o],d=e[o];l&&d?a[o]=r(l,d):l?a[o]=l:d&&(a[o]=d)}return a};var S={};ht(S,{safePush:()=>ym,unique:()=>hm});var ym=(t,...e)=>t?[...t,...e]:[...e],hm=t=>Array.from(new Set(t));var me={};ht(me,{setName:()=>mm});var mm=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var Ud=t=>{let{name:e,version:r}=t,n={actions:{},events:{},channels:{}},s={name:e,version:r,entities:M.mapValues(t.entities,o=>({name:o.name})),actions:{},events:{},channels:{}},a=M.mapValues(t.entities,o=>o.schema);for(let[o,l]of Object.entries(t.definition.actions??{})){let d=l.input.schema.dereference(a),f=l.output.schema.dereference(a),g=t.actions?.[o]?.name??o;n.actions[g]={...l,...t.actions?.[o]??{},input:{schema:d},output:{schema:f}},s.actions[o]={name:g}}for(let[o,l]of Object.entries(t.definition.events??{})){let d=l.schema.dereference(a),f=t.events?.[o]?.name??o;n.events[f]={...l,...t.events?.[o]??{},schema:d},s.events[o]={name:f}}for(let[o,l]of Object.entries(t.definition.channels??{})){let d={};for(let[g,h]of Object.entries(l.messages)){let x=h.schema.dereference(a);d[g]={...h,schema:x}}let f=t.channels?.[o]?.name??o;n.channels[f]={...l,...t.channels?.[o]??{},message:{...l.message??{},tags:{...l.message?.tags??{},...t.channels?.[o]?.message?.tags??{}}},conversation:{...l.conversation??{},tags:{...l.conversation?.tags??{},...t.channels?.[o]?.conversation?.tags??{}}},messages:d},s.channels[o]={name:f}}return{resolved:n,statement:s}};var yn=Symbol("schemaName"),Fd=t=>t?M.mapValues(t,(r,n)=>({...r,[yn]:n})):{},zd=t=>yn in t&&t[yn]!==void 0,Ld=t=>t[yn];var hn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.identifier=e.identifier,this.description=e.description,this.configuration=e.configuration,this.configurations=e.configurations,this.events=e.events,this.actions=e.actions,this.channels=e.channels,this.states=e.states,this.user=e.user,this.secrets=e.secrets,this.entities=e.entities,this.interfaces=e.interfaces,this.__advanced=e.__advanced,this.attributes=e.attributes}name;version;title;description;icon;readme;configuration;configurations;events;actions;channels;states;user;secrets;identifier;entities;interfaces;__advanced;attributes;extend(e,r){let{entities:n,actions:s,events:a,channels:o}=this._callBuilder(e,r),l=this;l.interfaces??={};let d=Object.values(n).map(x=>x.name),f=d.length===0?e.name:`${e.name}<${d.join(",")}>`,{resolved:g,statement:h}=Ud({...e,entities:n,actions:M.stripUndefinedProps(s),events:M.stripUndefinedProps(a),channels:M.stripUndefinedProps(o)});return l.actions=M.mergeRecords(l.actions??{},g.actions,this._mergeActions),l.channels=M.mergeRecords(l.channels??{},g.channels,this._mergeChannels),l.events=M.mergeRecords(l.events??{},g.events,this._mergeEvents),l.interfaces[f]={id:e.id,...h},this}_callBuilder(e,r){let s={entities:Fd(this.entities)},a=r(s),o=M.pairs(a.entities).find(([d,f])=>!zd(f));if(o)throw new Error(`Cannot extend interface "${e.name}" with entity "${o[0]}"; the provided schema is not part of the integration's entities.`);return{entities:M.mapValues(a.entities,d=>({name:Ld(d),schema:d.schema})),actions:a.actions??{},events:a.events??{},channels:a.channels??{}}}_mergeActions=(e,r)=>({...e,...r,input:{schema:pt(e.input.schema,r.input.schema)},output:{schema:pt(e.output.schema,r.output.schema)}});_mergeEvents=(e,r)=>({...e,...r,schema:pt(e.schema,r.schema)});_mergeChannels=(e,r)=>{let n=M.mergeRecords(e.messages,r.messages,this._mergeMessage),s;(e.conversation||r.conversation)&&(s={tags:{...e.conversation?.tags,...r.conversation?.tags}});let a;return(e.message||r.message)&&(a={tags:{...e.message?.tags,...r.message?.tags}}),{...e,...r,messages:n,conversation:s,message:a}};_mergeMessage=(e,r)=>({schema:pt(e.schema,r.schema)})};var Ve=require("@botpress/client");var Wd=zs(require("@botpress/client")),mn={retries:3,retryCondition:t=>Wd.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(vm(e.response?.headers??{})??t)*1e3},vm=t=>{let e=["RateLimit-Reset","X-RateLimit-Reset","Retry-After","ratelimit-reset","x-ratelimit-reset","retry-after"];for(let r of e){let n=t[r];if(n!==void 0)return _m(String(n))}},_m=t=>{let e=Tm(t)?bm(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},Tm=t=>t.includes(" "),bm=t=>{let e=wm(t);if(!e)return;let r=new Date;return Math.max(0,Math.floor((e.getTime()-r.getTime())/1e3))},wm=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};var ft=class{constructor(e){this._client=e}createConversation=e=>this._client.createConversation(e);getConversation=e=>this._client.getConversation(e);listConversations=e=>this._client.listConversations(e);getOrCreateConversation=e=>this._client.getOrCreateConversation(e);updateConversation=e=>this._client.updateConversation(e);deleteConversation=e=>this._client.deleteConversation(e);listParticipants=e=>this._client.listParticipants(e);addParticipant=e=>this._client.addParticipant(e);getParticipant=e=>this._client.getParticipant(e);removeParticipant=e=>this._client.removeParticipant(e);createEvent=e=>this._client.createEvent(e);getEvent=e=>this._client.getEvent(e);listEvents=e=>this._client.listEvents(e);createMessage=e=>this._client.createMessage(e);getOrCreateMessage=e=>this._client.getOrCreateMessage(e);getMessage=e=>this._client.getMessage(e);updateMessage=e=>this._client.updateMessage(e);listMessages=e=>this._client.listMessages(e);deleteMessage=e=>this._client.deleteMessage(e);createUser=e=>this._client.createUser(e);getUser=e=>this._client.getUser(e);listUsers=e=>this._client.listUsers(e);getOrCreateUser=e=>this._client.getOrCreateUser(e);updateUser=e=>this._client.updateUser(e);deleteUser=e=>this._client.deleteUser(e);getState=e=>this._client.getState(e);setState=e=>this._client.setState(e);getOrSetState=e=>this._client.getOrSetState(e);patchState=e=>this._client.patchState(e);configureIntegration=e=>this._client.configureIntegration(e);uploadFile=e=>this._client.uploadFile(e);upsertFile=e=>this._client.upsertFile(e);deleteFile=e=>this._client.deleteFile(e);listFiles=e=>this._client.listFiles(e);getFile=e=>this._client.getFile(e);updateFileMetadata=e=>this._client.updateFileMetadata(e);trackAnalytics=e=>this._client.trackAnalytics(e)};var vn=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};var _n="#";var Pm=_.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),Vd=t=>{let e=t[Lt],r=t[Rs],n=t[Hs],s=t[Ds],a=t[Ms],o=t[Wt],l=Pm.parse(t[qt]);if(!e)throw new Error("Missing bot headers");if(!r)throw new Error("Missing bot user headers");if(!n)throw new Error("Missing integration headers");if(!s)throw new Error("Missing webhook headers");if(!o)throw new Error("Missing configuration headers");if(!l)throw new Error("Missing operation headers");return{botId:e,botUserId:r,integrationId:n,webhookId:s,operation:l,configurationType:a??null,configuration:o?JSON.parse(Buffer.from(o,"base64").toString("utf-8")):{}}};var Gd=zs(require("util")),gt=class{defaultOptions;constructor(e){this.defaultOptions=e}info(...e){this._log("info",e)}debug(...e){this._log("debug",e)}warn(...e){this._log("warn",e)}error(...e){this._log("error",e)}_log(e,r){this._getConsoleMethod(e)(this._serializeMessage(r))}_serializeMessage(e){let r=Gd.default.format(...e);return process.env.BP_LOG_FORMAT==="json"?this.getJsonMessage(r):r}getJsonMessage(e){return JSON.stringify({msg:e,options:this.defaultOptions})}_getConsoleMethod(e){switch(e){case"debug":return console.debug;case"warn":return console.warn;case"error":return console.error;default:return console.info}}};var we=class extends gt{constructor(e){super({visibleToBotOwners:!0,...e})}with(e){return new we({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withVisibleToBotOwners(e){return this.with({visibleToBotOwners:e})}forBot(){return this.withVisibleToBotOwners(!0)}getJsonMessage(e){return JSON.stringify({msg:e,visible_to_bot_owner:this.defaultOptions.visibleToBotOwners,options:this.defaultOptions})}};var xm=t=>["traceparent","tracestate","sentry-trace"].reduce((e,r)=>(t[r]&&(e[r]=t[r]),e),{}),Jd=t=>async e=>{let r=Vd(e.headers),[,n]=(e.headers.traceparent||"").split("-"),s=new Ve.Client({botId:r.botId,integrationId:r.integrationId,retry:mn,headers:xm(e.headers)}),a=new ft(s),o=new we({traceId:n}),l={ctx:r,req:e,client:a,logger:o,instance:t};try{let d;switch(r.operation){case"webhook_received":d=await Sm(l);break;case"register":d=await Em(l);break;case"unregister":d=await Om(l);break;case"message_created":d=await Im(l);break;case"action_triggered":d=await Cm(l);break;case"ping":d=await km(l);break;case"create_user":d=await Zm(l);break;case"create_conversation":d=await Bm(l);break;default:throw new Error(`Unknown operation ${r.operation}`)}return d?{...d,status:d.status??200}:{status:200}}catch(d){if((0,Ve.isApiError)(d)){let g=d.type==="Runtime"?d:new Ve.RuntimeError(d.message,d);return o.forBot().error(g.message),{status:g.code,body:JSON.stringify(g.toJSON())}}console.error(d);let f=new Ve.RuntimeError("An unexpected error occurred in the integration. Bot owners: Check logs for more informations. Integration owners: throw a RuntimeError to return a custom error message instead.");return o.forBot().error(f.message),{status:f.code,body:JSON.stringify(f.toJSON())}}},km=async t=>{},Sm=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{let{req:a}=oe(r);return s.webhook({client:t,ctx:e,req:a,logger:n})},Em=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.register)return;let{webhookUrl:a}=oe(r);await s.register({client:t,ctx:e,webhookUrl:a,logger:n})},Om=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.unregister)return;let{webhookUrl:a}=oe(r);await s.unregister({ctx:e,webhookUrl:a,client:t,logger:n})},Zm=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createUser)return;let{tags:a}=oe(r);return await s.createUser({ctx:e,client:t,tags:a,logger:n})},Bm=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createConversation)return;let{channel:a,tags:o}=oe(r);return await s.createConversation({ctx:e,client:t,channel:a,tags:o,logger:n})},Im=async({ctx:t,req:e,client:r,logger:n,instance:s})=>{let{conversation:a,user:o,type:l,payload:d,message:f}=oe(e),g=s.channels[a.channel];if(!g)throw new Error(`Channel ${a.channel} not found`);let h=g.messages[l];if(!h)throw new Error(`Message of type ${l} not found in channel ${a.channel}`);await h({ctx:t,conversation:a,message:f,user:o,type:l,client:r,payload:d,ack:async({tags:O})=>{await r.updateMessage({id:f.id,tags:O})},logger:n})},Cm=async({req:t,ctx:e,client:r,logger:n,instance:s})=>{let{input:a,type:o}=oe(t);if(!o)throw new Error("Missing action type");let l=s.actions[o];if(!l)throw new Error(`Action ${o} not found`);let d=new vn,g={output:await l({ctx:e,input:a,client:r,type:o,logger:n,metadata:d}),meta:d.toJSON()};return{body:JSON.stringify(g)}};var Tn=class{constructor(e){this.props=e;this.actions=e.actions,this.channels=e.channels,this.register=e.register,this.unregister=e.unregister,this.createUser=e.createUser,this.createConversation=e.createConversation,this.webhook=e.handler}actions;channels;register;unregister;createUser;createConversation;webhook;handler=Jd(this);start=e=>Vt(this.handler,e)};var bn=class{constructor(e){this.props=e;this.integrations=e.integrations,this.plugins=e.plugins,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.states=e.states,this.configuration=e.configuration,this.events=e.events,this.recurringEvents=e.recurringEvents,this.actions=e.actions,this.tables=e.tables,this.workflows=e.workflows,this.attributes=e.attributes}integrations;plugins;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;attributes;addIntegration(e,r){let n=this;return n.integrations||(n.integrations={}),n.integrations[e.name]={enabled:r.enabled,...e,configurationType:r.configurationType,configuration:r.configuration,disabledChannels:r.disabledChannels},this}addPlugin(e,r){let n=this;n.plugins||(n.plugins={});let s=r.alias??e.name;return n.plugins[s]={...e,alias:r.alias,configuration:r.configuration,interfaces:r.interfaces},n.user=this._mergeUser(n.user,e.definition.user),n.conversation=this._mergeConversation(n.conversation,e.definition.conversation),n.message=this._mergeMessage(n.message,e.definition.message),n.recurringEvents=this._mergeRecurringEvents(n.recurringEvents,e.definition.recurringEvents),n.tables=this._mergeTables(n.tables,e.definition.tables),n.workflows=this._mergeWorkflows(n.workflows,e.definition.workflows),n.states=this._mergeStates(n.states,this._prefixKeys(e.definition.states,r.alias)),n.events=this._mergeEvents(n.events,this._prefixKeys(e.definition.events,r.alias)),n.actions=this._mergeActions(n.actions,this._prefixKeys(e.definition.actions,r.alias)),this}_mergeUser=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeConversation=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeMessage=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeStates=(e,r)=>({...e,...r});_mergeEvents=(e,r)=>({...e,...r});_mergeRecurringEvents=(e,r)=>({...e,...r});_mergeActions=(e,r)=>({...e,...r});_mergeTables=(e,r)=>({...e,...r});_mergeWorkflows=(e,r)=>({...e,...r});_prefixKeys=(e,r)=>!e||!r?e:M.mapKeys(e,n=>`${r}${_n}${n}`)};var Ge=require("@botpress/client");var Pe=class extends gt{constructor(e){super({...e})}with(e){return new Pe({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withWorkflowId(e){return this.with({workflowId:e})}withEventId(e){return this.with({eventId:e})}withMessageId(e){return this.with({messageId:e})}};var ce=class{constructor(e,r={before:{},after:{}}){this._client=e;this._hooks=r}getConversation=e=>this._run("getConversation",e);listConversations=e=>this._run("listConversations",e);updateConversation=e=>this._run("updateConversation",e);deleteConversation=e=>this._run("deleteConversation",e);listParticipants=e=>this._run("listParticipants",e);addParticipant=e=>this._run("addParticipant",e);getParticipant=e=>this._run("getParticipant",e);removeParticipant=e=>this._run("removeParticipant",e);createEvent=e=>this._run("createEvent",e);getEvent=e=>this._run("getEvent",e);listEvents=e=>this._run("listEvents",e);createMessage=e=>this._run("createMessage",e);getOrCreateMessage=e=>this._run("getOrCreateMessage",e);getMessage=e=>this._run("getMessage",e);updateMessage=e=>this._run("updateMessage",e);listMessages=e=>this._run("listMessages",e);deleteMessage=e=>this._run("deleteMessage",e);getUser=e=>this._run("getUser",e);listUsers=e=>this._run("listUsers",e);updateUser=e=>this._run("updateUser",e);deleteUser=e=>this._run("deleteUser",e);getState=e=>this._run("getState",e);setState=e=>this._run("setState",e);getOrSetState=e=>this._run("getOrSetState",e);patchState=e=>this._run("patchState",e);callAction=e=>this._run("callAction",e);uploadFile=e=>this._run("uploadFile",e);upsertFile=e=>this._run("upsertFile",e);deleteFile=e=>this._run("deleteFile",e);listFiles=e=>this._run("listFiles",e);getFile=e=>this._run("getFile",e);updateFileMetadata=e=>this._run("updateFileMetadata",e);searchFiles=e=>this._run("searchFiles",e);trackAnalytics=e=>this._run("trackAnalytics",e);getTableRow=e=>this._run("getTableRow",e);createTableRows=e=>this._run("createTableRows",e);findTableRows=e=>this._run("findTableRows",e);deleteTableRows=e=>this._run("deleteTableRows",e);updateTableRows=e=>this._run("updateTableRows",e);upsertTableRows=e=>this._run("upsertTableRows",e);createWorkflow=e=>this._run("createWorkflow",e);getWorkflow=e=>this._run("getWorkflow",e);updateWorkflow=e=>this._run("updateWorkflow",e);deleteWorkflow=e=>this._run("deleteWorkflow",e);listWorkflows=e=>this._run("listWorkflows",e);createConversation=e=>this._client.createConversation(e);getOrCreateConversation=e=>this._client.getOrCreateConversation(e);createUser=e=>this._client.createUser(e);getOrCreateUser=e=>this._client.getOrCreateUser(e);_run=async(e,r)=>{let n=this._hooks.before[e];n&&(r=await n(r));let s=await this._client[e](r),a=this._hooks.after[e];return a&&(s=await a(s,r)),s}};var yt=t=>new Proxy({},{get:(e,r)=>({listInstances:{all:n=>xe({workflowName:r,client:t,input:n}),running:n=>xe({workflowName:r,client:t,input:n,statuses:["in_progress"]}),scheduled:n=>xe({workflowName:r,client:t,input:n,statuses:["pending","listening"]}),allFinished:n=>xe({workflowName:r,client:t,input:n,statuses:["completed","cancelled","failed","timedout"]}),cancelled:n=>xe({workflowName:r,client:t,input:n,statuses:["cancelled"]}),failed:n=>xe({workflowName:r,client:t,input:n,statuses:["failed"]}),succeeded:n=>xe({workflowName:r,client:t,input:n,statuses:["completed"]}),timedOut:n=>xe({workflowName:r,client:t,input:n,statuses:["timedout"]})},startNewInstance:async n=>{let{workflow:s}=await t.createWorkflow({name:r,status:"pending",...n});return{workflow:ke({client:t,workflow:s})}}})}),xe=async t=>{let e=await t.client.listWorkflows({name:t.workflowName,statuses:t.statuses,...t.input});return{...e,workflows:e.workflows.map(r=>ke({client:t.client,workflow:r}))}},ke=t=>({...t.workflow,async update(e){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,...e});return{workflow:ke({client:t.client,workflow:r})}},async setFailed({failureReason:e}){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"failed",failureReason:e});return{workflow:ke({client:t.client,workflow:r})}},async setCompleted({output:e}={}){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"completed",output:e});return{workflow:ke({client:t.client,workflow:r})}},async cancel(){let{workflow:e}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return{workflow:ke({client:t.client,workflow:e})}}});var Am=_.enum(["event_received","register","unregister","ping","action_triggered"]),Xd=t=>{let e=t[Lt],r=t[Wt],n=t[Ns],s=Am.parse(t[qt]);if(!e)throw new Error("Missing bot headers");if(!n)throw new Error("Missing type headers");if(!r)throw new Error("Missing configuration headers");if(!s)throw new Error("Missing operation headers");return{botId:e,operation:s,type:n,configuration:r?JSON.parse(Buffer.from(r,"base64").toString("utf-8")):{}}};var Y={status:200};var js=t=>{switch(t){case"workflow_continued":return"continued";case"workflow_started":return"started";case"workflow_timedout":return"timed_out";default:throw new Error(`Unsupported workflow update type: ${t}`)}};var Rm=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],Yd=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!Rm.includes(e.payload.type))throw new Error("Unexpected event type");let r={...t,logger:Hm(t,e)};if(!e.payload.workflow.name)return r.logger.warn("Received workflow update event without a workflow name. Assuming this workflow was not defined by the bot.",e.payload.workflow),Y;switch(e.payload.type){case"child_workflow_deleted":case"child_workflow_finished":r.logger.info(`Received child workflow event "${e.payload.type}", but child workflows are not yet supported`);break;case"workflow_timedout":case"workflow_started":case"workflow_continued":return await Dm(r,e);default:e.payload.type}return Y},Hm=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),Dm=async(t,e)=>{let r=js(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name];return!n||n.length===0?(t.logger.warn(`No ${r} handler found for workflow "${e.payload.workflow.name}"`),Y):(await Mm(t,e),await Nm(t,e),Y)},Mm=async(t,e)=>{e.payload.workflow.status==="pending"&&await t.client.updateWorkflow({id:e.payload.workflow.id,status:"in_progress",eventId:e.id})},Nm=async(t,e)=>{let r=js(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name];for(let s of n)await s({...t,conversation:e.payload.conversation,user:e.payload.user,workflow:ke({...t,workflow:e.payload.workflow}),workflows:yt(t.client)})};var Qd=t=>async e=>{let r=Xd(e.headers),n=new Pe,s=new Ge.Client({botId:r.botId,retry:mn}),a=new ce(s,{before:{createMessage:async l=>{let d=t.hookHandlers.before_outgoing_message[l.type]??[];for(let f of d){let g=new ce(s);l=(await f({client:g,ctx:r,logger:n.with({conversationId:l.conversationId,userId:l.userId}),data:l,...Se({client:g})}))?.data??l}return l},callAction:async l=>{let d=t.hookHandlers.before_outgoing_call_action[l.type]??[];for(let f of d){let g=new ce(s);l=(await f({client:g,ctx:r,logger:n,data:l,...Se({client:g})}))?.data??l}return l}},after:{createMessage:async l=>{let d=t.hookHandlers.after_outgoing_message[l.message.type]??[];for(let f of d){let g=new ce(s);l=(await f({client:g,ctx:r,logger:n.with({messageId:l.message.id,conversationId:l.message.conversationId,userId:l.message.userId}),data:l,...Se({client:g})}))?.data??l}return l},callAction:async(l,d)=>{let{type:f}=d,g=t.hookHandlers.after_outgoing_call_action[f]??[];for(let h of g){let x=new ce(s);l=(await h({client:x,ctx:r,logger:n,data:{type:f,...l},...Se({client:x})}))?.data??l}return l}}}),o={req:e,ctx:r,logger:n,client:a,self:t};try{switch(r.operation){case"action_triggered":return await Fm(o);case"event_received":return await Um(o);case"register":return await jm(o);case"unregister":return await Km(o);case"ping":return await $m(o);default:throw new Error(`Unknown operation ${r.operation}`)}}catch(l){let d=l instanceof Error?l:new Error(String(l));if((0,Ge.isApiError)(d)){let g=d.type==="Runtime"?d:new Ge.RuntimeError(d.message,d);return n.error(g.message),{status:g.code,body:JSON.stringify(g.toJSON())}}let f=new Ge.RuntimeError("An unexpected error occurred in the bot.",d);return n.error(f.message,d),{status:f.code,body:JSON.stringify(f.toJSON())}}},$m=async t=>Y,jm=async t=>Y,Km=async t=>Y,Um=async t=>{let{ctx:e,logger:r,req:n,client:s,self:a}=t,o={client:s,ctx:e,logger:r,...Se({client:s})},l=oe(n);if(o.logger=o.logger.with({eventId:l.event.id,messageId:l.event.messageId,conversationId:l.event.conversationId,userId:l.event.userId}),e.type==="workflow_update")return await Yd(t,l.event);if(e.type==="message_created"){let O=l.event,B=O.payload.message;o.logger=o.logger.with({messageId:B.id,conversationId:B.conversationId,userId:B.userId});let U=a.hookHandlers.before_incoming_message[B.type]??[];for(let q of U){let se=await q({...o,data:B});if(B=se?.data??B,se?.stop)return Y}let W={...o,user:O.payload.user,conversation:O.payload.conversation,message:B,event:O},Q=a.messageHandlers[B.type]??[];for(let q of Q)await q(W);let ae=a.hookHandlers.after_incoming_message[B.type]??[];for(let q of ae){let se=await q({...o,data:B});if(B=se?.data??B,se?.stop)return Y}return Y}if(e.type==="state_expired"){let B=l.event.payload.state,U={...o,state:B},W=a.stateExpiredHandlers["*"]??[];for(let Q of W)await Q(U);return Y}let d=l.event,f=a.hookHandlers.before_incoming_event[d.type]??[];for(let O of f){let B=await O({...o,data:d});if(d=B?.data??d,B?.stop)return Y}let g={...o,event:d},h=a.eventHandlers[d.type]??[];for(let O of h)await O(g);let x=a.hookHandlers.after_incoming_event[d.type]??[];for(let O of x){let B=await O({...o,data:d});if(d=B?.data??d,B?.stop)return Y}return Y},Fm=async({ctx:t,logger:e,req:r,client:n,self:s})=>{let{input:a,type:o}=oe(r);if(!o)throw new Error("Missing action type");let l=s.hookHandlers.before_incoming_call_action[o]??[];for(let x of l){let O=await x({ctx:t,logger:e,client:n,data:{type:o,input:a},...Se({client:n})});a=O?.data?.input??a,o=O?.data?.type??o}let d=s.actionHandlers[o];if(!d)throw new Error(`Action ${o} not found`);let f=await d({ctx:t,logger:e,input:a,client:n,type:o,...Se({client:n})}),g=s.hookHandlers.after_incoming_call_action[o]??[];for(let x of g){let O=await x({ctx:t,logger:e,client:n,data:{type:o,output:f},...Se({client:n})});o=O?.data?.type??o,f=O?.data?.output??f}return{status:200,body:JSON.stringify({output:f})}},Se=t=>({workflows:yt(t.client)});var wn=class{constructor(e){this.props=e;this._actionHandlers=e.actions,this._plugins=e.plugins}_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_plugins={};_registerOrder=0;get actionHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._actionHandlers[r];if(n)return n;for(let s of Object.values(this._plugins))if(n=s.actionHandlers[r],n)return n}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.messageHandlers[r]??[]),s=this._messageHandlers[r]??[],a=this._messageHandlers["*"]??[],o=[...s,...a].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return S.unique([...n,...o])}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.eventHandlers[r]??[]),s=this._eventHandlers[r]??[],a=this._eventHandlers["*"]??[],o=[...s,...a].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return S.unique([...n,...o])}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.stateExpiredHandlers[r]??[]),s=this._stateExpiredHandlers[r]??[],a=this._stateExpiredHandlers["*"]??[],o=[...s,...a].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return S.unique([...n,...o])}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{if(this._hookHandlers[r])return new Proxy({},{get:(s,a)=>{let o=Object.values(this._plugins).flatMap(h=>h.hookHandlers[r]?.[a]??[]),l=this._hookHandlers[r]??{},d=l[a]??[],f=l["*"]??[],g=[...d,...f].sort((h,x)=>h.order-x.order).map(({handler:h})=>h);return S.unique([...o,...g])}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,a)=>{let o=n[a]?.sort((d,f)=>d.order-f.order).map(({handler:d})=>d)??[],l=Object.values(this._plugins).flatMap(d=>d.workflowHandlers[r]?.[a]??[]);return S.unique([...o,...l])}})}})}on={message:(e,r)=>{this._messageHandlers[e]=S.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=S.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=S.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=S.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=S.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=S.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=S.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=S.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=S.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=S.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=S.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=S.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=S.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=S.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=S.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=S.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};handler=Qd(this);start=e=>Vt(this.handler,e)};var Pn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.title=e.title,this.description=e.description,this.readme=e.readme,this.entities=e.entities??{},this.attributes=e.attributes;let r=this._getEntityReference(this.entities),n=e.events===void 0?{}:M.mapValues(e.events,o=>({...o,schema:o.schema(r)})),s=e.actions===void 0?{}:M.mapValues(e.actions,o=>({...o,input:{...o.input,schema:o.input.schema(r)},output:{...o.output,schema:o.output.schema(r)}})),a=e.channels===void 0?{}:M.mapValues(e.channels,o=>({...o,messages:M.mapValues(o.messages,l=>({...l,schema:l.schema(r)}))}));this.events=n,this.actions=s,this.channels=a}name;version;title;description;icon;readme;attributes;entities;events;actions;channels;_getEntityReference=e=>{let r={};for(let[n,s]of Object.entries(e)){let a=s.schema._def["x-zui"]?.title,o=s.schema._def.description,l=Id.ref(n);a&&l.title(a),o&&l.describe(o),r[n]=l}return r}};var xn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.description=e.description,this.integrations=e.integrations,this.interfaces=e.interfaces,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.states=e.states,this.configuration=e.configuration,this.events=e.events,this.recurringEvents=e.recurringEvents,this.actions=e.actions,this.tables=e.tables,this.workflows=e.workflows,this.attributes=e.attributes}name;version;title;description;icon;readme;attributes;integrations;interfaces;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows};var Ks=":";var eu=t=>{let[e,r]=t.split(Ks);return!e||!r?null:{namespace:e,eventName:r}},tu=t=>`${t.namespace}${Ks}${t.actionName}`,ru=t=>`${t.namespace}${Ks}${t.eventName}`,nu=(t,e)=>{let r=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},n=r.name,s=r.actions[t.actionName]?.name??t.actionName;return{namespace:n,actionName:s}},su=(t,e)=>{let r=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},n=r.name,s=r.events[t.eventName]?.name??t.eventName;return{namespace:n,eventName:s}};var au=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,a)=>o=>zm({client:t,interfaces:e.interfaces,integrationOrInterfaceName:n,methodName:a,input:o})})}),zm=async({client:t,interfaces:e,integrationOrInterfaceName:r,methodName:n,input:s})=>{let a=nu({namespace:r,actionName:n},e),o=tu(a);return(await t.callAction({type:o,input:s})).output};var Us=class{constructor(e,r,n){this._client=e;this._stateType=r;this._stateName=n}async get(e){return await this._client.getState({type:this._stateType,name:this._stateName,id:e}).then(r=>r.state.payload)}async set(e,r){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:r})}async getOrSet(e,r){return await this._client.getOrSetState({type:this._stateType,name:this._stateName,id:e,payload:r}).then(n=>n.state.payload)}async delete(e){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:null})}async patch(e,r){await this._client.patchState({type:this._stateType,name:this._stateName,id:e,payload:r})}},iu=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,a)=>{let o=e.alias!==void 0?`${e.alias}${_n}${a}`:a;return new Us(t,n,o)}})});var kn=class{constructor(e){this.props=e;this._actionHandlers=e.actions}_runtimeProps;_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_registerOrder=0;initialize(e){return this._runtimeProps=e,this}get _runtime(){if(!this._runtimeProps)throw new Error("Plugin not correctly initialized. This is likely because you access your plugin config outside of an handler.");return this._runtimeProps}_getTools(e){let{configuration:r,interfaces:n,alias:s}=this._runtime,a=au(e,this._runtime),o=iu(e,this._runtime),l=yt(e);return{configuration:r,interfaces:n,actions:a,states:o,alias:s,workflows:l}}get actionHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._actionHandlers[r];if(n)return me.setName(s=>n({...s,...this._getTools(s.client)}),n.name)}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._messageHandlers[r]??[],s=this._messageHandlers["*"]??[];return S.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>me.setName(l=>o({...l,...this._getTools(l.client)}),o.name))}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._eventHandlers[r]??[],s=Object.entries(this._eventHandlers).filter(([l])=>this._eventResolvesTo(l,r)).flatMap(([,l])=>l??[]),a=this._eventHandlers["*"]??[];return S.unique([...n,...s,...a]).sort((l,d)=>l.order-d.order).map(({handler:l})=>me.setName(d=>l({...d,...this._getTools(d.client)}),l.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._stateExpiredHandlers[r]??[],s=this._stateExpiredHandlers["*"]??[];return S.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>me.setName(l=>o({...l,...this._getTools(l.client)}),o.name))}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._hookHandlers[r];if(n)return new Proxy({},{get:(s,a)=>{a=this._stripAliasPrefix(a);let o=n[a]??[],l=Object.entries(n).filter(([g])=>this._eventResolvesTo(g,a)).flatMap(([,g])=>g??[]),d=n["*"]??[];return S.unique([...o,...l,...d]).sort((g,h)=>g.order-h.order).map(({handler:g})=>me.setName(h=>g({...h,...this._getTools(h.client)}),g.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,a)=>(n[a]?.sort((l,d)=>l.order-d.order)??[]).map(({handler:l})=>me.setName(d=>l({...d,...this._getTools(d.client)}),l.name))})}})}on={message:(e,r)=>{this._messageHandlers[e]=S.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=S.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=S.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=S.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=S.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=S.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=S.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=S.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=S.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=S.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=S.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=S.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=S.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=S.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=S.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=S.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};_eventResolvesTo=(e,r)=>{let n=eu(e);if(!n)return!1;let s=su(n,this._runtime.interfaces);return ru(s)===r};_stripAliasPrefix=e=>{let{alias:r}=this._runtime;if(!r)return e;let n=`${r}:`;return e.startsWith(n)?e.slice(n.length):e}};0&&(module.exports={BRAND,Bot,BotDefinition,BotLogger,BotSpecificClient,DIRTY,EMPTY_PATH,INVALID,Integration,IntegrationDefinition,IntegrationLogger,IntegrationSpecificClient,InterfaceDefinition,NEVER,OK,ParseInputLazyPath,ParseStatus,Plugin,PluginDefinition,RuntimeError,Schema,WELL_KNOWN_ATTRIBUTES,ZodAny,ZodArray,ZodBigInt,ZodBoolean,ZodBranded,ZodCatch,ZodDate,ZodDefault,ZodDiscriminatedUnion,ZodEffects,ZodEnum,ZodError,ZodFirstPartyTypeKind,ZodFunction,ZodIntersection,ZodIssueCode,ZodLazy,ZodLiteral,ZodMap,ZodNaN,ZodNativeEnum,ZodNever,ZodNull,ZodNullable,ZodNumber,ZodObject,ZodOptional,ZodParsedType,ZodPipeline,ZodPromise,ZodReadonly,ZodRecord,ZodRef,ZodSchema,ZodSet,ZodString,ZodSymbol,ZodTransformer,ZodTuple,ZodType,ZodUndefined,ZodUnion,ZodUnknown,ZodVoid,addIssueToContext,agent,aimodel,any,array,bigint,boolean,botIdHeader,botUserIdHeader,coerce,configurationHeader,configurationTypeHeader,conversation,createZodEnum,cuid2Regex,cuidRegex,custom,datasource,date,discriminatedUnion,effect,emailRegex,enum:null,errorUtil,event,function:null,getErrorMap,getParsedType,instanceof:null,integrationIdHeader,intent,intersection,ipv4Regex,ipv6Regex,isAborted,isApiError,isAsync,isDirty,isEmojiRegex,isValid,knowledgebase,late,lazy,literal,makeIssue,map,mergeObjectSchemas,message,messages,nan,nativeEnum,never,null:null,nullable,number,object,objectUtil,oboolean,onumber,operationHeader,optional,ostring,parseBody,pipeline,preprocess,processCreateParams,promise,quotelessJson,readonly,record,ref,serve,set,setErrorMap,strictObject,string,symbol,table,tablerow,transformer,transforms,tuple,typeHeader,ulidRegex,undefined,union,unknown,user,util,uuidRegex,variable,void:null,webhookIdHeader,z});
67
+ `,s+="})"}let a=r?s?r+s:n?n==="z.never()"?r+".strict()":r+`.catchall(${n})`:r:s||(n?`z.record(${n})`:"z.record(z.any())");return $.an.anyOf(t)&&(a+=`.and(${sd(p(c({},t),{anyOf:t.anyOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),$.a.oneOf(t)&&(a+=`.and(${Cs(p(c({},t),{oneOf:t.oneOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),$.an.allOf(t)&&(a+=`.and(${jt(p(c({},t),{allOf:t.allOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),a}i(ad,"parseObject");var _h=i(t=>{var e;let r="z.string()";if((e=t[b])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";r="z.coerce.string()"}return r+=G(t,"format",({value:n})=>{switch(n){case"email":return[".email(",")"];case"ip":return[".ip(",")"];case"ipv4":return['.ip({ version: "v4"',", message: "," })"];case"ipv6":return['.ip({ version: "v6"',", message: "," })"];case"uri":return[".url(",")"];case"uuid":return[".uuid(",")"];case"date-time":return[".datetime(",")"]}}),r+=G(t,"pattern",({json:n})=>[`.regex(new RegExp(${n})`,", ",")"]),r+=G(t,"minLength",({json:n})=>[`.min(${n}`,", ",")"]),r+=G(t,"maxLength",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseString"),Th=i((t,e)=>`${L(ph(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),bh=i(t=>`z.ref('${t.$ref}')`,"parseRef"),wh=i((t,e)=>{var r,n;if(t.oneOf.length<=1||!((r=t.discriminator)!=null&&r.propertyName))return Cs(t,e);let s=t.oneOf.map((a,o)=>L(a,p(c({},e),{path:[...e.path,"oneOf",o]})));return`z.discriminatedUnion("${(n=t.discriminator)==null?void 0:n.propertyName}", [${s.join(", ")}])`},"parseDiscriminator"),L=i((t,e={seen:new Map,path:[]},r)=>{if(typeof t!="object")return t?"z.any()":"z.never()";if(e.parserOverride){let a=e.parserOverride(t,e);if(typeof a=="string")return a}let n=e.seen.get(t);if(n){if(n.r!==void 0)return n.r;if(e.depth===void 0||n.n>=e.depth)return"z.any()";n.n+=1}else n={r:void 0,n:0},e.seen.set(t,n);let s=kh(t,e);return r||(s=Ph(t,s),e.withoutDefaults||(s=xh(t,s))),n.r=s,s},"parseSchema"),Ph=i((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),xh=i((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),kh=i((t,e)=>$.a.nullable(t)?Th(t,e):$.an.object(t)?ad(t,e):$.an.array(t)?gh(t,e):$.an.anyOf(t)?sd(t,e):$.an.allOf(t)?jt(t,e):$.a.discriminator(t)?wh(t,e):$.a.oneOf(t)?Cs(t,e):$.a.not(t)?ch(t,e):$.an.enum(t)?hh(t):$.a.const(t)?yh(t):$.a.multipleType(t)?lh(t,e):$.a.primitive(t,"string")?_h(t):$.a.primitive(t,"number")||$.a.primitive(t,"integer")?vh(t):$.a.primitive(t,"boolean")?ih(t):$.a.primitive(t,"null")?dh(t):$.a.conditional(t)?mh(t,e):$.a.ref(t)?bh(t):oh(t),"selectParser"),$={an:{object:i(t=>t.type==="object","object"),array:i(t=>t.type==="array","array"),anyOf:i(t=>t.anyOf!==void 0,"anyOf"),allOf:i(t=>t.allOf!==void 0,"allOf"),enum:i(t=>t.enum!==void 0,"enum")},a:{nullable:i(t=>t.nullable===!0,"nullable"),multipleType:i(t=>Array.isArray(t.type),"multipleType"),not:i(t=>t.not!==void 0,"not"),const:i(t=>t.const!==void 0,"const"),primitive:i((t,e)=>t.type===e,"primitive"),conditional:i(t=>Boolean("if"in t&&t.if&&"then"in t&&"else"in t&&t.then&&t.else),"conditional"),discriminator:i(t=>{var e;return t.oneOf!==void 0&&((e=t.discriminator)==null?void 0:e.propertyName)!==void 0},"discriminator"),oneOf:i(t=>t.oneOf!==void 0,"oneOf"),ref:i(t=>t.$ref!==void 0,"ref")}},Sh=i(t=>{let e;try{e=new Function("z",`return ${t}`)(u)}catch(r){return{sucess:!1,error:`Failed to evaluate schema: ${(r instanceof Error?r:new Error(String(r))).message}`}}return e instanceof u.ZodType?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),Eh=i(t=>L(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),Oh=i(t=>{let e=Eh(t);e=e.replaceAll("errors: z.ZodError[]","errors");let r=Sh(e);if(!r.sucess)throw new Wr(r.error);return r.value},"jsonSchemaToZod"),Ct=i((t,e)=>{var r,n;if(e[b]&&t._def&&(t._def[b]=e[b]),((r=t._def)==null?void 0:r.typeName)==="ZodObject"&&e.type==="object"&&e.properties&&Object.entries(e.properties).forEach(([s,a])=>{let o=typeof t._def.shape=="function"?t._def.shape():t._def.shape;o[s]&&Ct(o[s],a)}),((n=t._def)==null?void 0:n.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&Ct(t._def.valueType,e.additionalProperties),e.type==="array"&&e.items){let s=e.items;if(typeof s=="object"&&!Array.isArray(s)){let a=t._def.type;a&&Ct(a,s)}else Array.isArray(s)&&s.forEach((a,o)=>{let l=t._def;l.typeName===_.ZodFirstPartyTypeKind.ZodTuple&&Ct(l.items[o],a)})}},"applyZuiPropsRecursively"),Zh=i(t=>{let e=Oh(t);return Ct(e,t),e},"fromJSONSchemaLegacy"),Ih=i(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&id(n))&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodOptional},"isOptionalSchema"),Bh=i(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&n.type==="null")&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodNullable},"isNullableSchema"),id=i(t=>{var e,r;return t.not===!0&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodUndefined},"isUndefinedSchema"),Ch=i(t=>{var e,r;return!t.not&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodUnknown},"isUnknownSchema"),Ah=i(({type:t,minimum:e,exclusiveMinimum:r,maximum:n,exclusiveMaximum:s,multipleOf:a,format:o})=>{let l=u.number();return t==="integer"&&(l=l.int()),o==="finite"&&(l=l.finite()),r!==void 0?l=l.gt(r):e!==void 0&&(l=l.gte(e)),s!==void 0?l=l.lt(s):n!==void 0&&(l=l.lte(n)),a!==void 0&&(l=l.multipleOf(a)),l},"numberJSONSchemaToZuiNumber"),Rh=i(({format:t,pattern:e,minLength:r,maxLength:n})=>{let s=u.string();if(r&&n&&r===n?s=s.length(r):(r&&(s=s.min(r)),n&&(s=s.max(n))),t==="cuid"||e===j.cuid)s=s.cuid();else if(t==="cuid2"||e===j.cuid2)s=s.cuid2();else if(t==="emoji"||e===j.emoji)s=s.emoji();else if(t==="ulid"||e===j.ulid)s=s.ulid();else if(t==="date-time"){let{precision:a,offset:o}=e?Vy(e):{};s=s.datetime({precision:a,offset:o})}else t==="email"||e===j.email?s=s.email():t==="ipv4"||e===j.ipv4?s=s.ip():t==="ipv6"||e===j.ipv6?s=s.ip("v6"):t==="uri"?s=s.url():t==="uuid"||e===j.uuid?s=s.uuid():e&&(s=s.regex(new RegExp(e)));return s},"stringJSONSchemaToZuiString"),Tt=i((t,e)=>{let r=[];e.enum!==void 0&&r.push(...e.enum),e.const!==void 0&&r.push(e.const);let n=r.filter(o=>typeof o===t),[s]=n;if(!s){if(t==="string"&&e.type==="string")return Rh(e);if(t==="number"&&(e.type==="number"||e.type==="integer"))return Ah(e);if(t==="boolean")return u.boolean();if(t==="null")return u.null();throw new Wr(`Unknown primitive type: "${t}"`)}if(n.length===1)return u.literal(s);let a=n.map(o=>u.literal(o));return u.union(a)},"toZuiPrimitive"),Hh=i((t,e)=>Mh(t)?Nh(t,e):Dh(t)?$h(t,e):jh(t,e),"arrayJSONSchemaToZuiArray"),Mh=i(t=>Array.isArray(t.items),"_isTuple"),Dh=i(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),Nh=i(({items:t,additionalItems:e},r)=>{let n=t.map(r),s=u.tuple(n);return e!==void 0&&(s=s.rest(r(e))),s},"_handleTuple"),$h=i(({items:t,minItems:e,maxItems:r},n)=>{let s=u.set(n(t));return e&&(s=s.min(e)),r&&(s=s.max(r)),s},"_handleSet"),jh=i(({minItems:t,maxItems:e,items:r},n)=>{let s=u.array(n(r));return t&&t===e?s.length(t):(t&&(s=s.min(t)),e&&(s=s.max(e)),s)},"_handleArray"),Ye=u.any();function od(t){return z(t)}i(od,"fromJSONSchema");function z(t){var e;if(t===void 0)return Ye;if(t===!0)return u.any();if(t===!1)return u.never();if(t.default!==void 0)return z(p(c({},t),{default:void 0})).default(t.default);if(t.readOnly)return z(p(c({},t),{readOnly:void 0})).readonly();if(t.oneOf!==void 0)throw new ve({oneOf:t.oneOf});if(t.patternProperties!==void 0)throw new ve({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new ve({propertyNames:t.propertyNames});if(t.if!==void 0)throw new ve({if:t.if});if(t.then!==void 0)throw new ve({then:t.then});if(t.else!==void 0)throw new ve({else:t.else});if(t.$ref!==void 0)return u.ref(t.$ref);if(t.not!==void 0){if(id(t))return u.undefined();if(t.not===!0)return u.never();throw new ve({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return Ye;if(t.type.length===1)return z(p(c({},t),{type:t.type[0]}));let r=t,{type:n}=r,s=Ba(r,["type"]),a=t.type.map(o=>z(p(c({},s),{type:o})));return u.union(a)}if(t.type==="string")return t.enum&&t.enum.length>0?u.enum(t.enum):Tt("string",t);if(t.type==="integer"){let r=Tt("number",t);return r instanceof u.ZodNumber?r.int():r}if(t.type==="number")return Tt("number",t);if(t.type==="boolean")return Tt("boolean",t);if(t.type==="null")return Tt("null",t);if(t.type==="array")return Hh(t,z);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let r=z(t.additionalProperties);return z(p(c({},t),{additionalProperties:void 0})).catchall(r)}if(t.properties!==void 0){let r={};for(let[n,s]of Object.entries(t.properties)){let a=z(s),o=(e=t.required)!=null?e:[];r[n]=o.includes(n)?a:a.optional()}return u.object(r)}if(t.additionalProperties!==void 0){let r=z(t.additionalProperties);return u.record(r)}return u.record(Ye)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return Ye;if(t.anyOf.length===1)return z(t.anyOf[0]);if(Ih(t))return z(t.anyOf[0]).optional();if(Bh(t))return z(t.anyOf[0]).nullable();let r=t.anyOf.map(z);return u.union(r)}if(t.allOf!==void 0){if(t.allOf.length===0)return Ye;if(t.allOf.length===1)return z(t.allOf[0]);let[r,...n]=t.allOf,s=z(r),a=z({allOf:n});return u.intersection(s,a)}return Ch(t)?u.unknown():Ye}i(z,"_fromJSONSchema");var Kh=/^\d{4}-\d{2}-\d{2}(T|\s)?((\d{2}:\d{2}:\d{2}(\.\d{1,3})?)|(\d{2}:\d{2}))?(\s?([+-]\d{2}:\d{2}|Z))?$/,Ln=i((t,e,r=!0)=>{if(typeof t!="object")throw new Hn("Input must be an object");let n=i(o=>{let l=o;return e?.nullable&&(l=l.nullable()),e?.optional&&(l=l.optional()),e?.passtrough&&typeof l.passthrough=="function"&&(l=l.passthrough()),l},"applyOptions"),s=Object.entries(t).reduce((o,[l,d])=>{if(d===null)o[l]=n(_.null());else switch(typeof d){case"string":o[l]=Kh.test(d)?n(_.string().datetime()):n(_.string());break;case"number":o[l]=n(_.number());break;case"boolean":o[l]=n(_.boolean());break;case"object":Array.isArray(d)?d.length===0?o[l]=n(_.array(_.unknown())):typeof d[0]=="object"?o[l]=n(_.array(Ln(d[0],e,!1))):["string","number","boolean"].includes(typeof d[0])&&(o[l]=n(_.array(_[typeof d[0]]()))):o[l]=n(Ln(d,e,!1));break;default:throw new Hn(`Unsupported type for key ${l}`)}return o},{}),a=Object.keys(s).length>0;return e?.passtrough||!r&&!a?_.object(s).passthrough():_.object(s)},"fromObject");function ld(){return{}}i(ld,"parseAnyDef");function cd(t,e){var r,n;let s={type:"array"};return((n=(r=t.type)==null?void 0:r._def)==null?void 0:n.typeName)!=="ZodAny"&&(s.items=C(t.type._def,p(c({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&H(s,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&H(s,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(H(s,"minItems",t.exactLength.value,t.exactLength.message,e),H(s,"maxItems",t.exactLength.value,t.exactLength.message,e)),s}i(cd,"parseArrayDef");function dd(t,e){let r=c({type:"integer",format:"int64"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?H(r,"minimum",n.value,n.message,e):H(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),H(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?H(r,"maximum",n.value,n.message,e):H(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),H(r,"maximum",n.value,n.message,e));break;case"multipleOf":H(r,"multipleOf",n.value,n.message,e);break}return r}i(dd,"parseBigintDef");function ud(t){return c({type:"boolean"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{})}i(ud,"parseBooleanDef");function pd(t,e){return C(t.type._def,e)}i(pd,"parseBrandedDef");var Uh=i((t,e)=>C(t.innerType._def,e),"parseCatchDef");function fd(t,e){return e.dateStrategy=="integer"?Fh(t,e):c({type:"string",format:"date-time"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{})}i(fd,"parseDateDef");var Fh=i((t,e)=>{let r=c({type:"integer",format:"unix-time"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"&&H(r,"minimum",n.value,n.message,e);break;case"max":e.target==="jsonSchema7"&&H(r,"maximum",n.value,n.message,e);break}return r},"integerDateParser");function gd(t,e){return p(c({},C(t.innerType._def,e)),{default:t.defaultValue()})}i(gd,"parseDefaultDef");function yd(t,e){return e.effectStrategy==="input"?C(t.schema._def,e):{}}i(yd,"parseEffectsDef");function hd(t){return{type:"string",enum:t.values}}i(hd,"parseEnumDef");var zh=i(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function md(t,e){let r=[C(t.left._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),C(t.right._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(a=>!!a),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return r.forEach(a=>{if(zh(a))s.push(...a.allOf),a.unevaluatedProperties===void 0&&(n=void 0);else{let o=a;if("additionalProperties"in a&&a.additionalProperties===!1){let l=a,{additionalProperties:d}=l;o=Ba(l,["additionalProperties"])}else n=void 0;s.push(o)}}),s.length?c({allOf:s},n):void 0}i(md,"parseIntersectionDef");function vd(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}i(vd,"parseLiteralDef");function As(t,e){var r,n,s,a,o;if(e.target==="openApi3"&&((r=t.keyType)==null?void 0:r._def.typeName)==="ZodEnum")return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((d,f)=>{var g;return p(c({},d),{[f]:(g=C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"properties",f]})))!=null?g:{}})},{}),additionalProperties:!1};let l={type:"object",additionalProperties:(n=C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:{}};if(e.target==="openApi3")return l;if(((s=t.keyType)==null?void 0:s._def.typeName)==="ZodString"&&((a=t.keyType._def.checks)!=null&&a.length)){let d=Object.entries(os(t.keyType._def,e)).reduce((f,[g,h])=>g==="type"?f:p(c({},f),{[g]:h}),{});return p(c({},l),{propertyNames:d})}else if(((o=t.keyType)==null?void 0:o._def.typeName)==="ZodEnum")return p(c({},l),{propertyNames:{enum:t.keyType._def.values}});return l}i(As,"parseRecordDef");function _d(t,e){if(e.mapStrategy==="record")return As(t,e);let r=C(t.keyType._def,p(c({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},n=C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}i(_d,"parseMapDef");function Td(t){let e=t.values,n=Object.keys(t.values).filter(a=>typeof e[e[a]]!="number").map(a=>e[a]),s=Array.from(new Set(n.map(a=>typeof a)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n.filter(a=>typeof a=="string"||typeof a=="number")}}i(Td,"parseNativeEnumDef");function bd(){return{not:{}}}i(bd,"parseNeverDef");function wd(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}i(wd,"parseNullDef");var zr={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Pd(t,e){if(e.target==="openApi3")return Ea(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in zr&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,a)=>{let o=zr[a._def.typeName];return o&&!s.includes(o)?[...s,o]:s},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((s,a)=>{let o=typeof a._def.value;switch(o){case"string":case"number":case"boolean":return[...s,o];case"bigint":return[...s,"integer"];case"object":if(a._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===r.length){let s=n.filter((a,o,l)=>l.indexOf(a)===o);return{type:s.length>1?s:s[0],enum:r.reduce((a,o)=>a.includes(o._def.value)?a:[...a,o._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,s)=>[...n,...s._def.values.filter(a=>!n.includes(a))],[])};return Ea(t,e)}i(Pd,"parseUnionDef");var Ea=i((t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((s,a)=>C(s._def,p(c({},e),{currentPath:[...e.currentPath,e.unionStrategy,`${a}`]}))).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0)),n=e.discriminator&&t.typeName==="ZodDiscriminatedUnion"&&typeof t.discriminator=="string"?{discriminator:{propertyName:t.discriminator}}:{};if(r.length)return e.unionStrategy==="anyOf"?c({anyOf:r},n):c({oneOf:r},n)},"asUnionOf");function xd(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length)){let n=t.innerType;if(e.target==="openApi3"){let a={type:zr[n._def.typeName],nullable:!0};return Wn(n._def,e,a)}let s={type:[zr[n._def.typeName],"null"]};return Wn(n._def,e,s)}if(e.target==="openApi3"){let n=C(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath]}));return n&&p(c({},n),{nullable:!0})}let r=C(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return r&&{anyOf:[r,{type:"null"}]}}i(xd,"parseNullableDef");function kd(t,e){let r=c({type:"number"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",is(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?H(r,"minimum",n.value,n.message,e):H(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),H(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?H(r,"maximum",n.value,n.message,e):H(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),H(r,"maximum",n.value,n.message,e));break;case"multipleOf":H(r,"multipleOf",n.value,n.message,e);break}return r}i(kd,"parseNumberDef");var Lh=i((t,e)=>{var r;return t.unknownKeys instanceof E?(r=C(t.unknownKeys._def,p(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function Sd(t,e){let r=p(c({type:"object"},Object.entries(t.shape()).reduce((n,[s,a])=>{if(a===void 0||a._def===void 0)return n;let o=C(a._def,p(c({},e),{currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]}));return o===void 0?n:{properties:p(c({},n.properties),{[s]:o}),required:a.isOptional()?n.required:[...n.required,s]}},{properties:{},required:[]})),{additionalProperties:Lh(t,e)});return r.required.length||delete r.required,r}i(Sd,"parseObjectDef");var Wh=i((t,e)=>{var r;if(e.currentPath.toString()===((r=e.propertyPath)==null?void 0:r.toString()))return C(t.innerType._def,e);let n=C(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return n?{anyOf:[{not:{}},n]}:{}},"parseOptionalDef"),qh=i((t,e)=>{if(e.pipeStrategy==="input")return C(t.in._def,e);if(e.pipeStrategy==="output")return C(t.out._def,e);let r=C(t.in._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),n=C(t.out._def,p(c({},e),{currentPath:[...e.currentPath,"allOf",r?"1":"0"]}));return{allOf:[r,n].filter(s=>s!==void 0)}},"parsePipelineDef");function Ed(t,e){return C(t.type._def,e)}i(Ed,"parsePromiseDef");function Od(t,e){let n={type:"array",uniqueItems:!0,items:C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&H(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&H(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}i(Od,"parseSetDef");function Zd(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>C(r._def,p(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:C(t.rest._def,p(c({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>C(r._def,p(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[])}}i(Zd,"parseTupleDef");function Id(){return{not:{}}}i(Id,"parseUndefinedDef");function Bd(){return{}}i(Bd,"parseUnknownDef");var Vh=i((t,e)=>C(t.innerType._def,e),"parseReadonlyDef");function Cd(t){return{$ref:t.uri}}i(Cd,"parseRefDef");function C(t,e,r=!1){let n=e.seen.get(t);if(n&&!r){let o=Gh(n,e);if(o!==void 0)return o}let s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);let a=Xh(t,t.typeName,e);return a&&Wn(t,e,a),s.jsonSchema=a,a}i(C,"parseDef");var Gh=i((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Jh(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},"get$ref"),Jh=i((t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")},"getRelativePath"),Xh=i((t,e,r)=>{switch(e){case"ZodString":return os(t,r);case"ZodNumber":return kd(t,r);case"ZodObject":return Sd(t,r);case"ZodBigInt":return dd(t,r);case"ZodBoolean":return ud(t);case"ZodDate":return fd(t,r);case"ZodUndefined":return Id();case"ZodNull":return wd(r);case"ZodArray":return cd(t,r);case"ZodUnion":case"ZodDiscriminatedUnion":return Pd(t,r);case"ZodIntersection":return md(t,r);case"ZodTuple":return Zd(t,r);case"ZodRecord":return As(t,r);case"ZodRef":return Cd(t);case"ZodLiteral":return vd(t,r);case"ZodEnum":return hd(t);case"ZodNativeEnum":return Td(t);case"ZodNullable":return xd(t,r);case"ZodOptional":return Wh(t,r);case"ZodMap":return _d(t,r);case"ZodSet":return Od(t,r);case"ZodLazy":return C(t.getter()._def,r);case"ZodPromise":return Ed(t,r);case"ZodNaN":case"ZodNever":return bd();case"ZodEffects":return yd(t,r);case"ZodAny":return ld();case"ZodUnknown":return Bd();case"ZodDefault":return gd(t,r);case"ZodBranded":return pd(t,r);case"ZodReadonly":return Vh(t,r);case"ZodCatch":return Uh(t,r);case"ZodPipeline":return qh(t,r);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return(n=>{})(e)}},"selectParser"),Wn=i((t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),Object.assign(r,{[b]:c(c({},t[b]),r[b])}),r),"addMeta"),Oa={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"string",mapStrategy:"entries",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",emailStrategy:"format:email",discriminator:!1,unionStrategy:"anyOf"},Yh=i(t=>typeof t=="string"?p(c({},Oa),{name:t}):c(c({},Oa),t),"getDefaultOptions"),Qh=i(t=>{let e=Yh(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return p(c({},e),{currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))})},"getRefs"),em=i((t,e)=>{var r;let n=Qh(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((d,[f,g])=>{var h;return p(c({},d),{[f]:(h=C(g._def,p(c({},n),{currentPath:[...n.basePath,n.definitionPath,f]}),!0))!=null?h:{}})},{}):void 0,a=typeof e=="string"?e:e?.name,o=(r=C(t._def,a===void 0?n:p(c({},n),{currentPath:[...n.basePath,n.definitionPath,a]}),!1))!=null?r:{},l=a===void 0?s?p(c({},o),{[n.definitionPath]:s}):o:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,a].join("/"),[n.definitionPath]:p(c({},s),{[a]:o})};return n.target==="jsonSchema7"?l.$schema="http://json-schema.org/draft-07/schema#":n.target==="jsonSchema2019-09"&&(l.$schema="https://json-schema.org/draft/2019-09/schema#"),l},"zodToJsonSchema"),tm=i((t,e={target:"openApi3"})=>{let r=em(t,e);return e.$schemaUrl===!1?delete r.$schema:typeof e.$schemaUrl=="string"&&(r.$schema=e.$schemaUrl),r},"toJSONSchemaLegacy");var ft=(t,e)=>{let r=t._def,n=e._def;if(r.typeName===_.ZodFirstPartyTypeKind.ZodObject&&n.typeName===_.ZodFirstPartyTypeKind.ZodObject){let s=r.shape(),a=n.shape();return _.object({...s,...a})}if(r.typeName===_.ZodFirstPartyTypeKind.ZodRecord&&n.typeName===_.ZodFirstPartyTypeKind.ZodRecord)return _.record(_.intersection(r.valueType,n.valueType));throw new Error("Cannot merge object schemas with record schemas")},Ad=_;var re=_.string().min(1),Hd=_.object({text:re}),Md=_.object({markdown:re}),Dd=_.object({imageUrl:re}),Nd=_.object({audioUrl:re}),$d=_.object({videoUrl:re}),jd=_.object({fileUrl:re,title:re.optional()}),Kd=_.object({latitude:_.number(),longitude:_.number(),address:_.string().optional(),title:_.string().optional()}),Ud=_.object({title:re,subtitle:re.optional(),imageUrl:re.optional(),actions:_.array(_.object({action:_.enum(["postback","url","say"]),label:re,value:re}))}),Rd=_.object({text:re,options:_.array(_.object({label:re,value:re}))}),rm=_.object({items:_.array(Ud)}),nm=_.union([_.object({type:_.literal("text"),payload:Hd}),_.object({type:_.literal("markdown"),payload:Md}),_.object({type:_.literal("image"),payload:Dd}),_.object({type:_.literal("audio"),payload:Nd}),_.object({type:_.literal("video"),payload:$d}),_.object({type:_.literal("file"),payload:jd}),_.object({type:_.literal("location"),payload:Kd})]),sm=_.object({items:_.array(nm)}),am={schema:Md},im={text:{schema:Hd},image:{schema:Dd},audio:{schema:Nd},video:{schema:$d},file:{schema:jd},location:{schema:Kd},carousel:{schema:rm},card:{schema:Ud},dropdown:{schema:Rd},choice:{schema:Rd},bloc:{schema:sm}};var qt="x-bot-id",Hs="x-bot-user-id",Ms="x-integration-id",Ds="x-webhook-id",Ns="x-bp-configuration-type",Vt="x-bp-configuration",Gt="x-bp-operation",$s="x-bp-type",om={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};var Fd=require("browser-or-node");var js=console;function oe(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function Jt(t,e=8072,r=um){if(!Fd.isNode)throw new Error("This function can only be called in Node.js");let s=require("http").createServer(async(a,o)=>{try{let l=await lm(a);if(l.path==="/health"){o.writeHead(200).end("ok");return}let d=await t(l);o.writeHead(d?.status??200,d?.headers??{}).end(d?.body??"{}")}catch(l){js.error("Error while handling request",{error:l?.message??"Internal error occured"}),o.writeHead(500).end(JSON.stringify({error:l?.message??"Internal error occured"}))}});return s.listen(e,()=>r(e)),s}async function lm(t){let e=await dm(t),r={};for(let s=0;s<t.rawHeaders.length;s+=2){let a=t.rawHeaders[s].toLowerCase(),o=t.rawHeaders[s+1];r[a]=o}let n=new URL(t.url??"",t.headers.host?`http://${t.headers.host}`:"http://botpress.cloud");return{body:e,path:n.pathname,query:cm(n.search,"?"),headers:r,method:t.method?.toUpperCase()??"GET"}}function cm(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function dm(t){return new Promise((e,r)=>{if(t.method!=="POST"&&t.method!=="PUT"&&t.method!=="PATCH")return e(void 0);let n="";t.on("data",s=>n+=s.toString()),t.on("error",s=>r(s)),t.on("end",()=>e(n))})}function um(t){js.info(`Listening on port ${t}`)}var En=require("@botpress/client");var D={};vt(D,{mapKeys:()=>gm,mapValues:()=>fm,mergeRecords:()=>hm,pairs:()=>hn,stripUndefinedProps:()=>ym,values:()=>pm});var hn=t=>Object.entries(t),pm=t=>Object.values(t),fm=(t,e)=>Object.fromEntries(hn(t).map(([r,n])=>[r,e(n,r)])),gm=(t,e)=>Object.fromEntries(hn(t).map(([r,n])=>[e(r),n])),ym=t=>Object.fromEntries(hn(t).filter(([,e])=>e!==void 0)),hm=(t,e,r)=>{let n=[...Object.keys(t),...Object.keys(e)],s=[...new Set(n)],a={};for(let o of s){let l=t[o],d=e[o];l&&d?a[o]=r(l,d):l?a[o]=l:d&&(a[o]=d)}return a};var S={};vt(S,{safePush:()=>mm,unique:()=>vm});var mm=(t,...e)=>t?[...t,...e]:[...e],vm=t=>Array.from(new Set(t));var me={};vt(me,{setName:()=>_m});var _m=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var zd=t=>{let{name:e,version:r}=t,n={actions:{},events:{},channels:{}},s={name:e,version:r,entities:D.mapValues(t.entities,o=>({name:o.name})),actions:{},events:{},channels:{}},a=D.mapValues(t.entities,o=>o.schema);for(let[o,l]of Object.entries(t.definition.actions??{})){let d=l.input.schema.dereference(a),f=l.output.schema.dereference(a),g=t.actions?.[o]?.name??o;n.actions[g]={...l,...t.actions?.[o]??{},input:{schema:d},output:{schema:f}},s.actions[o]={name:g}}for(let[o,l]of Object.entries(t.definition.events??{})){let d=l.schema.dereference(a),f=t.events?.[o]?.name??o;n.events[f]={...l,...t.events?.[o]??{},schema:d},s.events[o]={name:f}}for(let[o,l]of Object.entries(t.definition.channels??{})){let d={};for(let[g,h]of Object.entries(l.messages)){let x=h.schema.dereference(a);d[g]={...h,schema:x}}let f=t.channels?.[o]?.name??o;n.channels[f]={...l,...t.channels?.[o]??{},message:{...l.message??{},tags:{...l.message?.tags??{},...t.channels?.[o]?.message?.tags??{}}},conversation:{...l.conversation??{},tags:{...l.conversation?.tags??{},...t.channels?.[o]?.conversation?.tags??{}}},messages:d},s.channels[o]={name:f}}return{resolved:n,statement:s}};var mn=Symbol("schemaName"),Ld=t=>t?D.mapValues(t,(r,n)=>({...r,[mn]:n})):{},Wd=t=>mn in t&&t[mn]!==void 0,qd=t=>t[mn];var vn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.identifier=e.identifier,this.description=e.description,this.configuration=e.configuration,this.configurations=e.configurations,this.events=e.events,this.actions=e.actions,this.channels=e.channels,this.states=e.states,this.user=e.user,this.secrets=e.secrets,this.entities=e.entities,this.interfaces=e.interfaces,this.__advanced=e.__advanced,this.attributes=e.attributes}name;version;title;description;icon;readme;configuration;configurations;events;actions;channels;states;user;secrets;identifier;entities;interfaces;__advanced;attributes;extend(e,r){let{entities:n,actions:s,events:a,channels:o}=this._callBuilder(e,r),l=this;l.interfaces??={};let d=Object.values(n).map(x=>x.name),f=d.length===0?e.name:`${e.name}<${d.join(",")}>`,{resolved:g,statement:h}=zd({...e,entities:n,actions:D.stripUndefinedProps(s),events:D.stripUndefinedProps(a),channels:D.stripUndefinedProps(o)});return l.actions=D.mergeRecords(l.actions??{},g.actions,this._mergeActions),l.channels=D.mergeRecords(l.channels??{},g.channels,this._mergeChannels),l.events=D.mergeRecords(l.events??{},g.events,this._mergeEvents),l.interfaces[f]={id:e.id,...h},this}_callBuilder(e,r){let s={entities:Ld(this.entities)},a=r(s),o=D.pairs(a.entities).find(([d,f])=>!Wd(f));if(o)throw new Error(`Cannot extend interface "${e.name}" with entity "${o[0]}"; the provided schema is not part of the integration's entities.`);return{entities:D.mapValues(a.entities,d=>({name:qd(d),schema:d.schema})),actions:a.actions??{},events:a.events??{},channels:a.channels??{}}}_mergeActions=(e,r)=>({...e,...r,input:{schema:ft(e.input.schema,r.input.schema)},output:{schema:ft(e.output.schema,r.output.schema)}});_mergeEvents=(e,r)=>({...e,...r,schema:ft(e.schema,r.schema)});_mergeChannels=(e,r)=>{let n=D.mergeRecords(e.messages,r.messages,this._mergeMessage),s;(e.conversation||r.conversation)&&(s={tags:{...e.conversation?.tags,...r.conversation?.tags}});let a;return(e.message||r.message)&&(a={tags:{...e.message?.tags,...r.message?.tags}}),{...e,...r,messages:n,conversation:s,message:a}};_mergeMessage=(e,r)=>({schema:ft(e.schema,r.schema)})};var Ve=require("@botpress/client");var Vd=Ws(require("@botpress/client")),_n={retries:3,retryCondition:t=>Vd.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(Tm(e.response?.headers??{})??t)*1e3},Tm=t=>{let e=["RateLimit-Reset","X-RateLimit-Reset","Retry-After","ratelimit-reset","x-ratelimit-reset","retry-after"];for(let r of e){let n=t[r];if(n!==void 0)return bm(String(n))}},bm=t=>{let e=wm(t)?Pm(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},wm=t=>t.includes(" "),Pm=t=>{let e=xm(t);if(!e)return;let r=new Date;return Math.max(0,Math.floor((e.getTime()-r.getTime())/1e3))},xm=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};var gt=class{constructor(e){this._client=e}createConversation=e=>this._client.createConversation(e);getConversation=e=>this._client.getConversation(e);listConversations=e=>this._client.listConversations(e);getOrCreateConversation=e=>this._client.getOrCreateConversation(e);updateConversation=e=>this._client.updateConversation(e);deleteConversation=e=>this._client.deleteConversation(e);listParticipants=e=>this._client.listParticipants(e);addParticipant=e=>this._client.addParticipant(e);getParticipant=e=>this._client.getParticipant(e);removeParticipant=e=>this._client.removeParticipant(e);createEvent=e=>this._client.createEvent(e);getEvent=e=>this._client.getEvent(e);listEvents=e=>this._client.listEvents(e);createMessage=e=>this._client.createMessage(e);getOrCreateMessage=e=>this._client.getOrCreateMessage(e);getMessage=e=>this._client.getMessage(e);updateMessage=e=>this._client.updateMessage(e);listMessages=e=>this._client.listMessages(e);deleteMessage=e=>this._client.deleteMessage(e);createUser=e=>this._client.createUser(e);getUser=e=>this._client.getUser(e);listUsers=e=>this._client.listUsers(e);getOrCreateUser=e=>this._client.getOrCreateUser(e);updateUser=e=>this._client.updateUser(e);deleteUser=e=>this._client.deleteUser(e);getState=e=>this._client.getState(e);setState=e=>this._client.setState(e);getOrSetState=e=>this._client.getOrSetState(e);patchState=e=>this._client.patchState(e);configureIntegration=e=>this._client.configureIntegration(e);uploadFile=e=>this._client.uploadFile(e);upsertFile=e=>this._client.upsertFile(e);deleteFile=e=>this._client.deleteFile(e);listFiles=e=>this._client.listFiles(e);getFile=e=>this._client.getFile(e);updateFileMetadata=e=>this._client.updateFileMetadata(e);trackAnalytics=e=>this._client.trackAnalytics(e)};var Tn=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};var yt="#";var km=_.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),Gd=t=>{let e=t[qt],r=t[Hs],n=t[Ms],s=t[Ds],a=t[Ns],o=t[Vt],l=km.parse(t[Gt]);if(!e)throw new Error("Missing bot headers");if(!r)throw new Error("Missing bot user headers");if(!n)throw new Error("Missing integration headers");if(!s)throw new Error("Missing webhook headers");if(!o)throw new Error("Missing configuration headers");if(!l)throw new Error("Missing operation headers");return{botId:e,botUserId:r,integrationId:n,webhookId:s,operation:l,configurationType:a??null,configuration:o?JSON.parse(Buffer.from(o,"base64").toString("utf-8")):{}}};var Jd=Ws(require("util")),ht=class{defaultOptions;constructor(e){this.defaultOptions=e}info(...e){this._log("info",e)}debug(...e){this._log("debug",e)}warn(...e){this._log("warn",e)}error(...e){this._log("error",e)}_log(e,r){this._getConsoleMethod(e)(this._serializeMessage(r))}_serializeMessage(e){let r=Jd.default.format(...e);return process.env.BP_LOG_FORMAT==="json"?this.getJsonMessage(r):r}getJsonMessage(e){return JSON.stringify({msg:e,options:this.defaultOptions})}_getConsoleMethod(e){switch(e){case"debug":return console.debug;case"warn":return console.warn;case"error":return console.error;default:return console.info}}};var we=class extends ht{constructor(e){super({visibleToBotOwners:!0,...e})}with(e){return new we({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withVisibleToBotOwners(e){return this.with({visibleToBotOwners:e})}forBot(){return this.withVisibleToBotOwners(!0)}getJsonMessage(e){return JSON.stringify({msg:e,visible_to_bot_owner:this.defaultOptions.visibleToBotOwners,options:this.defaultOptions})}};var Sm=t=>["traceparent","tracestate","sentry-trace"].reduce((e,r)=>(t[r]&&(e[r]=t[r]),e),{}),Xd=t=>async e=>{let r=Gd(e.headers),[,n]=(e.headers.traceparent||"").split("-"),s=new Ve.Client({botId:r.botId,integrationId:r.integrationId,retry:_n,headers:Sm(e.headers)}),a=new gt(s),o=new we({traceId:n}),l={ctx:r,req:e,client:a,logger:o,instance:t};try{let d;switch(d=await Hm(l),r.operation){case"webhook_received":d=await Om(l);break;case"register":d=await Zm(l);break;case"unregister":d=await Im(l);break;case"message_created":d=await Am(l);break;case"action_triggered":d=await Rm(l);break;case"ping":d=await Em(l);break;case"create_user":d=await Bm(l);break;case"create_conversation":d=await Cm(l);break;default:if(!d)throw new Error(`Unknown operation ${r.operation}`)}return d?{...d,status:d.status??200}:{status:200}}catch(d){if((0,Ve.isApiError)(d)){let g=d.type==="Runtime"?d:new Ve.RuntimeError(d.message,d);return o.forBot().error(g.message),{status:g.code,body:JSON.stringify(g.toJSON())}}console.error(d);let f=new Ve.RuntimeError("An unexpected error occurred in the integration. Bot owners: Check logs for more informations. Integration owners: throw a RuntimeError to return a custom error message instead.");return o.forBot().error(f.message),{status:f.code,body:JSON.stringify(f.toJSON())}}},Em=async t=>{},Om=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{let{req:a}=oe(r);return s.webhook({client:t,ctx:e,req:a,logger:n})},Zm=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.register)return;let{webhookUrl:a}=oe(r);await s.register({client:t,ctx:e,webhookUrl:a,logger:n})},Im=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.unregister)return;let{webhookUrl:a}=oe(r);await s.unregister({ctx:e,webhookUrl:a,client:t,logger:n})},Bm=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createUser)return;let{tags:a}=oe(r);return await s.createUser({ctx:e,client:t,tags:a,logger:n})},Cm=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createConversation)return;let{channel:a,tags:o}=oe(r);return await s.createConversation({ctx:e,client:t,channel:a,tags:o,logger:n})},Am=async({ctx:t,req:e,client:r,logger:n,instance:s})=>{let{conversation:a,user:o,type:l,payload:d,message:f}=oe(e),g=s.channels[a.channel];if(!g)throw new Error(`Channel ${a.channel} not found`);let h=g.messages[l];if(!h)throw new Error(`Message of type ${l} not found in channel ${a.channel}`);await h({ctx:t,conversation:a,message:f,user:o,type:l,client:r,payload:d,ack:async({tags:O})=>{await r.updateMessage({id:f.id,tags:O})},logger:n})},Rm=async({req:t,ctx:e,client:r,logger:n,instance:s})=>{let{input:a,type:o}=oe(t);if(!o)throw new Error("Missing action type");let l=s.actions[o];if(!l)throw new Error(`Action ${o} not found`);let d=new Tn,g={output:await l({ctx:e,input:a,client:r,type:o,logger:n,metadata:d}),meta:d.toJSON()};return{body:JSON.stringify(g)}},Hm=async({instance:t,client:e,ctx:r,logger:n,req:s})=>{let a=t.integrationOperationHandler;if(a)return await a({client:e,ctx:r,logger:n,req:s})??{status:200}};var bn=class{constructor(e){this.props=e;this.actions=e.actions,this.channels=e.channels,this.register=e.register,this.unregister=e.unregister,this.createUser=e.createUser,this.createConversation=e.createConversation,this.webhook=e.handler,this.integrationOperationHandler=e.__advanced?.integrationOperationHandler}actions;channels;register;unregister;createUser;createConversation;webhook;integrationOperationHandler;handler=Xd(this);start=e=>Jt(this.handler,e)};var wn=class{constructor(e){this.props=e;this.integrations=e.integrations,this.plugins=e.plugins,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.states=e.states,this.configuration=e.configuration,this.events=e.events,this.recurringEvents=e.recurringEvents,this.actions=e.actions,this.tables=e.tables,this.workflows=e.workflows,this.attributes=e.attributes}integrations;plugins;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;attributes;addIntegration(e,r){let n=this;return n.integrations||(n.integrations={}),n.integrations[e.name]={enabled:r.enabled,...e,configurationType:r.configurationType,configuration:r.configuration,disabledChannels:r.disabledChannels},this}addPlugin(e,r){let n=this;n.plugins||(n.plugins={});let s=r.alias??e.name;return n.plugins[s]={...e,alias:r.alias,configuration:r.configuration,interfaces:r.interfaces},n.user=this._mergeUser(n.user,e.definition.user),n.conversation=this._mergeConversation(n.conversation,e.definition.conversation),n.message=this._mergeMessage(n.message,e.definition.message),n.recurringEvents=this._mergeRecurringEvents(n.recurringEvents,e.definition.recurringEvents),n.tables=this._mergeTables(n.tables,e.definition.tables),n.workflows=this._mergeWorkflows(n.workflows,e.definition.workflows),n.states=this._mergeStates(n.states,this._prefixKeys(e.definition.states,r.alias)),n.events=this._mergeEvents(n.events,this._prefixKeys(e.definition.events,r.alias)),n.actions=this._mergeActions(n.actions,this._prefixKeys(e.definition.actions,r.alias)),this}_mergeUser=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeConversation=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeMessage=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeStates=(e,r)=>({...e,...r});_mergeEvents=(e,r)=>({...e,...r});_mergeRecurringEvents=(e,r)=>({...e,...r});_mergeActions=(e,r)=>({...e,...r});_mergeTables=(e,r)=>({...e,...r});_mergeWorkflows=(e,r)=>({...e,...r});_prefixKeys=(e,r)=>!e||!r?e:D.mapKeys(e,n=>`${r}${yt}${n}`)};var Ge=require("@botpress/client");var Pe=class extends ht{constructor(e){super({...e})}with(e){return new Pe({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withWorkflowId(e){return this.with({workflowId:e})}withEventId(e){return this.with({eventId:e})}withMessageId(e){return this.with({messageId:e})}};var ce=class{constructor(e,r={before:{},after:{}}){this._client=e;this._hooks=r}getConversation=e=>this._run("getConversation",e);listConversations=e=>this._run("listConversations",e);updateConversation=e=>this._run("updateConversation",e);deleteConversation=e=>this._run("deleteConversation",e);listParticipants=e=>this._run("listParticipants",e);addParticipant=e=>this._run("addParticipant",e);getParticipant=e=>this._run("getParticipant",e);removeParticipant=e=>this._run("removeParticipant",e);createEvent=e=>this._run("createEvent",e);getEvent=e=>this._run("getEvent",e);listEvents=e=>this._run("listEvents",e);createMessage=e=>this._run("createMessage",e);getOrCreateMessage=e=>this._run("getOrCreateMessage",e);getMessage=e=>this._run("getMessage",e);updateMessage=e=>this._run("updateMessage",e);listMessages=e=>this._run("listMessages",e);deleteMessage=e=>this._run("deleteMessage",e);getUser=e=>this._run("getUser",e);listUsers=e=>this._run("listUsers",e);updateUser=e=>this._run("updateUser",e);deleteUser=e=>this._run("deleteUser",e);getState=e=>this._run("getState",e);setState=e=>this._run("setState",e);getOrSetState=e=>this._run("getOrSetState",e);patchState=e=>this._run("patchState",e);callAction=e=>this._run("callAction",e);uploadFile=e=>this._run("uploadFile",e);upsertFile=e=>this._run("upsertFile",e);deleteFile=e=>this._run("deleteFile",e);listFiles=e=>this._run("listFiles",e);getFile=e=>this._run("getFile",e);updateFileMetadata=e=>this._run("updateFileMetadata",e);searchFiles=e=>this._run("searchFiles",e);trackAnalytics=e=>this._run("trackAnalytics",e);getTableRow=e=>this._run("getTableRow",e);createTableRows=e=>this._run("createTableRows",e);findTableRows=e=>this._run("findTableRows",e);deleteTableRows=e=>this._run("deleteTableRows",e);updateTableRows=e=>this._run("updateTableRows",e);upsertTableRows=e=>this._run("upsertTableRows",e);createWorkflow=e=>this._run("createWorkflow",e);getWorkflow=e=>this._run("getWorkflow",e);updateWorkflow=e=>this._run("updateWorkflow",e);deleteWorkflow=e=>this._run("deleteWorkflow",e);listWorkflows=e=>this._run("listWorkflows",e);createConversation=e=>this._client.createConversation(e);getOrCreateConversation=e=>this._client.getOrCreateConversation(e);createUser=e=>this._client.createUser(e);getOrCreateUser=e=>this._client.getOrCreateUser(e);_run=async(e,r)=>{let n=this._hooks.before[e];n&&(r=await n(r));let s=await this._client[e](r),a=this._hooks.after[e];return a&&(s=await a(s,r)),s}};var mt=t=>new Proxy({},{get:(e,r)=>({listInstances:{all:n=>xe({workflowName:r,client:t,input:n}),running:n=>xe({workflowName:r,client:t,input:n,statuses:["in_progress"]}),scheduled:n=>xe({workflowName:r,client:t,input:n,statuses:["pending","listening"]}),allFinished:n=>xe({workflowName:r,client:t,input:n,statuses:["completed","cancelled","failed","timedout"]}),cancelled:n=>xe({workflowName:r,client:t,input:n,statuses:["cancelled"]}),failed:n=>xe({workflowName:r,client:t,input:n,statuses:["failed"]}),succeeded:n=>xe({workflowName:r,client:t,input:n,statuses:["completed"]}),timedOut:n=>xe({workflowName:r,client:t,input:n,statuses:["timedout"]})},startNewInstance:async n=>{let{workflow:s}=await t.createWorkflow({name:r,status:"pending",...n});return{workflow:ke({client:t,workflow:s})}}})}),xe=async t=>{let e=await t.client.listWorkflows({name:t.workflowName,statuses:t.statuses,...t.input});return{...e,workflows:e.workflows.map(r=>ke({client:t.client,workflow:r}))}},ke=t=>({...t.workflow,async update(e){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,...e});return{workflow:ke({client:t.client,workflow:r})}},async setFailed({failureReason:e}){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"failed",failureReason:e});return{workflow:ke({client:t.client,workflow:r})}},async setCompleted({output:e}={}){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"completed",output:e});return{workflow:ke({client:t.client,workflow:r})}},async cancel(){let{workflow:e}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return{workflow:ke({client:t.client,workflow:e})}}});var Mm=_.enum(["event_received","register","unregister","ping","action_triggered"]),Yd=t=>{let e=t[qt],r=t[Vt],n=t[$s],s=Mm.parse(t[Gt]);if(!e)throw new Error("Missing bot headers");if(!n)throw new Error("Missing type headers");if(!r)throw new Error("Missing configuration headers");if(!s)throw new Error("Missing operation headers");return{botId:e,operation:s,type:n,configuration:r?JSON.parse(Buffer.from(r,"base64").toString("utf-8")):{}}};var Y={status:200};var Us=t=>{switch(t){case"workflow_continued":return"continued";case"workflow_started":return"started";case"workflow_timedout":return"timed_out";default:throw new Error(`Unsupported workflow update type: ${t}`)}};var Dm=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],Qd=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!Dm.includes(e.payload.type))throw new Error("Unexpected event type");let r={...t,logger:Nm(t,e)};if(!e.payload.workflow.name)return r.logger.warn("Received workflow update event without a workflow name. Assuming this workflow was not defined by the bot.",e.payload.workflow),Y;switch(e.payload.type){case"child_workflow_deleted":case"child_workflow_finished":r.logger.info(`Received child workflow event "${e.payload.type}", but child workflows are not yet supported`);break;case"workflow_timedout":case"workflow_started":case"workflow_continued":return await $m(r,e);default:e.payload.type}return Y},Nm=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),$m=async(t,e)=>{let r=Us(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name];return!n||n.length===0?(t.logger.warn(`No ${r} handler found for workflow "${e.payload.workflow.name}"`),Y):(await jm(t,e),await Km(t,e),Y)},jm=async(t,e)=>{e.payload.workflow.status==="pending"&&await t.client.updateWorkflow({id:e.payload.workflow.id,status:"in_progress",eventId:e.id})},Km=async(t,e)=>{let r=Us(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name];for(let s of n)await s({...t,conversation:e.payload.conversation,user:e.payload.user,workflow:ke({...t,workflow:e.payload.workflow}),workflows:mt(t.client)})};var eu=t=>async e=>{let r=Yd(e.headers),n=new Pe,s=new Ge.Client({botId:r.botId,retry:_n}),a=new ce(s,{before:{createMessage:async l=>{let d=t.hookHandlers.before_outgoing_message[l.type]??[];for(let f of d){let g=new ce(s);l=(await f({client:g,ctx:r,logger:n.with({conversationId:l.conversationId,userId:l.userId}),data:l,...Se({client:g})}))?.data??l}return l},callAction:async l=>{let d=t.hookHandlers.before_outgoing_call_action[l.type]??[];for(let f of d){let g=new ce(s);l=(await f({client:g,ctx:r,logger:n,data:l,...Se({client:g})}))?.data??l}return l}},after:{createMessage:async l=>{let d=t.hookHandlers.after_outgoing_message[l.message.type]??[];for(let f of d){let g=new ce(s);l=(await f({client:g,ctx:r,logger:n.with({messageId:l.message.id,conversationId:l.message.conversationId,userId:l.message.userId}),data:l,...Se({client:g})}))?.data??l}return l},callAction:async(l,d)=>{let{type:f}=d,g=t.hookHandlers.after_outgoing_call_action[f]??[];for(let h of g){let x=new ce(s);l=(await h({client:x,ctx:r,logger:n,data:{type:f,...l},...Se({client:x})}))?.data??l}return l}}}),o={req:e,ctx:r,logger:n,client:a,self:t};try{switch(r.operation){case"action_triggered":return await Wm(o);case"event_received":return await Lm(o);case"register":return await Fm(o);case"unregister":return await zm(o);case"ping":return await Um(o);default:throw new Error(`Unknown operation ${r.operation}`)}}catch(l){let d=l instanceof Error?l:new Error(String(l));if((0,Ge.isApiError)(d)){let g=d.type==="Runtime"?d:new Ge.RuntimeError(d.message,d);return n.error(g.message),{status:g.code,body:JSON.stringify(g.toJSON())}}let f=new Ge.RuntimeError("An unexpected error occurred in the bot.",d);return n.error(f.message,d),{status:f.code,body:JSON.stringify(f.toJSON())}}},Um=async t=>Y,Fm=async t=>Y,zm=async t=>Y,Lm=async t=>{let{ctx:e,logger:r,req:n,client:s,self:a}=t,o={client:s,ctx:e,logger:r,...Se({client:s})},l=oe(n);if(o.logger=o.logger.with({eventId:l.event.id,messageId:l.event.messageId,conversationId:l.event.conversationId,userId:l.event.userId}),e.type==="workflow_update")return await Qd(t,l.event);if(e.type==="message_created"){let O=l.event,I=O.payload.message;o.logger=o.logger.with({messageId:I.id,conversationId:I.conversationId,userId:I.userId});let U=a.hookHandlers.before_incoming_message[I.type]??[];for(let q of U){let se=await q({...o,data:I});if(I=se?.data??I,se?.stop)return Y}let W={...o,user:O.payload.user,conversation:O.payload.conversation,message:I,event:O},Q=a.messageHandlers[I.type]??[];for(let q of Q)await q(W);let ae=a.hookHandlers.after_incoming_message[I.type]??[];for(let q of ae){let se=await q({...o,data:I});if(I=se?.data??I,se?.stop)return Y}return Y}if(e.type==="state_expired"){let I=l.event.payload.state,U={...o,state:I},W=a.stateExpiredHandlers["*"]??[];for(let Q of W)await Q(U);return Y}let d=l.event,f=a.hookHandlers.before_incoming_event[d.type]??[];for(let O of f){let I=await O({...o,data:d});if(d=I?.data??d,I?.stop)return Y}let g={...o,event:d},h=a.eventHandlers[d.type]??[];for(let O of h)await O(g);let x=a.hookHandlers.after_incoming_event[d.type]??[];for(let O of x){let I=await O({...o,data:d});if(d=I?.data??d,I?.stop)return Y}return Y},Wm=async({ctx:t,logger:e,req:r,client:n,self:s})=>{let{input:a,type:o}=oe(r);if(!o)throw new Error("Missing action type");let l=s.hookHandlers.before_incoming_call_action[o]??[];for(let x of l){let O=await x({ctx:t,logger:e,client:n,data:{type:o,input:a},...Se({client:n})});a=O?.data?.input??a,o=O?.data?.type??o}let d=s.actionHandlers[o];if(!d)throw new Error(`Action ${o} not found`);let f=await d({ctx:t,logger:e,input:a,client:n,type:o,...Se({client:n})}),g=s.hookHandlers.after_incoming_call_action[o]??[];for(let x of g){let O=await x({ctx:t,logger:e,client:n,data:{type:o,output:f},...Se({client:n})});o=O?.data?.type??o,f=O?.data?.output??f}return{status:200,body:JSON.stringify({output:f})}},Se=t=>({workflows:mt(t.client)});var Pn=class{constructor(e){this.props=e;this._actionHandlers=e.actions,this._plugins=e.plugins}_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_plugins={};_registerOrder=0;get actionHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._actionHandlers[r];if(n)return n;for(let s of Object.values(this._plugins))if(n=s.actionHandlers[r],n)return n}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.messageHandlers[r]??[]),s=this._messageHandlers[r]??[],a=this._messageHandlers["*"]??[],o=[...s,...a].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return S.unique([...n,...o])}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.eventHandlers[r]??[]),s=this._eventHandlers[r]??[],a=this._eventHandlers["*"]??[],o=[...s,...a].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return S.unique([...n,...o])}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.stateExpiredHandlers[r]??[]),s=this._stateExpiredHandlers[r]??[],a=this._stateExpiredHandlers["*"]??[],o=[...s,...a].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return S.unique([...n,...o])}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{if(this._hookHandlers[r])return new Proxy({},{get:(s,a)=>{let o=Object.values(this._plugins).flatMap(h=>h.hookHandlers[r]?.[a]??[]),l=this._hookHandlers[r]??{},d=l[a]??[],f=l["*"]??[],g=[...d,...f].sort((h,x)=>h.order-x.order).map(({handler:h})=>h);return S.unique([...o,...g])}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,a)=>{let o=n[a]?.sort((d,f)=>d.order-f.order).map(({handler:d})=>d)??[],l=Object.values(this._plugins).flatMap(d=>d.workflowHandlers[r]?.[a]??[]);return S.unique([...o,...l])}})}})}on={message:(e,r)=>{this._messageHandlers[e]=S.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=S.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=S.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=S.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=S.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=S.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=S.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=S.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=S.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=S.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=S.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=S.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=S.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=S.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=S.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=S.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};handler=eu(this);start=e=>Jt(this.handler,e)};var xn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.title=e.title,this.description=e.description,this.readme=e.readme,this.entities=e.entities??{},this.attributes=e.attributes;let r=this._getEntityReference(this.entities),n=e.events===void 0?{}:D.mapValues(e.events,o=>({...o,schema:o.schema(r)})),s=e.actions===void 0?{}:D.mapValues(e.actions,o=>({...o,input:{...o.input,schema:o.input.schema(r)},output:{...o.output,schema:o.output.schema(r)}})),a=e.channels===void 0?{}:D.mapValues(e.channels,o=>({...o,messages:D.mapValues(o.messages,l=>({...l,schema:l.schema(r)}))}));this.events=n,this.actions=s,this.channels=a}name;version;title;description;icon;readme;attributes;entities;events;actions;channels;_getEntityReference=e=>{let r={};for(let[n,s]of Object.entries(e)){let a=s.schema._def["x-zui"]?.title,o=s.schema._def.description,l=Ad.ref(n);a&&l.title(a),o&&l.describe(o),r[n]=l}return r}};var kn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.description=e.description,this.integrations=e.integrations,this.interfaces=e.interfaces,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.states=e.states,this.configuration=e.configuration,this.events=e.events,this.recurringEvents=e.recurringEvents,this.actions=e.actions,this.tables=e.tables,this.workflows=e.workflows,this.attributes=e.attributes}name;version;title;description;icon;readme;attributes;integrations;interfaces;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows};var Fs=":";var tu=t=>{let[e,r]=t.split(Fs);return!e||!r?null:{namespace:e,eventName:r}},ru=t=>`${t.namespace}${Fs}${t.actionName}`,nu=t=>`${t.namespace}${Fs}${t.eventName}`,su=(t,e)=>{let r=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},n=r.name,s=r.actions[t.actionName]?.name??t.actionName;return{namespace:n,actionName:s}},au=(t,e)=>{let r=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},n=r.name,s=r.events[t.eventName]?.name??t.eventName;return{namespace:n,eventName:s}};var iu=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,a)=>o=>qm({client:t,interfaces:e.interfaces,integrationOrInterfaceName:n,methodName:a,input:o})})}),qm=async({client:t,interfaces:e,integrationOrInterfaceName:r,methodName:n,input:s})=>{let a=su({namespace:r,actionName:n},e),o=ru(a);return(await t.callAction({type:o,input:s})).output};var Je=class{constructor(e){this._props=e}async emit(e){let{conversationId:r,userId:n,messageId:s}=this._props;await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:r,userId:n,messageId:s})}async schedule(e,r){let{conversationId:n,userId:s,messageId:a}=this._props;await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:n,userId:s,messageId:a,schedule:r})}withConversationId(e){return new Je({...this._props,conversationId:e})}withUserId(e){return new Je({...this._props,userId:e})}withMessageId(e){return new Je({...this._props,messageId:e})}},ou=(t,e)=>new Proxy({},{get:(r,n)=>{let s=e.alias!==void 0?`${e.alias}${yt}${n}`:n;return new Je({client:t,eventName:s})}});var zs=class{constructor(e,r,n){this._client=e;this._stateType=r;this._stateName=n}async get(e){return await this._client.getState({type:this._stateType,name:this._stateName,id:e}).then(r=>r.state.payload)}async set(e,r){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:r})}async getOrSet(e,r){return await this._client.getOrSetState({type:this._stateType,name:this._stateName,id:e,payload:r}).then(n=>n.state.payload)}async delete(e){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:null})}async patch(e,r){await this._client.patchState({type:this._stateType,name:this._stateName,id:e,payload:r})}},lu=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,a)=>{let o=e.alias!==void 0?`${e.alias}${yt}${a}`:a;return new zs(t,n,o)}})});var Sn=class{constructor(e){this.props=e;this._actionHandlers=e.actions}_runtimeProps;_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_registerOrder=0;initialize(e){return this._runtimeProps=e,this}get _runtime(){if(!this._runtimeProps)throw new Error("Plugin not correctly initialized. This is likely because you access your plugin config outside of an handler.");return this._runtimeProps}_getTools(e){let{configuration:r,interfaces:n,alias:s}=this._runtime,a=iu(e,this._runtime),o=lu(e,this._runtime),l=mt(e),d=ou(e,this._runtime);return{configuration:r,interfaces:n,actions:a,states:o,alias:s,workflows:l,events:d}}get actionHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._actionHandlers[r];if(n)return me.setName(s=>n({...s,...this._getTools(s.client)}),n.name)}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._messageHandlers[r]??[],s=this._messageHandlers["*"]??[];return S.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>me.setName(l=>o({...l,...this._getTools(l.client)}),o.name))}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._eventHandlers[r]??[],s=Object.entries(this._eventHandlers).filter(([l])=>this._eventResolvesTo(l,r)).flatMap(([,l])=>l??[]),a=this._eventHandlers["*"]??[];return S.unique([...n,...s,...a]).sort((l,d)=>l.order-d.order).map(({handler:l})=>me.setName(d=>l({...d,...this._getTools(d.client)}),l.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._stateExpiredHandlers[r]??[],s=this._stateExpiredHandlers["*"]??[];return S.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>me.setName(l=>o({...l,...this._getTools(l.client)}),o.name))}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._hookHandlers[r];if(n)return new Proxy({},{get:(s,a)=>{a=this._stripAliasPrefix(a);let o=n[a]??[],l=Object.entries(n).filter(([g])=>this._eventResolvesTo(g,a)).flatMap(([,g])=>g??[]),d=n["*"]??[];return S.unique([...o,...l,...d]).sort((g,h)=>g.order-h.order).map(({handler:g})=>me.setName(h=>g({...h,...this._getTools(h.client)}),g.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,a)=>(n[a]?.sort((l,d)=>l.order-d.order)??[]).map(({handler:l})=>me.setName(d=>l({...d,...this._getTools(d.client)}),l.name))})}})}on={message:(e,r)=>{this._messageHandlers[e]=S.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=S.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=S.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=S.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=S.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=S.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=S.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=S.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=S.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=S.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=S.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=S.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=S.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=S.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=S.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=S.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};_eventResolvesTo=(e,r)=>{let n=tu(e);if(!n)return!1;let s=au(n,this._runtime.interfaces);return nu(s)===r};_stripAliasPrefix=e=>{let{alias:r}=this._runtime;if(!r)return e;let n=`${r}:`;return e.startsWith(n)?e.slice(n.length):e}};0&&(module.exports={BRAND,Bot,BotDefinition,BotLogger,BotSpecificClient,DIRTY,EMPTY_PATH,INVALID,Integration,IntegrationDefinition,IntegrationLogger,IntegrationSpecificClient,InterfaceDefinition,NEVER,OK,ParseInputLazyPath,ParseStatus,Plugin,PluginDefinition,RuntimeError,Schema,WELL_KNOWN_ATTRIBUTES,ZodAny,ZodArray,ZodBigInt,ZodBoolean,ZodBranded,ZodCatch,ZodDate,ZodDefault,ZodDiscriminatedUnion,ZodEffects,ZodEnum,ZodError,ZodFirstPartyTypeKind,ZodFunction,ZodIntersection,ZodIssueCode,ZodLazy,ZodLiteral,ZodMap,ZodNaN,ZodNativeEnum,ZodNever,ZodNull,ZodNullable,ZodNumber,ZodObject,ZodOptional,ZodParsedType,ZodPipeline,ZodPromise,ZodReadonly,ZodRecord,ZodRef,ZodSchema,ZodSet,ZodString,ZodSymbol,ZodTransformer,ZodTuple,ZodType,ZodUndefined,ZodUnion,ZodUnknown,ZodVoid,addIssueToContext,agent,aimodel,any,array,bigint,boolean,botIdHeader,botUserIdHeader,coerce,configurationHeader,configurationTypeHeader,conversation,createZodEnum,cuid2Regex,cuidRegex,custom,datasource,date,discriminatedUnion,effect,emailRegex,enum:null,errorUtil,event,function:null,getErrorMap,getParsedType,instanceof:null,integrationIdHeader,intent,intersection,ipv4Regex,ipv6Regex,isAborted,isApiError,isAsync,isDirty,isEmojiRegex,isValid,knowledgebase,late,lazy,literal,makeIssue,map,mergeObjectSchemas,message,messages,nan,nativeEnum,never,null:null,nullable,number,object,objectUtil,oboolean,onumber,operationHeader,optional,ostring,parseBody,pipeline,preprocess,processCreateParams,promise,quotelessJson,readonly,record,ref,serve,set,setErrorMap,strictObject,string,symbol,table,tablerow,transformer,transforms,tuple,typeHeader,ulidRegex,undefined,union,unknown,user,util,uuidRegex,variable,void:null,webhookIdHeader,z});
68
68
  /*! Bundled license information:
69
69
 
70
70
  @bpinternal/zui/dist/index.js: