@botpress/sdk 5.4.3 → 5.5.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,20 +1,5 @@
1
- "use strict";var Pd=Object.create;var en=Object.defineProperty;var xd=Object.getOwnPropertyDescriptor;var kd=Object.getOwnPropertyNames;var Sd=Object.getPrototypeOf,Od=Object.prototype.hasOwnProperty;var nt=(t,e)=>{for(var n in e)en(t,n,{get:e[n],enumerable:!0})},Qi=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of kd(e))!Od.call(t,i)&&i!==n&&en(t,i,{get:()=>e[i],enumerable:!(r=xd(e,i))||r.enumerable});return t};var Rr=(t,e,n)=>(n=t!=null?Pd(Sd(t)):{},Qi(e||!t||!t.__esModule?en(n,"default",{value:t,enumerable:!0}):n,t)),Ed=t=>Qi(en({},"__esModule",{value:!0}),t);var fv={};nt(fv,{BRAND:()=>Jl,Bot:()=>Er,BotDefinition:()=>Or,BotLogger:()=>bt,BotSpecificClient:()=>he,DIRTY:()=>Ke,EMPTY_PATH:()=>Fl,INVALID:()=>x,Integration:()=>Sr,IntegrationDefinition:()=>Tr,IntegrationLogger:()=>Tt,IntegrationSpecificClient:()=>vt,InterfaceDefinition:()=>Ir,NEVER:()=>pu,OK:()=>G,ParseInputLazyPath:()=>oe,ParseStatus:()=>ne,Plugin:()=>Br,PluginDefinition:()=>Zr,RuntimeError:()=>Ar.RuntimeError,Schema:()=>E,WELL_KNOWN_ATTRIBUTES:()=>xy,ZodAny:()=>pt,ZodArray:()=>ft,ZodBigInt:()=>sr,ZodBoolean:()=>ar,ZodBranded:()=>or,ZodCatch:()=>lr,ZodDate:()=>cr,ZodDefault:()=>Vt,ZodDiscriminatedUnion:()=>Ti,ZodEffects:()=>Ae,ZodEnum:()=>Qe,ZodError:()=>me,ZodFirstPartyTypeKind:()=>hi,ZodFunction:()=>wi,ZodIntersection:()=>ur,ZodIssueCode:()=>h,ZodLazy:()=>dr,ZodLiteral:()=>pr,ZodMap:()=>Pi,ZodNaN:()=>xi,ZodNativeEnum:()=>fr,ZodNever:()=>ht,ZodNull:()=>gr,ZodNullable:()=>Fe,ZodNumber:()=>mr,ZodObject:()=>ze,ZodOptional:()=>we,ZodParsedType:()=>_,ZodPipeline:()=>hr,ZodPromise:()=>Gt,ZodReadonly:()=>Jt,ZodRecord:()=>ki,ZodRef:()=>Si,ZodSchema:()=>E,ZodSet:()=>Oi,ZodString:()=>J,ZodSymbol:()=>Hi,ZodTransformer:()=>Ae,ZodTuple:()=>We,ZodType:()=>E,ZodUndefined:()=>Yt,ZodUnion:()=>yr,ZodUnknown:()=>lt,ZodVoid:()=>Di,addIssueToContext:()=>v,agent:()=>Tc,aimodel:()=>kc,any:()=>Dc,array:()=>$c,bigint:()=>Bc,boolean:()=>ji,coerce:()=>du,conversation:()=>yc,createZodEnum:()=>qt,cuid2Regex:()=>Ii,cuidRegex:()=>Ei,custom:()=>_i,datasource:()=>Sc,date:()=>Ac,discriminatedUnion:()=>zc,effect:()=>Xr,emailRegex:()=>Ai,enum:()=>tu,errorUtil:()=>P,event:()=>bc,function:()=>Xc,getErrorMap:()=>ut,getParsedType:()=>be,instanceof:()=>Ic,intent:()=>xc,intersection:()=>Wc,ipv4Regex:()=>Ci,ipv6Regex:()=>Ri,isAborted:()=>mn,isApiError:()=>Ar.isApiError,isAsync:()=>zt,isDirty:()=>hn,isEmojiRegex:()=>uc,isValid:()=>dt,json:()=>Bd,knowledgebase:()=>Oc,late:()=>Ec,lazy:()=>Qc,literal:()=>eu,makeIssue:()=>Ft,map:()=>Jc,mergeObjectSchemas:()=>yt,message:()=>_c,messages:()=>Ui,nan:()=>Zc,nativeEnum:()=>nu,never:()=>Mc,null:()=>Hc,nullable:()=>su,number:()=>Mi,object:()=>Kc,objectUtil:()=>fn,oboolean:()=>uu,onumber:()=>cu,optional:()=>iu,ostring:()=>lu,parseBody:()=>le,pipeline:()=>ou,preprocess:()=>au,processCreateParams:()=>S,promise:()=>ru,quotelessJson:()=>$l,readonly:()=>Gc,record:()=>Vc,ref:()=>qc,serve:()=>Xt,set:()=>Yc,setErrorMap:()=>vi,strictObject:()=>Uc,string:()=>Ni,symbol:()=>Cc,table:()=>wc,tablerow:()=>Pc,transformer:()=>Xr,transforms:()=>$s,tuple:()=>Lc,ulidRegex:()=>Zi,undefined:()=>Rc,union:()=>Fc,unknown:()=>Nc,user:()=>vc,util:()=>Z,uuidRegex:()=>Bi,variable:()=>hc,version:()=>Xi,void:()=>jc,z:()=>y});module.exports=Ed(fv);var Ui={};nt(Ui,{defaults:()=>Py,markdown:()=>by,markdownBloc:()=>wy});var ti=Object.defineProperty,Id=Object.defineProperties,Zd=Object.getOwnPropertyDescriptors,pn=Object.getOwnPropertySymbols,Ns=Object.prototype.hasOwnProperty,Ms=Object.prototype.propertyIsEnumerable,es=(t,e,n)=>e in t?ti(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,u=(t,e)=>{for(var n in e||(e={}))Ns.call(e,n)&&es(t,n,e[n]);if(pn)for(var n of pn(e))Ms.call(e,n)&&es(t,n,e[n]);return t},f=(t,e)=>Id(t,Zd(e)),l=(t,e)=>ti(t,"name",{value:e,configurable:!0}),js=(t,e)=>{var n={};for(var r in t)Ns.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&pn)for(var r of pn(t))e.indexOf(r)<0&&Ms.call(t,r)&&(n[r]=t[r]);return n},qn=(t,e)=>{for(var n in e)ti(t,n,{get:e[n],enumerable:!0})},Bd={},$s={};qn($s,{errors:()=>Ks,fromJSONSchema:()=>hu,fromJSONSchemaLegacy:()=>Wh,fromObject:()=>Qr,toJSONSchema:()=>V,toJSONSchemaLegacy:()=>vy,toTypescriptSchema:()=>gi,toTypescriptType:()=>mi});var w="x-zui",y={};qn(y,{BRAND:()=>Jl,DIRTY:()=>Ke,EMPTY_PATH:()=>Fl,INVALID:()=>x,NEVER:()=>pu,OK:()=>G,ParseInputLazyPath:()=>oe,ParseStatus:()=>ne,Schema:()=>E,ZodAny:()=>pt,ZodArray:()=>ft,ZodBigInt:()=>sr,ZodBoolean:()=>ar,ZodBranded:()=>or,ZodCatch:()=>lr,ZodDate:()=>cr,ZodDefault:()=>Vt,ZodDiscriminatedUnion:()=>Ti,ZodEffects:()=>Ae,ZodEnum:()=>Qe,ZodError:()=>me,ZodFirstPartyTypeKind:()=>hi,ZodFunction:()=>wi,ZodIntersection:()=>ur,ZodIssueCode:()=>h,ZodLazy:()=>dr,ZodLiteral:()=>pr,ZodMap:()=>Pi,ZodNaN:()=>xi,ZodNativeEnum:()=>fr,ZodNever:()=>ht,ZodNull:()=>gr,ZodNullable:()=>Fe,ZodNumber:()=>mr,ZodObject:()=>ze,ZodOptional:()=>we,ZodParsedType:()=>_,ZodPipeline:()=>hr,ZodPromise:()=>Gt,ZodReadonly:()=>Jt,ZodRecord:()=>ki,ZodRef:()=>Si,ZodSchema:()=>E,ZodSet:()=>Oi,ZodString:()=>J,ZodSymbol:()=>Hi,ZodTransformer:()=>Ae,ZodTuple:()=>We,ZodType:()=>E,ZodUndefined:()=>Yt,ZodUnion:()=>yr,ZodUnknown:()=>lt,ZodVoid:()=>Di,addIssueToContext:()=>v,agent:()=>Tc,aimodel:()=>kc,any:()=>Dc,array:()=>$c,bigint:()=>Bc,boolean:()=>ji,coerce:()=>du,conversation:()=>yc,createZodEnum:()=>qt,cuid2Regex:()=>Ii,cuidRegex:()=>Ei,custom:()=>_i,datasource:()=>Sc,date:()=>Ac,default:()=>bh,discriminatedUnion:()=>zc,effect:()=>Xr,emailRegex:()=>Ai,enum:()=>tu,errorUtil:()=>P,event:()=>bc,function:()=>Xc,getErrorMap:()=>ut,getParsedType:()=>be,instanceof:()=>Ic,intent:()=>xc,intersection:()=>Wc,ipv4Regex:()=>Ci,ipv6Regex:()=>Ri,isAborted:()=>mn,isAsync:()=>zt,isDirty:()=>hn,isEmojiRegex:()=>uc,isValid:()=>dt,knowledgebase:()=>Oc,late:()=>Ec,lazy:()=>Qc,literal:()=>eu,makeIssue:()=>Ft,map:()=>Jc,message:()=>_c,nan:()=>Zc,nativeEnum:()=>nu,never:()=>Mc,null:()=>Hc,nullable:()=>su,number:()=>Mi,object:()=>Kc,objectUtil:()=>fn,oboolean:()=>uu,onumber:()=>cu,optional:()=>iu,ostring:()=>lu,pipeline:()=>ou,preprocess:()=>au,processCreateParams:()=>S,promise:()=>ru,quotelessJson:()=>$l,readonly:()=>Gc,record:()=>Vc,ref:()=>qc,set:()=>Yc,setErrorMap:()=>vi,strictObject:()=>Uc,string:()=>Ni,symbol:()=>Cc,table:()=>wc,tablerow:()=>Pc,transformer:()=>Xr,tuple:()=>Lc,ulidRegex:()=>Zi,undefined:()=>Rc,union:()=>Fc,unknown:()=>Nc,user:()=>vc,util:()=>Z,uuidRegex:()=>Bi,variable:()=>hc,void:()=>jc});var Ks={};qn(Ks,{JSONSchemaToZuiError:()=>Gn,ObjectToZuiError:()=>Ur,UnrepresentableGenericError:()=>Fr,UnsupportedJSONSchemaToZuiError:()=>Ee,UnsupportedZuiCheckToJSONSchemaError:()=>qs,UnsupportedZuiToJSONSchemaError:()=>te,UnsupportedZuiToTypescriptSchemaError:()=>He,UnsupportedZuiToTypescriptTypeError:()=>ta,UntitledDeclarationError:()=>ra,ZuiToJSONSchemaError:()=>Jn,ZuiToTypescriptSchemaError:()=>Ys,ZuiToTypescriptTypeError:()=>Yn,ZuiTransformError:()=>mt});var Us=class extends Error{constructor(e,n){super(n),this.transform=e}};l(Us,"ZuiTransformError");var mt=Us,Fs=class extends mt{constructor(e){super("json-schema-to-zui",e)}};l(Fs,"JSONSchemaToZuiError");var Gn=Fs,zs=class extends mt{constructor(e){super("object-to-zui",e)}};l(zs,"ObjectToZuiError");var Ur=zs,Ws=class extends mt{constructor(e){super("zui-to-json-schema",e)}};l(Ws,"ZuiToJSONSchemaError");var Jn=Ws,Ls=class extends Jn{constructor(e,{suggestedAlternative:n}={}){super(`Zod type ${e} cannot be transformed to JSON Schema.`+(n?` Suggested alternative: ${n}`:""))}};l(Ls,"UnsupportedZuiToJSONSchemaError");var te=Ls,Vs=class extends Jn{constructor({zodType:e,checkKind:n}){super(`Zod check .${n}() of type ${e} cannot be transformed to JSON Schema.`)}};l(Vs,"UnsupportedZuiCheckToJSONSchemaError");var qs=Vs,Gs=class extends Gn{constructor(e){super(`JSON Schema ${JSON.stringify(e)} cannot be transformed to ZUI type.`)}};l(Gs,"UnsupportedJSONSchemaToZuiError");var Ee=Gs,Js=class extends mt{constructor(e){super("zui-to-typescript-schema",e)}};l(Js,"ZuiToTypescriptSchemaError");var Ys=Js,Xs=class extends Ys{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript schema.`)}};l(Xs,"UnsupportedZuiToTypescriptSchemaError");var He=Xs,Qs=class extends mt{constructor(e){super("zui-to-typescript-type",e)}};l(Qs,"ZuiToTypescriptTypeError");var Yn=Qs,ea=class extends Yn{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript type.`)}};l(ea,"UnsupportedZuiToTypescriptTypeError");var ta=ea,na=class extends Yn{constructor(){super("Schema must have a title to be transformed to a TypeScript type with a declaration.")}};l(na,"UntitledDeclarationError");var ra=na,ia=class extends Yn{constructor(){super('ZodRef can only be transformed to a TypeScript type with a "type" declaration.')}};l(ia,"UnrepresentableGenericError");var Fr=ia,Ad=l((t,e)=>{let n={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[w]&&(n[w]=t._def[w]),t._def.minLength&&(n.minItems=t._def.minLength.value),t._def.maxLength&&(n.maxItems=t._def.maxLength.value),t._def.exactLength&&(n.minItems=t._def.exactLength.value,n.maxItems=t._def.exactLength.value),n},"zodArrayToJsonArray"),Cd=l(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[w]&&(e[w]=t._def[w]);for(let n of t._def.checks)switch(n.kind){case"min":{let r=n.inclusive?"minimum":"exclusiveMinimum",i=n.inclusive?"exclusiveMinimum":"minimum";e[r]=n.value,delete e[i];break}case"max":{let r=n.inclusive?"maximum":"exclusiveMaximum",i=n.inclusive?"exclusiveMaximum":"maximum";e[r]=n.value,delete e[i];break}case"int":e.type="integer";break;case"finite":{e.format="finite";break}case"multipleOf":e.multipleOf=n.value;break;default:}return e},"zodNumberToJsonNumber"),Rd=l((t,e)=>{let n={type:"array",description:t.description,uniqueItems:!0,items:e(t._def.valueType),"x-zui":t._def["x-zui"]};return t._def[w]&&(n[w]=t._def[w]),t._def.minSize&&(n.minItems=t._def.minSize.value),t._def.maxSize&&(n.maxItems=t._def.maxSize.value),n},"zodSetToJsonSet"),sa="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",aa="(([+-]\\d{2}(:?\\d{2})?)|Z)",Hd="Z",oa="(\\.\\d+)?",zr="\\.\\d{",Dd="}",la=l(t=>{let e=t.precision?zr+t.precision+Dd:t.precision===0?"":oa,n=t.offset?aa:Hd;return new RegExp(`^${sa}${e}${n}$`)},"generateDatetimeRegex"),Nd=l(t=>({precision:Md(t),offset:t.endsWith(`${aa}$`)}),"extractPrecisionAndOffset"),Md=l(t=>{let e=t.slice(1+sa.length);return e.startsWith(oa)?null:e.startsWith(zr)?parseInt(e.slice(zr.length)):0},"_extractPrecision"),Nt={};qn(Nt,{escapeSpecialChars:()=>jd});var jd=l(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function ni(t,e,n,r){r?.errorMessages&&n&&(t.errorMessage=f(u({},t.errorMessage),{[e]:n}))}l(ni,"addErrorMessage");function R(t,e,n,r,i){t[e]=n,ni(t,e,r,i)}l(R,"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 ri(t,e){let n=u({type:"string"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});function r(i){return e.patternStrategy==="escape"?Nt.escapeSpecialChars(i):i}if(l(r,"processPattern"),t.checks)for(let i of t.checks)switch(i.kind){case"min":R(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,i.value):i.value,i.message,e);break;case"max":R(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,i.value):i.value,i.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Re(n,"email",i.message,e);break;case"format:idn-email":Re(n,"idn-email",i.message,e);break;case"pattern:zod":_e(n,j.email,i.message,e);break}break;case"url":Re(n,"uri",i.message,e);break;case"uuid":Re(n,"uuid",i.message,e);break;case"regex":_e(n,i.regex.source,i.message,e);break;case"cuid":_e(n,j.cuid,i.message,e);break;case"cuid2":_e(n,j.cuid2,i.message,e);break;case"startsWith":_e(n,"^"+r(i.value),i.message,e);break;case"endsWith":_e(n,r(i.value)+"$",i.message,e);break;case"datetime":Re(n,"date-time",i.message,e);break;case"length":R(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,i.value):i.value,i.message,e),R(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,i.value):i.value,i.message,e);break;case"includes":{_e(n,r(i.value),i.message,e);break}case"ip":{i.version!=="v6"&&Re(n,"ipv4",i.message,e),i.version!=="v4"&&Re(n,"ipv6",i.message,e);break}case"emoji":_e(n,j.emoji,i.message,e);break;case"ulid":{_e(n,j.ulid,i.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return n}l(ri,"parseStringDef");var Re=l((t,e,n,r)=>{var i;t.format||(i=t.anyOf)!=null&&i.some(s=>s.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push(u({format:t.format},t.errorMessage&&r.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(u({format:e},n&&r.errorMessages&&{errorMessage:{format:n}}))):R(t,"format",e,n,r)},"addFormat"),_e=l((t,e,n,r)=>{var i;t.pattern||(i=t.allOf)!=null&&i.some(s=>s.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push(u({pattern:t.pattern},t.errorMessage&&r.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(u({pattern:e},n&&r.errorMessages&&{errorMessage:{pattern:n}}))):R(t,"pattern",e,n,r)},"addPattern"),$d=l(t=>{let e={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[w]&&(e[w]=t._def[w]);for(let n of t._def.checks)switch(n.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=n.version==="v6"?"ipv6":"ipv4",e.pattern=n.version==="v6"?j.ipv6:j.ipv4;break;case"datetime":e.format="date-time",(n.precision!==null||n.offset)&&(e.pattern=la(n).source,e[w]=f(u({},e[w]),{precision:n.precision,offset:n.offset}));break;case"url":e.format="uri";break;case"endsWith":e.pattern=`${Nt.escapeSpecialChars(n.value)}$`;break;case"startsWith":e.pattern=`^${Nt.escapeSpecialChars(n.value)}`;break;case"includes":let r=n.position&&n.position>=1?`^(?:.{${n.position}}).*`:"";e.pattern=`${r}${Nt.escapeSpecialChars(n.value)}`;break;case"regex":e.pattern=n.regex.source;break;case"length":e.minLength=e.maxLength=Math.max(0,n.value);break;case"min":e.minLength=Math.max(0,n.value);break;case"max":e.maxLength=Math.max(0,n.value);break;default:throw new qs({zodType:p.ZodFirstPartyTypeKind.ZodString,checkKind:n.kind})}return e},"zodStringToJsonString"),Kd=l((t,e)=>{let n={type:"array",description:t.description,items:t._def.items.map(r=>e(r))};return t._def[w]&&(n[w]=t._def[w]),t._def.rest&&(n.additionalItems=e(t._def.rest)),n},"zodTupleToJsonTuple");function V(t){let e=t,n=e._def;switch(n.typeName){case p.ZodFirstPartyTypeKind.ZodString:return $d(e);case p.ZodFirstPartyTypeKind.ZodNumber:return Cd(e);case p.ZodFirstPartyTypeKind.ZodNaN:throw new te(p.ZodFirstPartyTypeKind.ZodNaN);case p.ZodFirstPartyTypeKind.ZodBigInt:throw new te(p.ZodFirstPartyTypeKind.ZodBigInt,{suggestedAlternative:"serialize bigint to string"});case p.ZodFirstPartyTypeKind.ZodBoolean:return{type:"boolean",description:n.description,"x-zui":n["x-zui"]};case p.ZodFirstPartyTypeKind.ZodDate:throw new te(p.ZodFirstPartyTypeKind.ZodDate,{suggestedAlternative:"use z.string().datetime() instead"});case p.ZodFirstPartyTypeKind.ZodUndefined:return Hr(n);case p.ZodFirstPartyTypeKind.ZodNull:return Dr(n);case p.ZodFirstPartyTypeKind.ZodAny:return{description:n.description,"x-zui":n["x-zui"]};case p.ZodFirstPartyTypeKind.ZodUnknown:return{description:n.description,"x-zui":f(u({},n["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodUnknown}})};case p.ZodFirstPartyTypeKind.ZodNever:return{not:!0,description:n.description,"x-zui":n["x-zui"]};case p.ZodFirstPartyTypeKind.ZodVoid:throw new te(p.ZodFirstPartyTypeKind.ZodVoid);case p.ZodFirstPartyTypeKind.ZodArray:return Ad(e,V);case p.ZodFirstPartyTypeKind.ZodObject:let r=Object.entries(n.shape()),i=r.filter(([g,m])=>!m.isOptional()),s=i.length?i.map(([g])=>g):void 0,a=r.map(([g,m])=>[g,m.mandatory()]).map(([g,m])=>[g,V(m)]),o=!1;return n.unknownKeys instanceof p.ZodType?o=V(n.unknownKeys):n.unknownKeys==="passthrough"&&(o=!0),{type:"object",description:n.description,properties:Object.fromEntries(a),required:s,additionalProperties:o,"x-zui":n["x-zui"]};case p.ZodFirstPartyTypeKind.ZodUnion:return{description:n.description,anyOf:n.options.map(g=>V(g)),"x-zui":n["x-zui"]};case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return{description:n.description,anyOf:n.options.map(g=>V(g)),"x-zui":f(u({},n["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion,discriminator:n.discriminator}})};case p.ZodFirstPartyTypeKind.ZodIntersection:let c=V(n.left),d=V(n.right);return"additionalProperties"in c&&delete c.additionalProperties,"additionalProperties"in d&&delete d.additionalProperties,{description:n.description,allOf:[c,d],"x-zui":n["x-zui"]};case p.ZodFirstPartyTypeKind.ZodTuple:return Kd(e,V);case p.ZodFirstPartyTypeKind.ZodRecord:return{type:"object",description:n.description,additionalProperties:V(n.valueType),"x-zui":n["x-zui"]};case p.ZodFirstPartyTypeKind.ZodMap:throw new te(p.ZodFirstPartyTypeKind.ZodMap);case p.ZodFirstPartyTypeKind.ZodSet:return Rd(e,V);case p.ZodFirstPartyTypeKind.ZodFunction:throw new te(p.ZodFirstPartyTypeKind.ZodFunction);case p.ZodFirstPartyTypeKind.ZodLazy:throw new te(p.ZodFirstPartyTypeKind.ZodLazy);case p.ZodFirstPartyTypeKind.ZodLiteral:if(typeof n.value=="string")return{type:"string",description:n.description,const:n.value,"x-zui":n["x-zui"]};if(typeof n.value=="number")return{type:"number",description:n.description,const:n.value,"x-zui":n["x-zui"]};if(typeof n.value=="boolean")return{type:"boolean",description:n.description,const:n.value,"x-zui":n["x-zui"]};if(n.value===null)return Dr(n);if(n.value===void 0)return Hr(n);{p.util.assertEqual(!0);let g=typeof n.value;throw new Jn(`Unsupported literal type: "${g}"`)}case p.ZodFirstPartyTypeKind.ZodEnum:return{type:"string",description:n.description,enum:n.values,"x-zui":n["x-zui"]};case p.ZodFirstPartyTypeKind.ZodEffects:throw new te(p.ZodFirstPartyTypeKind.ZodEffects);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new te(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return{description:n.description,anyOf:[V(n.innerType),Hr()],"x-zui":f(u({},n["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodOptional}})};case p.ZodFirstPartyTypeKind.ZodNullable:return{anyOf:[V(n.innerType),Dr()],"x-zui":f(u({},n["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodNullable}})};case p.ZodFirstPartyTypeKind.ZodDefault:return f(u({},V(n.innerType)),{default:n.defaultValue()});case p.ZodFirstPartyTypeKind.ZodCatch:throw new te(p.ZodFirstPartyTypeKind.ZodCatch);case p.ZodFirstPartyTypeKind.ZodPromise:throw new te(p.ZodFirstPartyTypeKind.ZodPromise);case p.ZodFirstPartyTypeKind.ZodBranded:throw new te(p.ZodFirstPartyTypeKind.ZodBranded);case p.ZodFirstPartyTypeKind.ZodPipeline:throw new te(p.ZodFirstPartyTypeKind.ZodPipeline);case p.ZodFirstPartyTypeKind.ZodSymbol:throw new te(p.ZodFirstPartyTypeKind.ZodPipeline);case p.ZodFirstPartyTypeKind.ZodReadonly:return f(u({},V(n.innerType)),{readOnly:!0});case p.ZodFirstPartyTypeKind.ZodRef:return{$ref:n.uri,description:n.description,"x-zui":n["x-zui"]};default:p.util.assertNever(n)}}l(V,"toJSONSchema");var Hr=l(t=>({not:!0,description:t?.description,"x-zui":f(u({},t?.["x-zui"]),{def:{typeName:p.ZodFirstPartyTypeKind.ZodUndefined}})}),"undefinedSchema"),Dr=l(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),Ud=typeof global=="object"&&global&&global.Object===Object&&global,ca=Ud,Fd=typeof self=="object"&&self&&self.Object===Object&&self,zd=ca||Fd||Function("return this")(),xe=zd,Wd=xe.Symbol,Ze=Wd,ua=Object.prototype,Ld=ua.hasOwnProperty,Vd=ua.toString,Pt=Ze?Ze.toStringTag:void 0;function da(t){var e=Ld.call(t,Pt),n=t[Pt];try{t[Pt]=void 0;var r=!0}catch{}var i=Vd.call(t);return r&&(e?t[Pt]=n:delete t[Pt]),i}l(da,"getRawTag");var qd=da,Gd=Object.prototype,Jd=Gd.toString;function pa(t){return Jd.call(t)}l(pa,"objectToString");var Yd=pa,Xd="[object Null]",Qd="[object Undefined]",ts=Ze?Ze.toStringTag:void 0;function fa(t){return t==null?t===void 0?Qd:Xd:ts&&ts in Object(t)?qd(t):Yd(t)}l(fa,"baseGetTag");var Le=fa;function ga(t){return t!=null&&typeof t=="object"}l(ga,"isObjectLike");var Ue=ga,ep="[object Symbol]";function ma(t){return typeof t=="symbol"||Ue(t)&&Le(t)==ep}l(ma,"isSymbol");var ii=ma;function ha(t,e){for(var n=-1,r=t==null?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}l(ha,"arrayMap");var ya=ha,tp=Array.isArray,Pe=tp,np=1/0,ns=Ze?Ze.prototype:void 0,rs=ns?ns.toString:void 0;function si(t){if(typeof t=="string")return t;if(Pe(t))return ya(t,si)+"";if(ii(t))return rs?rs.call(t):"";var e=t+"";return e=="0"&&1/t==-np?"-0":e}l(si,"baseToString");var rp=si;function va(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}l(va,"isObject");var ct=va;function _a(t){return t}l(_a,"identity");var ip=_a,sp="[object AsyncFunction]",ap="[object Function]",op="[object GeneratorFunction]",lp="[object Proxy]";function Ta(t){if(!ct(t))return!1;var e=Le(t);return e==ap||e==op||e==sp||e==lp}l(Ta,"isFunction");var ba=Ta,cp=xe["__core-js_shared__"],Nr=cp,is=(function(){var t=/[^.]+$/.exec(Nr&&Nr.keys&&Nr.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function wa(t){return!!is&&is in t}l(wa,"isMasked");var up=wa,dp=Function.prototype,pp=dp.toString;function Pa(t){if(t!=null){try{return pp.call(t)}catch{}try{return t+""}catch{}}return""}l(Pa,"toSource");var Ve=Pa,fp=/[\\^$.*+?()[\]{}|]/g,gp=/^\[object .+?Constructor\]$/,mp=Function.prototype,hp=Object.prototype,yp=mp.toString,vp=hp.hasOwnProperty,_p=RegExp("^"+yp.call(vp).replace(fp,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function xa(t){if(!ct(t)||up(t))return!1;var e=ba(t)?_p:gp;return e.test(Ve(t))}l(xa,"baseIsNative");var Tp=xa;function ka(t,e){return t?.[e]}l(ka,"getValue");var bp=ka;function Sa(t,e){var n=bp(t,e);return Tp(n)?n:void 0}l(Sa,"getNative");var qe=Sa,wp=qe(xe,"WeakMap"),Wr=wp,Pp=(function(){try{var t=qe(Object,"defineProperty");return t({},"",{}),t}catch{}})(),ss=Pp,xp=9007199254740991,kp=/^(?:0|[1-9]\d*)$/;function Oa(t,e){var n=typeof t;return e=e??xp,!!e&&(n=="number"||n!="symbol"&&kp.test(t))&&t>-1&&t%1==0&&t<e}l(Oa,"isIndex");var ai=Oa;function Ea(t,e,n){e=="__proto__"&&ss?ss(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}l(Ea,"baseAssignValue");var Ia=Ea;function Za(t,e){return t===e||t!==t&&e!==e}l(Za,"eq");var oi=Za,Sp=Object.prototype,Op=Sp.hasOwnProperty;function Ba(t,e,n){var r=t[e];(!(Op.call(t,e)&&oi(r,n))||n===void 0&&!(e in t))&&Ia(t,e,n)}l(Ba,"assignValue");var Ep=Ba,Ip=9007199254740991;function Aa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Ip}l(Aa,"isLength");var li=Aa;function Ca(t){return t!=null&&li(t.length)&&!ba(t)}l(Ca,"isArrayLike");var Ra=Ca,Zp=Object.prototype;function Ha(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||Zp;return t===n}l(Ha,"isPrototype");var Da=Ha;function Na(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}l(Na,"baseTimes");var Bp=Na,Ap="[object Arguments]";function Ma(t){return Ue(t)&&Le(t)==Ap}l(Ma,"baseIsArguments");var as=Ma,ja=Object.prototype,Cp=ja.hasOwnProperty,Rp=ja.propertyIsEnumerable,Hp=as((function(){return arguments})())?as:function(t){return Ue(t)&&Cp.call(t,"callee")&&!Rp.call(t,"callee")},$a=Hp;function Ka(){return!1}l(Ka,"stubFalse");var Dp=Ka,Ua=typeof exports=="object"&&exports&&!exports.nodeType&&exports,os=Ua&&typeof module=="object"&&module&&!module.nodeType&&module,Np=os&&os.exports===Ua,ls=Np?xe.Buffer:void 0,Mp=ls?ls.isBuffer:void 0,jp=Mp||Dp,Lr=jp,$p="[object Arguments]",Kp="[object Array]",Up="[object Boolean]",Fp="[object Date]",zp="[object Error]",Wp="[object Function]",Lp="[object Map]",Vp="[object Number]",qp="[object Object]",Gp="[object RegExp]",Jp="[object Set]",Yp="[object String]",Xp="[object WeakMap]",Qp="[object ArrayBuffer]",ef="[object DataView]",tf="[object Float32Array]",nf="[object Float64Array]",rf="[object Int8Array]",sf="[object Int16Array]",af="[object Int32Array]",of="[object Uint8Array]",lf="[object Uint8ClampedArray]",cf="[object Uint16Array]",uf="[object Uint32Array]",H={};H[tf]=H[nf]=H[rf]=H[sf]=H[af]=H[of]=H[lf]=H[cf]=H[uf]=!0;H[$p]=H[Kp]=H[Qp]=H[Up]=H[ef]=H[Fp]=H[zp]=H[Wp]=H[Lp]=H[Vp]=H[qp]=H[Gp]=H[Jp]=H[Yp]=H[Xp]=!1;function Fa(t){return Ue(t)&&li(t.length)&&!!H[Le(t)]}l(Fa,"baseIsTypedArray");var df=Fa;function za(t){return function(e){return t(e)}}l(za,"baseUnary");var pf=za,Wa=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Mt=Wa&&typeof module=="object"&&module&&!module.nodeType&&module,ff=Mt&&Mt.exports===Wa,Mr=ff&&ca.process,gf=(function(){try{var t=Mt&&Mt.require&&Mt.require("util").types;return t||Mr&&Mr.binding&&Mr.binding("util")}catch{}})(),cs=gf,us=cs&&cs.isTypedArray,mf=us?pf(us):df,La=mf,hf=Object.prototype,yf=hf.hasOwnProperty;function Va(t,e){var n=Pe(t),r=!n&&$a(t),i=!n&&!r&&Lr(t),s=!n&&!r&&!i&&La(t),a=n||r||i||s,o=a?Bp(t.length,String):[],c=o.length;for(var d in t)(e||yf.call(t,d))&&!(a&&(d=="length"||i&&(d=="offset"||d=="parent")||s&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||ai(d,c)))&&o.push(d);return o}l(Va,"arrayLikeKeys");var qa=Va;function Ga(t,e){return function(n){return t(e(n))}}l(Ga,"overArg");var Ja=Ga,vf=Ja(Object.keys,Object),_f=vf,Tf=Object.prototype,bf=Tf.hasOwnProperty;function Ya(t){if(!Da(t))return _f(t);var e=[];for(var n in Object(t))bf.call(t,n)&&n!="constructor"&&e.push(n);return e}l(Ya,"baseKeys");var wf=Ya;function Xa(t){return Ra(t)?qa(t):wf(t)}l(Xa,"keys");var ci=Xa;function Qa(t){var e=[];if(t!=null)for(var n in Object(t))e.push(n);return e}l(Qa,"nativeKeysIn");var Pf=Qa,xf=Object.prototype,kf=xf.hasOwnProperty;function eo(t){if(!ct(t))return Pf(t);var e=Da(t),n=[];for(var r in t)r=="constructor"&&(e||!kf.call(t,r))||n.push(r);return n}l(eo,"baseKeysIn");var Sf=eo;function to(t){return Ra(t)?qa(t,!0):Sf(t)}l(to,"keysIn");var Of=to,Ef=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,If=/^\w*$/;function no(t,e){if(Pe(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||ii(t)?!0:If.test(t)||!Ef.test(t)||e!=null&&t in Object(e)}l(no,"isKey");var ui=no,Zf=qe(Object,"create"),$t=Zf;function ro(){this.__data__=$t?$t(null):{},this.size=0}l(ro,"hashClear");var Bf=ro;function io(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}l(io,"hashDelete");var Af=io,Cf="__lodash_hash_undefined__",Rf=Object.prototype,Hf=Rf.hasOwnProperty;function so(t){var e=this.__data__;if($t){var n=e[t];return n===Cf?void 0:n}return Hf.call(e,t)?e[t]:void 0}l(so,"hashGet");var Df=so,Nf=Object.prototype,Mf=Nf.hasOwnProperty;function ao(t){var e=this.__data__;return $t?e[t]!==void 0:Mf.call(e,t)}l(ao,"hashHas");var jf=ao,$f="__lodash_hash_undefined__";function oo(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=$t&&e===void 0?$f:e,this}l(oo,"hashSet");var Kf=oo;function Ge(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}l(Ge,"Hash");Ge.prototype.clear=Bf;Ge.prototype.delete=Af;Ge.prototype.get=Df;Ge.prototype.has=jf;Ge.prototype.set=Kf;var ds=Ge;function lo(){this.__data__=[],this.size=0}l(lo,"listCacheClear");var Uf=lo;function co(t,e){for(var n=t.length;n--;)if(oi(t[n][0],e))return n;return-1}l(co,"assocIndexOf");var Xn=co,Ff=Array.prototype,zf=Ff.splice;function uo(t){var e=this.__data__,n=Xn(e,t);if(n<0)return!1;var r=e.length-1;return n==r?e.pop():zf.call(e,n,1),--this.size,!0}l(uo,"listCacheDelete");var Wf=uo;function po(t){var e=this.__data__,n=Xn(e,t);return n<0?void 0:e[n][1]}l(po,"listCacheGet");var Lf=po;function fo(t){return Xn(this.__data__,t)>-1}l(fo,"listCacheHas");var Vf=fo;function go(t,e){var n=this.__data__,r=Xn(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}l(go,"listCacheSet");var qf=go;function Je(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}l(Je,"ListCache");Je.prototype.clear=Uf;Je.prototype.delete=Wf;Je.prototype.get=Lf;Je.prototype.has=Vf;Je.prototype.set=qf;var Qn=Je,Gf=qe(xe,"Map"),Kt=Gf;function mo(){this.size=0,this.__data__={hash:new ds,map:new(Kt||Qn),string:new ds}}l(mo,"mapCacheClear");var Jf=mo;function ho(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}l(ho,"isKeyable");var Yf=ho;function yo(t,e){var n=t.__data__;return Yf(e)?n[typeof e=="string"?"string":"hash"]:n.map}l(yo,"getMapData");var er=yo;function vo(t){var e=er(this,t).delete(t);return this.size-=e?1:0,e}l(vo,"mapCacheDelete");var Xf=vo;function _o(t){return er(this,t).get(t)}l(_o,"mapCacheGet");var Qf=_o;function To(t){return er(this,t).has(t)}l(To,"mapCacheHas");var eg=To;function bo(t,e){var n=er(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}l(bo,"mapCacheSet");var tg=bo;function Ye(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}l(Ye,"MapCache");Ye.prototype.clear=Jf;Ye.prototype.delete=Xf;Ye.prototype.get=Qf;Ye.prototype.has=eg;Ye.prototype.set=tg;var tr=Ye,ng="Expected a function";function nr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(ng);var n=l(function(){var r=arguments,i=e?e.apply(this,r):r[0],s=n.cache;if(s.has(i))return s.get(i);var a=t.apply(this,r);return n.cache=s.set(i,a)||s,a},"memoized");return n.cache=new(nr.Cache||tr),n}l(nr,"memoize");nr.Cache=tr;var rg=nr,ig=500;function wo(t){var e=rg(t,function(r){return n.size===ig&&n.clear(),r}),n=e.cache;return e}l(wo,"memoizeCapped");var sg=wo,ag=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,og=/\\(\\)?/g,lg=sg(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ag,function(n,r,i,s){e.push(i?s.replace(og,"$1"):r||n)}),e}),cg=lg;function Po(t){return t==null?"":rp(t)}l(Po,"toString");var ug=Po;function xo(t,e){return Pe(t)?t:ui(t,e)?[t]:cg(ug(t))}l(xo,"castPath");var rr=xo,dg=1/0;function ko(t){if(typeof t=="string"||ii(t))return t;var e=t+"";return e=="0"&&1/t==-dg?"-0":e}l(ko,"toKey");var Lt=ko;function So(t,e){e=rr(e,t);for(var n=0,r=e.length;t!=null&&n<r;)t=t[Lt(e[n++])];return n&&n==r?t:void 0}l(So,"baseGet");var di=So;function Oo(t,e,n){var r=t==null?void 0:di(t,e);return r===void 0?n:r}l(Oo,"get");var pg=Oo;function Eo(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}l(Eo,"arrayPush");var Io=Eo,fg=Ja(Object.getPrototypeOf,Object),Zo=fg,gg="[object Object]",mg=Function.prototype,hg=Object.prototype,Bo=mg.toString,yg=hg.hasOwnProperty,vg=Bo.call(Object);function Ao(t){if(!Ue(t)||Le(t)!=gg)return!1;var e=Zo(t);if(e===null)return!0;var n=yg.call(e,"constructor")&&e.constructor;return typeof n=="function"&&n instanceof n&&Bo.call(n)==vg}l(Ao,"isPlainObject");var ps=Ao;function Co(){this.__data__=new Qn,this.size=0}l(Co,"stackClear");var _g=Co;function Ro(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}l(Ro,"stackDelete");var Tg=Ro;function Ho(t){return this.__data__.get(t)}l(Ho,"stackGet");var bg=Ho;function Do(t){return this.__data__.has(t)}l(Do,"stackHas");var wg=Do,Pg=200;function No(t,e){var n=this.__data__;if(n instanceof Qn){var r=n.__data__;if(!Kt||r.length<Pg-1)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new tr(r)}return n.set(t,e),this.size=n.size,this}l(No,"stackSet");var xg=No;function Xe(t){var e=this.__data__=new Qn(t);this.size=e.size}l(Xe,"Stack");Xe.prototype.clear=_g;Xe.prototype.delete=Tg;Xe.prototype.get=bg;Xe.prototype.has=wg;Xe.prototype.set=xg;var rn=Xe;function Mo(t,e){for(var n=-1,r=t==null?0:t.length,i=0,s=[];++n<r;){var a=t[n];e(a,n,t)&&(s[i++]=a)}return s}l(Mo,"arrayFilter");var kg=Mo;function jo(){return[]}l(jo,"stubArray");var $o=jo,Sg=Object.prototype,Og=Sg.propertyIsEnumerable,fs=Object.getOwnPropertySymbols,Eg=fs?function(t){return t==null?[]:(t=Object(t),kg(fs(t),function(e){return Og.call(t,e)}))}:$o,Ko=Eg,Ig=Object.getOwnPropertySymbols,Zg=Ig?function(t){for(var e=[];t;)Io(e,Ko(t)),t=Zo(t);return e}:$o,Bg=Zg;function Uo(t,e,n){var r=e(t);return Pe(t)?r:Io(r,n(t))}l(Uo,"baseGetAllKeys");var Fo=Uo;function zo(t){return Fo(t,ci,Ko)}l(zo,"getAllKeys");var gs=zo;function Wo(t){return Fo(t,Of,Bg)}l(Wo,"getAllKeysIn");var Ag=Wo,Cg=qe(xe,"DataView"),Vr=Cg,Rg=qe(xe,"Promise"),qr=Rg,Hg=qe(xe,"Set"),Gr=Hg,ms="[object Map]",Dg="[object Object]",hs="[object Promise]",ys="[object Set]",vs="[object WeakMap]",_s="[object DataView]",Ng=Ve(Vr),Mg=Ve(Kt),jg=Ve(qr),$g=Ve(Gr),Kg=Ve(Wr),De=Le;(Vr&&De(new Vr(new ArrayBuffer(1)))!=_s||Kt&&De(new Kt)!=ms||qr&&De(qr.resolve())!=hs||Gr&&De(new Gr)!=ys||Wr&&De(new Wr)!=vs)&&(De=l(function(t){var e=Le(t),n=e==Dg?t.constructor:void 0,r=n?Ve(n):"";if(r)switch(r){case Ng:return _s;case Mg:return ms;case jg:return hs;case $g:return ys;case Kg:return vs}return e},"getTag"));var Ts=De,Ug=xe.Uint8Array,bs=Ug,Fg="__lodash_hash_undefined__";function Lo(t){return this.__data__.set(t,Fg),this}l(Lo,"setCacheAdd");var zg=Lo;function Vo(t){return this.__data__.has(t)}l(Vo,"setCacheHas");var Wg=Vo;function Ut(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new tr;++e<n;)this.add(t[e])}l(Ut,"SetCache");Ut.prototype.add=Ut.prototype.push=zg;Ut.prototype.has=Wg;var Lg=Ut;function qo(t,e){for(var n=-1,r=t==null?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}l(qo,"arraySome");var Vg=qo;function Go(t,e){return t.has(e)}l(Go,"cacheHas");var qg=Go,Gg=1,Jg=2;function Jo(t,e,n,r,i,s){var a=n&Gg,o=t.length,c=e.length;if(o!=c&&!(a&&c>o))return!1;var d=s.get(t),g=s.get(e);if(d&&g)return d==e&&g==t;var m=-1,T=!0,I=n&Jg?new Lg:void 0;for(s.set(t,e),s.set(e,t);++m<o;){var k=t[m],$=e[m];if(r)var z=a?r($,k,m,e,t,s):r(k,$,m,t,e,s);if(z!==void 0){if(z)continue;T=!1;break}if(I){if(!Vg(e,function(Q,se){if(!qg(I,se)&&(k===Q||i(k,Q,n,r,s)))return I.push(se)})){T=!1;break}}else if(!(k===$||i(k,$,n,r,s))){T=!1;break}}return s.delete(t),s.delete(e),T}l(Jo,"equalArrays");var Yo=Jo;function Xo(t){var e=-1,n=Array(t.size);return t.forEach(function(r,i){n[++e]=[i,r]}),n}l(Xo,"mapToArray");var Yg=Xo;function Qo(t){var e=-1,n=Array(t.size);return t.forEach(function(r){n[++e]=r}),n}l(Qo,"setToArray");var Xg=Qo,Qg=1,em=2,tm="[object Boolean]",nm="[object Date]",rm="[object Error]",im="[object Map]",sm="[object Number]",am="[object RegExp]",om="[object Set]",lm="[object String]",cm="[object Symbol]",um="[object ArrayBuffer]",dm="[object DataView]",ws=Ze?Ze.prototype:void 0,jr=ws?ws.valueOf:void 0;function el(t,e,n,r,i,s,a){switch(n){case dm:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case um:return!(t.byteLength!=e.byteLength||!s(new bs(t),new bs(e)));case tm:case nm:case sm:return oi(+t,+e);case rm:return t.name==e.name&&t.message==e.message;case am:case lm:return t==e+"";case im:var o=Yg;case om:var c=r&Qg;if(o||(o=Xg),t.size!=e.size&&!c)return!1;var d=a.get(t);if(d)return d==e;r|=em,a.set(t,e);var g=Yo(o(t),o(e),r,i,s,a);return a.delete(t),g;case cm:if(jr)return jr.call(t)==jr.call(e)}return!1}l(el,"equalByTag");var pm=el,fm=1,gm=Object.prototype,mm=gm.hasOwnProperty;function tl(t,e,n,r,i,s){var a=n&fm,o=gs(t),c=o.length,d=gs(e),g=d.length;if(c!=g&&!a)return!1;for(var m=c;m--;){var T=o[m];if(!(a?T in e:mm.call(e,T)))return!1}var I=s.get(t),k=s.get(e);if(I&&k)return I==e&&k==t;var $=!0;s.set(t,e),s.set(e,t);for(var z=a;++m<c;){T=o[m];var Q=t[T],se=e[T];if(r)var ge=a?r(se,Q,T,e,t,s):r(Q,se,T,t,e,s);if(!(ge===void 0?Q===se||i(Q,se,n,r,s):ge)){$=!1;break}z||(z=T=="constructor")}if($&&!z){var ae=t.constructor,ee=e.constructor;ae!=ee&&"constructor"in t&&"constructor"in e&&!(typeof ae=="function"&&ae instanceof ae&&typeof ee=="function"&&ee instanceof ee)&&($=!1)}return s.delete(t),s.delete(e),$}l(tl,"equalObjects");var hm=tl,ym=1,Ps="[object Arguments]",xs="[object Array]",tn="[object Object]",vm=Object.prototype,ks=vm.hasOwnProperty;function nl(t,e,n,r,i,s){var a=Pe(t),o=Pe(e),c=a?xs:Ts(t),d=o?xs:Ts(e);c=c==Ps?tn:c,d=d==Ps?tn:d;var g=c==tn,m=d==tn,T=c==d;if(T&&Lr(t)){if(!Lr(e))return!1;a=!0,g=!1}if(T&&!g)return s||(s=new rn),a||La(t)?Yo(t,e,n,r,i,s):pm(t,e,c,n,r,i,s);if(!(n&ym)){var I=g&&ks.call(t,"__wrapped__"),k=m&&ks.call(e,"__wrapped__");if(I||k){var $=I?t.value():t,z=k?e.value():e;return s||(s=new rn),i($,z,n,r,s)}}return T?(s||(s=new rn),hm(t,e,n,r,i,s)):!1}l(nl,"baseIsEqualDeep");var _m=nl;function pi(t,e,n,r,i){return t===e?!0:t==null||e==null||!Ue(t)&&!Ue(e)?t!==t&&e!==e:_m(t,e,n,r,pi,i)}l(pi,"baseIsEqual");var ir=pi,Tm=1,bm=2;function rl(t,e,n,r){var i=n.length,s=i,a=!r;if(t==null)return!s;for(t=Object(t);i--;){var o=n[i];if(a&&o[2]?o[1]!==t[o[0]]:!(o[0]in t))return!1}for(;++i<s;){o=n[i];var c=o[0],d=t[c],g=o[1];if(a&&o[2]){if(d===void 0&&!(c in t))return!1}else{var m=new rn;if(r)var T=r(d,g,c,t,e,m);if(!(T===void 0?ir(g,d,Tm|bm,r,m):T))return!1}}return!0}l(rl,"baseIsMatch");var wm=rl;function il(t){return t===t&&!ct(t)}l(il,"isStrictComparable");var sl=il;function al(t){for(var e=ci(t),n=e.length;n--;){var r=e[n],i=t[r];e[n]=[r,i,sl(i)]}return e}l(al,"getMatchData");var Pm=al;function ol(t,e){return function(n){return n==null?!1:n[t]===e&&(e!==void 0||t in Object(n))}}l(ol,"matchesStrictComparable");var ll=ol;function cl(t){var e=Pm(t);return e.length==1&&e[0][2]?ll(e[0][0],e[0][1]):function(n){return n===t||wm(n,t,e)}}l(cl,"baseMatches");var xm=cl;function ul(t,e){return t!=null&&e in Object(t)}l(ul,"baseHasIn");var km=ul;function dl(t,e,n){e=rr(e,t);for(var r=-1,i=e.length,s=!1;++r<i;){var a=Lt(e[r]);if(!(s=t!=null&&n(t,a)))break;t=t[a]}return s||++r!=i?s:(i=t==null?0:t.length,!!i&&li(i)&&ai(a,i)&&(Pe(t)||$a(t)))}l(dl,"hasPath");var Sm=dl;function pl(t,e){return t!=null&&Sm(t,e,km)}l(pl,"hasIn");var Om=pl,Em=1,Im=2;function fl(t,e){return ui(t)&&sl(e)?ll(Lt(t),e):function(n){var r=pg(n,t);return r===void 0&&r===e?Om(n,t):ir(e,r,Em|Im)}}l(fl,"baseMatchesProperty");var Zm=fl;function gl(t){return function(e){return e?.[t]}}l(gl,"baseProperty");var Bm=gl;function ml(t){return function(e){return di(e,t)}}l(ml,"basePropertyDeep");var Am=ml;function hl(t){return ui(t)?Bm(Lt(t)):Am(t)}l(hl,"property");var Cm=hl;function yl(t){return typeof t=="function"?t:t==null?ip:typeof t=="object"?Pe(t)?Zm(t[0],t[1]):xm(t):Cm(t)}l(yl,"baseIteratee");var fi=yl;function vl(t){return function(e,n,r){for(var i=-1,s=Object(e),a=r(e),o=a.length;o--;){var c=a[t?o:++i];if(n(s[c],c,s)===!1)break}return e}}l(vl,"createBaseFor");var Rm=vl,Hm=Rm(),Dm=Hm;function _l(t,e){return t&&Dm(t,e,ci)}l(_l,"baseForOwn");var Nm=_l;function Tl(t,e){return ir(t,e)}l(Tl,"isEqual");var Ie=Tl;function bl(t,e,n){n=typeof n=="function"?n:void 0;var r=n?n(t,e):void 0;return r===void 0?ir(t,e,void 0,n):!!r}l(bl,"isEqualWith");var Mm=bl;function wl(t){return t===void 0}l(wl,"isUndefined");var Ss=wl;function Pl(t,e){var n={};return e=fi(e,3),Nm(t,function(r,i,s){Ia(n,i,e(r,i,s))}),n}l(Pl,"mapValues");var jm=Pl,$m="Expected a function";function xl(t){if(typeof t!="function")throw new TypeError($m);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)}}l(xl,"negate");var Km=xl;function kl(t,e,n,r){if(!ct(t))return t;e=rr(e,t);for(var i=-1,s=e.length,a=s-1,o=t;o!=null&&++i<s;){var c=Lt(e[i]),d=n;if(c==="__proto__"||c==="constructor"||c==="prototype")return t;if(i!=a){var g=o[c];d=r?r(g,c,o):void 0,d===void 0&&(d=ct(g)?g:ai(e[i+1])?[]:{})}Ep(o,c,d),o=o[c]}return t}l(kl,"baseSet");var Um=kl;function Sl(t,e,n){for(var r=-1,i=e.length,s={};++r<i;){var a=e[r],o=di(t,a);n(o,a)&&Um(s,rr(a,t),o)}return s}l(Sl,"basePickBy");var Fm=Sl;function Ol(t,e){if(t==null)return{};var n=ya(Ag(t),function(r){return[r]});return e=fi(e),Fm(t,n,function(r,i){return e(r,i[0])})}l(Ol,"pickBy");var zm=Ol;function El(t,e){return zm(t,Km(fi(e)))}l(El,"omitBy");var Os=El;function Il(t){return typeof t=="symbol"?"symbol":typeof t=="bigint"?`${t.toString()}n`:b(t)}l(Il,"primitiveToTypscriptLiteralType");function b(t){return typeof t>"u"?"undefined":typeof t=="symbol"?t.description?`Symbol(${b(t.description)})`:"Symbol()":typeof t=="bigint"?`BigInt(${t.toString()})`:typeof t=="string"?Al(t):JSON.stringify(t)}l(b,"primitiveToTypescriptValue");function ot(t){return typeof t>"u"?"undefined":JSON.stringify(t)}l(ot,"unknownToTypescriptValue");var Zl=l((t,e)=>{let n=Object.entries(t),r=e?" as const":"";return`{ ${n.map(([i,s])=>`${Jr(i)}: ${ot(s)}`).join(", ")} }${r}`},"recordOfUnknownToTypescriptRecord"),Jr=l(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:b(t),"toPropertyKey"),Wm=l(t=>t.charAt(0).toUpperCase()+t.slice(1),"capitalize"),Bl=l(t=>{let e=/[^a-zA-Z0-9_]/g;return t.split(e).map(Wm).filter(r=>!!r).join("")},"toTypeArgumentName"),Es=l(t=>{for(var e;t.length&&!((e=t[0])!=null&&e.trim());)t.shift();for(;t.length&&!t[t.length-1].trim();)t.pop()},"trimEmptyLinesInPlace"),F=l(t=>{t=t?.replace(/(\n(\s*)?){3,}/g,`
2
-
3
- `);let e=l(i=>i.startsWith("* ")?` ${i}`:` * ${i}`,"ensureLineStartsWithAsterisk"),n=l(i=>i.replace(/\*\//g,"*\\/"),"escapeCommentEnd"),r=(t??"").split(`
4
- `).map(i=>i.trim());return Es(r),r.length&&(r[0]=r[0].replace(/^\/\*\*?/,""),r[r.length-1]=r[r.length-1].replace(/\*\/$/,"")),Es(r),r.length===0?"":r.length===1?`/** ${n(r[0])} */`:`/**
5
- ${r.map(e).map(n).join(`
6
- `)}
7
- */`},"getMultilineComment");function Al(t){if(typeof t!="string")return"";let n=String.raw`${t}`.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/"/g,'\\"').replace(/'/g,"\\'");return n.includes("`")?`"${n}"`:n.includes("'")?`"${n}"`:`'${n}'`}l(Al,"escapeString");var Lm=l(t=>{let e=[];if(t.exactLength){let{value:n,message:r}=t.exactLength;e.push(`.length(${b(n)}, ${b(r)})`)}if(t.minLength){let{value:n,message:r}=t.minLength;e.push(`.min(${b(n)}, ${b(r)})`)}if(t.maxLength){let{value:n,message:r}=t.maxLength;e.push(`.max(${b(n)}, ${b(r)})`)}return e.join("")},"generateArrayChecks"),Vm=l(t=>{let e=t.checks;return e.length===0?"":e.map(qm).join("")},"generateBigIntChecks"),qm=l(t=>{switch(t.kind){case"min":return`.min(${b(t.value)}, ${b(t.message)})`;case"max":return`.max(${b(t.value)}, ${b(t.message)})`;case"multipleOf":return`.multipleOf(${b(t.value)}, ${b(t.message)})`;default:return""}},"_generateBigIntCheck"),Gm=l(t=>{let e=t.checks;return e.length===0?"":e.map(Jm).join("")},"generateDateChecks"),Jm=l(t=>{switch(t.kind){case"min":return`.min(${Is(t.value)}, ${b(t.message)})`;case"max":return`.max(${Is(t.value)}, ${b(t.message)})`;default:return""}},"_generateDateCheck"),Is=l(t=>`new Date(${t})`,"dateTs"),Ym=l(t=>{let e=t.checks;return e.length===0?"":e.map(Xm).join("")},"generateNumberChecks"),Xm=l(t=>{switch(t.kind){case"min":return`.min(${b(t.value)}, ${b(t.message)})`;case"max":return`.max(${b(t.value)}, ${b(t.message)})`;case"int":return`.int(${b(t.message)})`;case"multipleOf":return`.multipleOf(${b(t.value)}, ${b(t.message)})`;case"finite":return`.finite(${b(t.message)})`;default:return""}},"_generateNumberCheck"),Qm=l(t=>{let e=[];if(t.minSize){let{value:n,message:r}=t.minSize;e.push(`.min(${b(n)}, ${b(r)})`)}if(t.maxSize){let{value:n,message:r}=t.maxSize;e.push(`.max(${b(n)}, ${b(r)})`)}return e.join("")},"generateSetChecks"),eh=l(t=>{let e=t.checks;return e.length===0?"":e.map(th).join("")},"generateStringChecks"),th=l(t=>{switch(t.kind){case"min":return`.min(${b(t.value)}, ${b(t.message)})`;case"max":return`.max(${b(t.value)}, ${b(t.message)})`;case"length":return`.length(${b(t.value)}, ${b(t.message)})`;case"email":return`.email(${b(t.message)})`;case"url":return`.url(${b(t.message)})`;case"emoji":return`.emoji(${b(t.message)})`;case"uuid":return`.uuid(${b(t.message)})`;case"cuid":return`.cuid(${b(t.message)})`;case"cuid2":return`.cuid2(${b(t.message)})`;case"ulid":return`.ulid(${b(t.message)})`;case"includes":let e=ot({message:t.message,position:t.position});return`.includes(${b(t.value)}, ${e})`;case"startsWith":return`.startsWith(${b(t.value)}, ${b(t.message)})`;case"endsWith":return`.endsWith(${b(t.value)}, ${b(t.message)})`;case"regex":return`.regex(${String(t.regex)}, ${b(t.message)})`;case"trim":return".trim()";case"toLowerCase":return".toLowerCase()";case"toUpperCase":return".toUpperCase()";case"datetime":let r=t.precision===null?void 0:t.precision;return`.datetime(${ot({message:t.message,precision:r,offset:t.offset})})`;case"ip":return`.ip(${ot({message:t.message,version:t.version})})`;default:return""}},"_generateStringCheck");function gi(t){return N(t)}l(gi,"toTypescriptSchema");function N(t){let n=t._def;switch(n.typeName){case p.ZodFirstPartyTypeKind.ZodString:return`z.string()${eh(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodNumber:return`z.number()${Ym(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodNaN:return`z.nan()${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodBigInt:return`z.bigint()${Vm(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodBoolean:return`z.boolean()${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodDate:return`z.date()${Gm(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodUndefined:return`z.undefined()${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodNull:return`z.null()${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodAny:return`z.any()${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodUnknown:return`z.unknown()${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodNever:return`z.never()${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodVoid:return`z.void()${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodArray:return`z.array(${N(n.type)})${Lm(n)}${C(n,n.type)}`;case p.ZodFirstPartyTypeKind.ZodObject:let r=jm(n.shape(),N),i=t.additionalProperties(),s=i?`.catchall(${N(i)})`:"";return["z.object({",...Object.entries(r).map(([bd,wd])=>` ${bd}: ${wd},`),`})${s}${C(n)}`].join(`
8
- `).trim();case p.ZodFirstPartyTypeKind.ZodUnion:return`z.union([${n.options.map(N).join(", ")}])${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let o=n.options.map(N);return`z.discriminatedUnion(${b(n.discriminator)}, [${o.join(", ")}])${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodIntersection:let d=N(n.left),g=N(n.right);return`z.intersection(${d}, ${g})${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodTuple:return`z.tuple([${n.items.map(N).join(", ")}])${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodRecord:let T=N(n.keyType),I=N(n.valueType);return`z.record(${T}, ${I})${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodMap:let k=N(n.keyType),$=N(n.valueType);return`z.map(${k}, ${$})${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodSet:return`z.set(${N(n.valueType)})${Qm(n)}${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodFunction:let z=n.args.items.map(N),Q=z.length?`.args(${z.join(", ")})`:"",se=N(n.returns);return`z.function()${Q}.returns(${se})${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodLazy:return`z.lazy(() => ${N(n.getter())})${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodLiteral:return`z.literal(${b(n.value)})${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodEnum:return`z.enum([${n.values.map(b).join(", ")}])${C(n)}`.trim();case p.ZodFirstPartyTypeKind.ZodEffects:throw new He(p.ZodFirstPartyTypeKind.ZodEffects);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new He(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return`z.optional(${N(n.innerType)})${C(n,n.innerType)}`.trim();case p.ZodFirstPartyTypeKind.ZodNullable:return`z.nullable(${N(n.innerType)})${C(n,n.innerType)}`.trim();case p.ZodFirstPartyTypeKind.ZodDefault:let ee=ot(n.defaultValue());return`z.default(${N(n.innerType)}, ${ee})${C(n,n.innerType)}`.trim();case p.ZodFirstPartyTypeKind.ZodCatch:throw new He(p.ZodFirstPartyTypeKind.ZodCatch);case p.ZodFirstPartyTypeKind.ZodPromise:return`z.promise(${N(n.type)})${C(n,n.type)}`.trim();case p.ZodFirstPartyTypeKind.ZodBranded:throw new He(p.ZodFirstPartyTypeKind.ZodBranded);case p.ZodFirstPartyTypeKind.ZodPipeline:throw new He(p.ZodFirstPartyTypeKind.ZodPipeline);case p.ZodFirstPartyTypeKind.ZodSymbol:throw new He(p.ZodFirstPartyTypeKind.ZodSymbol);case p.ZodFirstPartyTypeKind.ZodReadonly:return`z.readonly(${N(n.innerType)})${C(n,n.innerType)}`.trim();case p.ZodFirstPartyTypeKind.ZodRef:return`z.ref(${b(n.uri)})${C(n)}`.trim();default:Z.assertNever(n)}}l(N,"sUnwrapZod");var C=l((t,e)=>{let n=e?._def;return`${rh(t,n)}${nh(t,n)}`},"_addMetadata"),nh=l((t,e)=>!t.description||e&&e.description===t.description?"":`.describe(${b(t.description)})`,"_maybeDescribe"),rh=l((t,e)=>`${ih(t,e)}${sh(t,e)}${ah(t,e)}${oh(t,e)}${lh(t,e)}${ch(t,e)}${uh(t,e)}`,"_addZuiExtensions"),ih=l((t,e)=>{var n,r;let i=(n=t[w])==null?void 0:n.title;return!i||e&&((r=e[w])==null?void 0:r.title)===i?"":`.title(${b(i)})`},"_maybeTitle"),sh=l((t,e)=>{var n,r;let i=(n=t[w])==null?void 0:n.displayAs;return!i||e&&Ie((r=e[w])==null?void 0:r.displayAs,i)?"":`.displayAs(${Zl({id:i[0],params:i[1]})})`},"_maybeDisplayAs"),ah=l((t,e)=>{var n,r;let i=(n=t[w])==null?void 0:n.disabled;return!i||e&&((r=e[w])==null?void 0:r.disabled)===i?"":`.disabled(${i})`},"_maybeDisabled"),oh=l((t,e)=>{var n,r;let i=(n=t[w])==null?void 0:n.hidden;return!i||e&&((r=e[w])==null?void 0:r.hidden)===i?"":`.hidden(${i})`},"_maybeHidden"),lh=l((t,e)=>{var n,r;let i=(n=t[w])==null?void 0:n.placeholder;return!i||e&&((r=e[w])==null?void 0:r.placeholder)===i?"":`.placeholder(${b(i)})`},"_maybePlaceholder"),ch=l((t,e)=>{var n,r;let i=(n=t[w])==null?void 0:n.secret;return!i||e&&((r=e[w])==null?void 0:r.secret)===i?"":".secret()"},"_maybeSecret"),uh=l((t,e)=>{var n,r;let i=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],s=Object.entries((n=t[w])!=null?n:{}).filter(([a])=>!i.includes(a));if(s.length===0)return"";if(e){let a=Object.entries((r=e[w])!=null?r:{}).filter(([o])=>!i.includes(o));if(Ie(Object.fromEntries(s),Object.fromEntries(a)))return""}return`.metadata(${Zl(Object.fromEntries(s))})`},"_maybeSetMetadata"),Cl=["string","number","boolean","unknown","void","any","null","undefined","never","bigint","symbol","object"],dh=5,ph=l(t=>Cl.includes(t),"isPrimitive"),fh=l(t=>Cl.map(e=>`${e}[]`).includes(t),"isArrayOfPrimitives"),$r=l(t=>t.replace(/ +/g," ").trim(),"stripSpaces"),Rl=class{constructor(e,n){this.key=e,this.value=n}};l(Rl,"KeyValue");var nn=Rl,Hl=class{constructor(e){this.schema=e}};l(Hl,"FnParameters");var Zs=Hl,Dl=class{constructor(e){this.schema=e}};l(Dl,"FnReturn");var Bs=Dl,Nl=class{constructor(e){this.props=e}};l(Nl,"Declaration");var jt=Nl;function mi(t,e={}){let n=hh(t,e),r=B(n,e);return e.formatter&&(r=e.formatter(r)),r}l(mi,"toTypescriptType");var As=l(t=>t.endsWith("?")?t:`${t}?`,"_optionalKey");function B(t,e){var n,r,i;let s=f(u({},e),{declaration:!1,parent:t});if(t===null)return"";if(t instanceof jt)return gh(t,s);if(t instanceof nn){let c;if(t.value instanceof p.ZodOptional?c=t.value:t.value instanceof p.ZodDefault&&e.treatDefaultAsOptional&&(c=t.value._def.innerType.optional()),c){let k=c._def.innerType;return k instanceof p.Schema&&!k.description&&c.description&&(k=k?.describe(c.description)),B(new nn(As(t.key),k),s)}let d=F(t.value._def.description||t.value.description),g=d?.trim().length>0?`
9
- `:"",m=t.value.describe(""),I=t.value instanceof p.ZodAny?As(t.key):t.key;return`${g}${d}${g}${I}: ${B(m,s)}${g}`}if(t instanceof Zs){if(t.schema instanceof p.ZodTuple){let m="";for(let T=0;T<t.schema.items.length;T++){let I=(i=(r=(n=t.schema.items[T])==null?void 0:n.ui)==null?void 0:r.title)!=null?i:`arg${T}`,k=t.schema.items[T];m+=`${B(new nn(Jr(I),k),s)}${T<t.schema.items.length-1?", ":""} `}return m}let c=t.schema.naked()instanceof p.ZodLiteral,d=B(t.schema,s).trim();return d.startsWith("{")&&d.endsWith("}")||d.startsWith("[")&&d.endsWith("]")||d.startsWith("(")&&d.endsWith(")")||d.startsWith("Array<")&&d.endsWith(">")||d.startsWith("Record<")&&d.endsWith(">")||fh(d)||c?`args: ${d}`:d}if(t instanceof Bs)return t.schema instanceof p.ZodOptional?`${B(t.schema.unwrap(),s)} | undefined`:B(t.schema,s);let a=t,o=a._def;switch(o.typeName){case p.ZodFirstPartyTypeKind.ZodString:return`${F(a.description)} string`.trim();case p.ZodFirstPartyTypeKind.ZodNumber:case p.ZodFirstPartyTypeKind.ZodNaN:case p.ZodFirstPartyTypeKind.ZodBigInt:return`${F(a.description)} number`.trim();case p.ZodFirstPartyTypeKind.ZodBoolean:return`${F(a.description)} boolean`.trim();case p.ZodFirstPartyTypeKind.ZodDate:return`${F(a.description)} Date`.trim();case p.ZodFirstPartyTypeKind.ZodUndefined:return`${F(a.description)} undefined`.trim();case p.ZodFirstPartyTypeKind.ZodNull:return`${F(a.description)} null`.trim();case p.ZodFirstPartyTypeKind.ZodAny:return`${F(a.description)} any`.trim();case p.ZodFirstPartyTypeKind.ZodUnknown:return`${F(a.description)} unknown`.trim();case p.ZodFirstPartyTypeKind.ZodNever:return`${F(a.description)} never`.trim();case p.ZodFirstPartyTypeKind.ZodVoid:return`${F(a.description)} void`.trim();case p.ZodFirstPartyTypeKind.ZodArray:let c=B(o.type,s);return ph(c)?`${c}[]`:`Array<${c}>`;case p.ZodFirstPartyTypeKind.ZodObject:return`{ ${Object.entries(o.shape()).map(([ee,Cr])=>Cr instanceof p.Schema?B(new nn(Jr(ee),Cr),s):`${ee}: unknown`).join("; ")} }`;case p.ZodFirstPartyTypeKind.ZodUnion:let g=o.options.map(ee=>B(ee,s));return`${F(a.description)}
10
- ${g.join(" | ")}`;case p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let m=o.options.map(ee=>B(ee,s));return`${F(a.description)}
11
- ${m.join(" | ")}`;case p.ZodFirstPartyTypeKind.ZodIntersection:return`${B(o.left,s)} & ${B(o.right,s)}`;case p.ZodFirstPartyTypeKind.ZodTuple:return o.items.length===0?"[]":`[${o.items.map(ee=>B(ee,s)).join(", ")}]`;case p.ZodFirstPartyTypeKind.ZodRecord:let I=B(o.keyType,s),k=B(o.valueType,s);return`${F(a.description)} { [key: ${I}]: ${k} }`;case p.ZodFirstPartyTypeKind.ZodMap:return`Map<${B(o.keyType,s)}, ${B(o.valueType,s)}>`;case p.ZodFirstPartyTypeKind.ZodSet:return`Set<${B(o.valueType,s)}>`;case p.ZodFirstPartyTypeKind.ZodFunction:let $=B(new Zs(o.args),s),z=B(new Bs(o.returns),s),Q=e?.parent instanceof jt&&e?.parent.props.type==="type";return e?.declaration&&!Q?`${F(a.description)}
12
- (${$}): ${z}`:`${F(a.description)}
13
- (${$}) => ${z}`;case p.ZodFirstPartyTypeKind.ZodLazy:return B(o.getter(),s);case p.ZodFirstPartyTypeKind.ZodLiteral:let se=Il(o.value);return`${F(a.description)}
14
- ${se}`.trim();case p.ZodFirstPartyTypeKind.ZodEnum:return o.values.map(b).join(" | ");case p.ZodFirstPartyTypeKind.ZodEffects:return B(o.schema,s);case p.ZodFirstPartyTypeKind.ZodNativeEnum:throw new ta(p.ZodFirstPartyTypeKind.ZodNativeEnum);case p.ZodFirstPartyTypeKind.ZodOptional:return`${B(o.innerType,s)} | undefined`;case p.ZodFirstPartyTypeKind.ZodNullable:return`${B(o.innerType,s)} | null`;case p.ZodFirstPartyTypeKind.ZodDefault:let ae=e.treatDefaultAsOptional?o.innerType.optional():o.innerType;return B(ae,s);case p.ZodFirstPartyTypeKind.ZodCatch:return B(o.innerType,s);case p.ZodFirstPartyTypeKind.ZodPromise:return`Promise<${B(o.type,s)}>`;case p.ZodFirstPartyTypeKind.ZodBranded:return B(o.type,s);case p.ZodFirstPartyTypeKind.ZodPipeline:return B(o.in,s);case p.ZodFirstPartyTypeKind.ZodSymbol:return`${F(a.description)} symbol`.trim();case p.ZodFirstPartyTypeKind.ZodReadonly:return`Readonly<${B(o.innerType,s)}>`;case p.ZodFirstPartyTypeKind.ZodRef:return Bl(o.uri);default:Z.assertNever(o)}}l(B,"sUnwrapZod");var gh=l((t,e)=>{if(t.props.type==="none")return B(t.props.schema,e);let{schema:n,identifier:r}=t.props,i=F(n.description),s=n.describe(""),a=B(s,f(u({},e),{declaration:!0})),c=a.split(`
15
- `).length>=dh&&e.includeClosingTags?`// end of ${r}`:"";if(t.props.type!=="type"&&n instanceof p.ZodFunction)return $r(`${i}
16
- declare function ${r}${a};${c}`);if(t.props.type==="variable")return $r(`${i}declare const ${r}: ${a};${c}`);let d=t.props.args.length>0?`<${t.props.args.map(Bl).join(", ")}>`:"";return $r(`${i}type ${t.props.identifier}${d} = ${a};${c}`)},"unwrapDeclaration"),mh=l(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),hh=l((t,e)=>{let n=mh(e),r=t.getReferences();if(n==="none"){if(r.length>0)throw new Fr;return new jt({type:"none",schema:t})}let i="title"in t.ui?t.ui.title:null;if(!i)throw new ra;if(n==="variable"){if(r.length>0)throw new Fr;return new jt({type:"variable",identifier:i,schema:t})}return new jt({type:"type",identifier:i,schema:t,args:r})},"getDeclarationProps"),Ml=class{constructor(e,n,r,i){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=i}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}};l(Ml,"ParseInputLazyPath");var oe=Ml,Cs=l((t,e)=>{if(dt(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 n=new me(t.common.issues);return this._error=n,this._error}}},"handleResult"),jl=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(u({},this._def))}_getType(e){return be(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:be(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ne,ctx:{common:e.parent.common,data:e.data,parsedType:be(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(zt(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){var r;let i={common:{issues:[],async:(r=n?.async)!=null?r:!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:be(e)},s=this._parseSync({data:e,path:i.path,parent:i});return Cs(i,s)}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:be(e)},i=this._parse({data:e,path:r.path,parent:r}),s=await(zt(i)?i:Promise.resolve(i));return Cs(r,s)}refine(e,n){let r=l(i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n,"getIssueProperties");return this._refinement((i,s)=>{let a=e(i),o=l(()=>s.addIssue(u({code:h.custom},r(i))),"setError");return typeof Promise<"u"&&a instanceof Promise?a.then(c=>c?!0:(o(),!1)):a?!0:(o(),!1)})}refinement(e,n){return this._refinement((r,i)=>e(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(e){return new Ae({schema:this,typeName:"ZodEffects",effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return we.create(this,this._def)}nullable(){return Fe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ft.create(this,this._def)}promise(){return Gt.create(this,this._def)}mandatory(){return this}or(e){return yr.create([this,e],this._def)}and(e){return ur.create(this,e,this._def)}transform(e){return new Ae(f(u({},S(this._def)),{schema:this,typeName:"ZodEffects",effect:{type:"transform",transform:e}}))}default(e){let n=typeof e=="function"?e:()=>e;return new Vt(f(u({},S(this._def)),{innerType:this,defaultValue:n,typeName:"ZodDefault"}))}brand(){return new or(u({typeName:"ZodBranded",type:this},S(this._def)))}catch(e){let n=typeof e=="function"?e:()=>e;return new lr(f(u({},S(this._def)),{innerType:this,catchValue:n,typeName:"ZodCatch"}))}describe(e){let n=this.clone();return n._metadataRoot._def.description=e,n}pipe(e){return hr.create(this,e)}readonly(){return Jt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}metadata(e){var n,r,i;let s=this.clone(),a=s._metadataRoot;(i=(n=a._def)[r=w])!=null||(n[r]={});for(let[o,c]of Object.entries(e))a._def[w]=f(u({},a._def[w]),{[o]:c});return s}getMetadata(){return u({},this._metadataRoot._def[w])}setMetadata(e){this._metadataRoot._def[w]=u({},e)}get ui(){return u({},this._metadataRoot._def[w])}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 n;return e===void 0?n=!0:typeof e=="function"?n=e.toString():n=e,this.metadata({hidden:n})}disabled(e){let n;return e===void 0?n=!0:typeof e=="function"?n=e.toString():n=e,this.metadata({disabled:n})}placeholder(e){return this.metadata({placeholder:e})}toJSONSchema(){return V(this)}toTypescriptType(e){return mi(this,e)}toTypescriptSchema(){return gi(this)}naked(){return this}};l(jl,"ZodType");var E=jl,hi=(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))(hi||{}),Z;(t=>{t.assertEqual=l(i=>i,"assertEqual");function e(i){}t.assertIs=e,l(e,"assertIs");function n(i){throw new Error("assertNever called")}t.assertNever=n,l(n,"assertNever"),t.arrayToEnum=l(i=>{let s={};for(let a of i)s[a]=a;return s},"arrayToEnum"),t.getValidEnumValues=l(i=>{let s=(0,t.objectKeys)(i).filter(o=>typeof i[i[o]]!="number"),a={};for(let o of s)a[o]=i[o];return(0,t.objectValues)(a)},"getValidEnumValues"),t.objectValues=l(i=>(0,t.objectKeys)(i).map(function(s){return i[s]}),"objectValues"),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let a in i)Object.prototype.hasOwnProperty.call(i,a)&&s.push(a);return s},t.find=l((i,s)=>{for(let a of i)if(s(a))return a},"find"),t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(a=>typeof a=="string"?`'${a}'`:a).join(s)}t.joinValues=r,l(r,"joinValues"),t.jsonStringifyReplacer=l((i,s)=>typeof s=="bigint"?s.toString():s,"jsonStringifyReplacer"),t.compareFunctions=l((i,s)=>i.toString()===s.toString(),"compareFunctions"),t.mock=l(()=>({}),"mock")})(Z||(Z={}));var fn;(t=>{t.mergeShapes=l((e,n)=>u(u({},e),n),"mergeShapes")})(fn||(fn={}));var _=Z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),be=l(t=>{switch(typeof t){case"undefined":return _.undefined;case"string":return _.string;case"number":return isNaN(t)?_.nan:_.number;case"boolean":return _.boolean;case"function":return _.function;case"bigint":return _.bigint;case"symbol":return _.symbol;case"object":return Array.isArray(t)?_.array:t===null?_.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?_.promise:typeof Map<"u"&&t instanceof Map?_.map:typeof Set<"u"&&t instanceof Set?_.set:typeof Date<"u"&&t instanceof Date?_.date:_.object;default:return _.unknown}},"getParsedType");function S(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:i,supportsExtensions:s,[w]:a}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);let o=a?Object.fromEntries(Object.entries(a).filter(([d])=>d!=="secret"||s?.includes("secret"))):void 0;return e?{errorMap:e,description:i,[w]:o}:{errorMap:l((d,g)=>d.code!=="invalid_type"?{message:g.defaultError}:typeof g.data>"u"?{message:r??g.defaultError}:{message:n??g.defaultError},"customMap"),description:i,[w]:o}}l(S,"processCreateParams");var yi=l((t,e)=>{let n;switch(t.code){case h.invalid_type:t.received===_.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case h.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,Z.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:n=`Unrecognized key(s) in object: ${Z.joinValues(t.keys,", ")}`;break;case h.invalid_union:n="Invalid input";break;case h.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Z.joinValues(t.options)}`;break;case h.invalid_enum_value:n=`Invalid enum value. Expected ${Z.joinValues(t.options)}, received '${t.received}'`;break;case h.invalid_arguments:n="Invalid function arguments";break;case h.invalid_return_type:n="Invalid function return type";break;case h.invalid_date:n="Invalid date";break;case h.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:Z.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case h.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case h.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case h.custom:n="Invalid input";break;case h.invalid_intersection_types:n="Intersection results could not be merged";break;case h.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case h.not_finite:n="Number must be finite";break;case h.unresolved_reference:n="Unresolved reference";break;default:n=e.defaultError,Z.assertNever(t)}return{message:n}},"errorMap"),Rs=yi,h=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"]),$l=l(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),gn=class Kl extends Error{constructor(e){super(),this.issues=[],this.addIssue=l(r=>{this.issues=[...this.issues,r]},"addIssue"),this.addIssues=l((r=[])=>{this.issues=[...this.issues,...r]},"addIssues");let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let n=e||function(s){return s.message},r={_errors:[]},i=l(s=>{for(let a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let o=r,c=0;for(;c<a.path.length;){let d=a.path[c];c===a.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(n(a))):o[d]=o[d]||{_errors:[]},o=o[d],c++}}},"processError");return i(this),r}static assert(e){if(!(e instanceof Kl))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=n=>n.message){let n={},r=[];for(let i of this.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(e(i))):r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};l(gn,"ZodError");gn.create=l(t=>new gn(t),"create");var me=gn,Ul=yi;function vi(t){Ul=t}l(vi,"setErrorMap");function ut(){return Ul}l(ut,"getErrorMap");var Ft=l(t=>{var e;let{data:n,path:r,errorMaps:i,issueData:s}=t,a=[...r,...s.path||[]],o=f(u({},s),{path:a}),c="",d=i.filter(g=>!!g).slice().reverse();for(let g of d)c=g(o,{data:n,defaultError:c}).message;return f(u({},s),{path:a,message:(e=s.message)!=null?e:c})},"makeIssue"),Fl=[];function v(t,e){let n=Ft({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ut(),yi].filter(r=>!!r)});t.common.issues.push(n)}l(v,"addIssueToContext");var zl=class Wl{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let i of n){if(i.status==="aborted")return x;i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let i of n)r.push({key:await i.key,value:await i.value});return Wl.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let i of n){let{key:s,value:a}=i;if(s.status==="aborted"||a.status==="aborted")return x;s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(r[s.value]=a.value)}return{status:e.value,value:r}}};l(zl,"ParseStatus");var ne=zl,x=Object.freeze({status:"aborted"}),Ke=l(t=>({status:"dirty",value:t}),"DIRTY"),G=l(t=>({status:"valid",value:t}),"OK"),mn=l(t=>t.status==="aborted","isAborted"),hn=l(t=>t.status==="dirty","isDirty"),dt=l(t=>t.status==="valid","isValid"),zt=l(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),P;(t=>{t.errToObj=l(e=>typeof e=="string"?{message:e}:e||{},"errToObj"),t.toString=l(e=>typeof e=="string"?e:e?.message,"toString")})(P||(P={}));var yn=class Ll extends E{constructor(){super(...arguments),this._any=!0}_parse(e){return G(e.data)}isEqual(e){return e instanceof Ll}};l(yn,"ZodAny");yn.create=l(t=>new yn(u({typeName:"ZodAny"},S(t))),"create");var pt=yn,vn=class Ne extends E{dereference(e){return new Ne(f(u({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Ne(f(u({},this._def),{type:this._def.type.clone()}))}isEqual(e){var n,r,i,s,a,o;return e instanceof Ne?Ie((n=this._def.exactLength)==null?void 0:n.value,(r=e._def.exactLength)==null?void 0:r.value)&&Ie((i=this._def.maxLength)==null?void 0:i.value,(s=e._def.maxLength)==null?void 0:s.value)&&Ie((a=this._def.minLength)==null?void 0:a.value,(o=e._def.minLength)==null?void 0:o.value)&&this._def.type.isEqual(e._def.type):!1}_parse(e){let{ctx:n,status:r}=this._processInputParams(e),i=this._def;if(n.parsedType!==_.array)return v(n,{code:h.invalid_type,expected:_.array,received:n.parsedType}),x;if(i.exactLength!==null){let a=n.data.length>i.exactLength.value,o=n.data.length<i.exactLength.value;(a||o)&&(v(n,{code:a?h.too_big:h.too_small,minimum:o?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(v(n,{code:h.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(v(n,{code:h.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,o)=>i.type._parseAsync(new oe(n,a,n.path,o)))).then(a=>ne.mergeArray(r,a));let s=[...n.data].map((a,o)=>i.type._parseSync(new oe(n,a,n.path,o)));return ne.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new Ne(f(u({},this._def),{minLength:{value:e,message:P.toString(n)}}))}max(e,n){return new Ne(f(u({},this._def),{maxLength:{value:e,message:P.toString(n)}}))}length(e,n){return new Ne(f(u({},this._def),{exactLength:{value:e,message:P.toString(n)}}))}nonempty(e){return this.min(1,e)}};l(vn,"ZodArray");vn.create=l((t,e)=>new vn(u({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},S(e))),"create");var ft=vn,yh=l((t,e)=>Vl(t,e,new WeakSet),"isEqual"),Vl=l((t,e,n)=>Mm(t,e,vh(n)),"_isEqualWithVisitedTracking"),vh=l(t=>(e,n)=>{if(ps(e)&&!t.has(e)&&ps(n)&&!t.has(n)){let r=Os(e,Ss),i=Os(n,Ss);return t.add(r).add(i).add(e).add(n),Vl(r,i,t)}},"_customizerWithVisitedTracking"),_h={compare:yh},ql=class{constructor(e=[],n={}){this._options=u(u({},_h),n),this._items=[];for(let r of e)this.add(r)}get items(){return[...this._items]}get size(){return this._items.length}has(e){return this._items.some(n=>this._options.compare(n,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(n=>e.has(n))}};l(ql,"CustomSet");var U=ql,_n=class sn 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)!==_.bigint){let s=this._getOrReturnCtx(e);return v(s,{code:h.invalid_type,expected:_.bigint,received:s.parsedType}),x}let r,i=new ne;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),v(r,{code:h.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),v(r,{code:h.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),v(r,{code:h.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Z.assertNever(s);return{status:i.value,value:e.data}}isEqual(e){if(!(e instanceof sn)||this._def.coerce!==e._def.coerce)return!1;let n=new U(this._def.checks),r=new U(e._def.checks);return n.isEqual(r)}gte(e,n){return this.setLimit("min",e,!0,P.toString(n))}gt(e,n){return this.setLimit("min",e,!1,P.toString(n))}lte(e,n){return this.setLimit("max",e,!0,P.toString(n))}lt(e,n){return this.setLimit("max",e,!1,P.toString(n))}setLimit(e,n,r,i){return new sn(f(u({},this._def),{checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:P.toString(i)}]}))}_addCheck(e){return new sn(f(u({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:P.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:P.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:P.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:P.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:P.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};l(_n,"ZodBigInt");_n.create=l(t=>{var e;return new _n(u({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},S(t)))},"create");var sr=_n,Tn=class Gl extends E{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){let r=this._getOrReturnCtx(e);return v(r,{code:h.invalid_type,expected:_.boolean,received:r.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof Gl?this._def.coerce===e._def.coerce:!1}};l(Tn,"ZodBoolean");Tn.create=l(t=>new Tn(u({typeName:"ZodBoolean",coerce:t?.coerce||!1},S(t))),"create");var ar=Tn,Jl=Symbol("zod_brand"),Yl=class kt extends E{dereference(e){return new kt(f(u({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new kt(f(u({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}isEqual(e){return e instanceof kt?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new kt(f(u({},this._def),{type:this._def.type.mandatory()}))}};l(Yl,"ZodBranded");var or=Yl,bn=class St extends E{_parse(e){let{ctx:n}=this._processInputParams(e),r=f(u({},n),{common:f(u({},n.common),{issues:[]})}),i=this._def.innerType._parse({data:r.data,path:r.path,parent:u({},r)});return zt(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new me(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new me(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof St?this._def.innerType.isEqual(e._def.innerType)&&Z.compareFunctions(this._def.catchValue,e._def.catchValue):!1}dereference(e){return new St(f(u({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new St(f(u({},this._def),{innerType:this._def.innerType.clone()}))}naked(){return this._def.innerType.naked()}mandatory(){return new St(f(u({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(bn,"ZodCatch");bn.create=l((t,e)=>new bn(u({innerType:t,typeName:"ZodCatch",catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},S(e))),"create");var lr=bn,_i=l((t,e={},n)=>t?pt.create().superRefine((r,i)=>{var s,a;if(!t(r)){let o=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,c=(a=(s=o.fatal)!=null?s:n)!=null?a:!0,d=typeof o=="string"?{message:o}:o;i.addIssue(f(u({code:"custom"},d),{fatal:c}))}}):pt.create(),"custom"),wn=class Yr extends E{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){let s=this._getOrReturnCtx(e);return v(s,{code:h.invalid_type,expected:_.date,received:s.parsedType}),x}if(isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return v(s,{code:h.invalid_date}),x}let r=new ne,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),v(i,{code:h.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),v(i,{code:h.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):Z.assertNever(s);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Yr(f(u({},this._def),{checks:[...this._def.checks,e]}))}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:P.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:P.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}isEqual(e){if(!(e instanceof Yr))return!1;let n=new U(this._def.checks),r=new U(e._def.checks);return n.isEqual(r)&&this._def.coerce===e._def.coerce}};l(wn,"ZodDate");wn.create=l(t=>new wn(u({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},S(t))),"create");var cr=wn,Pn=class Ot extends E{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===_.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}dereference(e){return new Ot(f(u({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Ot(f(u({},this._def),{innerType:this._def.innerType.clone()}))}isEqual(e){return e instanceof Ot?this._def.innerType.isEqual(e._def.innerType)&&Ie(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new Ot(f(u({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(Pn,"ZodDefault");Pn.create=l((t,e,n)=>new Pn(u({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},S(n))),"create");var Vt=Pn,ke=l(t=>Array.from(new Set(t)),"unique"),Te=l(t=>t instanceof dr?Te(t.schema):t instanceof Ae?Te(t.innerType()):t instanceof pr?[t.value]:t instanceof Qe?t.options:t instanceof fr?Z.objectValues(t.enum):t instanceof Vt?Te(t._def.innerType):t instanceof Yt?[void 0]:t instanceof gr?[null]:t instanceof we?[void 0,...Te(t.unwrap())]:t instanceof Fe?[null,...Te(t.unwrap())]:t instanceof or||t instanceof Jt?Te(t.unwrap()):t instanceof lr?Te(t._def.innerType):[],"getDiscriminator"),Xl=class Me extends E{dereference(e){let n=this.options.map(i=>i.dereference(e)),r=Me._getOptionsMap(this.discriminator,n);return new Me(f(u({},this._def),{options:n,optionsMap:r}))}getReferences(){return ke(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(n=>n.clone());return new Me(f(u({},this._def),{options:e}))}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==_.object)return v(n,{code:h.invalid_type,expected:_.object,received:n.parsedType}),x;let r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(v(n,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let i=Me._getOptionsMap(e,n);return new Me(u({typeName:"ZodDiscriminatedUnion",discriminator:e,options:n,optionsMap:i},S(r)))}static _getOptionsMap(e,n){let r=new Map;for(let i of n){let s=Te(i.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of s){if(r.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);r.set(a,i)}}return r}isEqual(e){if(!(e instanceof Me)||this._def.discriminator!==e._def.discriminator)return!1;let n=l((s,a)=>s.isEqual(a),"compare"),r=new U(this._def.options,{compare:n}),i=new U(e._def.options,{compare:n});return r.isEqual(i)}};l(Xl,"ZodDiscriminatedUnion");var Ti=Xl;function qt(t,e){return new Qe(u({values:t,typeName:"ZodEnum"},S(e)))}l(qt,"createZodEnum");var bi=class an extends E{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return v(n,{expected:Z.joinValues(r),received:n.parsedType,code:h.invalid_type}),x}if(this._def.values.indexOf(e.data)===-1){let n=this._getOrReturnCtx(e),r=this._def.values;return v(n,{received:n.data,code:h.invalid_enum_value,options:r}),x}return G(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return an.create(e,u(u({},this._def),n))}exclude(e,n=this._def){return an.create(this.options.filter(r=>!e.includes(r)),u(u({},this._def),n))}isEqual(e){if(!(e instanceof an))return!1;let n=new U(this._def.values),r=new U(e._def.values);return n.isEqual(r)}};l(bi,"ZodEnum");bi.create=qt;var Qe=bi,Ql=class je extends E{constructor(){super(...arguments),this.validate=this.implement}dereference(e){let n=this._def.args.dereference(e),r=this._def.returns.dereference(e);return new je(f(u({},this._def),{args:n,returns:r}))}getReferences(){return ke([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new je(f(u({},this._def),{args:this._def.args.clone(),returns:this._def.returns.clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==_.function)return v(n,{code:h.invalid_type,expected:_.function,received:n.parsedType}),x;function r(o,c){return Ft({data:o,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,ut(),Rs].filter(d=>!!d),issueData:{code:h.invalid_arguments,argumentsError:c}})}l(r,"makeArgsIssue");function i(o,c){return Ft({data:o,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,ut(),Rs].filter(d=>!!d),issueData:{code:h.invalid_return_type,returnTypeError:c}})}l(i,"makeReturnsIssue");let s={errorMap:n.common.contextualErrorMap},a=n.data;if(this._def.returns instanceof Gt){let o=this;return G(async function(...c){let d=new me([]),g=await o._def.args.parseAsync(c,s).catch(I=>{throw d.addIssue(r(c,I)),d}),m=await Reflect.apply(a,this,g);return await o._def.returns._def.type.parseAsync(m,s).catch(I=>{throw d.addIssue(i(m,I)),d})})}else{let o=this;return G(function(...c){let d=o._def.args.safeParse(c,s);if(!d.success)throw new me([r(c,d.error)]);let g=Reflect.apply(a,this,d.data),m=o._def.returns.safeParse(g,s);if(!m.success)throw new me([i(g,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new je(f(u({},this._def),{args:We.create(e).rest(lt.create())}))}returns(e){return new je(f(u({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new je(u({args:e||We.create([]).rest(lt.create()),returns:n||lt.create(),typeName:"ZodFunction"},S(r)))}isEqual(e){return e instanceof je&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};l(Ql,"ZodFunction");var wi=Ql;function xn(t,e){let n=be(t),r=be(e);if(t===e)return{valid:!0,data:t};if(n===_.object&&r===_.object){let i=Z.objectKeys(e),s=Z.objectKeys(t).filter(o=>i.indexOf(o)!==-1),a=u(u({},t),e);for(let o of s){let c=xn(t[o],e[o]);if(!c.valid)return{valid:!1};a[o]=c.data}return{valid:!0,data:a}}else if(n===_.array&&r===_.array){if(t.length!==e.length)return{valid:!1};let i=[];for(let s=0;s<t.length;s++){let a=t[s],o=e[s],c=xn(a,o);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return n===_.date&&r===_.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}l(xn,"mergeValues");var kn=class on extends E{dereference(e){return new on(f(u({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return ke([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new on(f(u({},this._def),{left:this._def.left.clone(),right:this._def.right.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=l((s,a)=>{if(mn(s)||mn(a))return x;let o=xn(s.value,a.value);return o.valid?((hn(s)||hn(a))&&n.dirty(),{status:n.value,value:o.data}):(v(r,{code:h.invalid_intersection_types}),x)},"handleParsed");return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}isEqual(e){if(!(e instanceof on))return!1;let n=l((s,a)=>s.isEqual(a),"compare"),r=new U([this._def.left,this._def.right],{compare:n}),i=new U([e._def.left,e._def.right],{compare:n});return r.isEqual(i)}};l(kn,"ZodIntersection");kn.create=l((t,e,n)=>new kn(u({left:t,right:e,typeName:"ZodIntersection"},S(n))),"create");var ur=kn,Sn=class Et extends E{get schema(){return this._def.getter()}dereference(e){return new Et(f(u({},this._def),{getter:()=>this._def.getter().dereference(e)}))}getReferences(){return this._def.getter().getReferences()}clone(){return new Et(f(u({},this._def),{getter:()=>this._def.getter().clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}isEqual(e){return e instanceof Et?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new Et(f(u({},this._def),{getter:()=>this._def.getter().mandatory()}))}};l(Sn,"ZodLazy");Sn.create=l((t,e)=>new Sn(u({getter:t,typeName:"ZodLazy"},S(e))),"create");var dr=Sn,On=class ec extends E{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return v(n,{received:n.data,code:h.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}isEqual(e){return e instanceof ec?Ie(this._def.value,e._def.value):!1}};l(On,"ZodLiteral");On.create=l((t,e)=>new On(u({value:t,typeName:"ZodLiteral"},S(e))),"create");var pr=On,En=class ln extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let n=this._def.keyType.dereference(e),r=this._def.valueType.dereference(e);return new ln(f(u({},this._def),{keyType:n,valueType:r}))}getReferences(){return ke([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new ln(f(u({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==_.map)return v(r,{code:h.invalid_type,expected:_.map,received:r.parsedType}),x;let i=this._def.keyType,s=this._def.valueType,a=[...r.data.entries()].map(([o,c],d)=>({key:i._parse(new oe(r,o,r.path,[d,"key"])),value:s._parse(new oe(r,c,r.path,[d,"value"]))}));if(r.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of a){let d=await c.key,g=await c.value;if(d.status==="aborted"||g.status==="aborted")return x;(d.status==="dirty"||g.status==="dirty")&&n.dirty(),o.set(d.value,g.value)}return{status:n.value,value:o}})}else{let o=new Map;for(let c of a){let d=c.key,g=c.value;if(d.status==="aborted"||g.status==="aborted")return x;(d.status==="dirty"||g.status==="dirty")&&n.dirty(),o.set(d.value,g.value)}return{status:n.value,value:o}}}isEqual(e){return!(!(e instanceof ln)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};l(En,"ZodMap");En.create=l((t,e,n)=>new En(u({valueType:e,keyType:t,typeName:"ZodMap"},S(n))),"create");var Pi=En,In=class tc extends E{_parse(e){if(this._getType(e)!==_.nan){let r=this._getOrReturnCtx(e);return v(r,{code:h.invalid_type,expected:_.nan,received:r.parsedType}),x}return{status:"valid",value:e.data}}isEqual(e){return e instanceof tc}};l(In,"ZodNaN");In.create=l(t=>new In(u({typeName:"ZodNaN"},S(t))),"create");var xi=In,Zn=class nc extends E{_parse(e){let n=Z.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==_.string&&r.parsedType!==_.number){let i=Z.objectValues(n);return v(r,{expected:Z.joinValues(i),received:r.parsedType,code:h.invalid_type}),x}if(n.indexOf(e.data)===-1){let i=Z.objectValues(n);return v(r,{received:r.data,code:h.invalid_enum_value,options:i}),x}return G(e.data)}get enum(){return this._def.values}isEqual(e){return e instanceof nc?Ie(this._def.values,e._def.values):!1}};l(Zn,"ZodNativeEnum");Zn.create=l((t,e)=>new Zn(u({values:t,typeName:"ZodNativeEnum"},S(e))),"create");var fr=Zn,Bn=class rc extends E{_parse(e){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.never,received:n.parsedType}),x}isEqual(e){return e instanceof rc}};l(Bn,"ZodNever");Bn.create=l(t=>new Bn(u({typeName:"ZodNever"},S(t))),"create");var ht=Bn,An=class ic extends E{_parse(e){if(this._getType(e)!==_.null){let r=this._getOrReturnCtx(e);return v(r,{code:h.invalid_type,expected:_.null,received:r.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof ic}};l(An,"ZodNull");An.create=l(t=>new An(u({typeName:"ZodNull"},S(t))),"create");var gr=An,Cn=class It extends E{dereference(e){return new It(f(u({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new It(f(u({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.null?G(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof It?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new It(f(u({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(Cn,"ZodNullable");Cn.create=l((t,e)=>new Cn(u({innerType:t,typeName:"ZodNullable"},S(e))),"create");var Fe=Cn;function sc(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,i=n>r?n:r,s=parseInt(t.toFixed(i).replace(".","")),a=parseInt(e.toFixed(i).replace(".",""));return s%a/Math.pow(10,i)}l(sc,"floatSafeRemainder");var Rn=class cn 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)!==_.number){let s=this._getOrReturnCtx(e);return v(s,{code:h.invalid_type,expected:_.number,received:s.parsedType}),x}let r,i=new ne;for(let s of this._def.checks)s.kind==="int"?Z.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),v(r,{code:h.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),v(r,{code:h.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),v(r,{code:h.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?sc(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),v(r,{code:h.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),v(r,{code:h.not_finite,message:s.message}),i.dirty()):Z.assertNever(s);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,P.toString(n))}gt(e,n){return this.setLimit("min",e,!1,P.toString(n))}lte(e,n){return this.setLimit("max",e,!0,P.toString(n))}lt(e,n){return this.setLimit("max",e,!1,P.toString(n))}setLimit(e,n,r,i){return new cn(f(u({},this._def),{checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:P.toString(i)}]}))}_addCheck(e){return new cn(f(u({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:P.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:P.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:P.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:P.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:P.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:P.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:P.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:P.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:P.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.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,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}isEqual(e){if(!(e instanceof cn))return!1;let n=new U(this._def.checks),r=new U(e._def.checks);return n.isEqual(r)}};l(Rn,"ZodNumber");Rn.create=l(t=>new Rn(u({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},S(t))),"create");var mr=Rn;function $e(t){if(t instanceof ze){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=we.create($e(r))}return new ze(f(u({},t._def),{shape:()=>e}))}else return t instanceof ft?new ft(f(u({},t._def),{type:$e(t.element)})):t instanceof we?we.create($e(t.unwrap())):t instanceof Fe?Fe.create($e(t.unwrap())):t instanceof We?We.create(t.items.map(e=>$e(e))):t}l($e,"deepPartialify");var Be=class ie 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(),n=Z.objectKeys(e);return this._cached={shape:e,keys:n}}dereference(e){let n=this._def.shape(),r={};for(let i in n)r[i]=n[i].dereference(e);return new ie(f(u({},this._def),{shape:()=>r}))}getReferences(){let e=this._def.shape(),n=[];for(let r in e)n.push(...e[r].getReferences());return ke(n)}clone(){let e={},n=this._def.shape();for(let[r,i]of Object.entries(n))e[r]=i.clone();return new ie(f(u({},this._def),{shape:()=>e}))}_parse(e){if(this._getType(e)!==_.object){let g=this._getOrReturnCtx(e);return v(g,{code:h.invalid_type,expected:_.object,received:g.parsedType}),x}let{status:r,ctx:i}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),o=[];if(this._def.unknownKeys!=="strip")for(let g in i.data)a.includes(g)||o.push(g);let c=[];for(let g of a){let m=s[g],T=i.data[g];c.push({key:{status:"valid",value:g},value:m._parse(new oe(i,T,i.path,g)),alwaysSet:g in i.data})}let d=this._def.unknownKeys;if(d==="passthrough")for(let g of o)c.push({key:{status:"valid",value:g},value:{status:"valid",value:i.data[g]}});else if(d==="strict")o.length>0&&(v(i,{code:h.unrecognized_keys,keys:o}),r.dirty());else if(d!=="strip")for(let g of o){let m=i.data[g];c.push({key:{status:"valid",value:g},value:d._parse(new oe(i,m,i.path,g)),alwaysSet:g in i.data})}return i.common.async?Promise.resolve().then(async()=>{let g=[];for(let m of c){let T=await m.key;g.push({key:T,value:await m.value,alwaysSet:m.alwaysSet})}return g}).then(g=>ne.mergeObjectSync(r,g)):ne.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return P.errToObj,new ie(u(f(u({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:(n,r)=>{var i,s,a,o;let c=(a=(s=(i=this._def).errorMap)==null?void 0:s.call(i,n,r).message)!=null?a:r.defaultError;return n.code==="unrecognized_keys"?{message:(o=P.errToObj(e).message)!=null?o:c}:{message:c}}}:{}))}strip(){return new ie(f(u({},this._def),{unknownKeys:"strip"}))}passthrough(){return new ie(f(u({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(this._def.unknownKeys instanceof E)return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return pt.create();if(this._def.unknownKeys==="strict")return ht.create()}extend(e){return new ie(f(u({},this._def),{shape:()=>u(u({},this._def.shape()),e)}))}merge(e){return new ie({unknownKeys:e._def.unknownKeys,shape:()=>u(u({},this._def.shape()),e._def.shape()),typeName:"ZodObject"})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new ie(f(u({},this._def),{unknownKeys:e}))}pick(e){let n={};return Z.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new ie(f(u({},this._def),{shape:()=>n}))}omit(e){let n={};return Z.objectKeys(this.shape).forEach(r=>{e[r]||(n[r]=this.shape[r])}),new ie(f(u({},this._def),{shape:()=>n}))}deepPartial(){return $e(this)}partial(e){let n={};return Z.objectKeys(this.shape).forEach(r=>{let i=this.shape[r];e&&!e[r]?n[r]=i:n[r]=i?.optional()}),new ie(f(u({},this._def),{shape:()=>n}))}required(e){let n={};return Z.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof we;)s=s._def.innerType;n[r]=s}}),new ie(f(u({},this._def),{shape:()=>n}))}keyof(){return qt(Z.objectKeys(this.shape))}isEqual(e){if(!(e instanceof ie)||!this._unknownKeysEqual(e))return!1;let n=this._def.shape(),r=e._def.shape(),i=l((o,c)=>o[0]===c[0]&&o[1].isEqual(c[1]),"compare"),s=new U(Object.entries(n),{compare:i}),a=new U(Object.entries(r),{compare:i});return s.isEqual(a)}_unknownKeysEqual(e){let n=this.additionalProperties(),r=e.additionalProperties();return n===void 0||r===void 0?n===r:n.isEqual(r)}};l(Be,"ZodObject");Be.create=l((t,e)=>new Be(u({shape:()=>t,unknownKeys:"strip",typeName:"ZodObject"},S(e))),"create");Be.strictCreate=l((t,e)=>new Be(u({shape:()=>t,unknownKeys:"strict",typeName:"ZodObject"},S(e))),"strictCreate");Be.lazycreate=l((t,e)=>new Be(u({shape:t,unknownKeys:"strip",typeName:"ZodObject"},S(e))),"lazycreate");var ze=Be,Hn=class un extends E{dereference(e){return new un(f(u({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new un(f(u({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.undefined?G(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof un?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return this._def.innerType.mandatory()}};l(Hn,"ZodOptional");Hn.create=l((t,e)=>new Hn(u({innerType:t,typeName:"ZodOptional"},S(e))),"create");var we=Hn,ac=class Zt extends E{dereference(e){return new Zt(f(u({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return ke([...this._def.in.getReferences(),...this._def.out.getReferences()])}clone(){return new Zt(f(u({},this._def),{in:this._def.in.clone(),out:this._def.out.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return l(async()=>{let s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?x:s.status==="dirty"?(n.dirty(),Ke(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})},"handleAsync")();{let i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?x:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(e,n){return new Zt({in:e,out:n,typeName:"ZodPipeline"})}isEqual(e){return!(!(e instanceof Zt)||!this._def.in.isEqual(e._def.in)||!this._def.out.isEqual(e._def.out))}};l(ac,"ZodPipeline");var hr=ac,Dn=class dn extends E{unwrap(){return this._def.type}dereference(e){return new dn(f(u({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new dn(f(u({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==_.promise&&n.common.async===!1)return v(n,{code:h.invalid_type,expected:_.promise,received:n.parsedType}),x;let r=n.parsedType===_.promise?n.data:Promise.resolve(n.data);return G(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}isEqual(e){return e instanceof dn?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}};l(Dn,"ZodPromise");Dn.create=l((t,e)=>new Dn(u({type:t,typeName:"ZodPromise"},S(e))),"create");var Gt=Dn,Nn=class Bt extends E{dereference(e){return new Bt(f(u({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Bt(f(u({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){let n=this._def.innerType._parse(e);return dt(n)&&(n.value=Object.freeze(n.value)),n}unwrap(){return this._def.innerType}isEqual(e){return e instanceof Bt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new Bt(f(u({},this._def),{innerType:this._def.innerType.mandatory()}))}};l(Nn,"ZodReadonly");Nn.create=l((t,e)=>new Nn(u({innerType:t,typeName:"ZodReadonly"},S(e))),"create");var Jt=Nn,oc=class it extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let n=this._def.keyType.dereference(e),r=this._def.valueType.dereference(e);return new it(f(u({},this._def),{keyType:n,valueType:r}))}getReferences(){return ke([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new it(f(u({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==_.object)return v(r,{code:h.invalid_type,expected:_.object,received:r.parsedType}),x;let i=[],s=this._def.keyType,a=this._def.valueType;for(let o in r.data)i.push({key:s._parse(new oe(r,o,r.path,o)),value:a._parse(new oe(r,r.data[o],r.path,o))});return r.common.async?ne.mergeObjectAsync(n,i):ne.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof E?new it(u({keyType:e,valueType:n,typeName:"ZodRecord"},S(r))):new it(u({keyType:J.create(),valueType:e,typeName:"ZodRecord"},S(n)))}isEqual(e){return!(!(e instanceof it)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};l(oc,"ZodRecord");var ki=oc,Mn=class lc extends E{dereference(e){let n=e[this._def.uri];return n||this}getReferences(){return[this._def.uri]}_parse(e){let n=this._getOrReturnCtx(e);return v(n,{code:h.unresolved_reference}),x}isOptional(){return!1}isNullable(){return!1}isEqual(e){return e instanceof lc?this._def.uri===e._def.uri:!1}};l(Mn,"ZodRef");Mn.create=l(t=>new Mn({typeName:"ZodRef",uri:t}),"create");var Si=Mn,jn=class st extends E{dereference(e){return new st(f(u({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new st(f(u({},this._def),{valueType:this._def.valueType.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==_.set)return v(r,{code:h.invalid_type,expected:_.set,received:r.parsedType}),x;let i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(v(r,{code:h.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(v(r,{code:h.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());let s=this._def.valueType;function a(c){let d=new Set;for(let g of c){if(g.status==="aborted")return x;g.status==="dirty"&&n.dirty(),d.add(g.value)}return{status:n.value,value:d}}l(a,"finalizeSet");let o=[...r.data.values()].map((c,d)=>s._parse(new oe(r,c,r.path,d)));return r.common.async?Promise.all(o).then(c=>a(c)):a(o)}min(e,n){return new st(f(u({},this._def),{minSize:{value:e,message:P.toString(n)}}))}max(e,n){return new st(f(u({},this._def),{maxSize:{value:e,message:P.toString(n)}}))}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}isEqual(e){var n,r,i,s;if(!(e instanceof st))return!1;let a=(n=this._def.minSize)==null?void 0:n.value,o=(r=e._def.minSize)==null?void 0:r.value;if(a!==o)return!1;let c=(i=this._def.maxSize)==null?void 0:i.value,d=(s=e._def.maxSize)==null?void 0:s.value;return c!==d?!1:this._def.valueType.isEqual(e._def.valueType)}};l(jn,"ZodSet");jn.create=l((t,e)=>new jn(u({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},S(e))),"create");var Oi=jn,Ei=/^c[^\s-]{8,}$/i,Ii=/^[a-z][a-z0-9]*$/,Zi=/^[0-9A-HJKMNP-TV-Z]{26}$/,Bi=/^[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,Ai=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,cc="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",uc=l(t=>t===cc,"isEmojiRegex"),Kr,Ci=/^(((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}))$/,Ri=/^(([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 dc(t,e){return!!((e==="v4"||!e)&&Ci.test(t)||(e==="v6"||!e)&&Ri.test(t))}l(dc,"isValidIP");var $n=class at extends E{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){let s=this._getOrReturnCtx(e);return v(s,{code:h.invalid_type,expected:_.string,received:s.parsedType}),x}let r=new ne,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),v(i,{code:h.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),v(i,{code:h.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){let a=e.data.length>s.value,o=e.data.length<s.value;(a||o)&&(i=this._getOrReturnCtx(e,i),a?v(i,{code:h.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&v(i,{code:h.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")Ai.test(e.data)||(i=this._getOrReturnCtx(e,i),v(i,{validation:"email",code:h.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Kr||(Kr=new RegExp(cc,"u")),Kr.test(e.data)||(i=this._getOrReturnCtx(e,i),v(i,{validation:"emoji",code:h.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")Bi.test(e.data)||(i=this._getOrReturnCtx(e,i),v(i,{validation:"uuid",code:h.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")Ei.test(e.data)||(i=this._getOrReturnCtx(e,i),v(i,{validation:"cuid",code:h.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")Ii.test(e.data)||(i=this._getOrReturnCtx(e,i),v(i,{validation:"cuid2",code:h.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")Zi.test(e.data)||(i=this._getOrReturnCtx(e,i),v(i,{validation:"ulid",code:h.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),v(i,{validation:"url",code:h.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),v(i,{validation:"regex",code:h.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),v(i,{code:h.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),v(i,{code:h.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),v(i,{code:h.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?la(s).test(e.data)||(i=this._getOrReturnCtx(e,i),v(i,{code:h.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="ip"?dc(e.data,s.version)||(i=this._getOrReturnCtx(e,i),v(i,{validation:"ip",code:h.invalid_string,message:s.message}),r.dirty()):Z.assertNever(s);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(i=>e.test(i),u({validation:n,code:h.invalid_string},P.errToObj(r)))}_addCheck(e){return new at(f(u({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(u({kind:"email"},P.errToObj(e)))}url(e){return this._addCheck(u({kind:"url"},P.errToObj(e)))}emoji(e){return this._addCheck(u({kind:"emoji"},P.errToObj(e)))}uuid(e){return this._addCheck(u({kind:"uuid"},P.errToObj(e)))}cuid(e){return this._addCheck(u({kind:"cuid"},P.errToObj(e)))}cuid2(e){return this._addCheck(u({kind:"cuid2"},P.errToObj(e)))}ulid(e){return this._addCheck(u({kind:"ulid"},P.errToObj(e)))}ip(e){return this._addCheck(u({kind:"ip"},P.errToObj(e)))}datetime(e){var n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck(u({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(n=e?.offset)!=null?n:!1},P.errToObj(e?.message)))}regex(e,n){return this._addCheck(u({kind:"regex",regex:e},P.errToObj(n)))}includes(e,n){return this._addCheck(u({kind:"includes",value:e,position:n?.position},P.errToObj(n?.message)))}startsWith(e,n){return this._addCheck(u({kind:"startsWith",value:e},P.errToObj(n)))}endsWith(e,n){return this._addCheck(u({kind:"endsWith",value:e},P.errToObj(n)))}min(e,n){return this._addCheck(u({kind:"min",value:e},P.errToObj(n)))}max(e,n){return this._addCheck(u({kind:"max",value:e},P.errToObj(n)))}length(e,n){return this._addCheck(u({kind:"length",value:e},P.errToObj(n)))}nonempty(e){return this.min(1,P.errToObj(e))}trim(){return new at(f(u({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}secret(){return this._def[w]=f(u({},this._def[w]),{secret:!0}),this}toLowerCase(){return new at(f(u({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new at(f(u({},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 n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}isEqual(e){if(!(e instanceof at))return!1;let n=new U(this._def.checks),r=new U(e._def.checks);return n.isEqual(r)}};l($n,"ZodString");$n.create=l(t=>{var e;return new $n(u({checks:[],typeName:"ZodString",coerce:(e=t?.coerce)!=null?e:!1},S(f(u({},t),{supportsExtensions:["secret"]}))))},"create");var J=$n,Kn=class pc extends E{_parse(e){if(this._getType(e)!==_.symbol){let r=this._getOrReturnCtx(e);return v(r,{code:h.invalid_type,expected:_.symbol,received:r.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof pc}};l(Kn,"ZodSymbol");Kn.create=l(t=>new Kn(u({typeName:"ZodSymbol"},S(t))),"create");var Hi=Kn,gt=class At 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 At(f(u({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new At(f(u({},this._def),{schema:this._def.schema.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:a=>{v(r,a),a.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){let a=i.transform(r.data,s);if(r.common.async)return Promise.resolve(a).then(async o=>{if(n.value==="aborted")return x;let c=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return c.status==="aborted"?x:c.status==="dirty"||n.value==="dirty"?Ke(c.value):c});{if(n.value==="aborted")return x;let o=this._def.schema._parseSync({data:a,path:r.path,parent:r});return o.status==="aborted"?x:o.status==="dirty"||n.value==="dirty"?Ke(o.value):o}}if(i.type==="refinement"){let a=l(o=>{let c=i.refinement(o,s);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o},"executeRefinement");if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?x:(o.status==="dirty"&&n.dirty(),a(o.value),{status:n.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?x:(o.status==="dirty"&&n.dirty(),a(o.value).then(()=>({status:n.value,value:o.value}))))}if(i.type==="transform")if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!dt(a))return a;let o=i.transform(a.value,s);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>dt(a)?Promise.resolve(i.transform(a.value,s)).then(o=>({status:n.value,value:o})):a);Z.assertNever(i)}isEqual(e){return!(e instanceof At)||!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 At(f(u({},this._def),{schema:this._def.schema.mandatory()}))}};l(gt,"ZodEffects");gt.create=l((t,e,n)=>new gt(u({schema:t,typeName:"ZodEffects",effect:e},S(n))),"create");gt.createWithPreprocess=l((t,e,n)=>new gt(u({schema:e,effect:{type:"preprocess",transform:t},typeName:"ZodEffects"},S(n))),"createWithPreprocess");var Ae=gt,Un=class Ct extends E{dereference(e){let n=this._def.items.map(i=>i.dereference(e)),r=this._def.rest?this._def.rest.dereference(e):null;return new Ct(f(u({},this._def),{items:n,rest:r}))}getReferences(){return ke([...this._def.items.flatMap(e=>e.getReferences()),...this._def.rest?this._def.rest.getReferences():[]])}clone(){let e=this._def.items.map(r=>r.clone()),n=this._def.rest?this._def.rest.clone():null;return new Ct(f(u({},this._def),{items:e,rest:n}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==_.array)return v(r,{code:h.invalid_type,expected:_.array,received:r.parsedType}),x;if(r.data.length<this._def.items.length)return v(r,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&r.data.length>this._def.items.length&&(v(r,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let s=[...r.data].map((a,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new oe(r,a,r.path,o)):null}).filter(a=>!!a);return r.common.async?Promise.all(s).then(a=>ne.mergeArray(n,a)):ne.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new Ct(f(u({},this._def),{rest:e}))}isEqual(e){if(!(e instanceof Ct)||!this._restEquals(e))return!1;let n=l((s,a)=>s.isEqual(a),"compare"),r=new U(this._def.items,{compare:n}),i=new U(e._def.items,{compare:n});return r.isEqual(i)}_restEquals(e){return this._def.rest===null?e._def.rest===null:e._def.rest!==null&&this._def.rest.isEqual(e._def.rest)}};l(Un,"ZodTuple");Un.create=l((t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Un(u({items:t,typeName:"ZodTuple",rest:null},S(e)))},"create");var We=Un,Fn=class fc extends E{_parse(e){if(this._getType(e)!==_.undefined){let r=this._getOrReturnCtx(e);return v(r,{code:h.invalid_type,expected:_.undefined,received:r.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof fc}mandatory(){return ht.create(u({},this._def))}};l(Fn,"ZodUndefined");Fn.create=l(t=>new Fn(u({typeName:"ZodUndefined"},S(t))),"create");var Yt=Fn,zn=class Rt extends E{dereference(e){let n=this._def.options.map(r=>r.dereference(e));return new Rt(f(u({},this._def),{options:n}))}getReferences(){return ke(this._def.options.reduce((e,n)=>[...e,...n.getReferences()],[]))}clone(){let e=this._def.options.map(n=>n.clone());return new Rt(f(u({},this._def),{options:e}))}_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function i(s){for(let o of s)if(o.result.status==="valid")return o.result;for(let o of s)if(o.result.status==="dirty")return n.common.issues.push(...o.ctx.common.issues),o.result;let a=s.map(o=>new me(o.ctx.common.issues));return v(n,{code:h.invalid_union,unionErrors:a}),x}if(l(i,"handleResults"),n.common.async)return Promise.all(r.map(async s=>{let a=f(u({},n),{common:f(u({},n.common),{issues:[]}),parent:null});return{result:await s._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(i);{let s,a=[];for(let c of r){let d=f(u({},n),{common:f(u({},n.common),{issues:[]}),parent:null}),g=c._parseSync({data:n.data,path:n.path,parent:d});if(g.status==="valid")return g;g.status==="dirty"&&!s&&(s={result:g,ctx:d}),d.common.issues.length&&a.push(d.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;let o=a.map(c=>new me(c));return v(n,{code:h.invalid_union,unionErrors:o}),x}}get options(){return this._def.options}isEqual(e){if(!(e instanceof Rt))return!1;let n=l((s,a)=>s.isEqual(a),"compare"),r=new U([...this._def.options],{compare:n}),i=new U([...e._def.options],{compare:n});return r.isEqual(i)}mandatory(){let e=this._def.options.filter(s=>!(s instanceof Yt)).map(s=>s.mandatory()),[n,r,...i]=e;return n?r?new Rt(f(u({},this._def),{options:[n,r,...i]})):n:ht.create(u({},this._def))}};l(zn,"ZodUnion");zn.create=l((t,e)=>new zn(u({options:t,typeName:"ZodUnion"},S(e))),"create");var yr=zn,Wn=class gc extends E{constructor(){super(...arguments),this._unknown=!0}_parse(e){return G(e.data)}isEqual(e){return e instanceof gc}};l(Wn,"ZodUnknown");Wn.create=l(t=>new Wn(u({typeName:"ZodUnknown"},S(t))),"create");var lt=Wn,Ln=class mc extends E{_parse(e){if(this._getType(e)!==_.undefined){let r=this._getOrReturnCtx(e);return v(r,{code:h.invalid_type,expected:_.void,received:r.parsedType}),x}return G(e.data)}isEqual(e){return e instanceof mc}};l(Ln,"ZodVoid");Ln.create=l(t=>new Ln(u({typeName:"ZodVoid"},S(t))),"create");var Di=Ln,Th=["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"],Hv=Qe.create(["any","string","number","boolean","object","pattern","date","array","target","time","enum"]),hc=l(t=>J.create().displayAs({id:"variable",params:u({type:t?.type||"any"},t?.params)}),"variable"),yc=l(t=>J.create().displayAs({id:"conversation",params:u({},t?.params)}),"conversation"),vc=l(t=>J.create().displayAs({id:"user",params:u({},t?.params)}),"user"),_c=l(t=>J.create().displayAs({id:"message",params:u({},t?.params)}),"message"),Tc=l(t=>J.create().displayAs({id:"agent",params:u({},t?.params)}),"agent"),bc=l(t=>J.create().displayAs({id:"event",params:u({},t?.params)}),"event"),wc=l(t=>J.create().displayAs({id:"table",params:u({},t?.params)}),"table"),Pc=l(t=>J.create().displayAs({id:"tablerow",params:u({},t?.params)}),"tablerow"),xc=l(t=>J.create().displayAs({id:"intent",params:u({},t?.params)}),"intent"),kc=l(()=>Qe.create(Th).displayAs({id:"dropdown",params:{}}),"aimodel"),Sc=l(t=>J.create().displayAs({id:"datasource",params:u({},t)}),"datasource"),Oc=l(t=>J.create().displayAs({id:"knowledgebase",params:u({},t)}),"knowledgebase"),Ec={object:ze.lazycreate},Ic=l((t,e={message:`Input not instance of ${t.name}`})=>_i(n=>n instanceof t,e),"instanceOfType"),Ni=J.create,Mi=mr.create,Zc=xi.create,Bc=sr.create,ji=ar.create,Ac=cr.create,Cc=Hi.create,Rc=Yt.create,Hc=gr.create,Dc=pt.create,Nc=lt.create,Mc=ht.create,jc=Di.create,$c=ft.create,Kc=ze.create,Uc=ze.strictCreate,Fc=yr.create,zc=Ti.create,Wc=ur.create,Lc=We.create,Vc=ki.create,qc=Si.create,Gc=Jt.create,Jc=Pi.create,Yc=Oi.create,Xc=wi.create,Qc=dr.create,eu=pr.create,tu=Qe.create,nu=fr.create,ru=Gt.create,Xr=Ae.create,iu=we.create,su=Fe.create,bh=Vt.create,au=Ae.createWithPreprocess,ou=hr.create,lu=l(()=>Ni().optional(),"ostring"),cu=l(()=>Mi().optional(),"onumber"),uu=l(()=>ji().optional(),"oboolean"),du={string:t=>J.create(f(u({},t),{coerce:!0})),number:t=>mr.create(f(u({},t),{coerce:!0})),boolean:t=>ar.create(f(u({},t),{coerce:!0})),bigint:t=>sr.create(f(u({},t),{coerce:!0})),date:t=>cr.create(f(u({},t),{coerce:!0}))},pu=x,p=y,wh=l(t=>{let e;try{e=new Function("z",`return ${t}`)(p)}catch(n){return{sucess:!1,error:`Failed to evaluate schema: ${(n instanceof Error?n:new Error(String(n))).message}`}}return e instanceof p.ZodType?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),Ph=l(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),xh=l((t,...e)=>Object.keys(t).reduce((n,r)=>(e.includes(r)||(n[r]=t[r]),n),{}),"omit");function q(t,e,n){var r;let i=t[e],s="";if(i!==void 0){let a=n({value:i,json:JSON.stringify(i)});if(a){let o=a[0],c=a.length===3?a[1]:"",d=a.length===3?a[2]:a[1];s+=o,((r=t.errorMessage)==null?void 0:r[e])!==void 0&&(s+=c+JSON.stringify(t.errorMessage[e])),s+=d}}return s}l(q,"withMessage");var Ht=Symbol("Original index"),kh=l(t=>{let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(typeof r=="boolean")e.push(r?{[Ht]:n}:{[Ht]:n,not:{}});else{if(Ht in r)return t;e.push(f(u({},r),{[Ht]:n}))}}return e},"ensureOriginalIndex");function Wt(t,e){if(t.allOf.length===0)return"z.never()";if(t.allOf.length===1){let n=t.allOf[0];return W(n,f(u({},e),{path:[...e.path,"allOf",n[Ht]]}))}else{let[n,r]=Ph(kh(t.allOf));return`z.intersection(${Wt({allOf:n},e)}, ${Wt({allOf:r},e)})`}}l(Wt,"parseAllOf");var fu=l((t,e)=>t.anyOf.length?t.anyOf.length===1?W(t.anyOf[0],f(u({},e),{path:[...e.path,"anyOf",0]})):`z.union([${t.anyOf.map((n,r)=>W(n,f(u({},e),{path:[...e.path,"anyOf",r]}))).join(", ")}])`:"z.any()","parseAnyOf"),Sh=l((t,e)=>{if(Array.isArray(t.items))return`z.tuple([${t.items.map((r,i)=>W(r,f(u({},e),{path:[...e.path,"items",i]})))}])`;let n=t.items?`z.array(${W(t.items,f(u({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return n+=q(t,"minItems",({json:r})=>[`.min(${r}`,", ",")"]),n+=q(t,"maxItems",({json:r})=>[`.max(${r}`,", ",")"]),n},"parseArray"),Oh=l(t=>{var e;return(e=t[w])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),Eh=l(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),Ih=l(t=>"z.any()","parseDefault"),$i=l((t,e)=>t.oneOf.length?t.oneOf.length===1?W(t.oneOf[0],f(u({},e),{path:[...e.path,"oneOf",0]})):`z.any().superRefine((x, ctx) => {
17
- const schemas = [${t.oneOf.map((n,r)=>W(n,f(u({},e),{path:[...e.path,"oneOf",r]}))).join(", ")}];
1
+ "use strict";var vc=Object.create;var Kt=Object.defineProperty;var _c=Object.getOwnPropertyDescriptor;var Tc=Object.getOwnPropertyNames;var bc=Object.getPrototypeOf,wc=Object.prototype.hasOwnProperty;var Xe=(t,e)=>{for(var n in e)Kt(t,n,{get:e[n],enumerable:!0})},pi=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Tc(e))!wc.call(t,i)&&i!==n&&Kt(t,i,{get:()=>e[i],enumerable:!(r=_c(e,i))||r.enumerable});return t};var Kn=(t,e,n)=>(n=t!=null?vc(bc(t)):{},pi(e||!t||!t.__esModule?Kt(n,"default",{value:t,enumerable:!0}):n,t)),Pc=t=>pi(Kt({},"__esModule",{value:!0}),t);var iv={};Xe(iv,{Bot:()=>Mn,BotDefinition:()=>Hn,BotLogger:()=>dt,BotSpecificClient:()=>me,Integration:()=>Dn,IntegrationDefinition:()=>Bn,IntegrationLogger:()=>ct,IntegrationSpecificClient:()=>lt,InterfaceDefinition:()=>jn,Plugin:()=>Un,PluginDefinition:()=>$n,RuntimeError:()=>zn.RuntimeError,WELL_KNOWN_ATTRIBUTES:()=>my,isApiError:()=>zn.isApiError,messages:()=>ti,parseBody:()=>ne,serve:()=>Ut,version:()=>di,z:()=>y});module.exports=Pc(iv);var ti={};Xe(ti,{defaults:()=>gy,markdown:()=>py,markdownBloc:()=>fy});var mr=Object.defineProperty,xc=Object.defineProperties,kc=Object.getOwnPropertyDescriptors,tn=Object.getOwnPropertySymbols,Gi=Object.prototype.hasOwnProperty,Ji=Object.prototype.propertyIsEnumerable,fi=(t,e,n)=>e in t?mr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,c=(t,e)=>{for(var n in e||(e={}))Gi.call(e,n)&&fi(t,n,e[n]);if(tn)for(var n of tn(e))Ji.call(e,n)&&fi(t,n,e[n]);return t},p=(t,e)=>xc(t,kc(e)),o=(t,e)=>mr(t,"name",{value:e,configurable:!0}),Yi=(t,e)=>{var n={};for(var r in t)Gi.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&tn)for(var r of tn(t))e.indexOf(r)<0&&Ji.call(t,r)&&(n[r]=t[r]);return n},ce=(t,e)=>{for(var n in e)mr(t,n,{get:e[n],enumerable:!0})},y={};ce(y,{DIRTY:()=>Vr,ERR:()=>qr,OK:()=>on,any:()=>$e,array:()=>Me,bigint:()=>vn,boolean:()=>Ge,branded:()=>Fr,catch:()=>Wr,coerce:()=>Nl,custom:()=>hn,date:()=>_n,default:()=>Kr,discriminatedUnion:()=>wn,downstream:()=>jr,enum:()=>bn,function:()=>Dr,instanceof:()=>Or,intersection:()=>Pn,is:()=>z,lazy:()=>Rr,literal:()=>Nt,map:()=>Zr,nan:()=>Br,nativeEnum:()=>Cr,never:()=>Rt,null:()=>jt,nullable:()=>Ur,number:()=>Ve,object:()=>st,optional:()=>$r,pipeline:()=>Lr,preprocess:()=>Hr,promise:()=>Nr,readonly:()=>zr,record:()=>Dt,ref:()=>Tn,set:()=>xn,strictObject:()=>Ar,string:()=>we,symbol:()=>Ir,transforms:()=>Xi,tuple:()=>$t,undefined:()=>yn,union:()=>at,unknown:()=>Ce,upstream:()=>Mr,void:()=>Er,zuiKey:()=>B});var Xi={};ce(Xi,{errors:()=>Dl,fromJSONSchema:()=>ru,fromJSONSchemaLegacy:()=>th,fromObject:()=>pr,json:()=>uy,toJSONSchema:()=>L,toJSONSchemaLegacy:()=>Bh,toTypescriptSchema:()=>ei,toTypescriptType:()=>Qr});var Pe={};ce(Pe,{DIRTY:()=>Vr,ERR:()=>qr,OK:()=>on,any:()=>$e,array:()=>Me,bigint:()=>vn,boolean:()=>Ge,branded:()=>Fr,catch:()=>Wr,coerce:()=>Nl,custom:()=>hn,date:()=>_n,default:()=>Kr,discriminatedUnion:()=>wn,downstream:()=>jr,enum:()=>bn,function:()=>Dr,instanceof:()=>Or,intersection:()=>Pn,is:()=>z,lazy:()=>Rr,literal:()=>Nt,map:()=>Zr,nan:()=>Br,nativeEnum:()=>Cr,never:()=>Rt,null:()=>jt,nullable:()=>Ur,number:()=>Ve,object:()=>st,optional:()=>$r,pipeline:()=>Lr,preprocess:()=>Hr,promise:()=>Nr,readonly:()=>zr,record:()=>Dt,ref:()=>Tn,set:()=>xn,strictObject:()=>Ar,string:()=>we,symbol:()=>Ir,tuple:()=>$t,undefined:()=>yn,union:()=>at,unknown:()=>Ce,upstream:()=>Mr,void:()=>Er,zuiKey:()=>B});var B="x-zui",j={};ce(j,{CustomSet:()=>Zg});var ge={};ce(ge,{isEqual:()=>_o,unique:()=>Cg});var Sc=typeof global=="object"&&global&&global.Object===Object&&global,Qi=Sc,Oc=typeof self=="object"&&self&&self.Object===Object&&self,Ec=Qi||Oc||Function("return this")(),xe=Ec,Ic=xe.Symbol,Be=Ic,es=Object.prototype,Bc=es.hasOwnProperty,Cc=es.toString,ft=Be?Be.toStringTag:void 0;function ts(t){var e=Bc.call(t,ft),n=t[ft];try{t[ft]=void 0;var r=!0}catch{}var i=Cc.call(t);return r&&(e?t[ft]=n:delete t[ft]),i}o(ts,"getRawTag");var Ac=ts,Zc=Object.prototype,Rc=Zc.toString;function ns(t){return Rc.call(t)}o(ns,"objectToString");var Nc=ns,Dc="[object Null]",Hc="[object Undefined]",gi=Be?Be.toStringTag:void 0;function rs(t){return t==null?t===void 0?Hc:Dc:gi&&gi in Object(t)?Ac(t):Nc(t)}o(rs,"baseGetTag");var Ue=rs;function is(t){return t!=null&&typeof t=="object"}o(is,"isObjectLike");var je=is,Mc="[object Symbol]";function ss(t){return typeof t=="symbol"||je(t)&&Ue(t)==Mc}o(ss,"isSymbol");var hr=ss;function as(t,e){for(var n=-1,r=t==null?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}o(as,"arrayMap");var os=as,jc=Array.isArray,be=jc,$c=1/0,mi=Be?Be.prototype:void 0,hi=mi?mi.toString:void 0;function yr(t){if(typeof t=="string")return t;if(be(t))return os(t,yr)+"";if(hr(t))return hi?hi.call(t):"";var e=t+"";return e=="0"&&1/t==-$c?"-0":e}o(yr,"baseToString");var Uc=yr;function ls(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}o(ls,"isObject");var it=ls;function us(t){return t}o(us,"identity");var zc=us,Kc="[object AsyncFunction]",Wc="[object Function]",Lc="[object GeneratorFunction]",Fc="[object Proxy]";function cs(t){if(!it(t))return!1;var e=Ue(t);return e==Wc||e==Lc||e==Kc||e==Fc}o(cs,"isFunction");var ds=cs,qc=xe["__core-js_shared__"],Wn=qc,yi=(function(){var t=/[^.]+$/.exec(Wn&&Wn.keys&&Wn.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function ps(t){return!!yi&&yi in t}o(ps,"isMasked");var Vc=ps,Gc=Function.prototype,Jc=Gc.toString;function fs(t){if(t!=null){try{return Jc.call(t)}catch{}try{return t+""}catch{}}return""}o(fs,"toSource");var ze=fs,Yc=/[\\^$.*+?()[\]{}|]/g,Xc=/^\[object .+?Constructor\]$/,Qc=Function.prototype,ed=Object.prototype,td=Qc.toString,nd=ed.hasOwnProperty,rd=RegExp("^"+td.call(nd).replace(Yc,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function gs(t){if(!it(t)||Vc(t))return!1;var e=ds(t)?rd:Xc;return e.test(ze(t))}o(gs,"baseIsNative");var id=gs;function ms(t,e){return t?.[e]}o(ms,"getValue");var sd=ms;function hs(t,e){var n=sd(t,e);return id(n)?n:void 0}o(hs,"getNative");var Ke=hs,ad=Ke(xe,"WeakMap"),nr=ad,od=(function(){try{var t=Ke(Object,"defineProperty");return t({},"",{}),t}catch{}})(),vi=od,ld=9007199254740991,ud=/^(?:0|[1-9]\d*)$/;function ys(t,e){var n=typeof t;return e=e??ld,!!e&&(n=="number"||n!="symbol"&&ud.test(t))&&t>-1&&t%1==0&&t<e}o(ys,"isIndex");var vr=ys;function vs(t,e,n){e=="__proto__"&&vi?vi(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}o(vs,"baseAssignValue");var _s=vs;function Ts(t,e){return t===e||t!==t&&e!==e}o(Ts,"eq");var _r=Ts,cd=Object.prototype,dd=cd.hasOwnProperty;function bs(t,e,n){var r=t[e];(!(dd.call(t,e)&&_r(r,n))||n===void 0&&!(e in t))&&_s(t,e,n)}o(bs,"assignValue");var pd=bs,fd=9007199254740991;function ws(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=fd}o(ws,"isLength");var Tr=ws;function Ps(t){return t!=null&&Tr(t.length)&&!ds(t)}o(Ps,"isArrayLike");var xs=Ps,gd=Object.prototype;function ks(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||gd;return t===n}o(ks,"isPrototype");var Ss=ks;function Os(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}o(Os,"baseTimes");var md=Os,hd="[object Arguments]";function Es(t){return je(t)&&Ue(t)==hd}o(Es,"baseIsArguments");var _i=Es,Is=Object.prototype,yd=Is.hasOwnProperty,vd=Is.propertyIsEnumerable,_d=_i((function(){return arguments})())?_i:function(t){return je(t)&&yd.call(t,"callee")&&!vd.call(t,"callee")},Bs=_d;function Cs(){return!1}o(Cs,"stubFalse");var Td=Cs,As=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ti=As&&typeof module=="object"&&module&&!module.nodeType&&module,bd=Ti&&Ti.exports===As,bi=bd?xe.Buffer:void 0,wd=bi?bi.isBuffer:void 0,Pd=wd||Td,rr=Pd,xd="[object Arguments]",kd="[object Array]",Sd="[object Boolean]",Od="[object Date]",Ed="[object Error]",Id="[object Function]",Bd="[object Map]",Cd="[object Number]",Ad="[object Object]",Zd="[object RegExp]",Rd="[object Set]",Nd="[object String]",Dd="[object WeakMap]",Hd="[object ArrayBuffer]",Md="[object DataView]",jd="[object Float32Array]",$d="[object Float64Array]",Ud="[object Int8Array]",zd="[object Int16Array]",Kd="[object Int32Array]",Wd="[object Uint8Array]",Ld="[object Uint8ClampedArray]",Fd="[object Uint16Array]",qd="[object Uint32Array]",C={};C[jd]=C[$d]=C[Ud]=C[zd]=C[Kd]=C[Wd]=C[Ld]=C[Fd]=C[qd]=!0;C[xd]=C[kd]=C[Hd]=C[Sd]=C[Md]=C[Od]=C[Ed]=C[Id]=C[Bd]=C[Cd]=C[Ad]=C[Zd]=C[Rd]=C[Nd]=C[Dd]=!1;function Zs(t){return je(t)&&Tr(t.length)&&!!C[Ue(t)]}o(Zs,"baseIsTypedArray");var Vd=Zs;function Rs(t){return function(e){return t(e)}}o(Rs,"baseUnary");var Gd=Rs,Ns=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Et=Ns&&typeof module=="object"&&module&&!module.nodeType&&module,Jd=Et&&Et.exports===Ns,Ln=Jd&&Qi.process,Yd=(function(){try{var t=Et&&Et.require&&Et.require("util").types;return t||Ln&&Ln.binding&&Ln.binding("util")}catch{}})(),wi=Yd,Pi=wi&&wi.isTypedArray,Xd=Pi?Gd(Pi):Vd,Ds=Xd,Qd=Object.prototype,ep=Qd.hasOwnProperty;function Hs(t,e){var n=be(t),r=!n&&Bs(t),i=!n&&!r&&rr(t),s=!n&&!r&&!i&&Ds(t),a=n||r||i||s,l=a?md(t.length,String):[],u=l.length;for(var d in t)(e||ep.call(t,d))&&!(a&&(d=="length"||i&&(d=="offset"||d=="parent")||s&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||vr(d,u)))&&l.push(d);return l}o(Hs,"arrayLikeKeys");var Ms=Hs;function js(t,e){return function(n){return t(e(n))}}o(js,"overArg");var $s=js,tp=$s(Object.keys,Object),np=tp,rp=Object.prototype,ip=rp.hasOwnProperty;function Us(t){if(!Ss(t))return np(t);var e=[];for(var n in Object(t))ip.call(t,n)&&n!="constructor"&&e.push(n);return e}o(Us,"baseKeys");var sp=Us;function zs(t){return xs(t)?Ms(t):sp(t)}o(zs,"keys");var br=zs;function Ks(t){var e=[];if(t!=null)for(var n in Object(t))e.push(n);return e}o(Ks,"nativeKeysIn");var ap=Ks,op=Object.prototype,lp=op.hasOwnProperty;function Ws(t){if(!it(t))return ap(t);var e=Ss(t),n=[];for(var r in t)r=="constructor"&&(e||!lp.call(t,r))||n.push(r);return n}o(Ws,"baseKeysIn");var up=Ws;function Ls(t){return xs(t)?Ms(t,!0):up(t)}o(Ls,"keysIn");var cp=Ls,dp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,pp=/^\w*$/;function Fs(t,e){if(be(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||hr(t)?!0:pp.test(t)||!dp.test(t)||e!=null&&t in Object(e)}o(Fs,"isKey");var wr=Fs,fp=Ke(Object,"create"),Ct=fp;function qs(){this.__data__=Ct?Ct(null):{},this.size=0}o(qs,"hashClear");var gp=qs;function Vs(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}o(Vs,"hashDelete");var mp=Vs,hp="__lodash_hash_undefined__",yp=Object.prototype,vp=yp.hasOwnProperty;function Gs(t){var e=this.__data__;if(Ct){var n=e[t];return n===hp?void 0:n}return vp.call(e,t)?e[t]:void 0}o(Gs,"hashGet");var _p=Gs,Tp=Object.prototype,bp=Tp.hasOwnProperty;function Js(t){var e=this.__data__;return Ct?e[t]!==void 0:bp.call(e,t)}o(Js,"hashHas");var wp=Js,Pp="__lodash_hash_undefined__";function Ys(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=Ct&&e===void 0?Pp:e,this}o(Ys,"hashSet");var xp=Ys;function We(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}o(We,"Hash");We.prototype.clear=gp;We.prototype.delete=mp;We.prototype.get=_p;We.prototype.has=wp;We.prototype.set=xp;var xi=We;function Xs(){this.__data__=[],this.size=0}o(Xs,"listCacheClear");var kp=Xs;function Qs(t,e){for(var n=t.length;n--;)if(_r(t[n][0],e))return n;return-1}o(Qs,"assocIndexOf");var un=Qs,Sp=Array.prototype,Op=Sp.splice;function ea(t){var e=this.__data__,n=un(e,t);if(n<0)return!1;var r=e.length-1;return n==r?e.pop():Op.call(e,n,1),--this.size,!0}o(ea,"listCacheDelete");var Ep=ea;function ta(t){var e=this.__data__,n=un(e,t);return n<0?void 0:e[n][1]}o(ta,"listCacheGet");var Ip=ta;function na(t){return un(this.__data__,t)>-1}o(na,"listCacheHas");var Bp=na;function ra(t,e){var n=this.__data__,r=un(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}o(ra,"listCacheSet");var Cp=ra;function Le(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}o(Le,"ListCache");Le.prototype.clear=kp;Le.prototype.delete=Ep;Le.prototype.get=Ip;Le.prototype.has=Bp;Le.prototype.set=Cp;var cn=Le,Ap=Ke(xe,"Map"),At=Ap;function ia(){this.size=0,this.__data__={hash:new xi,map:new(At||cn),string:new xi}}o(ia,"mapCacheClear");var Zp=ia;function sa(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}o(sa,"isKeyable");var Rp=sa;function aa(t,e){var n=t.__data__;return Rp(e)?n[typeof e=="string"?"string":"hash"]:n.map}o(aa,"getMapData");var dn=aa;function oa(t){var e=dn(this,t).delete(t);return this.size-=e?1:0,e}o(oa,"mapCacheDelete");var Np=oa;function la(t){return dn(this,t).get(t)}o(la,"mapCacheGet");var Dp=la;function ua(t){return dn(this,t).has(t)}o(ua,"mapCacheHas");var Hp=ua;function ca(t,e){var n=dn(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}o(ca,"mapCacheSet");var Mp=ca;function Fe(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}o(Fe,"MapCache");Fe.prototype.clear=Zp;Fe.prototype.delete=Np;Fe.prototype.get=Dp;Fe.prototype.has=Hp;Fe.prototype.set=Mp;var pn=Fe,jp="Expected a function";function fn(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(jp);var n=o(function(){var r=arguments,i=e?e.apply(this,r):r[0],s=n.cache;if(s.has(i))return s.get(i);var a=t.apply(this,r);return n.cache=s.set(i,a)||s,a},"memoized");return n.cache=new(fn.Cache||pn),n}o(fn,"memoize");fn.Cache=pn;var $p=fn,Up=500;function da(t){var e=$p(t,function(r){return n.size===Up&&n.clear(),r}),n=e.cache;return e}o(da,"memoizeCapped");var zp=da,Kp=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Wp=/\\(\\)?/g,Lp=zp(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Kp,function(n,r,i,s){e.push(i?s.replace(Wp,"$1"):r||n)}),e}),Fp=Lp;function pa(t){return t==null?"":Uc(t)}o(pa,"toString");var qp=pa;function fa(t,e){return be(t)?t:wr(t,e)?[t]:Fp(qp(t))}o(fa,"castPath");var gn=fa,Vp=1/0;function ga(t){if(typeof t=="string"||hr(t))return t;var e=t+"";return e=="0"&&1/t==-Vp?"-0":e}o(ga,"toKey");var Mt=ga;function ma(t,e){e=gn(e,t);for(var n=0,r=e.length;t!=null&&n<r;)t=t[Mt(e[n++])];return n&&n==r?t:void 0}o(ma,"baseGet");var Pr=ma;function ha(t,e,n){var r=t==null?void 0:Pr(t,e);return r===void 0?n:r}o(ha,"get");var Gp=ha;function ya(t,e){for(var n=-1,r=e.length,i=t.length;++n<r;)t[i+n]=e[n];return t}o(ya,"arrayPush");var va=ya,Jp=$s(Object.getPrototypeOf,Object),_a=Jp,Yp="[object Object]",Xp=Function.prototype,Qp=Object.prototype,Ta=Xp.toString,ef=Qp.hasOwnProperty,tf=Ta.call(Object);function ba(t){if(!je(t)||Ue(t)!=Yp)return!1;var e=_a(t);if(e===null)return!0;var n=ef.call(e,"constructor")&&e.constructor;return typeof n=="function"&&n instanceof n&&Ta.call(n)==tf}o(ba,"isPlainObject");var nf=ba;function wa(){this.__data__=new cn,this.size=0}o(wa,"stackClear");var rf=wa;function Pa(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}o(Pa,"stackDelete");var sf=Pa;function xa(t){return this.__data__.get(t)}o(xa,"stackGet");var af=xa;function ka(t){return this.__data__.has(t)}o(ka,"stackHas");var of=ka,lf=200;function Sa(t,e){var n=this.__data__;if(n instanceof cn){var r=n.__data__;if(!At||r.length<lf-1)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new pn(r)}return n.set(t,e),this.size=n.size,this}o(Sa,"stackSet");var uf=Sa;function qe(t){var e=this.__data__=new cn(t);this.size=e.size}o(qe,"Stack");qe.prototype.clear=rf;qe.prototype.delete=sf;qe.prototype.get=af;qe.prototype.has=of;qe.prototype.set=uf;var Ft=qe;function Oa(t,e){for(var n=-1,r=t==null?0:t.length,i=0,s=[];++n<r;){var a=t[n];e(a,n,t)&&(s[i++]=a)}return s}o(Oa,"arrayFilter");var cf=Oa;function Ea(){return[]}o(Ea,"stubArray");var Ia=Ea,df=Object.prototype,pf=df.propertyIsEnumerable,ki=Object.getOwnPropertySymbols,ff=ki?function(t){return t==null?[]:(t=Object(t),cf(ki(t),function(e){return pf.call(t,e)}))}:Ia,Ba=ff,gf=Object.getOwnPropertySymbols,mf=gf?function(t){for(var e=[];t;)va(e,Ba(t)),t=_a(t);return e}:Ia,hf=mf;function Ca(t,e,n){var r=e(t);return be(t)?r:va(r,n(t))}o(Ca,"baseGetAllKeys");var Aa=Ca;function Za(t){return Aa(t,br,Ba)}o(Za,"getAllKeys");var Si=Za;function Ra(t){return Aa(t,cp,hf)}o(Ra,"getAllKeysIn");var yf=Ra,vf=Ke(xe,"DataView"),ir=vf,_f=Ke(xe,"Promise"),sr=_f,Tf=Ke(xe,"Set"),ar=Tf,Oi="[object Map]",bf="[object Object]",Ei="[object Promise]",Ii="[object Set]",Bi="[object WeakMap]",Ci="[object DataView]",wf=ze(ir),Pf=ze(At),xf=ze(sr),kf=ze(ar),Sf=ze(nr),Re=Ue;(ir&&Re(new ir(new ArrayBuffer(1)))!=Ci||At&&Re(new At)!=Oi||sr&&Re(sr.resolve())!=Ei||ar&&Re(new ar)!=Ii||nr&&Re(new nr)!=Bi)&&(Re=o(function(t){var e=Ue(t),n=e==bf?t.constructor:void 0,r=n?ze(n):"";if(r)switch(r){case wf:return Ci;case Pf:return Oi;case xf:return Ei;case kf:return Ii;case Sf:return Bi}return e},"getTag"));var Ai=Re,Of=xe.Uint8Array,Zi=Of,Ef="__lodash_hash_undefined__";function Na(t){return this.__data__.set(t,Ef),this}o(Na,"setCacheAdd");var If=Na;function Da(t){return this.__data__.has(t)}o(Da,"setCacheHas");var Bf=Da;function Zt(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new pn;++e<n;)this.add(t[e])}o(Zt,"SetCache");Zt.prototype.add=Zt.prototype.push=If;Zt.prototype.has=Bf;var Cf=Zt;function Ha(t,e){for(var n=-1,r=t==null?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}o(Ha,"arraySome");var Af=Ha;function Ma(t,e){return t.has(e)}o(Ma,"cacheHas");var Zf=Ma,Rf=1,Nf=2;function ja(t,e,n,r,i,s){var a=n&Rf,l=t.length,u=e.length;if(l!=u&&!(a&&u>l))return!1;var d=s.get(t),f=s.get(e);if(d&&f)return d==e&&f==t;var g=-1,h=!0,w=n&Nf?new Cf:void 0;for(s.set(t,e),s.set(e,t);++g<l;){var T=t[g],N=e[g];if(r)var F=a?r(N,T,g,e,t,s):r(T,N,g,t,e,s);if(F!==void 0){if(F)continue;h=!1;break}if(w){if(!Af(e,function(J,ae){if(!Zf(w,ae)&&(T===J||i(T,J,n,r,s)))return w.push(ae)})){h=!1;break}}else if(!(T===N||i(T,N,n,r,s))){h=!1;break}}return s.delete(t),s.delete(e),h}o(ja,"equalArrays");var $a=ja;function Ua(t){var e=-1,n=Array(t.size);return t.forEach(function(r,i){n[++e]=[i,r]}),n}o(Ua,"mapToArray");var Df=Ua;function za(t){var e=-1,n=Array(t.size);return t.forEach(function(r){n[++e]=r}),n}o(za,"setToArray");var Hf=za,Mf=1,jf=2,$f="[object Boolean]",Uf="[object Date]",zf="[object Error]",Kf="[object Map]",Wf="[object Number]",Lf="[object RegExp]",Ff="[object Set]",qf="[object String]",Vf="[object Symbol]",Gf="[object ArrayBuffer]",Jf="[object DataView]",Ri=Be?Be.prototype:void 0,Fn=Ri?Ri.valueOf:void 0;function Ka(t,e,n,r,i,s,a){switch(n){case Jf:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Gf:return!(t.byteLength!=e.byteLength||!s(new Zi(t),new Zi(e)));case $f:case Uf:case Wf:return _r(+t,+e);case zf:return t.name==e.name&&t.message==e.message;case Lf:case qf:return t==e+"";case Kf:var l=Df;case Ff:var u=r&Mf;if(l||(l=Hf),t.size!=e.size&&!u)return!1;var d=a.get(t);if(d)return d==e;r|=jf,a.set(t,e);var f=$a(l(t),l(e),r,i,s,a);return a.delete(t),f;case Vf:if(Fn)return Fn.call(t)==Fn.call(e)}return!1}o(Ka,"equalByTag");var Yf=Ka,Xf=1,Qf=Object.prototype,eg=Qf.hasOwnProperty;function Wa(t,e,n,r,i,s){var a=n&Xf,l=Si(t),u=l.length,d=Si(e),f=d.length;if(u!=f&&!a)return!1;for(var g=u;g--;){var h=l[g];if(!(a?h in e:eg.call(e,h)))return!1}var w=s.get(t),T=s.get(e);if(w&&T)return w==e&&T==t;var N=!0;s.set(t,e),s.set(e,t);for(var F=a;++g<u;){h=l[g];var J=t[h],ae=e[h];if(r)var oe=a?r(ae,J,h,e,t,s):r(J,ae,h,t,e,s);if(!(oe===void 0?J===ae||i(J,ae,n,r,s):oe)){N=!1;break}F||(F=h=="constructor")}if(N&&!F){var D=t.constructor,Oe=e.constructor;D!=Oe&&"constructor"in t&&"constructor"in e&&!(typeof D=="function"&&D instanceof D&&typeof Oe=="function"&&Oe instanceof Oe)&&(N=!1)}return s.delete(t),s.delete(e),N}o(Wa,"equalObjects");var tg=Wa,ng=1,Ni="[object Arguments]",Di="[object Array]",Wt="[object Object]",rg=Object.prototype,Hi=rg.hasOwnProperty;function La(t,e,n,r,i,s){var a=be(t),l=be(e),u=a?Di:Ai(t),d=l?Di:Ai(e);u=u==Ni?Wt:u,d=d==Ni?Wt:d;var f=u==Wt,g=d==Wt,h=u==d;if(h&&rr(t)){if(!rr(e))return!1;a=!0,f=!1}if(h&&!f)return s||(s=new Ft),a||Ds(t)?$a(t,e,n,r,i,s):Yf(t,e,u,n,r,i,s);if(!(n&ng)){var w=f&&Hi.call(t,"__wrapped__"),T=g&&Hi.call(e,"__wrapped__");if(w||T){var N=w?t.value():t,F=T?e.value():e;return s||(s=new Ft),i(N,F,n,r,s)}}return h?(s||(s=new Ft),tg(t,e,n,r,i,s)):!1}o(La,"baseIsEqualDeep");var ig=La;function xr(t,e,n,r,i){return t===e?!0:t==null||e==null||!je(t)&&!je(e)?t!==t&&e!==e:ig(t,e,n,r,xr,i)}o(xr,"baseIsEqual");var mn=xr,sg=1,ag=2;function Fa(t,e,n,r){var i=n.length,s=i,a=!r;if(t==null)return!s;for(t=Object(t);i--;){var l=n[i];if(a&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++i<s;){l=n[i];var u=l[0],d=t[u],f=l[1];if(a&&l[2]){if(d===void 0&&!(u in t))return!1}else{var g=new Ft;if(r)var h=r(d,f,u,t,e,g);if(!(h===void 0?mn(f,d,sg|ag,r,g):h))return!1}}return!0}o(Fa,"baseIsMatch");var og=Fa;function qa(t){return t===t&&!it(t)}o(qa,"isStrictComparable");var Va=qa;function Ga(t){for(var e=br(t),n=e.length;n--;){var r=e[n],i=t[r];e[n]=[r,i,Va(i)]}return e}o(Ga,"getMatchData");var lg=Ga;function Ja(t,e){return function(n){return n==null?!1:n[t]===e&&(e!==void 0||t in Object(n))}}o(Ja,"matchesStrictComparable");var Ya=Ja;function Xa(t){var e=lg(t);return e.length==1&&e[0][2]?Ya(e[0][0],e[0][1]):function(n){return n===t||og(n,t,e)}}o(Xa,"baseMatches");var ug=Xa;function Qa(t,e){return t!=null&&e in Object(t)}o(Qa,"baseHasIn");var cg=Qa;function eo(t,e,n){e=gn(e,t);for(var r=-1,i=e.length,s=!1;++r<i;){var a=Mt(e[r]);if(!(s=t!=null&&n(t,a)))break;t=t[a]}return s||++r!=i?s:(i=t==null?0:t.length,!!i&&Tr(i)&&vr(a,i)&&(be(t)||Bs(t)))}o(eo,"hasPath");var dg=eo;function to(t,e){return t!=null&&dg(t,e,cg)}o(to,"hasIn");var pg=to,fg=1,gg=2;function no(t,e){return wr(t)&&Va(e)?Ya(Mt(t),e):function(n){var r=Gp(n,t);return r===void 0&&r===e?pg(n,t):mn(e,r,fg|gg)}}o(no,"baseMatchesProperty");var mg=no;function ro(t){return function(e){return e?.[t]}}o(ro,"baseProperty");var hg=ro;function io(t){return function(e){return Pr(e,t)}}o(io,"basePropertyDeep");var yg=io;function so(t){return wr(t)?hg(Mt(t)):yg(t)}o(so,"property");var vg=so;function ao(t){return typeof t=="function"?t:t==null?zc:typeof t=="object"?be(t)?mg(t[0],t[1]):ug(t):vg(t)}o(ao,"baseIteratee");var kr=ao;function oo(t){return function(e,n,r){for(var i=-1,s=Object(e),a=r(e),l=a.length;l--;){var u=a[t?l:++i];if(n(s[u],u,s)===!1)break}return e}}o(oo,"createBaseFor");var _g=oo,Tg=_g(),bg=Tg;function lo(t,e){return t&&bg(t,e,br)}o(lo,"baseForOwn");var wg=lo;function uo(t,e){return mn(t,e)}o(uo,"isEqual");var Ie=uo;function co(t,e,n){n=typeof n=="function"?n:void 0;var r=n?n(t,e):void 0;return r===void 0?mn(t,e,void 0,n):!!r}o(co,"isEqualWith");var Pg=co;function po(t){return t===void 0}o(po,"isUndefined");var Mi=po;function fo(t,e){var n={};return e=kr(e,3),wg(t,function(r,i,s){_s(n,i,e(r,i,s))}),n}o(fo,"mapValues");var xg=fo,kg="Expected a function";function go(t){if(typeof t!="function")throw new TypeError(kg);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)}}o(go,"negate");var Sg=go;function mo(t,e,n,r){if(!it(t))return t;e=gn(e,t);for(var i=-1,s=e.length,a=s-1,l=t;l!=null&&++i<s;){var u=Mt(e[i]),d=n;if(u==="__proto__"||u==="constructor"||u==="prototype")return t;if(i!=a){var f=l[u];d=r?r(f,u,l):void 0,d===void 0&&(d=it(f)?f:vr(e[i+1])?[]:{})}pd(l,u,d),l=l[u]}return t}o(mo,"baseSet");var Og=mo;function ho(t,e,n){for(var r=-1,i=e.length,s={};++r<i;){var a=e[r],l=Pr(t,a);n(l,a)&&Og(s,gn(a,t),l)}return s}o(ho,"basePickBy");var Eg=ho;function yo(t,e){if(t==null)return{};var n=os(yf(t),function(r){return[r]});return e=kr(e),Eg(t,n,function(r,i){return e(r,i[0])})}o(yo,"pickBy");var Ig=yo;function vo(t,e){return Ig(t,Sg(kr(e)))}o(vo,"omitBy");var ji=vo,_o=o((t,e)=>To(t,e,new WeakSet),"isEqual"),$i=o(t=>nf(t),"_isPlainObject"),To=o((t,e,n)=>Pg(t,e,Bg(n)),"_isEqualWithVisitedTracking"),Bg=o(t=>(e,n)=>{if($i(e)&&!t.has(e)&&$i(n)&&!t.has(n)){let r=ji(e,Mi),i=ji(n,Mi);return t.add(r).add(i).add(e).add(n),To(r,i,t)}},"_customizerWithVisitedTracking"),Cg=o(t=>Array.from(new Set(t)),"unique"),Ag={compare:_o},bo=class{constructor(e=[],n={}){this._options=c(c({},Ag),n),this._items=[];for(let r of e)this.add(r)}get items(){return[...this._items]}get size(){return this._items.length}has(e){return this._items.some(n=>this._options.compare(n,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(n=>e.has(n))}};o(bo,"CustomSet");var Zg=bo,_={};ce(_,{errToObj:()=>Rg,toString:()=>Ng});var Rg=o(t=>typeof t=="string"?{message:t}:t||{},"errToObj"),Ng=o(t=>typeof t=="string"?t:t?.message,"toString"),ue={};ce(ue,{assertNever:()=>wo});function wo(t){throw new Error("assertNever called")}o(wo,"assertNever");var le={};ce(le,{compareFunctions:()=>Hg,joinValues:()=>Po,jsonStringifyReplacer:()=>Dg});function Po(t,e=" | "){return t.map(n=>typeof n=="string"?`'${n}'`:n).join(e)}o(Po,"joinValues");var Dg=o((t,e)=>typeof e=="bigint"?e.toString():e,"jsonStringifyReplacer"),Hg=o((t,e)=>t.toString()===e.toString(),"compareFunctions"),xo={};ce(xo,{extractPrecisionAndOffset:()=>So,generateDatetimeRegex:()=>ko});var ko=o(t=>{let e=t.precision?or+t.precision+jg:t.precision===0?"":Io,n=t.offset?Eo:Mg;return new RegExp(`^${Oo}${e}${n}$`)},"generateDatetimeRegex"),So=o(t=>({precision:$g(t),offset:t.endsWith(`${Eo}$`)}),"extractPrecisionAndOffset"),Oo="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",Eo="(([+-]\\d{2}(:?\\d{2})?)|Z)",Mg="Z",Io="(\\.\\d+)?",or="\\.\\d{",jg="}",$g=o(t=>{let e=t.slice(1+Oo.length);return e.startsWith(Io)?null:e.startsWith(or)?parseInt(e.slice(or.length)):0},"_extractPrecision"),nn=o((t,e)=>{let n;switch(t.code){case"invalid_type":t.received==="undefined"?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case"invalid_literal":n=`Invalid literal value, expected ${JSON.stringify(t.expected,le.jsonStringifyReplacer)}`;break;case"unrecognized_keys":n=`Unrecognized key(s) in object: ${le.joinValues(t.keys,", ")}`;break;case"invalid_union":n="Invalid input";break;case"invalid_union_discriminator":n=`Invalid discriminator value. Expected ${le.joinValues(t.options)}`;break;case"invalid_enum_value":n=`Invalid enum value. Expected ${le.joinValues(t.options)}, received '${t.received}'`;break;case"invalid_arguments":n="Invalid function arguments";break;case"invalid_return_type":n="Invalid function return type";break;case"invalid_date":n="Invalid date";break;case"invalid_string":typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:ue.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case"too_small":t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case"too_big":t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case"custom":n="Invalid input";break;case"invalid_intersection_types":n="Intersection results could not be merged";break;case"not_multiple_of":n=`Number must be a multiple of ${t.multipleOf}`;break;case"not_finite":n="Number must be finite";break;case"unresolved_reference":n="Unresolved reference";break;default:n=e.defaultError,ue.assertNever(t)}return{message:n}},"errorMap"),rn=class Bo extends Error{constructor(e){super(),this.__type__="ZuiError",this.issues=[],this.addIssue=o(r=>{this.issues=[...this.issues,r]},"addIssue"),this.addIssues=o((r=[])=>{this.issues=[...this.issues,...r]},"addIssues");let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let n=e||function(s){return s.message},r={_errors:[]},i=o(s=>{for(let a of s.issues)if(a.code==="invalid_union")a.unionErrors.map(i);else if(a.code==="invalid_return_type")i(a.returnTypeError);else if(a.code==="invalid_arguments")i(a.argumentsError);else if(a.path.length===0)r._errors.push(n(a));else{let l=r,u=0;for(;u<a.path.length;){let d=a.path[u];u===a.path.length-1?(l[d]=l[d]||{_errors:[]},l[d]._errors.push(n(a))):l[d]=l[d]||{_errors:[]},l=l[d],u++}}},"processError");return i(this),r}static assert(e){if(!(e instanceof Bo))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,le.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}};o(rn,"ZodError");rn.create=o(t=>new rn(t),"create");var Te=rn,Ug=nn;function sn(){return Ug}o(sn,"getErrorMap");var A={};function Co(t){Object.assign(A,t)}o(Co,"setBuilders");var lr=o(t=>{var e;let{data:n,path:r,errorMaps:i,issueData:s}=t,a=[...r,...s.path||[]],l=p(c({},s),{path:a}),u="",d=i.filter(f=>!!f).slice().reverse();for(let f of d)u=f(l,{data:n,defaultError:u}).message;return p(c({},s),{path:a,message:(e=s.message)!=null?e:u})},"makeIssue");function m(t,e){let n=lr({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,sn(),nn].filter(r=>!!r)});t.common.issues.push(n)}o(m,"addIssueToContext");var Ao=class Zo{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let i of n){if(i.status==="aborted")return{status:"aborted"};i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let i of n)r.push({key:await i.key,value:await i.value});return Zo.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let i of n){let{key:s,value:a}=i;if(s.status==="aborted")return{status:"aborted"};if(a.status==="aborted")return{status:"aborted"};s.status==="dirty"&&e.dirty(),a.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof a.value<"u"||i.alwaysSet)&&(r[s.value]=a.value)}return{status:e.value,value:r}}};o(Ao,"ParseStatus");var te=Ao,an=o(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),He=o(t=>{switch(typeof t){case"undefined":return"undefined";case"string":return"string";case"number":return isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":typeof Promise<"u"&&t instanceof Promise||t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":"object";default:return"unknown"}},"getParsedType"),Ro=class{constructor(e,n,r,i){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=i}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}};o(Ro,"ParseInputLazyPath");var fe=Ro,No=class extends Error{constructor(e){super(`Cannot access property ${e} before initialization. You're probably importing ZUI incorrectly. If not, reach out to the maintainers.`)}};o(No,"_CircularDependencyError");var qn=No,Do=class{constructor(e){this.__type__="ZuiType",this.spa=this.safeParseAsync,this._handleResult=o((n,r)=>{if(r.status==="valid")return{success:!0,data:r.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let i=new Te(n.common.issues);return this._error=i,this._error}}},"_handleResult"),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.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),this.downstream=this.downstream.bind(this)}get description(){return this._metadataRoot._def.description}get typeName(){return this._def.typeName}dereference(e){return this}getReferences(){return[]}clone(){let e=this.constructor;return new e(c({},this._def))}_getType(e){return He(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:He(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:He(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(an(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){var r;let i={common:{issues:[],async:(r=n?.async)!=null?r:!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:He(e)},s=this._parseSync({data:e,path:i.path,parent:i});return this._handleResult(i,s)}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:He(e)},i=this._parse({data:e,path:r.path,parent:r}),s=await(an(i)?i:Promise.resolve(i));return this._handleResult(r,s)}refine(e,n){let r=o(i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n,"getIssueProperties");return A.downstream(this,i=>{let s=e(i),a=[],l=o(()=>a.push(c({code:"custom"},r(i))),"setError");return typeof Promise<"u"&&s instanceof Promise?s.then(u=>u?{status:"valid",value:i}:(l(),{status:"dirty",value:i,issues:a})):s?{status:"valid",value:i}:(l(),{status:"dirty",value:i,issues:a})})}superRefine(e){return A.downstream(this,(n,r)=>{let i=[],s=e(n,{addIssue:a=>i.push(a),path:r.path});return typeof Promise<"u"&&s instanceof Promise?s.then(()=>i.some(a=>a.fatal)?{status:"aborted",issues:i}:i.length?{status:"dirty",value:n,issues:i}:{status:"valid",value:n}):i.some(a=>a.fatal)?{status:"aborted",issues:i}:i.length?{status:"dirty",value:n,issues:i}:{status:"valid",value:n}})}downstream(e,n){return A.downstream(this,e,n)}optional(){return A.optional(this,this._def)}nullable(){return A.nullable(this,this._def)}nullish(){return this.nullable().optional()}array(){return A.array(this,this._def)}promise(){return A.promise(this,this._def)}mandatory(){return this}or(e){return A.union([this,e])}and(e){return A.intersection(this,e)}transform(e){return A.downstream(this,(n,r)=>{let i=[],s=e(n,{addIssue:a=>i.push(a),path:r.path});return s instanceof Promise?s.then(a=>i.some(l=>l.fatal)?{status:"aborted",issues:i}:i.length?{status:"dirty",value:a,issues:i}:{status:"valid",value:a}):i.some(a=>a.fatal)?{status:"aborted",issues:i}:i.length?{status:"dirty",value:s,issues:i}:{status:"valid",value:s}},{failFast:!0})}default(e){let n=typeof e=="function"?e:()=>e;return A.default(this,n)}brand(){return A.branded(this)}catch(e){return A.catch(this,e)}describe(e){let n=this.clone();return n._metadataRoot._def.description=e,n}pipe(e){return A.pipeline(this,e)}readonly(){return A.readonly(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}metadata(e){var n,r,i;let s=this.clone(),a=s._metadataRoot;(i=(n=a._def)[r=B])!=null||(n[r]={});for(let[l,u]of Object.entries(e))a._def[B]=p(c({},a._def[B]),{[l]:u});return s}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 n;return e===void 0?n=!0:typeof e=="function"?n=e.toString():n=e,this.metadata({hidden:n})}disabled(e){let n;return e===void 0?n=!0:typeof e=="function"?n=e.toString():n=e,this.metadata({disabled:n})}placeholder(e){return this.metadata({placeholder:e})}toJSONSchema(){throw new qn("toJSONSchema")}toTypescriptType(e){throw new qn("toTypescriptType")}toTypescriptSchema(){throw new qn("toTypescriptSchema")}naked(){return this}};o(Do,"ZodBaseTypeImpl");var x=Do,Ho=class Mo extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return{status:"valid",value:e.data}}isEqual(e){return e instanceof Mo}};o(Ho,"ZodAnyImpl");var zg=Ho,jo=class Ne extends x{dereference(e){return new Ne(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Ne(p(c({},this._def),{type:this._def.type.clone()}))}isEqual(e){var n,r,i,s,a,l;return e instanceof Ne?Ie((n=this._def.exactLength)==null?void 0:n.value,(r=e._def.exactLength)==null?void 0:r.value)&&Ie((i=this._def.maxLength)==null?void 0:i.value,(s=e._def.maxLength)==null?void 0:s.value)&&Ie((a=this._def.minLength)==null?void 0:a.value,(l=e._def.minLength)==null?void 0:l.value)&&this._def.type.isEqual(e._def.type):!1}_parse(e){let{ctx:n,status:r}=this._processInputParams(e),i=this._def;if(n.parsedType!=="array")return m(n,{code:"invalid_type",expected:"array",received:n.parsedType}),{status:"aborted"};if(i.exactLength!==null){let a=n.data.length>i.exactLength.value,l=n.data.length<i.exactLength.value;(a||l)&&(m(n,{code:a?"too_big":"too_small",minimum:l?i.exactLength.value:void 0,maximum:a?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(m(n,{code:"too_small",minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(m(n,{code:"too_big",maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((a,l)=>i.type._parseAsync(new fe(n,a,n.path,l)))).then(a=>te.mergeArray(r,a));let s=[...n.data].map((a,l)=>i.type._parseSync(new fe(n,a,n.path,l)));return te.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new Ne(p(c({},this._def),{minLength:{value:e,message:_.toString(n)}}))}max(e,n){return new Ne(p(c({},this._def),{maxLength:{value:e,message:_.toString(n)}}))}length(e,n){return new Ne(p(c({},this._def),{exactLength:{value:e,message:_.toString(n)}}))}nonempty(e){return this.min(1,e)}};o(jo,"ZodArrayImpl");var Kg=jo,$o=class qt extends x{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)!=="bigint"){let s=this._getOrReturnCtx(e);return m(s,{code:"invalid_type",expected:"bigint",received:s.parsedType}),{status:"aborted"}}let r,i=new te;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:"too_small",type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:"too_big",type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),m(r,{code:"not_multiple_of",multipleOf:s.value,message:s.message}),i.dirty()):ue.assertNever(s);return{status:i.value,value:e.data}}isEqual(e){if(!(e instanceof qt)||this._def.coerce!==e._def.coerce)return!1;let n=new j.CustomSet(this._def.checks),r=new j.CustomSet(e._def.checks);return n.isEqual(r)}gte(e,n){return this.setLimit("min",e,!0,_.toString(n))}gt(e,n){return this.setLimit("min",e,!1,_.toString(n))}lte(e,n){return this.setLimit("max",e,!0,_.toString(n))}lt(e,n){return this.setLimit("max",e,!1,_.toString(n))}setLimit(e,n,r,i){return new qt(p(c({},this._def),{checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:_.toString(i)}]}))}_addCheck(e){return new qt(p(c({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};o($o,"ZodBigIntImpl");var Wg=$o,Uo=class zo extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!=="boolean"){let r=this._getOrReturnCtx(e);return m(r,{code:"invalid_type",expected:"boolean",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof zo?this._def.coerce===e._def.coerce:!1}};o(Uo,"ZodBooleanImpl");var Lg=Uo,Ko=class ht extends x{dereference(e){return new ht(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new ht(p(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}isEqual(e){return e instanceof ht?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new ht(p(c({},this._def),{type:this._def.type.mandatory()}))}};o(Ko,"ZodBrandedImpl");var Fg=Ko,Wo=class yt extends x{_parse(e){let{ctx:n}=this._processInputParams(e),r=p(c({},n),{common:p(c({},n.common),{issues:[]})}),i=this._def.innerType._parse({data:r.data,path:r.path,parent:c({},r)});return an(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Te(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Te(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof yt?this._def.innerType.isEqual(e._def.innerType)&&le.compareFunctions(this._def.catchValue,e._def.catchValue):!1}dereference(e){return new yt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new yt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}naked(){return this._def.innerType.naked()}mandatory(){return new yt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};o(Wo,"ZodCatchImpl");var qg=Wo,Lo=class ur extends x{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!=="date"){let s=this._getOrReturnCtx(e);return m(s,{code:"invalid_type",expected:"date",received:s.parsedType}),{status:"aborted"}}if(isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return m(s,{code:"invalid_date"}),{status:"aborted"}}let r=new te,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),m(i,{code:"too_small",message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),m(i,{code:"too_big",message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):ue.assertNever(s);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ur(p(c({},this._def),{checks:[...this._def.checks,e]}))}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:_.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:_.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}isEqual(e){if(!(e instanceof ur))return!1;let n=new j.CustomSet(this._def.checks),r=new j.CustomSet(e._def.checks);return n.isEqual(r)&&this._def.coerce===e._def.coerce}};o(Lo,"ZodDateImpl");var Vg=Lo,Fo=class vt extends x{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType==="undefined"&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}dereference(e){return new vt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new vt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}isEqual(e){return e instanceof vt?this._def.innerType.isEqual(e._def.innerType)&&Ie(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new vt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};o(Fo,"ZodDefaultImpl");var Gg=Fo,_e=o(t=>{let e=t;return e?e.typeName==="ZodLazy"?_e(e.schema):e.typeName==="ZodEffects"?_e(e.innerType()):e.typeName==="ZodLiteral"?[e.value]:e.typeName==="ZodEnum"?e.options:e.typeName==="ZodNativeEnum"?Object.values(e.enum):e.typeName==="ZodDefault"?_e(e._def.innerType):e.typeName==="ZodUndefined"?[void 0]:e.typeName==="ZodNull"?[null]:e.typeName==="ZodOptional"?[void 0,..._e(e.unwrap())]:e.typeName==="ZodNullable"?[null,..._e(e.unwrap())]:e.typeName==="ZodBranded"||e.typeName==="ZodReadonly"?_e(e.unwrap()):e.typeName==="ZodCatch"?_e(e._def.innerType):[]:[]},"getDiscriminator"),qo=class _t extends x{constructor(e){let n=_t._getOptionsMap(e.discriminator,e.options);super(p(c({},e),{optionsMap:n}))}dereference(e){let n=this.options.map(r=>r.dereference(e));return new _t(p(c({},this._def),{options:n}))}getReferences(){return ge.unique(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(n=>n.clone());return new _t(p(c({},this._def),{options:e}))}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!=="object")return m(n,{code:"invalid_type",expected:"object",received:n.parsedType}),{status:"aborted"};let r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(m(n,{code:"invalid_union_discriminator",options:Array.from(this.optionsMap.keys()),path:[r]}),{status:"aborted"})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static _getOptionsMap(e,n){let r=new Map;for(let i of n){let s=_e(i.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of s){if(r.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);r.set(a,i)}}return r}isEqual(e){if(!(e instanceof _t)||this._def.discriminator!==e._def.discriminator)return!1;let n=o((s,a)=>s.isEqual(a),"compare"),r=new j.CustomSet(this._def.options,{compare:n}),i=new j.CustomSet(e._def.options,{compare:n});return r.isEqual(i)}};o(qo,"ZodDiscriminatedUnionImpl");var Jg=qo,Vo=class Go extends x{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return m(n,{expected:le.joinValues(r),received:n.parsedType,code:"invalid_type"}),{status:"aborted"}}if(this._def.values.indexOf(e.data)===-1){let n=this._getOrReturnCtx(e),r=this._def.values;return m(n,{received:n.data,code:"invalid_enum_value",options:r}),{status:"aborted"}}return{status:"valid",value:e.data}}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){return this.enum}get Enum(){return this.enum}extract(e,n=this._def){return A.enum(e,c(c({},this._def),n))}exclude(e,n=this._def){return A.enum(this.options.filter(r=>!e.includes(r)),c(c({},this._def),n))}isEqual(e){if(!(e instanceof Go))return!1;let n=new j.CustomSet(this._def.values),r=new j.CustomSet(e._def.values);return n.isEqual(r)}};o(Vo,"ZodEnumImpl");var Yg=Vo,Jo=class et extends x{constructor(){super(...arguments),this.validate=this.implement}dereference(e){let n=this._def.args.dereference(e),r=this._def.returns.dereference(e);return new et(p(c({},this._def),{args:n,returns:r}))}getReferences(){return ge.unique([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new et(p(c({},this._def),{args:this._def.args.clone(),returns:this._def.returns.clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!=="function")return m(n,{code:"invalid_type",expected:"function",received:n.parsedType}),{status:"aborted"};function r(d,f){return lr({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,sn(),nn].filter(g=>!!g),issueData:{code:"invalid_arguments",argumentsError:f}})}o(r,"makeArgsIssue");function i(d,f){return lr({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,sn(),nn].filter(g=>!!g),issueData:{code:"invalid_return_type",returnTypeError:f}})}o(i,"makeReturnsIssue");let s={errorMap:n.common.contextualErrorMap},a=n.data,l=this,u=this._def.returns;return z.zuiPromise(u)?{status:"valid",async value(...d){let f=new Te([]),g=await l._def.args.parseAsync(d,s).catch(T=>{throw f.addIssue(r(d,T)),f}),h=await Reflect.apply(a,this,g);return await u._def.type.parseAsync(h,s).catch(T=>{throw z.zuiError(T)?(f.addIssue(i(h,T)),f):T})}}:{status:"valid",value(...d){let f=l._def.args.safeParse(d,s);if(!f.success)throw new Te([r(d,f.error)]);let g=Reflect.apply(a,this,f.data),h=l._def.returns.safeParse(g,s);if(!h.success)throw new Te([i(g,h.error)]);return h.data}}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new et(p(c({},this._def),{args:A.tuple(e).rest(A.unknown())}))}returns(e){return new et(p(c({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}isEqual(e){return e instanceof et&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};o(Jo,"ZodFunctionImpl");var Xg=Jo,Yo=class Vt extends x{dereference(e){return new Vt(p(c({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return ge.unique([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new Vt(p(c({},this._def),{left:this._def.left.clone(),right:this._def.right.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=o((s,a)=>{if(s.status==="aborted"||a.status==="aborted")return{status:"aborted"};let l=this._mergeValues(s.value,a.value);return l.valid?((s.status==="dirty"||a.status==="dirty")&&n.dirty(),{status:n.value,value:l.data}):(m(r,{code:"invalid_intersection_types"}),{status:"aborted"})},"handleParsed");return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,a])=>i(s,a)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}isEqual(e){if(!(e instanceof Vt))return!1;let n=o((s,a)=>s.isEqual(a),"compare"),r=new j.CustomSet([this._def.left,this._def.right],{compare:n}),i=new j.CustomSet([e._def.left,e._def.right],{compare:n});return r.isEqual(i)}_mergeValues(e,n){let r=He(e),i=He(n);if(e===n)return{valid:!0,data:e};if(r==="object"&&i==="object"){let s=Object.keys(n),a=Object.keys(e).filter(u=>s.indexOf(u)!==-1),l=c(c({},e),n);for(let u of a){let d=this._mergeValues(e[u],n[u]);if(!d.valid)return{valid:!1};l[u]=d.data}return{valid:!0,data:l}}else if(r==="array"&&i==="array"){if(e.length!==n.length)return{valid:!1};let s=[];for(let a=0;a<e.length;a++){let l=e[a],u=n[a],d=this._mergeValues(l,u);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return r==="date"&&i==="date"&&+e==+n?{valid:!0,data:e}:{valid:!1}}};o(Yo,"ZodIntersectionImpl");var Qg=Yo,Xo=class Tt extends x{get schema(){return this._def.getter()}dereference(e){return new Tt(p(c({},this._def),{getter:()=>this._def.getter().dereference(e)}))}getReferences(){return this._def.getter().getReferences()}clone(){return new Tt(p(c({},this._def),{getter:()=>this._def.getter().clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}isEqual(e){return e instanceof Tt?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new Tt(p(c({},this._def),{getter:()=>this._def.getter().mandatory()}))}};o(Xo,"ZodLazyImpl");var em=Xo,Qo=class el extends x{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return m(n,{received:n.data,code:"invalid_literal",expected:this._def.value}),{status:"aborted"}}return{status:"valid",value:e.data}}get value(){return this._def.value}isEqual(e){return e instanceof el?Ie(this._def.value,e._def.value):!1}};o(Qo,"ZodLiteralImpl");var tm=Qo,tl=class Gt extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let n=this._def.keyType.dereference(e),r=this._def.valueType.dereference(e);return new Gt(p(c({},this._def),{keyType:n,valueType:r}))}getReferences(){return ge.unique([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new Gt(p(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!=="map")return m(r,{code:"invalid_type",expected:"map",received:r.parsedType}),{status:"aborted"};let i=this._def.keyType,s=this._def.valueType,a=[...r.data.entries()].map(([l,u],d)=>({key:i._parse(new fe(r,l,r.path,[d,"key"])),value:s._parse(new fe(r,u,r.path,[d,"value"]))}));if(r.common.async){let l=new Map;return Promise.resolve().then(async()=>{for(let u of a){let d=await u.key,f=await u.value;if(d.status==="aborted"||f.status==="aborted")return{status:"aborted"};(d.status==="dirty"||f.status==="dirty")&&n.dirty(),l.set(d.value,f.value)}return{status:n.value,value:l}})}else{let l=new Map;for(let u of a){let d=u.key,f=u.value;if(d.status==="aborted"||f.status==="aborted")return{status:"aborted"};(d.status==="dirty"||f.status==="dirty")&&n.dirty(),l.set(d.value,f.value)}return{status:n.value,value:l}}}isEqual(e){return!(!(e instanceof Gt)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};o(tl,"ZodMapImpl");var nm=tl,nl=class rl extends x{_parse(e){if(this._getType(e)!=="nan"){let r=this._getOrReturnCtx(e);return m(r,{code:"invalid_type",expected:"nan",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof rl}};o(nl,"ZodNaNImpl");var rm=nl,il=class sl extends x{constructor(){super(...arguments),this._getValidEnumValues=o(e=>{let n=Object.keys(e).filter(i=>typeof e[e[i]]!="number"),r={};for(let i of n)r[i]=e[i];return Object.values(r)},"_getValidEnumValues")}_parse(e){let n=this._getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!=="string"&&r.parsedType!=="number"){let i=Object.values(n);return m(r,{expected:le.joinValues(i),received:r.parsedType,code:"invalid_type"}),{status:"aborted"}}if(n.indexOf(e.data)===-1){let i=Object.values(n);return m(r,{received:r.data,code:"invalid_enum_value",options:i}),{status:"aborted"}}return{status:"valid",value:e.data}}get enum(){return this._def.values}isEqual(e){return e instanceof sl?Ie(this._def.values,e._def.values):!1}};o(il,"ZodNativeEnumImpl");var im=il,al=class ol extends x{_parse(e){let n=this._getOrReturnCtx(e);return m(n,{code:"invalid_type",expected:"never",received:n.parsedType}),{status:"aborted"}}isEqual(e){return e instanceof ol}};o(al,"ZodNeverImpl");var sm=al,ll=class ul extends x{_parse(e){if(this._getType(e)!=="null"){let r=this._getOrReturnCtx(e);return m(r,{code:"invalid_type",expected:"null",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof ul}};o(ll,"ZodNullImpl");var am=ll,cl=class bt extends x{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()}))}_parse(e){return this._getType(e)==="null"?{status:"valid",value:null}:this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof bt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new bt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};o(cl,"ZodNullableImpl");var om=cl,dl=class Jt extends x{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)!=="number"){let s=this._getOrReturnCtx(e);return m(s,{code:"invalid_type",expected:"number",received:s.parsedType}),{status:"aborted"}}let r,i=new te;for(let s of this._def.checks)s.kind==="int"?Number.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:"invalid_type",expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:"too_small",minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:"too_big",maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?this._floatSafeRemainder(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),m(r,{code:"not_multiple_of",multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:"not_finite",message:s.message}),i.dirty()):ue.assertNever(s);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,_.toString(n))}gt(e,n){return this.setLimit("min",e,!1,_.toString(n))}lte(e,n){return this.setLimit("max",e,!0,_.toString(n))}lt(e,n){return this.setLimit("max",e,!1,_.toString(n))}setLimit(e,n,r,i){return new Jt(p(c({},this._def),{checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:_.toString(i)}]}))}_addCheck(e){return new Jt(p(c({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:_.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:_.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Number.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}isEqual(e){if(!(e instanceof Jt))return!1;let n=new j.CustomSet(this._def.checks),r=new j.CustomSet(e._def.checks);return n.isEqual(r)}_floatSafeRemainder(e,n){let r=(e.toString().split(".")[1]||"").length,i=(n.toString().split(".")[1]||"").length,s=r>i?r:i,a=parseInt(e.toFixed(s).replace(".","")),l=parseInt(n.toFixed(s).replace(".",""));return a%l/Math.pow(10,s)}};o(dl,"ZodNumberImpl");var lm=dl,pl=class Q extends x{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(),n=Object.keys(e);return this._cached={shape:e,keys:n}}dereference(e){let n=this._def.shape(),r={};for(let i in n)r[i]=n[i].dereference(e);return new Q(p(c({},this._def),{shape:()=>r}))}getReferences(){let e=this._def.shape(),n=[];for(let r in e)n.push(...e[r].getReferences());return ge.unique(n)}clone(){let e={},n=this._def.shape();for(let[i,s]of Object.entries(n))e[i]=s.clone();return new Q(p(c({},this._def),{shape:()=>e}))}_parse(e){if(this._getType(e)!=="object"){let f=this._getOrReturnCtx(e);return m(f,{code:"invalid_type",expected:"object",received:f.parsedType}),{status:"aborted"}}let{status:r,ctx:i}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),l=[];if(this._def.unknownKeys!=="strip")for(let f in i.data)a.includes(f)||l.push(f);let u=[];for(let f of a){let g=s[f],h=i.data[f];u.push({key:{status:"valid",value:f},value:g._parse(new fe(i,h,i.path,f)),alwaysSet:f in i.data})}let d=this._def.unknownKeys;if(d==="passthrough")for(let f of l)u.push({key:{status:"valid",value:f},value:{status:"valid",value:i.data[f]}});else if(d==="strict")l.length>0&&(m(i,{code:"unrecognized_keys",keys:l}),r.dirty());else if(d!=="strip")for(let f of l){let g=i.data[f];u.push({key:{status:"valid",value:f},value:d._parse(new fe(i,g,i.path,f)),alwaysSet:f in i.data})}return i.common.async?Promise.resolve().then(async()=>{let f=[];for(let g of u){let h=await g.key;f.push({key:h,value:await g.value,alwaysSet:g.alwaysSet})}return f}).then(f=>te.mergeObjectSync(r,f)):te.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(e){return _.errToObj,new Q(c(p(c({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:(n,r)=>{var i,s,a,l;let u=(a=(s=(i=this._def).errorMap)==null?void 0:s.call(i,n,r).message)!=null?a:r.defaultError;return n.code==="unrecognized_keys"?{message:(l=_.errToObj(e).message)!=null?l:u}:{message:u}}}:{}))}strip(){return new Q(p(c({},this._def),{unknownKeys:"strip"}))}passthrough(){return new Q(p(c({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(typeof this._def.unknownKeys=="object")return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return A.any();if(this._def.unknownKeys==="strict")return A.never()}extend(e){return new Q(p(c({},this._def),{shape:()=>c(c({},this._def.shape()),e)}))}merge(e){return new Q({unknownKeys:e._def.unknownKeys,shape:()=>c(c({},this._def.shape()),e._def.shape()),typeName:"ZodObject"})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new Q(p(c({},this._def),{unknownKeys:e}))}pick(e){let n={};return Object.keys(e).forEach(i=>{e[i]&&this.shape[i]&&(n[i]=this.shape[i])}),new Q(p(c({},this._def),{shape:()=>n}))}omit(e){let n={};return Object.entries(this.shape).forEach(([i,s])=>{e[i]||(n[i]=s)}),new Q(p(c({},this._def),{shape:()=>n}))}partial(e){let n={};return Object.keys(this.shape).forEach(i=>{let s=this.shape[i];e&&!e[i]?n[i]=s:n[i]=s?.optional()}),new Q(p(c({},this._def),{shape:()=>n}))}required(e){let n={};return Object.entries(this.shape).forEach(([r,i])=>{if(e&&!e[r])n[r]=i;else{let a=i;for(;z.zuiOptional(a);)a=a._def.innerType;n[r]=a}}),new Q(p(c({},this._def),{shape:()=>n}))}keyof(){let e=Object.keys(this.shape);return A.enum(e)}isEqual(e){if(!(e instanceof Q)||!this._unknownKeysEqual(e))return!1;let n=this._def.shape(),r=e._def.shape(),i=o((l,u)=>l[0]===u[0]&&l[1].isEqual(u[1]),"compare"),s=new j.CustomSet(Object.entries(n),{compare:i}),a=new j.CustomSet(Object.entries(r),{compare:i});return s.isEqual(a)}_unknownKeysEqual(e){let n=this.additionalProperties(),r=e.additionalProperties();return n===void 0||r===void 0?n===r:n.isEqual(r)}};o(pl,"ZodObjectImpl");var fl=pl,gl=class Yt extends x{dereference(e){return new Yt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Yt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)==="undefined"?{status:"valid",value:void 0}:this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof Yt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return this._def.innerType.mandatory()}};o(gl,"ZodOptionalImpl");var um=gl,ml=class Xt extends x{dereference(e){return new Xt(p(c({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return ge.unique([...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:n,ctx:r}=this._processInputParams(e);if(r.common.async)return o(async()=>{let s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?{status:"aborted"}:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})},"handleAsync")();{let i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?{status:"aborted"}:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}isEqual(e){return!(!(e instanceof Xt)||!this._def.in.isEqual(e._def.in)||!this._def.out.isEqual(e._def.out))}};o(ml,"ZodPipelineImpl");var cm=ml,hl=class Qt extends x{unwrap(){return this._def.type}dereference(e){return new Qt(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Qt(p(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e);return n.parsedType!=="promise"&&n.common.async===!1?(m(n,{code:"invalid_type",expected:"promise",received:n.parsedType}),{status:"aborted"}):{status:"valid",value:(n.parsedType==="promise"?n.data:Promise.resolve(n.data)).then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap}))}}isEqual(e){return e instanceof Qt?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}};o(hl,"ZodPromiseImpl");var dm=hl,yl=class wt extends x{constructor(){super(...arguments),this._freeze=o(e=>e.status!=="valid"?e:p(c({},e),{value:Object.freeze(e.value)}),"_freeze")}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()}))}_parse(e){let n=this._def.innerType._parse(e);return an(n)?n.then(this._freeze):this._freeze(n)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof wt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new wt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};o(yl,"ZodReadonlyImpl");var pm=yl,vl=class en extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let n=this._def.keyType.dereference(e),r=this._def.valueType.dereference(e);return new en(p(c({},this._def),{keyType:n,valueType:r}))}getReferences(){return ge.unique([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new en(p(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!=="object")return m(r,{code:"invalid_type",expected:"object",received:r.parsedType}),{status:"aborted"};let i=[],s=this._def.keyType,a=this._def.valueType;for(let l in r.data)i.push({key:s._parse(new fe(r,l,r.path,l)),value:a._parse(new fe(r,r.data[l],r.path,l))});return r.common.async?te.mergeObjectAsync(n,i):te.mergeObjectSync(n,i)}get element(){return this._def.valueType}isEqual(e){return!(!(e instanceof en)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};o(vl,"ZodRecordImpl");var Ui=vl,_l=class Tl extends x{dereference(e){let n=e[this._def.uri];return n||this}getReferences(){return[this._def.uri]}_parse(e){let n=this._getOrReturnCtx(e);return m(n,{code:"unresolved_reference"}),{status:"aborted"}}isOptional(){return!1}isNullable(){return!1}isEqual(e){return e instanceof Tl?this._def.uri===e._def.uri:!1}};o(_l,"ZodRefImpl");var fm=_l,bl=class tt extends x{dereference(e){return new tt(p(c({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new tt(p(c({},this._def),{valueType:this._def.valueType.clone()}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!=="set")return m(r,{code:"invalid_type",expected:"set",received:r.parsedType}),{status:"aborted"};let i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(m(r,{code:"too_small",minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(m(r,{code:"too_big",maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());let s=this._def.valueType;function a(u){let d=new Set;for(let f of u){if(f.status==="aborted")return{status:"aborted"};f.status==="dirty"&&n.dirty(),d.add(f.value)}return{status:n.value,value:d}}o(a,"finalizeSet");let l=[...r.data.values()].map((u,d)=>s._parse(new fe(r,u,r.path,d)));return r.common.async?Promise.all(l).then(u=>a(u)):a(l)}min(e,n){return new tt(p(c({},this._def),{minSize:{value:e,message:_.toString(n)}}))}max(e,n){return new tt(p(c({},this._def),{maxSize:{value:e,message:_.toString(n)}}))}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}isEqual(e){var n,r,i,s;if(!(e instanceof tt))return!1;let a=(n=this._def.minSize)==null?void 0:n.value,l=(r=e._def.minSize)==null?void 0:r.value;if(a!==l)return!1;let u=(i=this._def.maxSize)==null?void 0:i.value,d=(s=e._def.maxSize)==null?void 0:s.value;return u!==d?!1:this._def.valueType.isEqual(e._def.valueType)}};o(bl,"ZodSetImpl");var gm=bl,mm=/^c[^\s-]{8,}$/i,hm=/^[a-z][a-z0-9]*$/,ym=/^[0-9A-HJKMNP-TV-Z]{26}$/,vm=/^[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,_m=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Tm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Vn,bm=/^(((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}))$/,wm=/^(([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 wl(t,e){return!!((e==="v4"||!e)&&bm.test(t)||(e==="v6"||!e)&&wm.test(t))}o(wl,"isValidIP");var Pl=class nt extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!=="string"){let s=this._getOrReturnCtx(e);return m(s,{code:"invalid_type",expected:"string",received:s.parsedType}),{status:"aborted"}}let r=new te,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),m(i,{code:"too_small",minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),m(i,{code:"too_big",maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){let a=e.data.length>s.value,l=e.data.length<s.value;(a||l)&&(i=this._getOrReturnCtx(e,i),a?m(i,{code:"too_big",maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):l&&m(i,{code:"too_small",minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")_m.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"email",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="emoji")Vn||(Vn=new RegExp(Tm,"u")),Vn.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"emoji",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="uuid")vm.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"uuid",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="cuid")mm.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"cuid",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="cuid2")hm.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"cuid2",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="ulid")ym.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"ulid",code:"invalid_string",message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),m(i,{validation:"url",code:"invalid_string",message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"regex",code:"invalid_string",message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),m(i,{code:"invalid_string",validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),m(i,{code:"invalid_string",validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),m(i,{code:"invalid_string",validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?xo.generateDatetimeRegex(s).test(e.data)||(i=this._getOrReturnCtx(e,i),m(i,{code:"invalid_string",validation:"datetime",message:s.message}),r.dirty()):s.kind==="ip"?wl(e.data,s.version)||(i=this._getOrReturnCtx(e,i),m(i,{validation:"ip",code:"invalid_string",message:s.message}),r.dirty()):ue.assertNever(s);return{status:r.value,value:e.data}}_addCheck(e){return new nt(p(c({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(c({kind:"email"},_.errToObj(e)))}url(e){return this._addCheck(c({kind:"url"},_.errToObj(e)))}emoji(e){return this._addCheck(c({kind:"emoji"},_.errToObj(e)))}uuid(e){return this._addCheck(c({kind:"uuid"},_.errToObj(e)))}cuid(e){return this._addCheck(c({kind:"cuid"},_.errToObj(e)))}cuid2(e){return this._addCheck(c({kind:"cuid2"},_.errToObj(e)))}ulid(e){return this._addCheck(c({kind:"ulid"},_.errToObj(e)))}ip(e){return this._addCheck(c({kind:"ip"},_.errToObj(e)))}datetime(e){var n;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:(n=e?.offset)!=null?n:!1},_.errToObj(e?.message)))}regex(e,n){return this._addCheck(c({kind:"regex",regex:e},_.errToObj(n)))}includes(e,n){return this._addCheck(c({kind:"includes",value:e,position:n?.position},_.errToObj(n?.message)))}startsWith(e,n){return this._addCheck(c({kind:"startsWith",value:e},_.errToObj(n)))}endsWith(e,n){return this._addCheck(c({kind:"endsWith",value:e},_.errToObj(n)))}min(e,n){return this._addCheck(c({kind:"min",value:e},_.errToObj(n)))}max(e,n){return this._addCheck(c({kind:"max",value:e},_.errToObj(n)))}length(e,n){return this._addCheck(c({kind:"length",value:e},_.errToObj(n)))}nonempty(e){return this.min(1,_.errToObj(e))}trim(){return new nt(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 nt(p(c({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new nt(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 n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}isEqual(e){if(!(e instanceof nt))return!1;let n=new j.CustomSet(this._def.checks),r=new j.CustomSet(e._def.checks);return n.isEqual(r)}};o(Pl,"ZodStringImpl");var Pm=Pl,xl=class kl extends x{_parse(e){if(this._getType(e)!=="symbol"){let r=this._getOrReturnCtx(e);return m(r,{code:"invalid_type",expected:"symbol",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof kl}};o(xl,"ZodSymbolImpl");var xm=xl,Sl=class Pt extends x{innerType(){return this._def.schema}sourceType(){return z.zuiEffects(this._def.schema)?this._def.schema.sourceType():this._def.schema}dereference(e){return new Pt(p(c({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new Pt(p(c({},this._def),{schema:this._def.schema.clone()}))}_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.effect;if(r.type==="upstream"){let i=r.effect(n.data,{path:n.path});if(n.common.async)return Promise.resolve(i).then(async s=>{if(s??(s={status:"valid",value:n.data}),this._processResult(n,s),s.status==="aborted")return{status:"aborted"};let a=await this._def.schema._parseAsync({data:s.value,path:n.path,parent:n});return a.status==="aborted"?{status:"aborted"}:a.status==="dirty"?{status:"dirty",value:a.value}:s.status==="dirty"?{status:"dirty",value:a.value}:a});{if(i instanceof Promise)throw new Error("Asynchronous upstream transform encountered during synchronous parse operation. Use .parseAsync instead.");if(i??(i={status:"valid",value:n.data}),this._processResult(n,i),i.status==="aborted")return{status:"aborted"};let s=this._def.schema._parseSync({data:i.value,path:n.path,parent:n});return s.status==="aborted"?{status:"aborted"}:s.status==="dirty"?{status:"dirty",value:s.value}:i.status==="dirty"?{status:"dirty",value:s.value}:s}}if(r.type==="downstream")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(i.status==="aborted"||i.status==="dirty"&&r.failFast)return i;let s=r.effect(i.value,{path:n.path});if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return s??(s={status:"valid",value:i.value}),this._processResult(n,s),s.status==="aborted"?{status:"aborted"}:s.status==="dirty"?{status:"dirty",value:s.value}:i.status==="dirty"?{status:"dirty",value:s.value}:s}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>i.status==="aborted"||i.status==="dirty"&&r.failFast?i:Promise.resolve(r.effect(i.value,{path:n.path})).then(s=>(s??(s={status:"valid",value:i.value}),this._processResult(n,s),s.status==="aborted"?{status:"aborted"}:s.status==="dirty"?{status:"dirty",value:s.value}:i.status==="dirty"?{status:"dirty",value:s.value}:s)));ue.assertNever(r)}_processResult(e,n){if(n.status!=="valid")for(let r of n.issues)m(e,r)}isEqual(e){return!(e instanceof Pt)||!this._def.schema.isEqual(e._def.schema)?!1:this._def.effect.type==="upstream"?e._def.effect.type!=="upstream"?!1:le.compareFunctions(this._def.effect.effect,e._def.effect.effect):this._def.effect.type==="downstream"?e._def.effect.type!=="downstream"||this._def.effect.failFast!==e._def.effect.failFast?!1:le.compareFunctions(this._def.effect.effect,e._def.effect.effect):(this._def.effect,!1)}naked(){return this._def.schema.naked()}mandatory(){return new Pt(p(c({},this._def),{schema:this._def.schema.mandatory()}))}};o(Sl,"ZodEffectsImpl");var Sr=Sl,Ol=class xt extends x{dereference(e){let n=this._def.items.map(i=>i.dereference(e)),r=this._def.rest?this._def.rest.dereference(e):null;return new xt(p(c({},this._def),{items:n,rest:r}))}getReferences(){return ge.unique([...this._def.items.flatMap(e=>e.getReferences()),...this._def.rest?this._def.rest.getReferences():[]])}clone(){let e=this._def.items.map(r=>r.clone()),n=this._def.rest?this._def.rest.clone():null;return new xt(p(c({},this._def),{items:e,rest:n}))}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!=="array")return m(r,{code:"invalid_type",expected:"array",received:r.parsedType}),{status:"aborted"};if(r.data.length<this._def.items.length)return m(r,{code:"too_small",minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),{status:"aborted"};!this._def.rest&&r.data.length>this._def.items.length&&(m(r,{code:"too_big",maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let s=[...r.data].map((a,l)=>{let u=this._def.items[l]||this._def.rest;return u?u._parse(new fe(r,a,r.path,l)):null}).filter(a=>!!a);return r.common.async?Promise.all(s).then(a=>te.mergeArray(n,a)):te.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new xt(p(c({},this._def),{rest:e}))}isEqual(e){if(!(e instanceof xt)||!this._restEquals(e))return!1;let n=o((s,a)=>s.isEqual(a),"compare"),r=new j.CustomSet(this._def.items,{compare:n}),i=new j.CustomSet(e._def.items,{compare:n});return r.isEqual(i)}_restEquals(e){return this._def.rest===null?e._def.rest===null:e._def.rest!==null&&this._def.rest.isEqual(e._def.rest)}};o(Ol,"ZodTupleImpl");var km=Ol,El=class Il extends x{_parse(e){if(this._getType(e)!=="undefined"){let r=this._getOrReturnCtx(e);return m(r,{code:"invalid_type",expected:"undefined",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Il}mandatory(){return A.never(c({},this._def))}};o(El,"ZodUndefinedImpl");var Sm=El,Bl=class kt extends x{dereference(e){let n=this._def.options.map(r=>r.dereference(e));return new kt(p(c({},this._def),{options:n}))}getReferences(){return ge.unique(this._def.options.reduce((e,n)=>[...e,...n.getReferences()],[]))}clone(){let e=this._def.options.map(n=>n.clone());return new kt(p(c({},this._def),{options:e}))}_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function i(s){for(let l of s)if(l.result.status==="valid")return l.result;for(let l of s)if(l.result.status==="dirty")return n.common.issues.push(...l.ctx.common.issues),l.result;let a=s.map(l=>new Te(l.ctx.common.issues));return m(n,{code:"invalid_union",unionErrors:a}),{status:"aborted"}}if(o(i,"handleResults"),n.common.async)return Promise.all(r.map(async s=>{let a=p(c({},n),{common:p(c({},n.common),{issues:[]}),parent:null});return{result:await s._parseAsync({data:n.data,path:n.path,parent:a}),ctx:a}})).then(i);{let s,a=[];for(let u of r){let d=p(c({},n),{common:p(c({},n.common),{issues:[]}),parent:null}),f=u._parseSync({data:n.data,path:n.path,parent:d});if(f.status==="valid")return f;f.status==="dirty"&&!s&&(s={result:f,ctx:d}),d.common.issues.length&&a.push(d.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;let l=a.map(u=>new Te(u));return m(n,{code:"invalid_union",unionErrors:l}),{status:"aborted"}}}get options(){return this._def.options}isEqual(e){if(!(e instanceof kt))return!1;let n=o((s,a)=>s.isEqual(a),"compare"),r=new j.CustomSet([...this._def.options],{compare:n}),i=new j.CustomSet([...e._def.options],{compare:n});return r.isEqual(i)}mandatory(){let e=this._def.options.filter(s=>!z.zuiUndefined(s)).map(s=>s.mandatory()),[n,r,...i]=e;return n?r?new kt(p(c({},this._def),{options:[n,r,...i]})):n:A.never(c({},this._def))}};o(Bl,"ZodUnionImpl");var Om=Bl,Cl=class Al extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return{status:"valid",value:e.data}}isEqual(e){return e instanceof Al}};o(Cl,"ZodUnknownImpl");var Em=Cl,Zl=class Rl extends x{_parse(e){if(this._getType(e)!=="undefined"){let r=this._getOrReturnCtx(e);return m(r,{code:"invalid_type",expected:"void",received:r.parsedType}),{status:"aborted"}}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Rl}};o(Zl,"ZodVoidImpl");var Im=Zl,Bm=o(t=>t instanceof Error,"_isError"),Cm=o(t=>typeof t=="object"&&t!==null,"_isObject"),z={zuiError:t=>t instanceof Te||Bm(t)&&"__type__"in t&&t.__type__==="ZuiError",zuiType:t=>t instanceof x||Cm(t)&&"__type__"in t&&t.__type__==="ZuiType",zuiAny:t=>t.typeName==="ZodAny",zuiArray:t=>t.typeName==="ZodArray",zuiBigInt:t=>t.typeName==="ZodBigInt",zuiBoolean:t=>t.typeName==="ZodBoolean",zuiBranded:t=>t.typeName==="ZodBranded",zuiCatch:t=>t.typeName==="ZodCatch",zuiDate:t=>t.typeName==="ZodDate",zuiDefault:t=>t.typeName==="ZodDefault",zuiDiscriminatedUnion:t=>t.typeName==="ZodDiscriminatedUnion",zuiEnum:t=>t.typeName==="ZodEnum",zuiFunction:t=>t.typeName==="ZodFunction",zuiIntersection:t=>t.typeName==="ZodIntersection",zuiLazy:t=>t.typeName==="ZodLazy",zuiLiteral:t=>t.typeName==="ZodLiteral",zuiMap:t=>t.typeName==="ZodMap",zuiNaN:t=>t.typeName==="ZodNaN",zuiNativeEnum:t=>t.typeName==="ZodNativeEnum",zuiNever:t=>t.typeName==="ZodNever",zuiNull:t=>t.typeName==="ZodNull",zuiNullable:t=>t.typeName==="ZodNullable",zuiNumber:t=>t.typeName==="ZodNumber",zuiObject:t=>t.typeName==="ZodObject",zuiOptional:t=>t.typeName==="ZodOptional",zuiPipeline:t=>t.typeName==="ZodPipeline",zuiPromise:t=>t.typeName==="ZodPromise",zuiReadonly:t=>t.typeName==="ZodReadonly",zuiRecord:t=>t.typeName==="ZodRecord",zuiRef:t=>t.typeName==="ZodRef",zuiSet:t=>t.typeName==="ZodSet",zuiString:t=>t.typeName==="ZodString",zuiSymbol:t=>t.typeName==="ZodSymbol",zuiEffects:t=>t.typeName==="ZodEffects",zuiTuple:t=>t.typeName==="ZodTuple",zuiUndefined:t=>t.typeName==="ZodUndefined",zuiUnion:t=>t.typeName==="ZodUnion",zuiUnknown:t=>t.typeName==="ZodUnknown",zuiVoid:t=>t.typeName==="ZodVoid"},k=o(t=>{if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:i,supportsExtensions:s,[B]:a}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);let l=a?Object.fromEntries(Object.entries(a).filter(([d])=>d!=="secret"||s?.includes("secret"))):void 0;return e?{errorMap:e,description:i,[B]:l}:{errorMap:o((d,f)=>d.code!=="invalid_type"?{message:f.defaultError}:typeof f.data>"u"?{message:r??f.defaultError}:{message:n??f.defaultError},"customMap"),description:i,[B]:l}},"_processCreateParams"),hn=o((t,e={},n)=>t?$e().downstream(r=>{var i,s;if(!t(r)){let a=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e;return((s=(i=a.fatal)!=null?i:n)!=null?s:!0)?qr(c({code:"custom"},a)):Vr(r,c({code:"custom"},a))}}):$e(),"customType"),Or=o((t,e={message:`Input not instance of ${t.name}`})=>hn(n=>n instanceof t,e),"instanceOfType"),$e=o(t=>new zg(c({typeName:"ZodAny"},k(t))),"anyType"),Ce=o(t=>new Em(c({typeName:"ZodUnknown"},k(t))),"unknownType"),Rt=o(t=>new sm(c({typeName:"ZodNever"},k(t))),"neverType"),Er=o(t=>new Im(c({typeName:"ZodVoid"},k(t))),"voidType"),jt=o(t=>new am(c({typeName:"ZodNull"},k(t))),"nullType"),yn=o(t=>new Sm(c({typeName:"ZodUndefined"},k(t))),"undefinedType"),Ir=o(t=>new xm(c({typeName:"ZodSymbol"},k(t))),"symbolType"),Br=o(t=>new rm(c({typeName:"ZodNaN"},k(t))),"nanType"),we=o(t=>{var e;return new Pm(c({checks:[],typeName:"ZodString",coerce:(e=t?.coerce)!=null?e:!1},k(p(c({},t),{supportsExtensions:["secret"]}))))},"stringType"),Ve=o(t=>new lm(c({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},k(t))),"numberType"),Ge=o(t=>new Lg(c({typeName:"ZodBoolean",coerce:t?.coerce||!1},k(t))),"booleanType"),vn=o(t=>{var e;return new Wg(c({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},k(t)))},"bigIntType"),_n=o(t=>new Vg(c({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},k(t))),"dateType"),Tn=o(t=>new fm({typeName:"ZodRef",uri:t}),"refType"),Nt=o((t,e)=>new tm(c({value:t,typeName:"ZodLiteral"},k(e))),"literalType"),bn=o((t,e)=>new Yg(c({values:t,typeName:"ZodEnum"},k(e))),"enumType"),Cr=o((t,e)=>new im(c({values:t,typeName:"ZodNativeEnum"},k(e))),"nativeEnumType"),Me=o((t,e)=>new Kg(c({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},k(e))),"arrayType"),st=o((t,e)=>new fl(c({shape:()=>t,unknownKeys:"strip",typeName:"ZodObject"},k(e))),"objectType"),Ar=o((t,e)=>new fl(c({shape:()=>t,unknownKeys:"strict",typeName:"ZodObject"},k(e))),"strictObjectType"),at=o((t,e)=>new Om(c({options:t,typeName:"ZodUnion"},k(e))),"unionType"),wn=o((t,e,n)=>new Jg(c({typeName:"ZodDiscriminatedUnion",discriminator:t,options:e},k(n))),"discriminatedUnionType"),Pn=o((t,e,n)=>new Qg(c({left:t,right:e,typeName:"ZodIntersection"},k(n))),"intersectionType"),$t=o((t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new km(c({items:t,typeName:"ZodTuple",rest:null},k(e)))},"tupleType"),Dt=o((t,e,n)=>e instanceof x?new Ui(c({keyType:t,valueType:e,typeName:"ZodRecord"},k(n))):new Ui(c({keyType:we(),valueType:t,typeName:"ZodRecord"},k(e))),"recordType"),Zr=o((t,e,n)=>new nm(c({valueType:e,keyType:t,typeName:"ZodMap"},k(n))),"mapType"),xn=o((t,e)=>new gm(c({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},k(e))),"setType"),Rr=o((t,e)=>new em(c({getter:t,typeName:"ZodLazy"},k(e))),"lazyType"),Nr=o((t,e)=>new dm(c({type:t,typeName:"ZodPromise"},k(e))),"promiseType"),Dr=o((t,e,n)=>new Xg(c({args:t||$t([]).rest(Ce()),returns:e||Ce(),typeName:"ZodFunction"},k(n))),"functionType"),Hr=o((t,e,n)=>new Sr(c({schema:e,effect:{type:"upstream",effect:(r,i)=>{let s=t(r,i);return s instanceof Promise?s.then(a=>on(a)):on(s)}},typeName:"ZodEffects"},k(n))),"preprocessType"),Mr=o((t,e,n)=>new Sr(c({schema:e,effect:{type:"upstream",effect:t},typeName:"ZodEffects"},k(n))),"upstreamType"),jr=o((t,e,n)=>new Sr(c({schema:t,effect:{type:"downstream",effect:e,failFast:n?.failFast},typeName:"ZodEffects"},k(n))),"downstreamType"),$r=o((t,e)=>new um(c({innerType:t,typeName:"ZodOptional"},k(e))),"optionalType"),Ur=o((t,e)=>new om(c({innerType:t,typeName:"ZodNullable"},k(e))),"nullableType"),zr=o((t,e)=>new pm(c({innerType:t,typeName:"ZodReadonly"},k(e))),"readonlyType"),Kr=o((t,e,n)=>new Gg(c({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},k(n))),"defaultType"),Wr=o((t,e,n)=>new qg(c({innerType:t,typeName:"ZodCatch",catchValue:typeof e=="function"?e:()=>e},k(n))),"catchType"),Lr=o((t,e)=>new cm({in:t,out:e,typeName:"ZodPipeline"}),"pipelineType"),Fr=o(t=>new Fg(c({typeName:"ZodBranded",type:t},k({supportsExtensions:["secret"]}))),"brandedType");Co({any:$e,array:Me,bigint:vn,boolean:Ge,branded:Fr,catch:Wr,custom:hn,date:_n,default:Kr,discriminatedUnion:wn,enum:bn,function:Dr,instanceof:Or,intersection:Pn,lazy:Rr,literal:Nt,map:Zr,nan:Br,nativeEnum:Cr,never:Rt,null:jt,nullable:Ur,number:Ve,object:st,optional:$r,pipeline:Lr,preprocess:Hr,upstream:Mr,downstream:jr,promise:Nr,record:Dt,ref:Tn,readonly:zr,set:xn,strictObject:Ar,string:we,symbol:Ir,tuple:$t,undefined:yn,union:at,unknown:Ce,void:Er});var Nl={string(t){return we(p(c({},t),{coerce:!0}))},number(t){return Ve(p(c({},t),{coerce:!0}))},boolean(t){return Ge(p(c({},t),{coerce:!0}))},bigint(t){return vn(p(c({},t),{coerce:!0}))},date(t){return _n(p(c({},t),{coerce:!0}))}},on=o(t=>({status:"valid",value:t}),"OK"),qr=o((t,...e)=>({status:"aborted",issues:[t,...e]}),"ERR"),Vr=o((t,e,...n)=>({status:"dirty",value:t,issues:[e,...n]}),"DIRTY"),Dl={};ce(Dl,{JSONSchemaToZuiError:()=>kn,ObjectToZuiError:()=>cr,UnrepresentableGenericError:()=>dr,UnsupportedJSONSchemaToZuiError:()=>Ee,UnsupportedZuiCheckToJSONSchemaError:()=>Kl,UnsupportedZuiToJSONSchemaError:()=>Y,UnsupportedZuiToTypescriptSchemaError:()=>De,UnsupportedZuiToTypescriptTypeError:()=>Jl,UntitledDeclarationError:()=>Xl,ZuiToJSONSchemaError:()=>Sn,ZuiToTypescriptSchemaError:()=>Fl,ZuiToTypescriptTypeError:()=>On,ZuiTransformError:()=>ot});var Hl=class extends Error{constructor(e,n){super(n),this.transform=e}};o(Hl,"ZuiTransformError");var ot=Hl,Ml=class extends ot{constructor(e){super("json-schema-to-zui",e)}};o(Ml,"JSONSchemaToZuiError");var kn=Ml,jl=class extends ot{constructor(e){super("object-to-zui",e)}};o(jl,"ObjectToZuiError");var cr=jl,$l=class extends ot{constructor(e){super("zui-to-json-schema",e)}};o($l,"ZuiToJSONSchemaError");var Sn=$l,Ul=class extends Sn{constructor(e,{suggestedAlternative:n}={}){super(`Zod type ${e} cannot be transformed to JSON Schema.`+(n?` Suggested alternative: ${n}`:""))}};o(Ul,"UnsupportedZuiToJSONSchemaError");var Y=Ul,zl=class extends Sn{constructor({zodType:e,checkKind:n}){super(`Zod check .${n}() of type ${e} cannot be transformed to JSON Schema.`)}};o(zl,"UnsupportedZuiCheckToJSONSchemaError");var Kl=zl,Wl=class extends kn{constructor(e){super(`JSON Schema ${JSON.stringify(e)} cannot be transformed to ZUI type.`)}};o(Wl,"UnsupportedJSONSchemaToZuiError");var Ee=Wl,Ll=class extends ot{constructor(e){super("zui-to-typescript-schema",e)}};o(Ll,"ZuiToTypescriptSchemaError");var Fl=Ll,ql=class extends Fl{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript schema.`)}};o(ql,"UnsupportedZuiToTypescriptSchemaError");var De=ql,Vl=class extends ot{constructor(e){super("zui-to-typescript-type",e)}};o(Vl,"ZuiToTypescriptTypeError");var On=Vl,Gl=class extends On{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript type.`)}};o(Gl,"UnsupportedZuiToTypescriptTypeError");var Jl=Gl,Yl=class extends On{constructor(){super("Schema must have a title to be transformed to a TypeScript type with a declaration.")}};o(Yl,"UntitledDeclarationError");var Xl=Yl,Ql=class extends On{constructor(){super('ZodRef can only be transformed to a TypeScript type with a "type" declaration.')}};o(Ql,"UnrepresentableGenericError");var dr=Ql,Am=o(t=>{let e;try{e=new Function("z",`return ${t}`)(Pe)}catch(n){return{sucess:!1,error:`Failed to evaluate schema: ${(n instanceof Error?n:new Error(String(n))).message}`}}return z.zuiType(e)?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),P={ZodString:"ZodString",ZodNumber:"ZodNumber",ZodNaN:"ZodNaN",ZodBigInt:"ZodBigInt",ZodBoolean:"ZodBoolean",ZodDate:"ZodDate",ZodSymbol:"ZodSymbol",ZodUndefined:"ZodUndefined",ZodNull:"ZodNull",ZodAny:"ZodAny",ZodUnknown:"ZodUnknown",ZodNever:"ZodNever",ZodVoid:"ZodVoid",ZodArray:"ZodArray",ZodObject:"ZodObject",ZodUnion:"ZodUnion",ZodDiscriminatedUnion:"ZodDiscriminatedUnion",ZodIntersection:"ZodIntersection",ZodTuple:"ZodTuple",ZodRecord:"ZodRecord",ZodRef:"ZodRef",ZodMap:"ZodMap",ZodSet:"ZodSet",ZodFunction:"ZodFunction",ZodLazy:"ZodLazy",ZodLiteral:"ZodLiteral",ZodEnum:"ZodEnum",ZodEffects:"ZodEffects",ZodNativeEnum:"ZodNativeEnum",ZodOptional:"ZodOptional",ZodNullable:"ZodNullable",ZodDefault:"ZodDefault",ZodCatch:"ZodCatch",ZodPromise:"ZodPromise",ZodBranded:"ZodBranded",ZodPipeline:"ZodPipeline",ZodReadonly:"ZodReadonly"},Zm=o(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),Rm=o((t,...e)=>Object.keys(t).reduce((n,r)=>(e.includes(r)||(n[r]=t[r]),n),{}),"omit");function q(t,e,n){var r;let i=t[e],s="";if(i!==void 0){let a=n({value:i,json:JSON.stringify(i)});if(a){let l=a[0],u=a.length===3?a[1]:"",d=a.length===3?a[2]:a[1];s+=l,((r=t.errorMessage)==null?void 0:r[e])!==void 0&&(s+=u+JSON.stringify(t.errorMessage[e])),s+=d}}return s}o(q,"withMessage");var St=Symbol("Original index"),Nm=o(t=>{let e=[];for(let n=0;n<t.length;n++){let r=t[n];if(typeof r=="boolean")e.push(r?{[St]:n}:{[St]:n,not:{}});else{if(St in r)return t;e.push(p(c({},r),{[St]:n}))}}return e},"ensureOriginalIndex");function Ht(t,e){if(t.allOf.length===0)return"z.never()";if(t.allOf.length===1){let n=t.allOf[0];return K(n,p(c({},e),{path:[...e.path,"allOf",n[St]]}))}else{let[n,r]=Zm(Nm(t.allOf));return`z.intersection(${Ht({allOf:n},e)}, ${Ht({allOf:r},e)})`}}o(Ht,"parseAllOf");var eu=o((t,e)=>t.anyOf.length?t.anyOf.length===1?K(t.anyOf[0],p(c({},e),{path:[...e.path,"anyOf",0]})):`z.union([${t.anyOf.map((n,r)=>K(n,p(c({},e),{path:[...e.path,"anyOf",r]}))).join(", ")}])`:"z.any()","parseAnyOf"),Dm=o((t,e)=>{if(Array.isArray(t.items))return`z.tuple([${t.items.map((r,i)=>K(r,p(c({},e),{path:[...e.path,"items",i]})))}])`;let n=t.items?`z.array(${K(t.items,p(c({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return n+=q(t,"minItems",({json:r})=>[`.min(${r}`,", ",")"]),n+=q(t,"maxItems",({json:r})=>[`.max(${r}`,", ",")"]),n},"parseArray"),Hm=o(t=>{var e;return(e=t[B])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),Mm=o(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),jm=o(t=>"z.any()","parseDefault"),Gr=o((t,e)=>t.oneOf.length?t.oneOf.length===1?K(t.oneOf[0],p(c({},e),{path:[...e.path,"oneOf",0]})):`z.any().superRefine((x, ctx) => {
2
+ const schemas = [${t.oneOf.map((n,r)=>K(n,p(c({},e),{path:[...e.path,"oneOf",r]}))).join(", ")}];
18
3
  const errors = schemas.reduce(
19
4
  (errors: z.ZodError[], schema) =>
20
5
  ((result) => ("error" in result ? [...errors, result.error] : errors))(
@@ -30,20 +15,20 @@ declare function ${r}${a};${c}`);if(t.props.type==="variable")return $r(`${i}dec
30
15
  message: "Invalid input: Should pass single schema",
31
16
  });
32
17
  }
33
- })`:"z.any()","parseOneOf"),Zh=l((t,e)=>{var n,r;if(t.oneOf.length<=1||!((n=t.discriminator)!=null&&n.propertyName))return $i(t,e);let i=t.oneOf.map((s,a)=>W(s,f(u({},e),{path:[...e.path,"oneOf",a]})));return`z.discriminatedUnion("${(r=t.discriminator)==null?void 0:r.propertyName}", [${i.join(", ")}])`},"parseDiscriminator"),Bh=l(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"),Ah=l((t,e)=>{let n=W(t.if,f(u({},e),{path:[...e.path,"if"]})),r=W(t.then,f(u({},e),{path:[...e.path,"then"]})),i=W(t.else,f(u({},e),{path:[...e.path,"else"]}));return`z.union([${r}, ${i}]).superRefine((value,ctx) => {
18
+ })`:"z.any()","parseOneOf"),$m=o((t,e)=>{var n,r;if(t.oneOf.length<=1||!((n=t.discriminator)!=null&&n.propertyName))return Gr(t,e);let i=t.oneOf.map((s,a)=>K(s,p(c({},e),{path:[...e.path,"oneOf",a]})));return`z.discriminatedUnion("${(r=t.discriminator)==null?void 0:r.propertyName}", [${i.join(", ")}])`},"parseDiscriminator"),Um=o(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"),zm=o((t,e)=>{let n=K(t.if,p(c({},e),{path:[...e.path,"if"]})),r=K(t.then,p(c({},e),{path:[...e.path,"then"]})),i=K(t.else,p(c({},e),{path:[...e.path,"else"]}));return`z.union([${r}, ${i}]).superRefine((value,ctx) => {
34
19
  const result = ${n}.safeParse(value).success
35
20
  ? ${r}.safeParse(value)
36
21
  : ${i}.safeParse(value);
37
22
  if (!result.success) {
38
23
  result.error.errors.forEach((error) => ctx.addIssue(error))
39
24
  }
40
- })`},"parseIfThenElse"),Ch=l((t,e)=>`z.union([${t.type.map(n=>W(f(u({},t),{type:n}),e)).join(", ")}])`,"parseMultipleType"),Rh=l((t,e)=>`z.any().refine((value) => !${W(t.not,f(u({},e),{path:[...e.path,"not"]}))}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`,"parseNot"),Hh=l(t=>"z.null()","parseNull"),Dh=l((t,e)=>`${W(xh(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),Nh=l(t=>{var e;let n="z.number()";return(e=t[w])!=null&&e.coerce&&(n="z.coerce.number()"),t.type==="integer"?n+=q(t,"type",()=>[".int(",")"]):n+=q(t,"format",({value:r})=>{if(r==="int64")return[".int(",")"]}),n+=q(t,"multipleOf",({value:r,json:i})=>r===1?n.startsWith("z.number().int(")?void 0:[".int(",")"]:[`.multipleOf(${i}`,", ",")"]),typeof t.minimum=="number"?t.exclusiveMinimum===!0?n+=q(t,"minimum",({json:r})=>[`.gt(${r}`,", ",")"]):n+=q(t,"minimum",({json:r})=>[`.gte(${r}`,", ",")"]):typeof t.exclusiveMinimum=="number"&&(n+=q(t,"exclusiveMinimum",({json:r})=>[`.gt(${r}`,", ",")"])),typeof t.maximum=="number"?t.exclusiveMaximum===!0?n+=q(t,"maximum",({json:r})=>[`.lt(${r}`,", ",")"]):n+=q(t,"maximum",({json:r})=>[`.lte(${r}`,", ",")"]):typeof t.exclusiveMaximum=="number"&&(n+=q(t,"exclusiveMaximum",({json:r})=>[`.lt(${r}`,", ",")"])),n},"parseNumber");function gu(t,e){let n;t.properties&&(Object.keys(t.properties).length?(n="z.object({ ",n+=Object.keys(t.properties).map(a=>{let o=t.properties[a],c=`${JSON.stringify(a)}: ${W(o,f(u({},e),{path:[...e.path,"properties",a]}))}`,d=typeof o=="object"&&o.default!==void 0||typeof t.default=="object"&&t.default!==null&&a in t.default,g=Array.isArray(t.required)?t.required.includes(a):typeof o=="object"&&o.required===!0;return!d&&!g?`${c}.optional()`:c}).join(", "),n+=" })"):n="z.object({})");let r=t.additionalProperties!==void 0?W(t.additionalProperties,f(u({},e),{path:[...e.path,"additionalProperties"]})):void 0,i;if(t.patternProperties){let a=Object.fromEntries(Object.entries(t.patternProperties).map(([o,c])=>[o,W(c,f(u({},e),{path:[...e.path,"patternProperties",o]}))],{}));i="",n?r?i+=`.catchall(z.union([${[...Object.values(a),r].join(", ")}]))`:Object.keys(a).length>1?i+=`.catchall(z.union([${Object.values(a).join(", ")}]))`:i+=`.catchall(${Object.values(a)})`:r?i+=`z.record(z.union([${[...Object.values(a),r].join(", ")}]))`:Object.keys(a).length>1?i+=`z.record(z.union([${Object.values(a).join(", ")}]))`:i+=`z.record(${Object.values(a)})`,i+=`.superRefine((value, ctx) => {
25
+ })`},"parseIfThenElse"),Km=o((t,e)=>`z.union([${t.type.map(n=>K(p(c({},t),{type:n}),e)).join(", ")}])`,"parseMultipleType"),Wm=o((t,e)=>`z.any().refine((value) => !${K(t.not,p(c({},e),{path:[...e.path,"not"]}))}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`,"parseNot"),Lm=o(t=>"z.null()","parseNull"),Fm=o((t,e)=>`${K(Rm(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),qm=o(t=>{var e;let n="z.number()";return(e=t[B])!=null&&e.coerce&&(n="z.coerce.number()"),t.type==="integer"?n+=q(t,"type",()=>[".int(",")"]):n+=q(t,"format",({value:r})=>{if(r==="int64")return[".int(",")"]}),n+=q(t,"multipleOf",({value:r,json:i})=>r===1?n.startsWith("z.number().int(")?void 0:[".int(",")"]:[`.multipleOf(${i}`,", ",")"]),typeof t.minimum=="number"?t.exclusiveMinimum===!0?n+=q(t,"minimum",({json:r})=>[`.gt(${r}`,", ",")"]):n+=q(t,"minimum",({json:r})=>[`.gte(${r}`,", ",")"]):typeof t.exclusiveMinimum=="number"&&(n+=q(t,"exclusiveMinimum",({json:r})=>[`.gt(${r}`,", ",")"])),typeof t.maximum=="number"?t.exclusiveMaximum===!0?n+=q(t,"maximum",({json:r})=>[`.lt(${r}`,", ",")"]):n+=q(t,"maximum",({json:r})=>[`.lte(${r}`,", ",")"]):typeof t.exclusiveMaximum=="number"&&(n+=q(t,"exclusiveMaximum",({json:r})=>[`.lt(${r}`,", ",")"])),n},"parseNumber");function tu(t,e){let n;t.properties&&(Object.keys(t.properties).length?(n="z.object({ ",n+=Object.keys(t.properties).map(a=>{let l=t.properties[a],u=`${JSON.stringify(a)}: ${K(l,p(c({},e),{path:[...e.path,"properties",a]}))}`,d=typeof l=="object"&&l.default!==void 0||typeof t.default=="object"&&t.default!==null&&a in t.default,f=Array.isArray(t.required)?t.required.includes(a):typeof l=="object"&&l.required===!0;return!d&&!f?`${u}.optional()`:u}).join(", "),n+=" })"):n="z.object({})");let r=t.additionalProperties!==void 0?K(t.additionalProperties,p(c({},e),{path:[...e.path,"additionalProperties"]})):void 0,i;if(t.patternProperties){let a=Object.fromEntries(Object.entries(t.patternProperties).map(([l,u])=>[l,K(u,p(c({},e),{path:[...e.path,"patternProperties",l]}))],{}));i="",n?r?i+=`.catchall(z.union([${[...Object.values(a),r].join(", ")}]))`:Object.keys(a).length>1?i+=`.catchall(z.union([${Object.values(a).join(", ")}]))`:i+=`.catchall(${Object.values(a)})`:r?i+=`z.record(z.union([${[...Object.values(a),r].join(", ")}]))`:Object.keys(a).length>1?i+=`z.record(z.union([${Object.values(a).join(", ")}]))`:i+=`z.record(${Object.values(a)})`,i+=`.superRefine((value, ctx) => {
41
26
  `,i+=`for (const key in value) {
42
- `,r&&(t.properties?i+=`let evaluated = [${Object.keys(t.properties).map(o=>JSON.stringify(o)).join(", ")}].includes(key)
27
+ `,r&&(t.properties?i+=`let evaluated = [${Object.keys(t.properties).map(l=>JSON.stringify(l)).join(", ")}].includes(key)
43
28
  `:i+=`let evaluated = false
44
- `);for(let o in t.patternProperties)i+="if (key.match(new RegExp("+JSON.stringify(o)+`))) {
29
+ `);for(let l in t.patternProperties)i+="if (key.match(new RegExp("+JSON.stringify(l)+`))) {
45
30
  `,r&&(i+=`evaluated = true
46
- `),i+="const result = "+a[o]+`.safeParse(value[key])
31
+ `),i+="const result = "+a[l]+`.safeParse(value[key])
47
32
  `,i+=`if (!result.success) {
48
33
  `,i+=`ctx.addIssue({
49
34
  path: [...ctx.path, key],
@@ -69,10 +54,25 @@ declare function ${r}${a};${c}`);if(t.props.type==="variable")return $r(`${i}dec
69
54
  `,i+=`}
70
55
  `,i+=`}
71
56
  `),i+=`}
72
- `,i+="})"}let s=n?i?n+i:r?r==="z.never()"?n+".strict()":n+`.catchall(${r})`:n:i||(r?`z.record(${r})`:"z.record(z.any())");return M.an.anyOf(t)&&(s+=`.and(${fu(f(u({},t),{anyOf:t.anyOf.map(a=>typeof a=="object"&&!a.type&&(a.properties||a.additionalProperties||a.patternProperties)?f(u({},a),{type:"object"}):a)}),e)})`),M.a.oneOf(t)&&(s+=`.and(${$i(f(u({},t),{oneOf:t.oneOf.map(a=>typeof a=="object"&&!a.type&&(a.properties||a.additionalProperties||a.patternProperties)?f(u({},a),{type:"object"}):a)}),e)})`),M.an.allOf(t)&&(s+=`.and(${Wt(f(u({},t),{allOf:t.allOf.map(a=>typeof a=="object"&&!a.type&&(a.properties||a.additionalProperties||a.patternProperties)?f(u({},a),{type:"object"}):a)}),e)})`),s}l(gu,"parseObject");var Mh=l(t=>`z.ref('${t.$ref}')`,"parseRef"),jh=l(t=>{var e;let n="z.string()";if((e=t[w])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";n="z.coerce.string()"}return n+=q(t,"format",({value:r})=>{switch(r){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(",")"]}}),n+=q(t,"pattern",({json:r})=>[`.regex(new RegExp(${r})`,", ",")"]),n+=q(t,"minLength",({json:r})=>[`.min(${r}`,", ",")"]),n+=q(t,"maxLength",({json:r})=>[`.max(${r}`,", ",")"]),n},"parseString"),W=l((t,e={seen:new Map,path:[]},n)=>{if(typeof t!="object")return t?"z.any()":"z.never()";if(e.parserOverride){let s=e.parserOverride(t,e);if(typeof s=="string")return s}let r=e.seen.get(t);if(r){if(r.r!==void 0)return r.r;if(e.depth===void 0||r.n>=e.depth)return"z.any()";r.n+=1}else r={r:void 0,n:0},e.seen.set(t,r);let i=Uh(t,e);return n||(i=$h(t,i),e.withoutDefaults||(i=Kh(t,i))),r.r=i,i},"parseSchema"),$h=l((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),Kh=l((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),Uh=l((t,e)=>M.a.nullable(t)?Dh(t,e):M.an.object(t)?gu(t,e):M.an.array(t)?Sh(t,e):M.an.anyOf(t)?fu(t,e):M.an.allOf(t)?Wt(t,e):M.a.discriminator(t)?Zh(t,e):M.a.oneOf(t)?$i(t,e):M.a.not(t)?Rh(t,e):M.an.enum(t)?Bh(t):M.a.const(t)?Eh(t):M.a.multipleType(t)?Ch(t,e):M.a.primitive(t,"string")?jh(t):M.a.primitive(t,"number")||M.a.primitive(t,"integer")?Nh(t):M.a.primitive(t,"boolean")?Oh(t):M.a.primitive(t,"null")?Hh(t):M.a.conditional(t)?Ah(t,e):M.a.ref(t)?Mh(t):Ih(t),"selectParser"),M={an:{object:t=>t.type==="object",array:t=>t.type==="array",anyOf:t=>t.anyOf!==void 0,allOf:t=>t.allOf!==void 0,enum:t=>t.enum!==void 0},a:{nullable:t=>t.nullable===!0,multipleType:t=>Array.isArray(t.type),not:t=>t.not!==void 0,const:t=>t.const!==void 0,primitive:(t,e)=>t.type===e,conditional:t=>!!("if"in t&&t.if&&"then"in t&&"else"in t&&t.then&&t.else),discriminator:t=>{var e;return t.oneOf!==void 0&&((e=t.discriminator)==null?void 0:e.propertyName)!==void 0},oneOf:t=>t.oneOf!==void 0,ref:t=>t.$ref!==void 0}},Fh=l(t=>W(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),zh=l(t=>{let e=Fh(t);e=e.replaceAll("errors: z.ZodError[]","errors");let n=wh(e);if(!n.sucess)throw new Gn(n.error);return n.value},"jsonSchemaToZod"),Dt=l((t,e)=>{var n,r;if(e[w]&&t._def&&(t.naked()._def[w]=e[w]),((n=t._def)==null?void 0:n.typeName)==="ZodObject"&&e.type==="object"&&e.properties&&Object.entries(e.properties).forEach(([i,s])=>{let a=typeof t._def.shape=="function"?t._def.shape():t._def.shape;a[i]&&Dt(a[i],s)}),((r=t._def)==null?void 0:r.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&Dt(t._def.valueType,e.additionalProperties),e.type==="array"&&e.items){let i=e.items;if(typeof i=="object"&&!Array.isArray(i)){let s=t._def.type;s&&Dt(s,i)}else Array.isArray(i)&&i.forEach((s,a)=>{let o=t._def;o.typeName===y.ZodFirstPartyTypeKind.ZodTuple&&Dt(o.items[a],s)})}},"applyZuiPropsRecursively"),Wh=l(t=>{let e=zh(t);return Dt(e,t),e},"fromJSONSchemaLegacy"),Lh=l(t=>{var e,n;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(r=>typeof r!="boolean"&&mu(r))&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===p.ZodFirstPartyTypeKind.ZodOptional},"isOptionalSchema"),Vh=l(t=>{var e,n;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(r=>typeof r!="boolean"&&r.type==="null")&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===p.ZodFirstPartyTypeKind.ZodNullable},"isNullableSchema"),mu=l(t=>{var e,n;return t.not===!0&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===p.ZodFirstPartyTypeKind.ZodUndefined},"isUndefinedSchema"),qh=l(t=>{var e,n;return!t.not&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===p.ZodFirstPartyTypeKind.ZodUnknown},"isUnknownSchema"),Gh=l(t=>{var e,n;return t.anyOf!==void 0&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)===p.ZodFirstPartyTypeKind.ZodDiscriminatedUnion},"isDiscriminatedUnionSchema"),Jh=l((t,e)=>Yh(t)?Qh(t,e):Xh(t)?ey(t,e):ty(t,e),"arrayJSONSchemaToZuiArray"),Yh=l(t=>Array.isArray(t.items),"_isTuple"),Xh=l(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),Qh=l(({items:t,additionalItems:e},n)=>{let r=t.map(n),i=p.tuple(r);return e!==void 0&&(i=i.rest(n(e))),i},"_handleTuple"),ey=l(({items:t,minItems:e,maxItems:n},r)=>{let i=p.set(r(t));return e&&(i=i.min(e)),n&&(i=i.max(n)),i},"_handleSet"),ty=l(({minItems:t,maxItems:e,items:n},r)=>{let i=p.array(r(n));return t&&t===e?i.length(t):(t&&(i=i.min(t)),e&&(i=i.max(e)),i)},"_handleArray"),ny=l(({type:t,minimum:e,exclusiveMinimum:n,maximum:r,exclusiveMaximum:i,multipleOf:s,format:a})=>{let o=p.number();return t==="integer"&&(o=o.int()),a==="finite"&&(o=o.finite()),n!==void 0?o=o.gt(n):e!==void 0&&(o=o.gte(e)),i!==void 0?o=o.lt(i):r!==void 0&&(o=o.lte(r)),s!==void 0&&(o=o.multipleOf(s)),o},"numberJSONSchemaToZuiNumber"),ry=l(({format:t,pattern:e,minLength:n,maxLength:r})=>{let i=p.string();if(n&&r&&n===r?i=i.length(n):(n&&(i=i.min(n)),r&&(i=i.max(r))),t==="cuid"||e===j.cuid)i=i.cuid();else if(t==="cuid2"||e===j.cuid2)i=i.cuid2();else if(t==="emoji"||e===j.emoji)i=i.emoji();else if(t==="ulid"||e===j.ulid)i=i.ulid();else if(t==="date-time"){let{precision:s,offset:a}=e?Nd(e):{};i=i.datetime({precision:s,offset:a})}else t==="email"||e===j.email?i=i.email():t==="ipv4"||e===j.ipv4?i=i.ip():t==="ipv6"||e===j.ipv6?i=i.ip("v6"):t==="uri"?i=i.url():t==="uuid"||e===j.uuid?i=i.uuid():e&&(i=i.regex(new RegExp(e)));return i},"stringJSONSchemaToZuiString"),xt=l((t,e)=>{let n=[];e.enum!==void 0&&n.push(...e.enum),e.const!==void 0&&n.push(e.const);let r,i=n.filter(a=>typeof a===t),[s]=i;if(s)if(i.length===1)r=p.literal(s);else{let a=i.map(o=>p.literal(o));r=p.union(a)}else if(t==="string"&&e.type==="string"&&(r=ry(e)),t==="number"&&(e.type==="number"||e.type==="integer")&&(r=ny(e)),t==="boolean"&&(r=p.boolean()),t==="null"&&(r=p.null()),!r)throw new Gn(`Unknown primitive type: "${t}"`);return e.description&&(r=r.describe(e.description)),r},"toZuiPrimitive"),rt=p.any();function hu(t){return K(t)}l(hu,"fromJSONSchema");function K(t){var e,n,r;if(t===void 0)return rt;if(t===!0)return p.any();if(t===!1)return p.never();if(t.default!==void 0)return K(f(u({},t),{default:void 0})).default(t.default);if(t.readOnly)return K(f(u({},t),{readOnly:void 0})).readonly();if(t.description!==void 0)return K(f(u({},t),{description:void 0})).describe(t.description);if(t.oneOf!==void 0)throw new Ee({oneOf:t.oneOf});if(t.patternProperties!==void 0)throw new Ee({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new Ee({propertyNames:t.propertyNames});if(t.if!==void 0)throw new Ee({if:t.if});if(t.then!==void 0)throw new Ee({then:t.then});if(t.else!==void 0)throw new Ee({else:t.else});if(t.$ref!==void 0)return p.ref(t.$ref);if(t.not!==void 0){if(mu(t))return p.undefined();if(t.not===!0)return p.never();throw new Ee({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return rt;if(t.type.length===1)return K(f(u({},t),{type:t.type[0]}));let i=t,{type:s}=i,a=js(i,["type"]),o=t.type.map(c=>K(f(u({},a),{type:c})));return p.union(o)}if(t.type==="string")return t.enum&&t.enum.length>0?p.enum(t.enum):xt("string",t);if(t.type==="integer"){let i=xt("number",t);return i instanceof p.ZodNumber?i.int():i}if(t.type==="number")return xt("number",t);if(t.type==="boolean")return xt("boolean",t);if(t.type==="null")return xt("null",t);if(t.type==="array")return Jh(t,K);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let i=K(t.additionalProperties);return K(f(u({},t),{additionalProperties:void 0})).catchall(i)}if(t.properties!==void 0){let i={};for(let[s,a]of Object.entries(t.properties)){let o=K(a),c=(e=t.required)!=null?e:[];i[s]=c.includes(s)||o.isOptional()?o:o.optional()}return p.object(i)}if(t.additionalProperties!==void 0){let i=K(t.additionalProperties);return p.record(i)}return p.record(rt)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return rt;if(t.anyOf.length===1)return K(t.anyOf[0]);if(Lh(t))return K(t.anyOf[0]).optional();if(Vh(t))return K(t.anyOf[0]).nullable();if(Gh(t)&&((r=(n=t["x-zui"])==null?void 0:n.def)!=null&&r.discriminator)){let{discriminator:s}=t["x-zui"].def,a=t.anyOf.map(K);return p.discriminatedUnion(s,a)}let i=t.anyOf.map(K);return p.union(i)}if(t.allOf!==void 0){if(t.allOf.length===0)return rt;if(t.allOf.length===1)return K(t.allOf[0]);let[i,...s]=t.allOf,a=K(i),o=K({allOf:s});return p.intersection(a,o)}return qh(t)?p.unknown():rt}l(K,"_fromJSONSchema");var iy=/^\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))?$/,Qr=l((t,e,n=!0)=>{if(typeof t!="object")throw new Ur("Input must be an object");let r=l(a=>{let o=a;return e?.nullable&&(o=o.nullable()),e?.optional&&(o=o.optional()),e?.passtrough&&typeof o.passthrough=="function"&&(o=o.passthrough()),o},"applyOptions"),i=Object.entries(t).reduce((a,[o,c])=>{if(c===null)a[o]=r(y.null());else switch(typeof c){case"string":a[o]=iy.test(c)?r(y.string().datetime()):r(y.string());break;case"number":a[o]=r(y.number());break;case"boolean":a[o]=r(y.boolean());break;case"object":Array.isArray(c)?c.length===0?a[o]=r(y.array(y.unknown())):typeof c[0]=="object"?a[o]=r(y.array(Qr(c[0],e,!1))):["string","number","boolean"].includes(typeof c[0])&&(a[o]=r(y.array(y[typeof c[0]]()))):a[o]=r(Qr(c,e,!1));break;default:throw new Ur(`Unsupported type for key ${o}`)}return a},{}),s=Object.keys(i).length>0;return e?.passtrough||!n&&!s?y.object(i).passthrough():y.object(i)},"fromObject");function yu(){return{}}l(yu,"parseAnyDef");function vu(t,e){var n,r;let i={type:"array"};return((r=(n=t.type)==null?void 0:n._def)==null?void 0:r.typeName)!=="ZodAny"&&(i.items=A(t.type._def,f(u({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&R(i,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&R(i,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(R(i,"minItems",t.exactLength.value,t.exactLength.message,e),R(i,"maxItems",t.exactLength.value,t.exactLength.message,e)),i}l(vu,"parseArrayDef");function _u(t,e){let n=u({type:"integer",format:"int64"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"min":e.target==="jsonSchema7"?r.inclusive?R(n,"minimum",r.value,r.message,e):R(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),R(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?R(n,"maximum",r.value,r.message,e):R(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),R(n,"maximum",r.value,r.message,e));break;case"multipleOf":R(n,"multipleOf",r.value,r.message,e);break}return n}l(_u,"parseBigintDef");function Tu(t){return u({type:"boolean"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{})}l(Tu,"parseBooleanDef");function bu(t,e){return A(t.type._def,e)}l(bu,"parseBrandedDef");var sy=l((t,e)=>A(t.innerType._def,e),"parseCatchDef");function wu(t,e){return e.dateStrategy==="integer"?ay(t,e):u({type:"string",format:"date-time"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{})}l(wu,"parseDateDef");var ay=l((t,e)=>{let n=u({type:"integer",format:"unix-time"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});for(let r of t.checks)switch(r.kind){case"min":e.target==="jsonSchema7"&&R(n,"minimum",r.value,r.message,e);break;case"max":e.target==="jsonSchema7"&&R(n,"maximum",r.value,r.message,e);break}return n},"integerDateParser");function Pu(t,e){return f(u({},A(t.innerType._def,e)),{default:t.defaultValue()})}l(Pu,"parseDefaultDef");function xu(t,e){return e.effectStrategy==="input"?A(t.schema._def,e):{}}l(xu,"parseEffectsDef");function ku(t){return{type:"string",enum:t.values}}l(ku,"parseEnumDef");var oy=l(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function Su(t,e){let n=[A(t.left._def,f(u({},e),{currentPath:[...e.currentPath,"allOf","0"]})),A(t.right._def,f(u({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(s=>!!s),r=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];return n.forEach(s=>{if(oy(s))i.push(...s.allOf),s.unevaluatedProperties===void 0&&(r=void 0);else{let a=s;if("additionalProperties"in s&&s.additionalProperties===!1){let o=s,{additionalProperties:c}=o;a=js(o,["additionalProperties"])}else r=void 0;i.push(a)}}),i.length?u({allOf:i},r):void 0}l(Su,"parseIntersectionDef");function Ou(t,e){let n=typeof t.value;return n!=="bigint"&&n!=="number"&&n!=="boolean"&&n!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:n==="bigint"?"integer":n,enum:[t.value]}:{type:n==="bigint"?"integer":n,const:t.value}}l(Ou,"parseLiteralDef");function Ki(t,e){var n,r,i,s,a;if(e.target==="openApi3"&&((n=t.keyType)==null?void 0:n._def.typeName)==="ZodEnum")return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((c,d)=>{var g;return f(u({},c),{[d]:(g=A(t.valueType._def,f(u({},e),{currentPath:[...e.currentPath,"properties",d]})))!=null?g:{}})},{}),additionalProperties:!1};let o={type:"object",additionalProperties:(r=A(t.valueType._def,f(u({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:{}};if(e.target==="openApi3")return o;if(((i=t.keyType)==null?void 0:i._def.typeName)==="ZodString"&&((s=t.keyType._def.checks)!=null&&s.length)){let c=Object.entries(ri(t.keyType._def,e)).reduce((d,[g,m])=>g==="type"?d:f(u({},d),{[g]:m}),{});return f(u({},o),{propertyNames:c})}else if(((a=t.keyType)==null?void 0:a._def.typeName)==="ZodEnum")return f(u({},o),{propertyNames:{enum:t.keyType._def.values}});return o}l(Ki,"parseRecordDef");function Eu(t,e){if(e.mapStrategy==="record")return Ki(t,e);let n=A(t.keyType._def,f(u({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},r=A(t.valueType._def,f(u({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}l(Eu,"parseMapDef");function Iu(t){let e=t.values,r=Object.keys(t.values).filter(s=>typeof e[e[s]]!="number").map(s=>e[s]),i=Array.from(new Set(r.map(s=>typeof s)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:r.filter(s=>typeof s=="string"||typeof s=="number")}}l(Iu,"parseNativeEnumDef");function Zu(){return{not:{}}}l(Zu,"parseNeverDef");function Bu(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}l(Bu,"parseNullDef");var Vn={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Au(t,e){if(e.target==="openApi3")return Hs(t,e);let n=t.options instanceof Map?Array.from(t.options.values()):t.options;if(n.every(r=>r._def.typeName in Vn&&(!r._def.checks||!r._def.checks.length))){let r=n.reduce((i,s)=>{let a=Vn[s._def.typeName];return a&&!i.includes(a)?[...i,a]:i},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){let r=n.reduce((i,s)=>{let a=typeof s._def.value;switch(a){case"string":case"number":case"boolean":return[...i,a];case"bigint":return[...i,"integer"];case"object":if(s._def.value===null)return[...i,"null"];case"symbol":case"undefined":case"function":default:return i}},[]);if(r.length===n.length){let i=r.filter((s,a,o)=>o.indexOf(s)===a);return{type:i.length>1?i:i[0],enum:n.reduce((s,a)=>s.includes(a._def.value)?s:[...s,a._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,i)=>[...r,...i._def.values.filter(s=>!r.includes(s))],[])};return Hs(t,e)}l(Au,"parseUnionDef");var Hs=l((t,e)=>{let n=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((i,s)=>A(i._def,f(u({},e),{currentPath:[...e.currentPath,e.unionStrategy,`${s}`]}))).filter(i=>!!i&&(!e.strictUnions||typeof i=="object"&&Object.keys(i).length>0)),r=e.discriminator&&t.typeName==="ZodDiscriminatedUnion"&&typeof t.discriminator=="string"?{discriminator:{propertyName:t.discriminator}}:{};if(n.length)return e.unionStrategy==="anyOf"?u({anyOf:n},r):u({oneOf:n},r)},"asUnionOf");function Cu(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length)){let r=t.innerType;if(e.target==="openApi3"){let s={type:Vn[r._def.typeName],nullable:!0};return ei(r._def,e,s)}let i={type:[Vn[r._def.typeName],"null"]};return ei(r._def,e,i)}if(e.target==="openApi3"){let r=A(t.innerType._def,f(u({},e),{currentPath:[...e.currentPath]}));return r&&f(u({},r),{nullable:!0})}let n=A(t.innerType._def,f(u({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return n&&{anyOf:[n,{type:"null"}]}}l(Cu,"parseNullableDef");function Ru(t,e){let n=u({type:"number"},t.coerce?{[w]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"int":n.type="integer",ni(n,"type",r.message,e);break;case"min":e.target==="jsonSchema7"?r.inclusive?R(n,"minimum",r.value,r.message,e):R(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),R(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?R(n,"maximum",r.value,r.message,e):R(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),R(n,"maximum",r.value,r.message,e));break;case"multipleOf":R(n,"multipleOf",r.value,r.message,e);break}return n}l(Ru,"parseNumberDef");var ly=l((t,e)=>{var n;return t.unknownKeys instanceof E?(n=A(t.unknownKeys._def,f(u({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function Hu(t,e){let n=f(u({type:"object"},Object.entries(t.shape()).reduce((r,[i,s])=>{if(s===void 0||s._def===void 0)return r;let a=A(s._def,f(u({},e),{currentPath:[...e.currentPath,"properties",i],propertyPath:[...e.currentPath,"properties",i]}));return a===void 0?r:{properties:f(u({},r.properties),{[i]:a}),required:s.isOptional()?r.required:[...r.required,i]}},{properties:{},required:[]})),{additionalProperties:ly(t,e)});return n.required.length||delete n.required,n}l(Hu,"parseObjectDef");var cy=l((t,e)=>{var n;if(e.currentPath.toString()===((n=e.propertyPath)==null?void 0:n.toString()))return A(t.innerType._def,e);let r=A(t.innerType._def,f(u({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return r?{anyOf:[{not:{}},r]}:{}},"parseOptionalDef"),uy=l((t,e)=>{if(e.pipeStrategy==="input")return A(t.in._def,e);if(e.pipeStrategy==="output")return A(t.out._def,e);let n=A(t.in._def,f(u({},e),{currentPath:[...e.currentPath,"allOf","0"]})),r=A(t.out._def,f(u({},e),{currentPath:[...e.currentPath,"allOf",n?"1":"0"]}));return{allOf:[n,r].filter(i=>i!==void 0)}},"parsePipelineDef");function Du(t,e){return A(t.type._def,e)}l(Du,"parsePromiseDef");var dy=l((t,e)=>A(t.innerType._def,e),"parseReadonlyDef");function Nu(t){return{$ref:t.uri}}l(Nu,"parseRefDef");function Mu(t,e){let r={type:"array",uniqueItems:!0,items:A(t.valueType._def,f(u({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&R(r,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&R(r,"maxItems",t.maxSize.value,t.maxSize.message,e),r}l(Mu,"parseSetDef");function ju(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((n,r)=>A(n._def,f(u({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:A(t.rest._def,f(u({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((n,r)=>A(n._def,f(u({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((n,r)=>r===void 0?n:[...n,r],[])}}l(ju,"parseTupleDef");function $u(){return{not:{}}}l($u,"parseUndefinedDef");function Ku(){return{}}l(Ku,"parseUnknownDef");function A(t,e,n=!1){let r=e.seen.get(t);if(r&&!n){let a=py(r,e);if(a!==void 0)return a}let i={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,i);let s=gy(t,t.typeName,e);return s&&ei(t,e,s),i.jsonSchema=s,s}l(A,"parseDef");var py=l((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:fy(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((n,r)=>e.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},"get$ref"),fy=l((t,e)=>{let n=0;for(;n<t.length&&n<e.length&&t[n]===e[n];n++);return[(t.length-n).toString(),...e.slice(n)].join("/")},"getRelativePath"),gy=l((t,e,n)=>{switch(e){case"ZodString":return ri(t,n);case"ZodNumber":return Ru(t,n);case"ZodObject":return Hu(t,n);case"ZodBigInt":return _u(t,n);case"ZodBoolean":return Tu(t);case"ZodDate":return wu(t,n);case"ZodUndefined":return $u();case"ZodNull":return Bu(n);case"ZodArray":return vu(t,n);case"ZodUnion":case"ZodDiscriminatedUnion":return Au(t,n);case"ZodIntersection":return Su(t,n);case"ZodTuple":return ju(t,n);case"ZodRecord":return Ki(t,n);case"ZodRef":return Nu(t);case"ZodLiteral":return Ou(t,n);case"ZodEnum":return ku(t);case"ZodNativeEnum":return Iu(t);case"ZodNullable":return Cu(t,n);case"ZodOptional":return cy(t,n);case"ZodMap":return Eu(t,n);case"ZodSet":return Mu(t,n);case"ZodLazy":return A(t.getter()._def,n);case"ZodPromise":return Du(t,n);case"ZodNaN":case"ZodNever":return Zu();case"ZodEffects":return xu(t,n);case"ZodAny":return yu();case"ZodUnknown":return Ku();case"ZodDefault":return Pu(t,n);case"ZodBranded":return bu(t,n);case"ZodReadonly":return dy(t,n);case"ZodCatch":return sy(t,n);case"ZodPipeline":return uy(t,n);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return(r=>{})(e)}},"selectParser"),ei=l((t,e,n)=>(t.description&&(n.description=t.description,e.markdownDescription&&(n.markdownDescription=t.description)),Object.assign(n,{[w]:u(u({},t[w]),n[w])}),n),"addMeta"),Ds={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"},my=l(t=>typeof t=="string"?f(u({},Ds),{name:t}):u(u({},Ds),t),"getDefaultOptions"),hy=l(t=>{let e=my(t),n=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return f(u({},e),{currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([r,i])=>[i._def,{def:i._def,path:[...e.basePath,e.definitionPath,r],jsonSchema:void 0}]))})},"getRefs"),yy=l((t,e)=>{var n;let r=hy(e),i=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[d,g])=>{var m;return f(u({},c),{[d]:(m=A(g._def,f(u({},r),{currentPath:[...r.basePath,r.definitionPath,d]}),!0))!=null?m:{}})},{}):void 0,s=typeof e=="string"?e:e?.name,a=(n=A(t._def,s===void 0?r:f(u({},r),{currentPath:[...r.basePath,r.definitionPath,s]}),!1))!=null?n:{},o=s===void 0?i?f(u({},a),{[r.definitionPath]:i}):a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:f(u({},i),{[s]:a})};return r.target==="jsonSchema7"?o.$schema="http://json-schema.org/draft-07/schema#":r.target==="jsonSchema2019-09"&&(o.$schema="https://json-schema.org/draft/2019-09/schema#"),o},"zodToJsonSchema"),vy=l((t,e={target:"openApi3"})=>{let n=yy(t,e);return e.$schemaUrl===!1?delete n.$schema:typeof e.$schemaUrl=="string"&&(n.$schema=e.$schemaUrl),n},"toJSONSchemaLegacy");var yt=(t,e)=>{let n=t._def,r=e._def;if(n.typeName===y.ZodFirstPartyTypeKind.ZodObject&&r.typeName===y.ZodFirstPartyTypeKind.ZodObject){let i=n.shape(),s=r.shape();return y.object({...i,...s})}if(n.typeName===y.ZodFirstPartyTypeKind.ZodRecord&&r.typeName===y.ZodFirstPartyTypeKind.ZodRecord)return y.record(y.intersection(n.valueType,r.valueType));throw new Error("Cannot merge object schemas with record schemas")},Uu=y;var L=y.string().min(1),zu=y.object({text:L}),Wu=y.object({markdown:L}),Lu=y.object({imageUrl:L,title:L.optional()}),Vu=y.object({audioUrl:L,title:L.optional()}),qu=y.object({videoUrl:L,title:L.optional()}),Gu=y.object({fileUrl:L,title:L.optional()}),Ju=y.object({latitude:y.number(),longitude:y.number(),address:y.string().optional(),title:y.string().optional()}),Yu=y.object({title:L,subtitle:L.optional(),imageUrl:L.optional(),actions:y.array(y.object({action:y.enum(["postback","url","say"]),label:L,value:L}))}),Fu=y.object({text:L,options:y.array(y.object({label:L,value:L}))}),_y=y.object({items:y.array(Yu)}),Xu=y.union([y.object({type:y.literal("text"),payload:zu}),y.object({type:y.literal("image"),payload:Lu}),y.object({type:y.literal("audio"),payload:Vu}),y.object({type:y.literal("video"),payload:qu}),y.object({type:y.literal("file"),payload:Gu}),y.object({type:y.literal("location"),payload:Ju})]),Ty=y.object({items:y.array(Xu)}),by={schema:Wu},wy={schema:y.object({items:y.array(y.union([...Xu.options,y.object({type:y.literal("markdown"),payload:Wu})]))})},Py={text:{schema:zu},image:{schema:Lu},audio:{schema:Vu},video:{schema:qu},file:{schema:Gu},location:{schema:Ju},carousel:{schema:_y},card:{schema:Yu},dropdown:{schema:Fu},choice:{schema:Fu},bloc:{schema:Ty}};var xy={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};var Qu=require("browser-or-node");var Fi=console;function le(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function Xt(t,e=8072,n=Ey){if(!Qu.isNode)throw new Error("This function can only be called in Node.js");let i=require("http").createServer(async(s,a)=>{try{let o=await ky(s);if(o.path==="/health"){a.writeHead(200).end("ok");return}let c=await t(o);a.writeHead(c?.status??200,c?.headers??{}).end(c?.body??"{}")}catch(o){let c=o instanceof Error?o.message:String(o);Fi.error("Error while handling request",{error:c??"Internal error occured"}),a.writeHead(500).end(JSON.stringify({error:c??"Internal error occured"}))}});return i.listen(e,()=>n(e)),i}async function ky(t){let e=await Oy(t),n={};for(let i=0;i<t.rawHeaders.length;i+=2){let s=t.rawHeaders[i].toLowerCase(),a=t.rawHeaders[i+1];n[s]=a}let r=new URL(t.url??"",t.headers.host?`http://${t.headers.host}`:"http://botpress.cloud");return{body:e,path:r.pathname,query:Sy(r.search,"?"),headers:n,method:t.method?.toUpperCase()??"GET"}}function Sy(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function Oy(t){return new Promise((e,n)=>{if(t.method!=="POST"&&t.method!=="PUT"&&t.method!=="PATCH")return e(void 0);let r="";t.on("data",i=>r+=i.toString()),t.on("error",i=>n(i)),t.on("end",()=>e(r))})}function Ey(t){Fi.info(`Listening on port ${t}`)}var Ar=require("@botpress/client");var D={};nt(D,{mapKeys:()=>By,mapValues:()=>Zy,mergeRecords:()=>Cy,pairs:()=>vr,stripUndefinedProps:()=>Ay,values:()=>Iy});var vr=t=>Object.entries(t),Iy=t=>Object.values(t),Zy=(t,e)=>Object.fromEntries(vr(t).map(([n,r])=>[n,e(r,n)])),By=(t,e)=>Object.fromEntries(vr(t).map(([n,r])=>[e(n),r])),Ay=t=>Object.fromEntries(vr(t).filter(([,e])=>e!==void 0)),Cy=(t,e,n)=>{let r=[...Object.keys(t),...Object.keys(e)],i=[...new Set(r)],s={};for(let a of i){let o=t[a],c=e[a];o&&c?s[a]=n(o,c):o?s[a]=o:c&&(s[a]=c)}return s};var O={};nt(O,{safePush:()=>Ry,unique:()=>Hy});var Ry=(t,...e)=>t?[...t,...e]:[...e],Hy=t=>Array.from(new Set(t));var Y={};nt(Y,{setName:()=>Dy});var Dy=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var ed=t=>{let{name:e,version:n}=t,r={actions:{},events:{},channels:{}},i={name:e,version:n,entities:D.mapValues(t.entities,a=>({name:a.name})),actions:{},events:{},channels:{}},s=D.mapValues(t.entities,a=>a.schema);for(let[a,o]of Object.entries(t.definition.actions??{})){let c=o.input.schema.dereference(s),d=o.output.schema.dereference(s),g=t.actions?.[a]?.name??a;r.actions[g]={...o,...t.actions?.[a]??{},input:{schema:c},output:{schema:d}},i.actions[a]={name:g}}for(let[a,o]of Object.entries(t.definition.events??{})){let c=o.schema.dereference(s),d=t.events?.[a]?.name??a;r.events[d]={...o,...t.events?.[a]??{},schema:c},i.events[a]={name:d}}for(let[a,o]of Object.entries(t.definition.channels??{})){let c={};for(let[g,m]of Object.entries(o.messages)){let T=m.schema.dereference(s);c[g]={...m,schema:T}}let d=t.channels?.[a]?.name??a;r.channels[d]={...o,...t.channels?.[a]??{},message:{...o.message??{},tags:{...o.message?.tags??{},...t.channels?.[a]?.message?.tags??{}}},conversation:{...o.conversation??{},tags:{...o.conversation?.tags??{},...t.channels?.[a]?.conversation?.tags??{}}},messages:c},i.channels[a]={name:d}}return{resolved:r,statement:i}};var td="5.4.3";var Ce=td;var _r=Symbol("schemaName"),nd=t=>t?D.mapValues(t,(n,r)=>({...n,[_r]:r})):{},rd=t=>_r in t&&t[_r]!==void 0,id=t=>t[_r];var Tr=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;get metadata(){return{sdkVersion:Ce}}extend(e,n){let{entities:r,actions:i,events:s,channels:a}=this._callBuilder(e,n),o=this;o.interfaces??={};let c=Object.values(r).map(T=>T.name),d=c.length===0?e.name:`${e.name}<${c.join(",")}>`,{resolved:g,statement:m}=ed({...e,entities:r,actions:D.stripUndefinedProps(i),events:D.stripUndefinedProps(s),channels:D.stripUndefinedProps(a)});return o.actions=D.mergeRecords(o.actions??{},g.actions,this._mergeActions),o.channels=D.mergeRecords(o.channels??{},g.channels,this._mergeChannels),o.events=D.mergeRecords(o.events??{},g.events,this._mergeEvents),o.interfaces[d]={id:e.id,...m},this}_callBuilder(e,n){let i={entities:nd(this.entities)},s=n(i),a=D.pairs(s.entities).find(([c,d])=>!rd(d));if(a)throw new Error(`Cannot extend interface "${e.name}" with entity "${a[0]}"; the provided schema is not part of the integration's entities.`);return{entities:D.mapValues(s.entities,c=>({name:id(c),schema:c.schema})),actions:s.actions??{},events:s.events??{},channels:s.channels??{}}}_mergeActions=(e,n)=>({...e,...n,input:{schema:yt(e.input.schema,n.input.schema)},output:{schema:yt(e.output.schema,n.output.schema)}});_mergeEvents=(e,n)=>({...e,...n,schema:yt(e.schema,n.schema)});_mergeChannels=(e,n)=>{let r=D.mergeRecords(e.messages,n.messages,this._mergeMessage),i;(e.conversation||n.conversation)&&(i={tags:{...e.conversation?.tags,...n.conversation?.tags}});let s;return(e.message||n.message)&&(s={tags:{...e.message?.tags,...n.message?.tags}}),{...e,...n,messages:r,conversation:i,message:s}};_mergeMessage=(e,n)=>({schema:yt(e.schema,n.schema)})};var Se=require("@botpress/client");var sd=Rr(require("@botpress/client")),br={retries:3,retryCondition:t=>sd.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(My(e.response?.headers??{})??t)*1e3},My=t=>{let e=["RateLimit-Reset","X-RateLimit-Reset","Retry-After","ratelimit-reset","x-ratelimit-reset","retry-after"];for(let n of e){let r=t[n];if(r!==void 0)return jy(String(r))}},jy=t=>{let e=$y(t)?Ky(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},$y=t=>t.includes(" "),Ky=t=>{let e=Uy(t);if(!e)return;let n=new Date;return Math.max(0,Math.floor((e.getTime()-n.getTime())/1e3))},Uy=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};var vt=class{constructor(e){this._client=e}get _inner(){return this._client}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).then(n=>n));updateMessage=(e=>this._client.updateMessage(e).then(n=>n));listMessages=(e=>this._client.listMessages(e));deleteMessage=(e=>this._client.deleteMessage(e));initializeIncomingMessage=(e=>this._client.initializeIncomingMessage(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 wr=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};var pe="#",Pr="x-bot-id",ad="x-bot-user-id",od="x-integration-id",ld="x-integration-alias",cd="x-webhook-id",ud="x-bp-configuration-type",xr="x-bp-configuration",kr="x-bp-operation",dd="x-bp-type";var ce=t=>{throw t instanceof Error?t:new Error(t)};var m_=y.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),pd=t=>({botId:t[Pr]||ce("Missing bot header"),botUserId:t[ad]||ce("Missing bot user header"),integrationId:t[od]||ce("Missing integration header"),integrationAlias:t[ld]||ce("Missing integration alias header"),webhookId:t[cd]||ce("Missing webhook header"),operation:t[kr]||ce("Missing operation header"),configurationType:t[ud]??null,configuration:JSON.parse(Buffer.from(t[xr]||ce("Missing configuration header"),"base64").toString("utf-8"))});var fd=Rr(require("util")),_t=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)}issue(e){console.info(JSON.stringify(e))}_log(e,n){this._getConsoleMethod(e)(this._serializeMessage(n))}_serializeMessage(e){let n=fd.default.format(...e);return process.env.BP_LOG_FORMAT==="json"?this.getJsonMessage(n):n}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 Tt=class t extends _t{constructor(e){super({visibleToBotOwners:!1,hiddenToIntegrationOwners:!1,...e})}with(e){return new t({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withVisibleToBotOwners(e){return this.with({visibleToBotOwners:e})}withHiddenToIntegrationOwners(e){return this.with({hiddenToIntegrationOwners:e})}forBot(){return this.with({hiddenToIntegrationOwners:!1,visibleToBotOwners:!0})}forBotOnly(){return this.with({hiddenToIntegrationOwners:!0,visibleToBotOwners:!0})}getJsonMessage(e){return JSON.stringify({msg:e,visible_to_bot_owner:this.defaultOptions.visibleToBotOwners,hidden_to_integration_owner:this.defaultOptions.hiddenToIntegrationOwners,options:this.defaultOptions})}};var Fy=t=>["traceparent","tracestate","sentry-trace"].reduce((e,n)=>(t[n]&&(e[n]=t[n]),e),{}),zy=(t,e,n)=>{let[,r]=(e.headers.traceparent||"").split("-"),i=new Se.Client({botId:t.botId,integrationId:t.integrationId,integrationAlias:t.integrationAlias,retry:br,headers:Fy(e.headers)}),s=new vt(i),a=new Tt({traceId:r});return{ctx:t,req:e,client:s,logger:a,instance:n}},Wy=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await Vy(t);case"register":return await qy(t);case"unregister":return await Gy(t);case"message_created":return await Xy(t);case"action_triggered":return await Qy(t);case"ping":return await Ly(t);case"create_user":return await Jy(t);case"create_conversation":return await Yy(t);default:throw new Se.InvalidPayloadError(`Unknown operation ${e.operation}`)}},gd=t=>async e=>{let n=pd(e.headers),r=zy(n,e,t),{logger:i}=r;try{let s;return s=await ev(r),s?{...s,status:s.status??200}:(s=await Wy(r),s?{...s,status:s.status??200}:{status:200})}catch(s){if((0,Se.isApiError)(s)){let o=s.type==="Runtime"?s:new Se.RuntimeError(s.message,s);return i.forBot().error(o.message),{status:o.code,body:JSON.stringify(o.toJSON())}}console.error(s);let a=new Se.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 i.forBot().error(a.message),{status:a.code,body:JSON.stringify(a.toJSON())}}},Ly=async t=>{},Vy=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{let{req:s}=le(n);return i.webhook({client:t,ctx:e,req:s,logger:r})},qy=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.register)return;let{webhookUrl:s}=le(n);await i.register({client:t,ctx:e,webhookUrl:s,logger:r})},Gy=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.unregister)return;let{webhookUrl:s}=le(n);await i.unregister({ctx:e,webhookUrl:s,client:t,logger:r})},Jy=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.createUser)return;let{tags:s}=le(n);return await i.createUser({ctx:e,client:t,tags:s,logger:r})},Yy=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.createConversation)return;let{channel:s,tags:a}=le(n);return await i.createConversation({ctx:e,client:t,channel:s,tags:a,logger:r})},Xy=async({ctx:t,req:e,client:n,logger:r,instance:i})=>{let{conversation:s,user:a,type:o,payload:c,message:d}=le(e),g=i.channels[s.channel];if(!g)throw new Error(`Channel ${s.channel} not found`);let m=g.messages[o];if(!m)throw new Error(`Message of type ${o} not found in channel ${s.channel}`);await m({ctx:t,conversation:s,message:d,user:a,type:o,client:n,payload:c,ack:async({tags:I})=>{await n.updateMessage({id:d.id,tags:I})},logger:r})},Qy=async({req:t,ctx:e,client:n,logger:r,instance:i})=>{let{input:s,type:a}=le(t);if(!a)throw new Error("Missing action type");let o=i.actions[a];if(!o)throw new Error(`Action ${a} not found`);let c=new wr,g={output:await o({ctx:e,input:s,client:n,type:a,logger:r,metadata:c}),meta:c.toJSON()};return{body:JSON.stringify(g)}},ev=async({instance:t,client:e,ctx:n,logger:r,req:i})=>{let s=t.unknownOperationHandler;if(s)return await s({client:e,ctx:n,logger:r,req:i})};var Sr=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.unknownOperationHandler=e.__advanced?.unknownOperationHandler}actions;channels;register;unregister;createUser;createConversation;webhook;unknownOperationHandler;handler=gd(this);start=e=>Xt(this.handler,e)};var Or=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,this.__advanced=e.__advanced,this.withPlugins={user:e.user,conversation:e.conversation,message:e.message,states:e.states,events:e.events,recurringEvents:e.recurringEvents,actions:e.actions,tables:e.tables,workflows:e.workflows}}integrations;plugins;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;attributes;__advanced;withPlugins;get metadata(){return{sdkVersion:Ce}}addIntegration(e,n){let r=this;r.integrations||(r.integrations={});let i=n?.alias??e.name;if(r.integrations[i])throw new Error(`Another integration with alias "${i}" is already installed in the bot`);return r.integrations[i]={...e,alias:i,enabled:n?.enabled,configurationType:n&&"configurationType"in n?n.configurationType:void 0,configuration:n&&"configuration"in n?n.configuration??{}:{},disabledChannels:n?.disabledChannels},this}addPlugin(e,n){let r=this;r.plugins||(r.plugins={});let i=n.alias??e.name;if(r.plugins[i])throw new Error(`Another plugin with alias "${i}" is already installed in the bot`);let s=Object.fromEntries(Object.entries(n.dependencies??{}).filter(([o,c])=>"integrationInterfaceAlias"in c).map(([o,c])=>{let d=this.integrations?.[c.integrationAlias];if(!d){let m=Object.keys(this.integrations??{}).join(", ")||"(none)";throw new Error(`Interface with alias "${o}" of plugin with alias "${i}" references integration with alias "${c.integrationAlias}" which is not installed. Please make sure to add the integration via addIntegration() before calling addPlugin().
73
- Available integration aliases: ${m}`)}let g=d.definition.interfaces?.[c.integrationInterfaceAlias];if(!g){let m=Object.keys(d.definition.interfaces??{}).join(", ")||"(none)";throw new Error(`Interface with alias "${c.integrationInterfaceAlias}" does not exist in integration "${d.name}" referenced by interface with alias "${o}" of plugin with alias "${i}".
74
- Available interface aliases: ${m}`)}return[o,{...g,id:d.id,name:d.name,version:d.version,...c}]})),a=Object.fromEntries(Object.entries(n.dependencies??{}).filter(([o,c])=>!("integrationInterfaceAlias"in c)).map(([o,c])=>{let d=this.integrations?.[c.integrationAlias];if(!d){let g=Object.keys(this.integrations??{}).join(", ")||"(none)";throw new Error(`Integration with alias "${o}" of plugin with alias "${i}" references integration with alias "${c.integrationAlias}" which is not installed. Please make sure to add the integration via addIntegration() before calling addPlugin().
75
- Available integration aliases: ${g}`)}return[o,{...d,...c}]}));return r.plugins[i]={...e,alias:i,configuration:n.configuration??{},interfaces:s,integrations:a},r.withPlugins.user=this._mergeUser(r.withPlugins.user,e.definition.user),r.withPlugins.conversation=this._mergeConversation(r.withPlugins.conversation,e.definition.conversation),r.withPlugins.message=this._mergeMessage(r.withPlugins.message,e.definition.message),r.withPlugins.recurringEvents=this._mergeRecurringEvents(r.withPlugins.recurringEvents,e.definition.recurringEvents),r.withPlugins.tables=this._mergeTables(r.withPlugins.tables,e.definition.tables),r.withPlugins.workflows=this._mergeWorkflows(r.withPlugins.workflows,e.definition.workflows),r.withPlugins.states=this._mergeStates(r.withPlugins.states,this._prefixKeysWithPluginAlias(e.definition.states,i)),r.withPlugins.events=this._mergeEvents(r.withPlugins.events,this._prefixKeysWithPluginAlias(e.definition.events,i)),r.withPlugins.actions=this._mergeActions(r.withPlugins.actions,this._prefixKeysWithPluginAlias(e.definition.actions,i)),this}_mergeUser=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeConversation=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeMessage=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeStates=(e,n)=>({...e,...n});_mergeEvents=(e,n)=>({...e,...n});_mergeRecurringEvents=(e,n)=>({...e,...n});_mergeActions=(e,n)=>({...e,...n});_mergeTables=(e,n)=>({...e,...n});_mergeWorkflows=(e,n)=>({...e,...n});_prefixKeysWithPluginAlias=(e,n)=>D.mapKeys(e??{},r=>`${n}${pe}${r}`);dereferencePluginEntities(){let e=this._buildZuiReferenceMap();return{...this,withPlugins:{...this.withPlugins,events:this._dereferenceDefinitionSchemas(this.withPlugins.events,e),states:this._dereferenceDefinitionSchemas(this.withPlugins.states,e),tables:this._dereferenceDefinitionSchemas(this.withPlugins.tables,e),actions:this._dereferenceActionDefinitionSchemas(this.withPlugins.actions,e)},plugins:Object.fromEntries(Object.entries(this.plugins??{}).map(([n,r])=>[n,{...r,definition:{...r.definition,configuration:this._dereferenceDefinitionSchema(r.definition.configuration,e),events:this._dereferenceDefinitionSchemas(r.definition.events,e),states:this._dereferenceDefinitionSchemas(r.definition.states,e),tables:this._dereferenceDefinitionSchemas(r.definition.tables,e),actions:this._dereferenceActionDefinitionSchemas(r.definition.actions,e)}}]))}}_buildZuiReferenceMap(){let e={},n=Object.entries(this.plugins??{});for(let[r,i]of n){let s=Object.entries(i.interfaces??{});for(let[a,o]of s){let c=this.integrations?.[o.integrationAlias];if(!c)throw new Error(`Interface with alias "${a}" of plugin with alias "${r}" references integration "${o.name}" which is not installed`);let d=Object.entries(o.entities??{});for(let[g,{name:m}]of d){let T=c.definition.entities?.[m]?.schema;if(!T)throw new Error(`Interface entity "${m}" does not exist in integration "${c.name}"`);e[`interface:${a}/entities/${g}`]=T}}}return e}_dereferenceZuiSchema(e,n){return e.dereference(n)}_dereferenceDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,this._dereferenceDefinitionSchema(i,n)]))}_dereferenceDefinitionSchema(e,n){return e&&{...e,schema:this._dereferenceZuiSchema(e.schema,n)}}_dereferenceActionDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,{...i,input:{schema:this._dereferenceZuiSchema(i.input.schema,n)},output:{schema:this._dereferenceZuiSchema(i.output.schema,n)}}]))}};var tt=require("@botpress/client");var bt=class t extends _t{constructor(e){super({...e})}with(e){return new t({...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 he=class{constructor(e,n={before:{},after:{}}){this._client=e;this._hooks=n}get _inner(){return this._client}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));getOrCreateWorkflow=(e=>this._run("getOrCreateWorkflow",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,n)=>{let r=this._hooks.before[e];r&&(n=await r(n));let i=await this._client[e](n),s=this._hooks.after[e];return s&&(i=await s(i,n)),i}};var tv=y.enum(["event_received","register","unregister","ping","action_triggered"]),md=t=>({botId:t[Pr]||ce("Missing bot id header"),operation:tv.parse(t[kr]),type:t[dd]||ce("Missing type header"),configuration:JSON.parse(Buffer.from(t[xr]||ce("Missing configuration header"),"base64").toString("utf-8"))});var X={status:200};var Wi=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 nv=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],hd=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!nv.includes(e.payload.type))throw new Error("Unexpected event type");let n={...t,logger:rv(t,e)};if(!e.payload.workflow.name)return n.logger.warn("Received workflow update event without a workflow name. Assuming this workflow was not defined by the bot.",e.payload.workflow),X;switch(e.payload.type){case"child_workflow_deleted":case"child_workflow_finished":n.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 iv(n,e);default:e.payload.type}return X},rv=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),iv=async(t,e)=>{let n=Wi(e.payload.type),r=t.self.workflowHandlers[n]?.[e.payload.workflow.name];if(!r||r.length===0)return t.logger.warn(`No ${n} handler found for workflow "${e.payload.workflow.name}"`),X;let{updatedWorkflow:i}=await sv(t,e);return i.status==="pending"&&t.logger.warn(`Workflow "${e.payload.workflow.name}" is still in pending status after processing "${n}" event. This may indicate that the workflow was not properly acknowledged or terminated by the handler. `),X},sv=async(t,e)=>{let n=Wi(e.payload.type),r=t.self.workflowHandlers[n]?.[e.payload.workflow.name],i=structuredClone(e.payload.workflow);for(let s of r??[])i=await s({...t,event:e,conversation:e.payload.conversation,user:e.payload.user,workflow:i});return{updatedWorkflow:i}};var yd=t=>async e=>{let n=md(e.headers),r=new bt,i=new tt.Client({botId:n.botId,retry:br}),s=new he(i,{before:{createMessage:async o=>{let c=t.hookHandlers.before_outgoing_message[o.type]??[];for(let d of c){let g=new he(i);o=(await d({client:g,ctx:n,logger:r.with({conversationId:o.conversationId,userId:o.userId}),data:o}))?.data??o}return o},callAction:async o=>{let c=t.hookHandlers.before_outgoing_call_action[o.type]??[];for(let d of c){let g=new he(i);o=(await d({client:g,ctx:n,logger:r,data:o}))?.data??o}return o}},after:{createMessage:async o=>{let c=t.hookHandlers.after_outgoing_message[o.message.type]??[];for(let d of c){let g=new he(i);o=(await d({client:g,ctx:n,logger:r.with({messageId:o.message.id,conversationId:o.message.conversationId,userId:o.message.userId}),data:o}))?.data??o}return o},callAction:async(o,c)=>{let{type:d}=c,g=t.hookHandlers.after_outgoing_call_action[d]??[];for(let m of g){let T=new he(i);o=(await m({client:T,ctx:n,logger:r,data:{type:d,...o}}))?.data??o}return o}}}),a={req:e,ctx:n,logger:r,client:s,self:t};try{switch(n.operation){case"action_triggered":return await uv(a);case"event_received":return await cv(a);case"register":return await ov(a);case"unregister":return await lv(a);case"ping":return await av(a);default:throw new Error(`Unknown operation ${n.operation}`)}}catch(o){let c=o instanceof Error?o:new Error(String(o));if((0,tt.isApiError)(c)){let g=c.type==="Runtime"?c:new tt.RuntimeError(c.message,c);return r.error(g.message),{status:g.code,body:JSON.stringify(g.toJSON())}}let d=new tt.RuntimeError("An unexpected error occurred in the bot.",c);return r.error(d.message,c),{status:d.code,body:JSON.stringify(d.toJSON())}}},av=async t=>X,ov=async t=>(await t.self.registerHandler?.({client:t.client,ctx:t.ctx,logger:t.logger}),X),lv=async t=>X,cv=async t=>{let{ctx:e,logger:n,req:r,client:i,self:s}=t,a={client:i,ctx:e,logger:n},o=le(r);if(a.logger=a.logger.with({eventId:o.event.id,messageId:o.event.messageId,conversationId:o.event.conversationId,userId:o.event.userId}),e.type==="workflow_update")return await hd(t,o.event);if(e.type==="message_created"){let I=o.event,k=I.payload.message;a.logger=a.logger.with({messageId:k.id,conversationId:k.conversationId,userId:k.userId});let $=s.hookHandlers.before_incoming_message[k.type]??[];for(let ge of $){let ae=await ge({...a,data:k});if(k=ae?.data??k,ae?.stop)return X}let z={...a,user:I.payload.user,conversation:I.payload.conversation,message:k,event:I},Q=s.messageHandlers[k.type]??[];for(let ge of Q)await ge(z);let se=s.hookHandlers.after_incoming_message[k.type]??[];for(let ge of se){let ae=await ge({...a,data:k});if(k=ae?.data??k,ae?.stop)return X}return X}if(e.type==="state_expired"){let k=o.event.payload.state,$={...a,state:k},z=s.stateExpiredHandlers[k.name]??[];for(let Q of z)await Q($);return X}let c=o.event,d=s.hookHandlers.before_incoming_event[c.type]??[];for(let I of d){let k=await I({...a,data:c});if(c=k?.data??c,k?.stop)return X}let g={...a,event:c},m=s.eventHandlers[c.type]??[];for(let I of m)await I(g);let T=s.hookHandlers.after_incoming_event[c.type]??[];for(let I of T){let k=await I({...a,data:c});if(c=k?.data??c,k?.stop)return X}return X},uv=async({ctx:t,logger:e,req:n,client:r,self:i})=>{let{input:s,type:a}=le(n);if(!a)throw new Error("Missing action type");let o=i.hookHandlers.before_incoming_call_action[a]??[];for(let T of o){let I=await T({ctx:t,logger:e,client:r,data:{type:a,input:s}});s=I?.data?.input??s,a=I?.data?.type??a}let c=i.actionHandlers[a];if(!c)throw new Error(`Action ${a} not found`);let d=await c({ctx:t,logger:e,input:s,client:r,type:a}),g=i.hookHandlers.after_incoming_call_action[a]??[];for(let T of g){let I=await T({ctx:t,logger:e,client:r,data:{type:a,output:d}});a=I?.data?.type??a,d=I?.data?.output??d}return{status:200,body:JSON.stringify({output:d})}};var ye=(t,{alias:e})=>{if(!("tags"in t)||!e)return t;let n=`${e}${pe}`,r=Object.fromEntries(Object.entries(t.tags??{}).flatMap(([i,s])=>i.startsWith(n)?[[i.slice(n.length),s]]:[]));return{...t,tags:r}},re=(t,{alias:e})=>{if(!("tags"in t)||!e)return t;let n=`${e}${pe}`,r=Object.fromEntries(Object.entries(t.tags??{}).map(([i,s])=>[i.startsWith(n)?i:`${n}${i}`,s]));return{...t,tags:r}};var Li=class{constructor(e){this._list=e}_nextToken;_elementsBuffer=[];_isExhausted=!1;[Symbol.asyncIterator](){return this}async next(){return this._bufferIsEmpty&&!this._isExhausted&&await this._fetchNextPageIntoBuffer(),this._bufferIsEmpty?{done:!0,value:void 0}:{done:!1,value:this._elementsBuffer.shift()}}async take(e){let n=[];for(let r=0;r<e;++r){let i=await this.next();if(i.done)break;n.push(i.value)}return n}async takePage(e){for(let r=0;r<e;++r)this._isExhausted||await this._fetchNextPageIntoBuffer();let n=[...this._elementsBuffer];return this._elementsBuffer.length=0,n}async takeAll(){return this.take(Number.POSITIVE_INFINITY)}get isExhausted(){return this._isExhausted}async _fetchNextPageIntoBuffer(){let{items:e,meta:n}=await this._list({nextToken:this._nextToken});this._elementsBuffer.push(...e),this._nextToken=n.nextToken,n.nextToken||(this._isExhausted=!0)}get _bufferIsEmpty(){return this._elementsBuffer.length===0}},ue=t=>new Li(t);var Oe=t=>new Proxy({},{get:(e,n)=>({listInstances:r=>ue(({nextToken:i})=>t.client.listWorkflows({...r,name:n,nextToken:i}).then(({meta:s,workflows:a})=>({meta:s,items:a.map(o=>de({...t,workflow:o}))}))),startNewInstance:async r=>{let{workflow:i}=await t.client.createWorkflow({name:n,status:"pending",...re(r,{alias:void 0})});return{workflow:de({...t,workflow:i})}}})}),de=t=>{let e=!1;return{...ye(t.workflow,{alias:void 0}),async update(n){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,...re(n,{alias:void 0})});return await t.onWorkflowUpdate?.(r),{workflow:de({...t,workflow:r})}},async acknowledgeStartOfProcessing(){if(!t.event||t.workflow.status!=="pending"||e)return{workflow:de(t)};let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"in_progress",eventId:t.event.id});return e=!0,await t.onWorkflowUpdate?.(n),{workflow:de({...t,workflow:n})}},async setFailed({failureReason:n}){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"failed",failureReason:n});return await t.onWorkflowUpdate?.(r),{workflow:de({...t,workflow:r})}},async setCompleted({output:n}={}){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"completed",output:n});return await t.onWorkflowUpdate?.(r),{workflow:de({...t,workflow:r})}},async cancel(){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return await t.onWorkflowUpdate?.(n),{workflow:de({...t,workflow:n})}}}};var Er=class{constructor(e){this.props=e;this._registerHandler=e.register,this._actionHandlers=e.actions,this._plugins=e.plugins}_registerHandler;_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 registerHandler(){return this._registerHandler}get actionHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._actionHandlers[n];if(r)return Y.setName(i=>r({...i,workflows:Oe(i)}),r.name);for(let[i,s]of Object.entries(this._plugins)){let[a,o]=n.split(pe);if(!(a!==i||!o))return s.actionHandlers[o]}}})}get messageHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(o=>o.messageHandlers[n]??[]),i=n==="*"?[]:this._messageHandlers[n]??[],s=this._messageHandlers["*"]??[],a=[...i,...s].sort((o,c)=>o.order-c.order).map(({handler:o})=>Y.setName(c=>o({...c,workflows:Oe(c)}),o.name));return O.unique([...r,...a])}})}get eventHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(o=>o.eventHandlers[n]??[]),i=n==="*"?[]:this._eventHandlers[n]??[],s=this._eventHandlers["*"]??[],a=[...i,...s].sort((o,c)=>o.order-c.order).map(({handler:o})=>Y.setName(c=>o({...c,workflows:Oe(c)}),o.name));return O.unique([...r,...a])}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(o=>o.stateExpiredHandlers[n]??[]),i=n==="*"?[]:this._stateExpiredHandlers[n]??[],s=this._stateExpiredHandlers["*"]??[],a=[...i,...s].sort((o,c)=>o.order-c.order).map(({handler:o})=>Y.setName(c=>o({...c,workflows:Oe(c)}),o.name));return O.unique([...r,...a])}})}get hookHandlers(){return new Proxy({},{get:(e,n)=>{if(this._hookHandlers[n])return new Proxy({},{get:(i,s)=>{let a=Object.values(this._plugins).flatMap(m=>m.hookHandlers[n]?.[s]??[]),o=this._hookHandlers[n]??{},c=s==="*"?[]:o[s]??[],d=o["*"]??[],g=[...c,...d].sort((m,T)=>m.order-T.order).map(({handler:m})=>Y.setName(T=>m({...T,workflows:Oe(T)}),m.name));return O.unique([...a,...g])}})}})}get workflowHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._workflowHandlers[n];if(r)return new Proxy({},{get:(i,s)=>{let a=r[s]?.sort((c,d)=>c.order-d.order).map(({handler:c})=>Y.setName(async d=>{let g=d.workflow;return await c({...d,workflow:de({...d,onWorkflowUpdate(m){g=m}}),workflows:Oe(d)}),g},c.name))??[],o=Object.values(this._plugins).flatMap(c=>c.workflowHandlers[n]?.[s]??[]);return O.unique([...a,...o])}})}})}on={message:(e,n)=>{this._messageHandlers[e]=O.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=O.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=O.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=O.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=O.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=O.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=O.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=O.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=O.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=O.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=O.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=O.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=O.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=O.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=O.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=O.safePush(this._workflowHandlers.timed_out[e],{handler:n,order:this._registerOrder++})}};handler=yd(this);start=e=>Xt(this.handler,e)};var Ir=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,this.__advanced=e.__advanced;let n=this._getEntityReference(this.entities),r=e.events===void 0?{}:D.mapValues(e.events,a=>({...a,schema:a.schema(n)})),i=e.actions===void 0?{}:D.mapValues(e.actions,a=>({...a,input:{...a.input,schema:a.input.schema(n)},output:{...a.output,schema:a.output.schema(n)}})),s=e.channels===void 0?{}:D.mapValues(e.channels,a=>({...a,messages:D.mapValues(a.messages,o=>({...o,schema:o.schema(n)}))}));this.events=r,this.actions=i,this.channels=s}name;version;title;description;icon;readme;attributes;entities;events;actions;channels;__advanced;get metadata(){return{sdkVersion:Ce}}_getEntityReference=e=>{let n={};for(let[r,i]of Object.entries(e)){let s=i.schema._def["x-zui"]?.title,a=i.schema._def.description,o=Uu.ref(r);s&&o.title(s),a&&o.describe(a),n[r]=o}return n}};var Zr=class{constructor(e){this.props=e;let n=Object.fromEntries(Object.entries(e.interfaces??{}).map(([i,s])=>[i,Object.fromEntries(Object.entries(s.definition.entities??{}).map(([a])=>[a,y.ref(`interface:${i}/entities/${a}`)]))]));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.recurringEvents=e.recurringEvents,this.workflows=e.workflows,this.attributes=e.attributes,this.__advanced=e.__advanced;let r=new Set;for(let i of[...Object.keys(e.integrations??{}),...Object.keys(e.interfaces??{})]){if(r.has(i))throw new Error(`Duplicate interface or integration alias detected in plugin definition: '${i}'. Please use unique aliases for each interface and integration.`);r.add(i)}this.configuration=e.configuration?{...e.configuration,schema:typeof e.configuration.schema=="object"?e.configuration.schema:e.configuration.schema({entities:n})}:void 0,this.states=Object.fromEntries(Object.entries(e.states??{}).map(([i,s])=>[i,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:n})}])),this.events=Object.fromEntries(Object.entries(e.events??{}).map(([i,s])=>[i,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:n})}])),this.actions=Object.fromEntries(Object.entries(e.actions??{}).map(([i,s])=>[i,{...s,input:{...s.input,schema:typeof s.input.schema=="object"?s.input.schema:s.input.schema({entities:n})},output:{...s.output,schema:typeof s.output.schema=="object"?s.output.schema:s.output.schema({entities:n})}}])),this.tables=Object.fromEntries(Object.entries(e.tables??{}).map(([i,s])=>[i,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:n})}]))}name;version;title;description;icon;readme;attributes;integrations;interfaces;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;__advanced;get metadata(){return{sdkVersion:Ce}}dereferenceEntities({intersectWithUnknownRecord:e}={intersectWithUnknownRecord:!0}){let n=this._buildZuiReferenceMap(e);return{...this,configuration:this.configuration?{...this.configuration,schema:this._dereferenceZuiSchema(this.configuration.schema,n)}:void 0,events:this._dereferenceDefinitionSchemas(this.events,n),states:this._dereferenceDefinitionSchemas(this.states,n),tables:this._dereferenceDefinitionSchemas(this.tables,n),actions:this._dereferenceActionDefinitionSchemas(this.actions,n)}}_buildZuiReferenceMap(e){return Object.fromEntries(Object.entries(this.interfaces??{}).flatMap(([n,r])=>Object.entries(r.definition.entities??{}).map(([i,s])=>[`interface:${n}/entities/${i}`,e?s.schema.and(y.record(y.string(),y.unknown())):s.schema])))}_dereferenceZuiSchema(e,n){return e.dereference(n)}_dereferenceDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,{...i,schema:this._dereferenceZuiSchema(i.schema,n)}]))}_dereferenceActionDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,{...i,input:{schema:this._dereferenceZuiSchema(i.input.schema,n)},output:{schema:this._dereferenceZuiSchema(i.output.schema,n)}}]))}};var vd=(t,e)=>new Proxy({},{get:(n,r)=>new Proxy({},{get:(i,s)=>a=>{let o=(e.integrations[r]??e.interfaces[r])?.integrationAlias,c=e.interfaces[r]?.actions?.[s]?.name??s;return t.callAction({type:`${o}:${c}`,input:a}).then(d=>d.output)}})});var Vi=t=>({async getById({id:e}){let n=await t.client.getMessage({id:e});return fe({...t,message:n.message})},list(e){return ue(({nextToken:n})=>t.client.listMessages({...re(e??{},{alias:t.plugin?.alias}),nextToken:n}).then(({meta:r,messages:i})=>({meta:r,items:i.map(s=>fe({...t,message:s}))})))}}),fe=t=>({...ye(t.message,{alias:t.plugin?.alias}),async delete(){await t.client.deleteMessage({id:t.message.id})},async update(e){let{message:n}=await t.client.updateMessage({...re(e,{alias:t.plugin?.alias}),id:t.message.id});return fe({...t,message:n})}});var qi=t=>({list(e){return ue(({nextToken:n})=>t.client.listUsers({...re(e??{},{alias:t.pluginAlias}),nextToken:n}).then(({meta:r,users:i})=>({meta:r,items:i.map(s=>ve({...t,conversationId:e?.conversationId,user:s}))})))},async getById({id:e}){let n=await t.client.getUser({id:e});return ve({...t,user:n.user,conversationId:void 0})}}),ve=t=>{let e={...ye(t.user,{alias:t.pluginAlias}),async update(n){let{user:r}=await t.client.updateUser({...re(n,{alias:t.pluginAlias}),id:t.user.id});return ve({...t,user:r})}};return t.conversationId?{...e,async removeFromConversation(){return await t.client.removeParticipant({id:t.conversationId,userId:t.user.id}),ve({...t,conversationId:void 0})}}:{...e,async addToConversation({conversationId:n}){let{participant:r}=await t.client.addParticipant({id:n,userId:t.user.id});return ve({...t,user:r,conversationId:n})}}};var Gi=t=>new Proxy({},{get:(e,n)=>new Proxy({},{get:(r,i)=>({list(s){let a=t.plugin?.interfaces[n]?.integrationAlias??t.plugin?.integrations[n]?.integrationAlias,o=t.plugin?.interfaces[n]?.channels?.[i]?.name??i;return ue(({nextToken:c})=>t.client.listConversations({...re(s??{},{alias:t.plugin?.alias}),channel:o==="*"?void 0:o,integrationName:a==="*"?void 0:a,nextToken:c}).then(({meta:d,conversations:g})=>({meta:d,items:g.map(m=>wt({...t,conversation:m}))})))},async getById({id:s}){let a=await t.client.getConversation({id:s});return wt({...t,conversation:a.conversation})}})})}),wt=t=>{let e=t.client;return{...ye(t.conversation,{alias:t.plugin?.alias}),async delete(){await e.deleteConversation({id:t.conversation.id})},async update(n){let{conversation:r}=await e.updateConversation({...re(n,{alias:t.plugin?.alias}),id:t.conversation.id});return wt({...t,conversation:r})},async getMessage({id:n}){let r=await e.getMessage({id:n});return fe({...t,message:r.message})},async getOrCreateMessage(n){let{message:r}=await e.getOrCreateMessage({...re(n,{alias:t.plugin?.alias}),conversationId:t.conversation.id});return fe({...t,message:r})},async createMessage(n){let{message:r}=await e.createMessage({...re(n,{alias:t.plugin?.alias}),conversationId:t.conversation.id});return fe({...t,message:r})},listMessages(n){return ue(({nextToken:r})=>e.listMessages({...re(n??{},{alias:t.plugin?.alias}),conversationId:t.conversation.id,nextToken:r}).then(({meta:i,messages:s})=>({meta:i,items:s.map(a=>fe({...t,message:a}))})))},listParticipants(){return ue(({nextToken:n})=>e.listParticipants({id:t.conversation.id,nextToken:n}).then(({meta:r,participants:i})=>({meta:r,items:i.map(s=>ve({...t,user:s,conversationId:t.conversation.id}))})))}}};var Ji=class t{constructor(e){this._props=e}async emit(e){let{conversationId:n,userId:r,messageId:i}=this._props,{event:s}=await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:n,userId:r,messageId:i});return s}async schedule(e,n){let{conversationId:r,userId:i,messageId:s}=this._props,{event:a}=await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:r,userId:i,messageId:s,schedule:n});return a}withConversationId(e){return new t({...this._props,conversationId:e})}withUserId(e){return new t({...this._props,userId:e})}withMessageId(e){return new t({...this._props,messageId:e})}async getById(e){return(await this._props.client.getEvent({id:e.id})).event}list(e){return ue(({nextToken:n})=>this._props.client.listEvents({...e,type:this._props.eventName,conversationId:this._props.conversationId,userId:this._props.userId,messageId:this._props.messageId,nextToken:n}).then(({meta:r,events:i})=>({meta:r,items:i})))}},_d=(t,e)=>new Proxy({},{get:(n,r)=>{let i=e.alias!==void 0?`${e.alias}${pe}${r}`:r;return new Ji({client:t,eventName:i})}});var Yi=class{constructor(e,n,r){this._client=e;this._stateType=n;this._stateName=r}async get(e){return await this._client.getState({type:this._stateType,name:this._stateName,id:e}).then(n=>n.state.payload)}async set(e,n,r){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:n,expiry:r?.expiryMs})}async getOrSet(e,n,r){return await this._client.getOrSetState({type:this._stateType,name:this._stateName,id:e,payload:n,expiry:r?.expiryMs}).then(i=>i.state.payload)}async delete(e){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:null})}async patch(e,n){await this._client.patchState({type:this._stateType,name:this._stateName,id:e,payload:n})}},Td=(t,e)=>new Proxy({},{get:(n,r)=>new Proxy({},{get:(i,s)=>{let a=e.alias!==void 0?`${e.alias}${pe}${s}`:s;return new Yi(t,r,a)}})});var Br=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:n,interfaces:r,integrations:i,alias:s}=this._runtime,a=vd(e,this._runtime),o=Td(e,this._runtime),c=Oe({client:e,pluginAlias:this._runtime.alias}),d=_d(e,this._runtime),g=qi({client:e,pluginAlias:this._runtime.alias}),m=Gi({client:e,plugin:this._runtime}),T=Vi({client:e,plugin:this._runtime});return{configuration:n,interfaces:r,integrations:i,actions:a,states:o,alias:s,workflows:c,events:d,users:g,conversations:m,messages:T}}get actionHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=this._actionHandlers[n];if(r)return Y.setName(i=>r({...i,...this._getTools(i.client)}),r.name)}})}get messageHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=n==="*"?[]:this._messageHandlers[n]??[],i=this._messageHandlers["*"]??[];return O.unique([...r,...i]).sort((a,o)=>a.order-o.order).map(({handler:a})=>Y.setName(o=>a({...o,user:ve({...o,conversationId:o.conversation.id,pluginAlias:this._runtime.alias}),message:fe({...o,plugin:this._runtime,message:o.message}),conversation:wt({...o,plugin:this._runtime,conversation:o.conversation}),...this._getTools(o.client)}),a.name))}})}get eventHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=n==="*"?[]:this._eventHandlers[n]??[],i=Object.entries(this._eventHandlers).filter(([o])=>this._eventResolvesTo(o,n)).flatMap(([,o])=>o??[]),s=this._eventHandlers["*"]??[];return O.unique([...r,...i,...s]).sort((o,c)=>o.order-c.order).map(({handler:o})=>Y.setName(c=>o({...c,...this._getTools(c.client)}),o.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=n==="*"?[]:this._stateExpiredHandlers[n]??[],i=this._stateExpiredHandlers["*"]??[];return O.unique([...r,...i]).sort((a,o)=>a.order-o.order).map(({handler:a})=>Y.setName(o=>a({...o,...this._getTools(o.client)}),a.name))}})}get hookHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._hookHandlers[n];if(r)return new Proxy({},{get:(i,s)=>{s=this._stripAliasPrefix(s);let a=s==="*"?[]:r[s]??[],o=Object.entries(r).filter(([g])=>this._eventResolvesTo(g,s)).flatMap(([,g])=>g??[]),c=r["*"]??[];return O.unique([...a,...o,...c]).sort((g,m)=>g.order-m.order).map(({handler:g})=>Y.setName(m=>g({...m,data:ye(m.data,{alias:this._runtime.alias}),...this._getTools(m.client)}),g.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._workflowHandlers[n];if(r)return new Proxy({},{get:(i,s)=>(r[s]?.sort((o,c)=>o.order-c.order)??[]).map(({handler:o})=>Y.setName(async c=>{let d=c.workflow;return await o({...c,workflow:de({...c,workflow:d,onWorkflowUpdate(g){d=g},pluginAlias:this._runtime.alias}),...this._getTools(c.client)}),d},o.name))})}})}on={message:(e,n)=>{this._messageHandlers[e]=O.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=O.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=O.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=O.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=O.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=O.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=O.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=O.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=O.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=O.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=O.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=O.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=O.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=O.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=O.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=O.safePush(this._workflowHandlers.timed_out[e],{handler:n,order:this._registerOrder++})}};_eventResolvesTo=(e,n)=>{let[i,s]=e.split(":");if(!i||!s)return!1;let a=this._runtime.interfaces[i];if(a&&n===`${a.integrationAlias}:${a?.events?.[s]?.name}`)return!0;let o=this._runtime.integrations[i];return!!(o&&n===`${o.integrationAlias}:${s}`)};_stripAliasPrefix=e=>{let{alias:n}=this._runtime;if(!n)return e;let r=`${n}#`;return e.startsWith(r)?e.slice(r.length):e}};var Xi={};nt(Xi,{allWithinMajorOf:()=>dv,allWithinMinorOf:()=>pv});var Qt=Rr(require("semver"));function dv(t){let e=Qt.major(t.version);return{...t,version:`>=${e}.0.0 <${e+1}.0.0`}}function pv(t){let e=Qt.major(t.version),n=Qt.minor(t.version);return{...t,version:`>=${e}.${n}.0 <${e}.${n+1}.0`}}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,coerce,conversation,createZodEnum,cuid2Regex,cuidRegex,custom,datasource,date,discriminatedUnion,effect,emailRegex,enum:null,errorUtil,event,function:null,getErrorMap,getParsedType,instanceof:null,intent,intersection,ipv4Regex,ipv6Regex,isAborted,isApiError,isAsync,isDirty,isEmojiRegex,isValid,json,knowledgebase,late,lazy,literal,makeIssue,map,mergeObjectSchemas,message,messages,nan,nativeEnum,never,null:null,nullable,number,object,objectUtil,oboolean,onumber,optional,ostring,parseBody,pipeline,preprocess,processCreateParams,promise,quotelessJson,readonly,record,ref,serve,set,setErrorMap,strictObject,string,symbol,table,tablerow,transformer,transforms,tuple,ulidRegex,undefined,union,unknown,user,util,uuidRegex,variable,version,void:null,z});
57
+ `,i+="})"}let s=n?i?n+i:r?r==="z.never()"?n+".strict()":n+`.catchall(${r})`:n:i||(r?`z.record(${r})`:"z.record(z.any())");return H.an.anyOf(t)&&(s+=`.and(${eu(p(c({},t),{anyOf:t.anyOf.map(a=>typeof a=="object"&&!a.type&&(a.properties||a.additionalProperties||a.patternProperties)?p(c({},a),{type:"object"}):a)}),e)})`),H.a.oneOf(t)&&(s+=`.and(${Gr(p(c({},t),{oneOf:t.oneOf.map(a=>typeof a=="object"&&!a.type&&(a.properties||a.additionalProperties||a.patternProperties)?p(c({},a),{type:"object"}):a)}),e)})`),H.an.allOf(t)&&(s+=`.and(${Ht(p(c({},t),{allOf:t.allOf.map(a=>typeof a=="object"&&!a.type&&(a.properties||a.additionalProperties||a.patternProperties)?p(c({},a),{type:"object"}):a)}),e)})`),s}o(tu,"parseObject");var Vm=o(t=>`z.ref('${t.$ref}')`,"parseRef"),Gm=o(t=>{var e;let n="z.string()";if((e=t[B])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";n="z.coerce.string()"}return n+=q(t,"format",({value:r})=>{switch(r){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(",")"]}}),n+=q(t,"pattern",({json:r})=>[`.regex(new RegExp(${r})`,", ",")"]),n+=q(t,"minLength",({json:r})=>[`.min(${r}`,", ",")"]),n+=q(t,"maxLength",({json:r})=>[`.max(${r}`,", ",")"]),n},"parseString"),K=o((t,e={seen:new Map,path:[]},n)=>{if(typeof t!="object")return t?"z.any()":"z.never()";if(e.parserOverride){let s=e.parserOverride(t,e);if(typeof s=="string")return s}let r=e.seen.get(t);if(r){if(r.r!==void 0)return r.r;if(e.depth===void 0||r.n>=e.depth)return"z.any()";r.n+=1}else r={r:void 0,n:0},e.seen.set(t,r);let i=Xm(t,e);return n||(i=Jm(t,i),e.withoutDefaults||(i=Ym(t,i))),r.r=i,i},"parseSchema"),Jm=o((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),Ym=o((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),Xm=o((t,e)=>H.a.nullable(t)?Fm(t,e):H.an.object(t)?tu(t,e):H.an.array(t)?Dm(t,e):H.an.anyOf(t)?eu(t,e):H.an.allOf(t)?Ht(t,e):H.a.discriminator(t)?$m(t,e):H.a.oneOf(t)?Gr(t,e):H.a.not(t)?Wm(t,e):H.an.enum(t)?Um(t):H.a.const(t)?Mm(t):H.a.multipleType(t)?Km(t,e):H.a.primitive(t,"string")?Gm(t):H.a.primitive(t,"number")||H.a.primitive(t,"integer")?qm(t):H.a.primitive(t,"boolean")?Hm(t):H.a.primitive(t,"null")?Lm(t):H.a.conditional(t)?zm(t,e):H.a.ref(t)?Vm(t):jm(t),"selectParser"),H={an:{object:t=>t.type==="object",array:t=>t.type==="array",anyOf:t=>t.anyOf!==void 0,allOf:t=>t.allOf!==void 0,enum:t=>t.enum!==void 0},a:{nullable:t=>t.nullable===!0,multipleType:t=>Array.isArray(t.type),not:t=>t.not!==void 0,const:t=>t.const!==void 0,primitive:(t,e)=>t.type===e,conditional:t=>!!("if"in t&&t.if&&"then"in t&&"else"in t&&t.then&&t.else),discriminator:t=>{var e;return t.oneOf!==void 0&&((e=t.discriminator)==null?void 0:e.propertyName)!==void 0},oneOf:t=>t.oneOf!==void 0,ref:t=>t.$ref!==void 0}},Qm=o(t=>K(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),eh=o(t=>{let e=Qm(t);e=e.replaceAll("errors: z.ZodError[]","errors");let n=Am(e);if(!n.sucess)throw new kn(n.error);return n.value},"jsonSchemaToZod"),Ot=o((t,e)=>{var n,r;if(e[B]&&t._def&&(t.naked()._def[B]=e[B]),((n=t._def)==null?void 0:n.typeName)==="ZodObject"&&e.type==="object"&&e.properties&&Object.entries(e.properties).forEach(([i,s])=>{let a=typeof t._def.shape=="function"?t._def.shape():t._def.shape;a[i]&&Ot(a[i],s)}),((r=t._def)==null?void 0:r.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&Ot(t._def.valueType,e.additionalProperties),e.type==="array"&&e.items){let i=e.items;if(typeof i=="object"&&!Array.isArray(i)){let s=t._def.type;s&&Ot(s,i)}else Array.isArray(i)&&i.forEach((s,a)=>{let l=t._def;l.typeName===P.ZodTuple&&Ot(l.items[a],s)})}},"applyZuiPropsRecursively"),th=o(t=>{let e=eh(t);return Ot(e,t),e},"fromJSONSchemaLegacy"),nh=o(t=>{var e,n;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(r=>typeof r!="boolean"&&nu(r))&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodOptional"},"isOptionalSchema"),rh=o(t=>{var e,n;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(r=>typeof r!="boolean"&&r.type==="null")&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodNullable"},"isNullableSchema"),nu=o(t=>{var e,n;return t.not===!0&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodUndefined"},"isUndefinedSchema"),ih=o(t=>{var e,n;return!t.not&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodUnknown"},"isUnknownSchema"),sh=o(t=>{var e,n;return t.anyOf!==void 0&&((n=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:n.typeName)==="ZodDiscriminatedUnion"},"isDiscriminatedUnionSchema"),ah=o((t,e)=>oh(t)?uh(t,e):lh(t)?ch(t,e):dh(t,e),"arrayJSONSchemaToZuiArray"),oh=o(t=>Array.isArray(t.items),"_isTuple"),lh=o(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),uh=o(({items:t,additionalItems:e},n)=>{let r=t.map(n),i=$t(r);return e!==void 0&&(i=i.rest(n(e))),i},"_handleTuple"),ch=o(({items:t,minItems:e,maxItems:n},r)=>{let i=xn(r(t));return e&&(i=i.min(e)),n&&(i=i.max(n)),i},"_handleSet"),dh=o(({minItems:t,maxItems:e,items:n},r)=>{let i=Me(r(n));return t&&t===e?i.length(t):(t&&(i=i.min(t)),e&&(i=i.max(e)),i)},"_handleArray"),ph=o(({type:t,minimum:e,exclusiveMinimum:n,maximum:r,exclusiveMaximum:i,multipleOf:s,format:a})=>{let l=Ve();return t==="integer"&&(l=l.int()),a==="finite"&&(l=l.finite()),n!==void 0?l=l.gt(n):e!==void 0&&(l=l.gte(e)),i!==void 0?l=l.lt(i):r!==void 0&&(l=l.lte(r)),s!==void 0&&(l=l.multipleOf(s)),l},"numberJSONSchemaToZuiNumber"),It={};ce(It,{escapeSpecialChars:()=>fh});var fh=o(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function Jr(t,e,n,r){r?.errorMessages&&n&&(t.errorMessage=p(c({},t.errorMessage),{[e]:n}))}o(Jr,"addErrorMessage");function I(t,e,n,r,i){t[e]=n,Jr(t,e,r,i)}o(I,"setResponseValueAndErrors");var M={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 Yr(t,e){let n=c({type:"string"},t.coerce?{[B]:{coerce:t.coerce||void 0}}:{});function r(i){return e.patternStrategy==="escape"?It.escapeSpecialChars(i):i}if(o(r,"processPattern"),t.checks)for(let i of t.checks)switch(i.kind){case"min":I(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,i.value):i.value,i.message,e);break;case"max":I(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,i.value):i.value,i.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Ze(n,"email",i.message,e);break;case"format:idn-email":Ze(n,"idn-email",i.message,e);break;case"pattern:zod":ve(n,M.email,i.message,e);break}break;case"url":Ze(n,"uri",i.message,e);break;case"uuid":Ze(n,"uuid",i.message,e);break;case"regex":ve(n,i.regex.source,i.message,e);break;case"cuid":ve(n,M.cuid,i.message,e);break;case"cuid2":ve(n,M.cuid2,i.message,e);break;case"startsWith":ve(n,"^"+r(i.value),i.message,e);break;case"endsWith":ve(n,r(i.value)+"$",i.message,e);break;case"datetime":Ze(n,"date-time",i.message,e);break;case"length":I(n,"minLength",typeof n.minLength=="number"?Math.max(n.minLength,i.value):i.value,i.message,e),I(n,"maxLength",typeof n.maxLength=="number"?Math.min(n.maxLength,i.value):i.value,i.message,e);break;case"includes":{ve(n,r(i.value),i.message,e);break}case"ip":{i.version!=="v6"&&Ze(n,"ipv4",i.message,e),i.version!=="v4"&&Ze(n,"ipv6",i.message,e);break}case"emoji":ve(n,M.emoji,i.message,e);break;case"ulid":{ve(n,M.ulid,i.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return n}o(Yr,"parseStringDef");var Ze=o((t,e,n,r)=>{var i;t.format||(i=t.anyOf)!=null&&i.some(s=>s.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push(c({format:t.format},t.errorMessage&&r.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},n&&r.errorMessages&&{errorMessage:{format:n}}))):I(t,"format",e,n,r)},"addFormat"),ve=o((t,e,n,r)=>{var i;t.pattern||(i=t.allOf)!=null&&i.some(s=>s.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push(c({pattern:t.pattern},t.errorMessage&&r.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},n&&r.errorMessages&&{errorMessage:{pattern:n}}))):I(t,"pattern",e,n,r)},"addPattern"),gh=o(({format:t,pattern:e,minLength:n,maxLength:r})=>{let i=we();if(n&&r&&n===r?i=i.length(n):(n&&(i=i.min(n)),r&&(i=i.max(r))),t==="cuid"||e===M.cuid)i=i.cuid();else if(t==="cuid2"||e===M.cuid2)i=i.cuid2();else if(t==="emoji"||e===M.emoji)i=i.emoji();else if(t==="ulid"||e===M.ulid)i=i.ulid();else if(t==="date-time"){let{precision:s,offset:a}=e?So(e):{};i=i.datetime({precision:s,offset:a})}else t==="email"||e===M.email?i=i.email():t==="ipv4"||e===M.ipv4?i=i.ip():t==="ipv6"||e===M.ipv6?i=i.ip("v6"):t==="uri"?i=i.url():t==="uuid"||e===M.uuid?i=i.uuid():e&&(i=i.regex(new RegExp(e)));return i},"stringJSONSchemaToZuiString"),gt=o((t,e)=>{let n=[];e.enum!==void 0&&n.push(...e.enum),e.const!==void 0&&n.push(e.const);let r,i=n.filter(a=>typeof a===t),[s]=i;if(s)if(i.length===1)r=Nt(s);else{let a=i.map(l=>Nt(l));r=at(a)}else if(t==="string"&&e.type==="string"&&(r=gh(e)),t==="number"&&(e.type==="number"||e.type==="integer")&&(r=ph(e)),t==="boolean"&&(r=Ge()),t==="null"&&(r=jt()),!r)throw new kn(`Unknown primitive type: "${t}"`);return e.description&&(r=r.describe(e.description)),r},"toZuiPrimitive"),Qe=$e();function ru(t){return $(t)}o(ru,"fromJSONSchema");function $(t){var e,n,r;if(t===void 0)return Qe;if(t===!0)return $e();if(t===!1)return Rt();if(t.default!==void 0)return $(p(c({},t),{default:void 0})).default(t.default);if(t.readOnly)return $(p(c({},t),{readOnly:void 0})).readonly();if(t.description!==void 0)return $(p(c({},t),{description:void 0})).describe(t.description);if(t.oneOf!==void 0)throw new Ee({oneOf:t.oneOf});if(t.patternProperties!==void 0)throw new Ee({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new Ee({propertyNames:t.propertyNames});if(t.if!==void 0)throw new Ee({if:t.if});if(t.then!==void 0)throw new Ee({then:t.then});if(t.else!==void 0)throw new Ee({else:t.else});if(t.$ref!==void 0)return Tn(t.$ref);if(t.not!==void 0){if(nu(t))return yn();if(t.not===!0)return Rt();throw new Ee({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return Qe;if(t.type.length===1)return $(p(c({},t),{type:t.type[0]}));let i=t,{type:s}=i,a=Yi(i,["type"]),l=t.type.map(u=>$(p(c({},a),{type:u})));return at(l)}if(t.type==="string")return t.enum&&t.enum.length>0?bn(t.enum):gt("string",t);if(t.type==="integer"){let i=gt("number",t);return i.typeName==="ZodNumber"?i.int():i}if(t.type==="number")return gt("number",t);if(t.type==="boolean")return gt("boolean",t);if(t.type==="null")return gt("null",t);if(t.type==="array")return ah(t,$);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let i=$(t.additionalProperties);return $(p(c({},t),{additionalProperties:void 0})).catchall(i)}if(t.properties!==void 0){let i={};for(let[s,a]of Object.entries(t.properties)){let l=$(a),u=(e=t.required)!=null?e:[];i[s]=u.includes(s)||l.isOptional()?l:l.optional()}return st(i)}if(t.additionalProperties!==void 0){let i=$(t.additionalProperties);return Dt(i)}return Dt(Qe)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return Qe;if(t.anyOf.length===1)return $(t.anyOf[0]);if(nh(t))return $(t.anyOf[0]).optional();if(rh(t))return $(t.anyOf[0]).nullable();if(sh(t)&&((r=(n=t["x-zui"])==null?void 0:n.def)!=null&&r.discriminator)){let{discriminator:s}=t["x-zui"].def,a=t.anyOf.map($);return wn(s,a)}let i=t.anyOf.map($);return at(i)}if(t.allOf!==void 0){if(t.allOf.length===0)return Qe;if(t.allOf.length===1)return $(t.allOf[0]);let[i,...s]=t.allOf,a=$(i),l=$({allOf:s});return Pn(a,l)}return t.type,ih(t)?Ce():Qe}o($,"_fromJSONSchema");var mh=/^\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))?$/,pr=o((t,e,n=!0)=>{if(typeof t!="object")throw new cr("Input must be an object");let r=o(a=>{let l=a;return e?.nullable&&(l=l.nullable()),e?.optional&&(l=l.optional()),e?.passtrough&&z.zuiObject(l)&&(l=l.passthrough()),l},"applyOptions"),i=Object.entries(t).reduce((a,[l,u])=>{if(u===null)a[l]=r(jt());else switch(typeof u){case"string":a[l]=mh.test(u)?r(we().datetime()):r(we());break;case"number":a[l]=r(Ve());break;case"boolean":a[l]=r(Ge());break;case"object":if(Array.isArray(u)){let[d]=u;if(d==null)a[l]=r(Me(Ce()));else if(typeof d=="object")a[l]=r(Me(pr(d,e,!1)));else if(typeof d=="string"||typeof d=="number"||typeof d=="boolean"){let f=hh(d);a[l]=r(Me(f))}}else a[l]=r(pr(u,e,!1));break;default:throw new cr(`Unsupported type for key ${l}`)}return a},{}),s=Object.keys(i).length>0;return e?.passtrough||!n&&!s?st(i).passthrough():st(i)},"fromObject"),hh=o(t=>typeof t=="string"?we():typeof t=="number"?Ve():typeof t=="boolean"?Ge():Ce(),"_getInnerType");function iu(){return{}}o(iu,"parseAnyDef");function su(t,e){var n,r;let i={type:"array"};return((r=(n=t.type)==null?void 0:n._def)==null?void 0:r.typeName)!==P.ZodAny&&(i.items=O(t.type._def,p(c({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&I(i,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&I(i,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(I(i,"minItems",t.exactLength.value,t.exactLength.message,e),I(i,"maxItems",t.exactLength.value,t.exactLength.message,e)),i}o(su,"parseArrayDef");function au(t,e){let n=c({type:"integer",format:"int64"},t.coerce?{[B]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"min":e.target==="jsonSchema7"?r.inclusive?I(n,"minimum",r.value,r.message,e):I(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),I(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?I(n,"maximum",r.value,r.message,e):I(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),I(n,"maximum",r.value,r.message,e));break;case"multipleOf":I(n,"multipleOf",r.value,r.message,e);break}return n}o(au,"parseBigintDef");function ou(t){return c({type:"boolean"},t.coerce?{[B]:{coerce:t.coerce||void 0}}:{})}o(ou,"parseBooleanDef");function lu(t,e){return O(t.type._def,e)}o(lu,"parseBrandedDef");var yh=o((t,e)=>O(t.innerType._def,e),"parseCatchDef");function uu(t,e){return e.dateStrategy==="integer"?vh(t,e):c({type:"string",format:"date-time"},t.coerce?{[B]:{coerce:t.coerce||void 0}}:{})}o(uu,"parseDateDef");var vh=o((t,e)=>{let n=c({type:"integer",format:"unix-time"},t.coerce?{[B]:{coerce:t.coerce||void 0}}:{});for(let r of t.checks)switch(r.kind){case"min":e.target==="jsonSchema7"&&I(n,"minimum",r.value,r.message,e);break;case"max":e.target==="jsonSchema7"&&I(n,"maximum",r.value,r.message,e);break}return n},"integerDateParser");function cu(t,e){return p(c({},O(t.innerType._def,e)),{default:t.defaultValue()})}o(cu,"parseDefaultDef");function du(t,e){return e.effectStrategy==="input"?O(t.schema._def,e):{}}o(du,"parseEffectsDef");function pu(t){return{type:"string",enum:t.values}}o(pu,"parseEnumDef");var _h=o(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function fu(t,e){let n=[O(t.left._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),O(t.right._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(s=>!!s),r=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,i=[];return n.forEach(s=>{if(_h(s))i.push(...s.allOf),s.unevaluatedProperties===void 0&&(r=void 0);else{let a=s;if("additionalProperties"in s&&s.additionalProperties===!1){let l=s,{additionalProperties:u}=l;a=Yi(l,["additionalProperties"])}else r=void 0;i.push(a)}}),i.length?c({allOf:i},r):void 0}o(fu,"parseIntersectionDef");function gu(t,e){let n=typeof t.value;return n!=="bigint"&&n!=="number"&&n!=="boolean"&&n!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:n==="bigint"?"integer":n,enum:[t.value]}:{type:n==="bigint"?"integer":n,const:t.value}}o(gu,"parseLiteralDef");function Xr(t,e){var n,r,i,s,a;if(e.target==="openApi3"&&((n=t.keyType)==null?void 0:n._def.typeName)===P.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((u,d)=>{var f;return p(c({},u),{[d]:(f=O(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"properties",d]})))!=null?f:{}})},{}),additionalProperties:!1};let l={type:"object",additionalProperties:(r=O(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:{}};if(e.target==="openApi3")return l;if(((i=t.keyType)==null?void 0:i._def.typeName)===P.ZodString&&((s=t.keyType._def.checks)!=null&&s.length)){let u=Object.entries(Yr(t.keyType._def,e)).reduce((d,[f,g])=>f==="type"?d:p(c({},d),{[f]:g}),{});return p(c({},l),{propertyNames:u})}else if(((a=t.keyType)==null?void 0:a._def.typeName)===P.ZodEnum)return p(c({},l),{propertyNames:{enum:t.keyType._def.values}});return l}o(Xr,"parseRecordDef");function mu(t,e){if(e.mapStrategy==="record")return Xr(t,e);let n=O(t.keyType._def,p(c({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},r=O(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}o(mu,"parseMapDef");function hu(t){let e=t.values,r=Object.keys(t.values).filter(s=>typeof e[e[s]]!="number").map(s=>e[s]),i=Array.from(new Set(r.map(s=>typeof s)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:r.filter(s=>typeof s=="string"||typeof s=="number")}}o(hu,"parseNativeEnumDef");function yu(){return{not:{}}}o(yu,"parseNeverDef");function vu(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}o(vu,"parseNullDef");var ln={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function _u(t,e){if(e.target==="openApi3")return zi(t,e);let n=t.options instanceof Map?Array.from(t.options.values()):t.options;if(n.every(r=>r._def.typeName in ln&&(!r._def.checks||!r._def.checks.length))){let r=n.reduce((i,s)=>{let a=ln[s._def.typeName];return a&&!i.includes(a)?[...i,a]:i},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){let r=n.reduce((i,s)=>{let a=typeof s._def.value;switch(a){case"string":case"number":case"boolean":return[...i,a];case"bigint":return[...i,"integer"];case"object":if(s._def.value===null)return[...i,"null"];case"symbol":case"undefined":case"function":default:return i}},[]);if(r.length===n.length){let i=r.filter((s,a,l)=>l.indexOf(s)===a);return{type:i.length>1?i:i[0],enum:n.reduce((s,a)=>s.includes(a._def.value)?s:[...s,a._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,i)=>[...r,...i._def.values.filter(s=>!r.includes(s))],[])};return zi(t,e)}o(_u,"parseUnionDef");var zi=o((t,e)=>{let n=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((i,s)=>O(i._def,p(c({},e),{currentPath:[...e.currentPath,e.unionStrategy,`${s}`]}))).filter(i=>!!i&&(!e.strictUnions||typeof i=="object"&&Object.keys(i).length>0)),r=e.discriminator&&t.typeName==="ZodDiscriminatedUnion"&&typeof t.discriminator=="string"?{discriminator:{propertyName:t.discriminator}}:{};if(n.length)return e.unionStrategy==="anyOf"?c({anyOf:n},r):c({oneOf:n},r)},"asUnionOf");function Tu(t,e){let n=t.innerType;if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(n._def.typeName)&&(!n._def.checks||!n._def.checks.length)){if(e.target==="openApi3"){let s={type:ln[n._def.typeName],nullable:!0};return fr(n._def,e,s)}let i={type:[ln[n._def.typeName],"null"]};return fr(n._def,e,i)}if(e.target==="openApi3"){let i=O(n._def,p(c({},e),{currentPath:[...e.currentPath]}));return i&&p(c({},i),{nullable:!0})}let r=O(n._def,p(c({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return r&&{anyOf:[r,{type:"null"}]}}o(Tu,"parseNullableDef");function bu(t,e){let n=c({type:"number"},t.coerce?{[B]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return n;for(let r of t.checks)switch(r.kind){case"int":n.type="integer",Jr(n,"type",r.message,e);break;case"min":e.target==="jsonSchema7"?r.inclusive?I(n,"minimum",r.value,r.message,e):I(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),I(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?I(n,"maximum",r.value,r.message,e):I(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),I(n,"maximum",r.value,r.message,e));break;case"multipleOf":I(n,"multipleOf",r.value,r.message,e);break}return n}o(bu,"parseNumberDef");var{zuiKey:Pv}=Pe,Th=o((t,e)=>{var n;return z.zuiType(t.unknownKeys)?(n=O(t.unknownKeys._def,p(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function wu(t,e){let n=p(c({type:"object"},Object.entries(t.shape()).reduce((r,[i,s])=>{if(s===void 0||s._def===void 0)return r;let a=O(s._def,p(c({},e),{currentPath:[...e.currentPath,"properties",i],propertyPath:[...e.currentPath,"properties",i]}));return a===void 0?r:{properties:p(c({},r.properties),{[i]:a}),required:s.isOptional()?r.required:[...r.required,i]}},{properties:{},required:[]})),{additionalProperties:Th(t,e)});return n.required.length||delete n.required,n}o(wu,"parseObjectDef");var bh=o((t,e)=>{var n;if(e.currentPath.toString()===((n=e.propertyPath)==null?void 0:n.toString()))return O(t.innerType._def,e);let r=O(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return r?{anyOf:[{not:{}},r]}:{}},"parseOptionalDef"),wh=o((t,e)=>{if(e.pipeStrategy==="input")return O(t.in._def,e);if(e.pipeStrategy==="output")return O(t.out._def,e);let n=O(t.in._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),r=O(t.out._def,p(c({},e),{currentPath:[...e.currentPath,"allOf",n?"1":"0"]}));return{allOf:[n,r].filter(i=>i!==void 0)}},"parsePipelineDef");function Pu(t,e){return O(t.type._def,e)}o(Pu,"parsePromiseDef");var Ph=o((t,e)=>O(t.innerType._def,e),"parseReadonlyDef");function xu(t){return{$ref:t.uri}}o(xu,"parseRefDef");function ku(t,e){let r={type:"array",uniqueItems:!0,items:O(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&I(r,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&I(r,"maxItems",t.maxSize.value,t.maxSize.message,e),r}o(ku,"parseSetDef");function Su(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((n,r)=>O(n._def,p(c({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:O(t.rest._def,p(c({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((n,r)=>O(n._def,p(c({},e),{currentPath:[...e.currentPath,"items",`${r}`]}))).reduce((n,r)=>r===void 0?n:[...n,r],[])}}o(Su,"parseTupleDef");function Ou(){return{not:{}}}o(Ou,"parseUndefinedDef");function Eu(){return{}}o(Eu,"parseUnknownDef");function O(t,e,n=!1){let r=e.seen.get(t);if(r&&!n){let a=xh(r,e);if(a!==void 0)return a}let i={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,i);let s=Sh(t,t.typeName,e);return s&&fr(t,e,s),i.jsonSchema=s,s}o(O,"parseDef");var xh=o((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:kh(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((n,r)=>e.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},"get$ref"),kh=o((t,e)=>{let n=0;for(;n<t.length&&n<e.length&&t[n]===e[n];n++);return[(t.length-n).toString(),...e.slice(n)].join("/")},"getRelativePath"),Sh=o((t,e,n)=>{switch(e){case P.ZodString:return Yr(t,n);case P.ZodNumber:return bu(t,n);case P.ZodObject:return wu(t,n);case P.ZodBigInt:return au(t,n);case P.ZodBoolean:return ou(t);case P.ZodDate:return uu(t,n);case P.ZodUndefined:return Ou();case P.ZodNull:return vu(n);case P.ZodArray:return su(t,n);case P.ZodUnion:case P.ZodDiscriminatedUnion:return _u(t,n);case P.ZodIntersection:return fu(t,n);case P.ZodTuple:return Su(t,n);case P.ZodRecord:return Xr(t,n);case P.ZodRef:return xu(t);case P.ZodLiteral:return gu(t,n);case P.ZodEnum:return pu(t);case P.ZodNativeEnum:return hu(t);case P.ZodNullable:return Tu(t,n);case P.ZodOptional:return bh(t,n);case P.ZodMap:return mu(t,n);case P.ZodSet:return ku(t,n);case P.ZodLazy:return O(t.getter()._def,n);case P.ZodPromise:return Pu(t,n);case P.ZodNaN:case P.ZodNever:return yu();case P.ZodEffects:return du(t,n);case P.ZodAny:return iu();case P.ZodUnknown:return Eu();case P.ZodDefault:return cu(t,n);case P.ZodBranded:return lu(t,n);case P.ZodReadonly:return Ph(t,n);case P.ZodCatch:return yh(t,n);case P.ZodPipeline:return wh(t,n);case P.ZodFunction:case P.ZodVoid:case P.ZodSymbol:return;default:return(r=>{})(e)}},"selectParser"),fr=o((t,e,n)=>(t.description&&(n.description=t.description,e.markdownDescription&&(n.markdownDescription=t.description)),Object.assign(n,{[B]:c(c({},t[B]),n[B])}),n),"addMeta"),Ki={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"},Oh=o(t=>typeof t=="string"?p(c({},Ki),{name:t}):c(c({},Ki),t),"getDefaultOptions"),Eh=o(t=>{let e=Oh(t),n=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return p(c({},e),{currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([r,i])=>[i._def,{def:i._def,path:[...e.basePath,e.definitionPath,r],jsonSchema:void 0}]))})},"getRefs"),Ih=o((t,e)=>{var n;let r=Eh(e),i=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((u,[d,f])=>{var g;return p(c({},u),{[d]:(g=O(f._def,p(c({},r),{currentPath:[...r.basePath,r.definitionPath,d]}),!0))!=null?g:{}})},{}):void 0,s=typeof e=="string"?e:e?.name,a=(n=O(t._def,s===void 0?r:p(c({},r),{currentPath:[...r.basePath,r.definitionPath,s]}),!1))!=null?n:{},l=s===void 0?i?p(c({},a),{[r.definitionPath]:i}):a:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:p(c({},i),{[s]:a})};return r.target==="jsonSchema7"?l.$schema="http://json-schema.org/draft-07/schema#":r.target==="jsonSchema2019-09"&&(l.$schema="https://json-schema.org/draft/2019-09/schema#"),l},"zodToJsonSchema"),Bh=o((t,e={target:"openApi3"})=>{let n=Ih(t,e);return e.$schemaUrl===!1?delete n.$schema:typeof e.$schemaUrl=="string"&&(n.$schema=e.$schemaUrl),n},"toJSONSchemaLegacy"),{zuiKey:Gn}=Pe,Ch=o((t,e)=>{let n={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[Gn]&&(n[Gn]=t._def[Gn]),t._def.minLength&&(n.minItems=t._def.minLength.value),t._def.maxLength&&(n.maxItems=t._def.maxLength.value),t._def.exactLength&&(n.minItems=t._def.exactLength.value,n.maxItems=t._def.exactLength.value),n},"zodArrayToJsonArray"),{zuiKey:Jn}=Pe,Ah=o(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[Jn]&&(e[Jn]=t._def[Jn]);for(let n of t._def.checks)switch(n.kind){case"min":{let r=n.inclusive?"minimum":"exclusiveMinimum",i=n.inclusive?"exclusiveMinimum":"minimum";e[r]=n.value,delete e[i];break}case"max":{let r=n.inclusive?"maximum":"exclusiveMaximum",i=n.inclusive?"exclusiveMaximum":"maximum";e[r]=n.value,delete e[i];break}case"int":e.type="integer";break;case"finite":{e.format="finite";break}case"multipleOf":e.multipleOf=n.value;break;default:}return e},"zodNumberToJsonNumber"),{zuiKey:Yn}=Pe,Zh=o((t,e)=>{let n={type:"array",description:t.description,uniqueItems:!0,items:e(t._def.valueType),"x-zui":t._def["x-zui"]};return t._def[Yn]&&(n[Yn]=t._def[Yn]),t._def.minSize&&(n.minItems=t._def.minSize.value),t._def.maxSize&&(n.maxItems=t._def.maxSize.value),n},"zodSetToJsonSet"),{zuiKey:mt}=Pe,Rh=o(t=>{let e={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[mt]&&(e[mt]=t._def[mt]);for(let n of t._def.checks)switch(n.kind){case"cuid":e.format="cuid",e.pattern=M.cuid;break;case"cuid2":e.format="cuid2",e.pattern=M.cuid2;break;case"ulid":e.format="ulid",e.pattern=M.ulid;break;case"uuid":e.format="uuid",e.pattern=M.uuid;break;case"emoji":e.format="emoji",e.pattern=M.emoji;break;case"email":e.format="email",e.pattern=M.email;break;case"ip":e.format=n.version==="v6"?"ipv6":"ipv4",e.pattern=n.version==="v6"?M.ipv6:M.ipv4;break;case"datetime":e.format="date-time",(n.precision!==null||n.offset)&&(e.pattern=ko(n).source,e[mt]=p(c({},e[mt]),{precision:n.precision,offset:n.offset}));break;case"url":e.format="uri";break;case"endsWith":e.pattern=`${It.escapeSpecialChars(n.value)}$`;break;case"startsWith":e.pattern=`^${It.escapeSpecialChars(n.value)}`;break;case"includes":let r=n.position&&n.position>=1?`^(?:.{${n.position}}).*`:"";e.pattern=`${r}${It.escapeSpecialChars(n.value)}`;break;case"regex":e.pattern=n.regex.source;break;case"length":e.minLength=e.maxLength=Math.max(0,n.value);break;case"min":e.minLength=Math.max(0,n.value);break;case"max":e.maxLength=Math.max(0,n.value);break;default:throw new Kl({zodType:"ZodString",checkKind:n.kind})}return e},"zodStringToJsonString"),{zuiKey:Xn}=Pe,Nh=o((t,e)=>{let n={type:"array",description:t.description,items:t._def.items.map(r=>e(r))};return t._def[Xn]&&(n[Xn]=t._def[Xn]),t._def.rest&&(n.additionalItems=e(t._def.rest)),n},"zodTupleToJsonTuple");function L(t){let e=t;switch(e.typeName){case"ZodString":return Rh(e);case"ZodNumber":return Ah(e);case"ZodNaN":throw new Y("ZodNaN");case"ZodBigInt":throw new Y("ZodBigInt",{suggestedAlternative:"serialize bigint to string"});case"ZodBoolean":return{type:"boolean",description:e.description,"x-zui":e._def["x-zui"]};case"ZodDate":throw new Y("ZodDate",{suggestedAlternative:"use z.string().datetime() instead"});case"ZodUndefined":return Qn(e);case"ZodNull":return er(e);case"ZodAny":return{description:e.description,"x-zui":e._def["x-zui"]};case"ZodUnknown":return{description:e.description,"x-zui":p(c({},e._def["x-zui"]),{def:{typeName:"ZodUnknown"}})};case"ZodNever":return{not:!0,description:e.description,"x-zui":e._def["x-zui"]};case"ZodVoid":throw new Y("ZodVoid");case"ZodArray":return Ch(e,L);case"ZodObject":let n=Object.entries(e.shape),r=n.filter(([u,d])=>!d.isOptional()),i=r.length?r.map(([u])=>u):void 0,s=n.map(([u,d])=>[u,d.mandatory()]).map(([u,d])=>[u,L(d)]);return{type:"object",description:e.description,properties:Object.fromEntries(s),required:i,additionalProperties:Dh(e._def),"x-zui":e._def["x-zui"]};case"ZodUnion":return{description:e.description,anyOf:e.options.map(u=>L(u)),"x-zui":e._def["x-zui"]};case"ZodDiscriminatedUnion":return{description:e.description,anyOf:e.options.map(u=>L(u)),"x-zui":p(c({},e._def["x-zui"]),{def:{typeName:"ZodDiscriminatedUnion",discriminator:e.discriminator}})};case"ZodIntersection":let a=L(e._def.left),l=L(e._def.right);return"additionalProperties"in a&&delete a.additionalProperties,"additionalProperties"in l&&delete l.additionalProperties,{description:e.description,allOf:[a,l],"x-zui":e._def["x-zui"]};case"ZodTuple":return Nh(e,L);case"ZodRecord":return{type:"object",description:e.description,additionalProperties:L(e._def.valueType),"x-zui":e._def["x-zui"]};case"ZodMap":throw new Y("ZodMap");case"ZodSet":return Zh(e,L);case"ZodFunction":throw new Y("ZodFunction");case"ZodLazy":throw new Y("ZodLazy");case"ZodLiteral":if(typeof e.value=="string")return{type:"string",description:e.description,const:e.value,"x-zui":e._def["x-zui"]};if(typeof e.value=="number")return{type:"number",description:e.description,const:e.value,"x-zui":e._def["x-zui"]};if(typeof e.value=="boolean")return{type:"boolean",description:e.description,const:e.value,"x-zui":e._def["x-zui"]};if(e.value===null)return er(e._def);if(e.value===void 0)return Qn(e._def);{e.value;let u=typeof e.value;throw new Sn(`Unsupported literal type: "${u}"`)}case"ZodEnum":return{type:"string",description:e.description,enum:e._def.values,"x-zui":e._def["x-zui"]};case"ZodEffects":throw new Y("ZodEffects");case"ZodNativeEnum":throw new Y("ZodNativeEnum");case"ZodOptional":return{description:e.description,anyOf:[L(e._def.innerType),Qn()],"x-zui":p(c({},e._def["x-zui"]),{def:{typeName:"ZodOptional"}})};case"ZodNullable":return{anyOf:[L(e._def.innerType),er()],"x-zui":p(c({},e._def["x-zui"]),{def:{typeName:"ZodNullable"}})};case"ZodDefault":return p(c({},L(e._def.innerType)),{default:e._def.defaultValue()});case"ZodCatch":throw new Y("ZodCatch");case"ZodPromise":throw new Y("ZodPromise");case"ZodBranded":throw new Y("ZodBranded");case"ZodPipeline":throw new Y("ZodPipeline");case"ZodSymbol":throw new Y("ZodPipeline");case"ZodReadonly":return p(c({},L(e._def.innerType)),{readOnly:!0});case"ZodRef":return{$ref:e._def.uri,description:e.description,"x-zui":e._def["x-zui"]};default:ue.assertNever(e)}}o(L,"toJSONSchema");var Qn=o(t=>({not:!0,description:t?.description,"x-zui":p(c({},t?.["x-zui"]),{def:{typeName:"ZodUndefined"}})}),"undefinedSchema"),er=o(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),Dh=o(t=>t.unknownKeys==="passthrough"?!0:t.unknownKeys==="strict"||!z.zuiType(t.unknownKeys)||t.unknownKeys.typeName==="ZodNever"?!1:L(t.unknownKeys),"additionalPropertiesSchema");function Iu(t){return typeof t=="symbol"?"symbol":typeof t=="bigint"?`${t.toString()}n`:v(t)}o(Iu,"primitiveToTypscriptLiteralType");function v(t){return typeof t>"u"?"undefined":typeof t=="symbol"?t.description?`Symbol(${v(t.description)})`:"Symbol()":typeof t=="bigint"?`BigInt(${t.toString()})`:typeof t=="string"?Au(t):JSON.stringify(t)}o(v,"primitiveToTypescriptValue");function rt(t){return typeof t>"u"?"undefined":JSON.stringify(t)}o(rt,"unknownToTypescriptValue");var Bu=o((t,e)=>{let n=Object.entries(t),r=e?" as const":"";return`{ ${n.map(([i,s])=>`${gr(i)}: ${rt(s)}`).join(", ")} }${r}`},"recordOfUnknownToTypescriptRecord"),gr=o(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:v(t),"toPropertyKey"),Hh=o(t=>t.charAt(0).toUpperCase()+t.slice(1),"capitalize"),Cu=o(t=>{let e=/[^a-zA-Z0-9_]/g;return t.split(e).map(Hh).filter(r=>!!r).join("")},"toTypeArgumentName"),Wi=o(t=>{for(var e;t.length&&!((e=t[0])!=null&&e.trim());)t.shift();for(;t.length&&!t[t.length-1].trim();)t.pop()},"trimEmptyLinesInPlace"),U=o(t=>{t=t?.replace(/(\n(\s*)?){3,}/g,`
58
+
59
+ `);let e=o(i=>i.startsWith("* ")?` ${i}`:` * ${i}`,"ensureLineStartsWithAsterisk"),n=o(i=>i.replace(/\*\//g,"*\\/"),"escapeCommentEnd"),r=(t??"").split(`
60
+ `).map(i=>i.trim());return Wi(r),r.length&&(r[0]=r[0].replace(/^\/\*\*?/,""),r[r.length-1]=r[r.length-1].replace(/\*\/$/,"")),Wi(r),r.length===0?"":r.length===1?`/** ${n(r[0])} */`:`/**
61
+ ${r.map(e).map(n).join(`
62
+ `)}
63
+ */`},"getMultilineComment");function Au(t){if(typeof t!="string")return"";let n=String.raw`${t}`.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/"/g,'\\"').replace(/'/g,"\\'");return n.includes("`")?`"${n}"`:n.includes("'")?`"${n}"`:`'${n}'`}o(Au,"escapeString");var Zu=["string","number","boolean","unknown","void","any","null","undefined","never","bigint","symbol","object"],Mh=5,jh=o(t=>Zu.includes(t),"isPrimitive"),$h=o(t=>Zu.map(e=>`${e}[]`).includes(t),"isArrayOfPrimitives"),tr=o(t=>t.replace(/ +/g," ").trim(),"stripSpaces"),Ru=class{constructor(e,n){this.key=e,this.value=n}};o(Ru,"KeyValue");var Lt=Ru,Nu=class{constructor(e){this.schema=e}};o(Nu,"FnParameters");var Li=Nu,Du=class{constructor(e){this.schema=e}};o(Du,"FnReturn");var Fi=Du,Hu=class{constructor(e){this.props=e}};o(Hu,"Declaration");var Bt=Hu;function Qr(t,e={}){let n=Kh(t,e),r=S(n,e);return e.formatter&&(r=e.formatter(r)),r}o(Qr,"toTypescriptType");var qi=o(t=>t.endsWith("?")?t:`${t}?`,"_optionalKey");function S(t,e){var n,r,i;let s=p(c({},e),{declaration:!1,parent:t});if(t===null)return"";if(t instanceof Bt)return Uh(t,s);if(t instanceof Lt){let l;if(z.zuiOptional(t.value)?l=t.value:z.zuiDefault(t.value)&&e.treatDefaultAsOptional&&(l=t.value._def.innerType.optional()),l){let w=l._def.innerType;return z.zuiType(w)&&!w.description&&l.description&&(w=w?.describe(l.description)),S(new Lt(qi(t.key),w),s)}let u=U(t.value._def.description||t.value.description),d=u?.trim().length>0?`
64
+ `:"",f=t.value.describe(""),h=z.zuiAny(t.value)?qi(t.key):t.key;return`${d}${u}${d}${h}: ${S(f,s)}${d}`}if(t instanceof Li){if(z.zuiTuple(t.schema)){let f="";for(let g=0;g<t.schema.items.length;g++){let h=(i=(r=(n=t.schema.items[g])==null?void 0:n.ui)==null?void 0:r.title)!=null?i:`arg${g}`,w=t.schema.items[g];f+=`${S(new Lt(gr(h),w),s)}${g<t.schema.items.length-1?", ":""} `}return f}let l=z.zuiLiteral(t.schema.naked()),u=S(t.schema,s).trim();return u.startsWith("{")&&u.endsWith("}")||u.startsWith("[")&&u.endsWith("]")||u.startsWith("(")&&u.endsWith(")")||u.startsWith("Array<")&&u.endsWith(">")||u.startsWith("Record<")&&u.endsWith(">")||$h(u)||l?`args: ${u}`:u}if(t instanceof Fi)return z.zuiOptional(t.schema)?`${S(t.schema.unwrap(),s)} | undefined`:S(t.schema,s);let a=t;switch(a.typeName){case"ZodString":return`${U(a.description)} string`.trim();case"ZodNumber":case"ZodNaN":case"ZodBigInt":return`${U(a.description)} number`.trim();case"ZodBoolean":return`${U(a.description)} boolean`.trim();case"ZodDate":return`${U(a.description)} Date`.trim();case"ZodUndefined":return`${U(a.description)} undefined`.trim();case"ZodNull":return`${U(a.description)} null`.trim();case"ZodAny":return`${U(a.description)} any`.trim();case"ZodUnknown":return`${U(a.description)} unknown`.trim();case"ZodNever":return`${U(a.description)} never`.trim();case"ZodVoid":return`${U(a.description)} void`.trim();case"ZodArray":let l=S(a._def.type,s);return jh(l)?`${l}[]`:`Array<${l}>`;case"ZodObject":return`{ ${Object.entries(a._def.shape()).map(([D,Oe])=>z.zuiType(Oe)?S(new Lt(gr(D),Oe),s):`${D}: unknown`).join("; ")} }`;case"ZodUnion":let d=a._def.options.map(D=>S(D,s));return`${U(a.description)}
65
+ ${d.join(" | ")}`;case"ZodDiscriminatedUnion":let f=a._def.options.map(D=>S(D,s));return`${U(a.description)}
66
+ ${f.join(" | ")}`;case"ZodIntersection":return`${S(a._def.left,s)} & ${S(a._def.right,s)}`;case"ZodTuple":return a._def.items.length===0?"[]":`[${a._def.items.map(D=>S(D,s)).join(", ")}]`;case"ZodRecord":let h=S(a._def.keyType,s),w=S(a._def.valueType,s);return`${U(a.description)} { [key: ${h}]: ${w} }`;case"ZodMap":return`Map<${S(a._def.keyType,s)}, ${S(a._def.valueType,s)}>`;case"ZodSet":return`Set<${S(a._def.valueType,s)}>`;case"ZodFunction":let T=S(new Li(a._def.args),s),N=S(new Fi(a._def.returns),s),F=e?.parent instanceof Bt&&e?.parent.props.type==="type";return e?.declaration&&!F?`${U(a.description)}
67
+ (${T}): ${N}`:`${U(a.description)}
68
+ (${T}) => ${N}`;case"ZodLazy":return S(a._def.getter(),s);case"ZodLiteral":let J=Iu(a._def.value);return`${U(a.description)}
69
+ ${J}`.trim();case"ZodEnum":return a._def.values.map(v).join(" | ");case"ZodEffects":return S(a._def.schema,s);case"ZodNativeEnum":throw new Jl("ZodNativeEnum");case"ZodOptional":return`${S(a._def.innerType,s)} | undefined`;case"ZodNullable":return`${S(a._def.innerType,s)} | null`;case"ZodDefault":let oe=e.treatDefaultAsOptional?a._def.innerType.optional():a._def.innerType;return S(oe,s);case"ZodCatch":return S(a._def.innerType,s);case"ZodPromise":return`Promise<${S(a._def.type,s)}>`;case"ZodBranded":return S(a._def.type,s);case"ZodPipeline":return S(a._def.in,s);case"ZodSymbol":return`${U(a.description)} symbol`.trim();case"ZodReadonly":return`Readonly<${S(a._def.innerType,s)}>`;case"ZodRef":return Cu(a._def.uri);default:ue.assertNever(a)}}o(S,"sUnwrapZod");var Uh=o((t,e)=>{if(t.props.type==="none")return S(t.props.schema,e);let{schema:n,identifier:r}=t.props,i=U(n.description),s=n.describe(""),a=S(s,p(c({},e),{declaration:!0})),u=a.split(`
70
+ `).length>=Mh&&e.includeClosingTags?`// end of ${r}`:"";if(t.props.type!=="type"&&n.typeName==="ZodFunction")return tr(`${i}
71
+ declare function ${r}${a};${u}`);if(t.props.type==="variable")return tr(`${i}declare const ${r}: ${a};${u}`);let d=t.props.args.length>0?`<${t.props.args.map(Cu).join(", ")}>`:"";return tr(`${i}type ${t.props.identifier}${d} = ${a};${u}`)},"unwrapDeclaration"),zh=o(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),Kh=o((t,e)=>{let n=zh(e),r=t.getReferences();if(n==="none"){if(r.length>0)throw new dr;return new Bt({type:"none",schema:t})}let i="title"in t.ui?t.ui.title:null;if(!i)throw new Xl;if(n==="variable"){if(r.length>0)throw new dr;return new Bt({type:"variable",identifier:i,schema:t})}return new Bt({type:"type",identifier:i,schema:t,args:r})},"getDeclarationProps"),Wh=o(t=>{let e=[];if(t.exactLength){let{value:n,message:r}=t.exactLength;e.push(`.length(${v(n)}, ${v(r)})`)}if(t.minLength){let{value:n,message:r}=t.minLength;e.push(`.min(${v(n)}, ${v(r)})`)}if(t.maxLength){let{value:n,message:r}=t.maxLength;e.push(`.max(${v(n)}, ${v(r)})`)}return e.join("")},"generateArrayChecks"),Lh=o(t=>{let e=t.checks;return e.length===0?"":e.map(Fh).join("")},"generateBigIntChecks"),Fh=o(t=>{switch(t.kind){case"min":return`.min(${v(t.value)}, ${v(t.message)})`;case"max":return`.max(${v(t.value)}, ${v(t.message)})`;case"multipleOf":return`.multipleOf(${v(t.value)}, ${v(t.message)})`;default:return""}},"_generateBigIntCheck"),qh=o(t=>{let e=t.checks;return e.length===0?"":e.map(Vh).join("")},"generateDateChecks"),Vh=o(t=>{switch(t.kind){case"min":return`.min(${Vi(t.value)}, ${v(t.message)})`;case"max":return`.max(${Vi(t.value)}, ${v(t.message)})`;default:return""}},"_generateDateCheck"),Vi=o(t=>`new Date(${t})`,"dateTs"),Gh=o(t=>{let e=t.checks;return e.length===0?"":e.map(Jh).join("")},"generateNumberChecks"),Jh=o(t=>{switch(t.kind){case"min":return`.min(${v(t.value)}, ${v(t.message)})`;case"max":return`.max(${v(t.value)}, ${v(t.message)})`;case"int":return`.int(${v(t.message)})`;case"multipleOf":return`.multipleOf(${v(t.value)}, ${v(t.message)})`;case"finite":return`.finite(${v(t.message)})`;default:return""}},"_generateNumberCheck"),Yh=o(t=>{let e=[];if(t.minSize){let{value:n,message:r}=t.minSize;e.push(`.min(${v(n)}, ${v(r)})`)}if(t.maxSize){let{value:n,message:r}=t.maxSize;e.push(`.max(${v(n)}, ${v(r)})`)}return e.join("")},"generateSetChecks"),Xh=o(t=>{let e=t.checks;return e.length===0?"":e.map(Qh).join("")},"generateStringChecks"),Qh=o(t=>{switch(t.kind){case"min":return`.min(${v(t.value)}, ${v(t.message)})`;case"max":return`.max(${v(t.value)}, ${v(t.message)})`;case"length":return`.length(${v(t.value)}, ${v(t.message)})`;case"email":return`.email(${v(t.message)})`;case"url":return`.url(${v(t.message)})`;case"emoji":return`.emoji(${v(t.message)})`;case"uuid":return`.uuid(${v(t.message)})`;case"cuid":return`.cuid(${v(t.message)})`;case"cuid2":return`.cuid2(${v(t.message)})`;case"ulid":return`.ulid(${v(t.message)})`;case"includes":let e=rt({message:t.message,position:t.position});return`.includes(${v(t.value)}, ${e})`;case"startsWith":return`.startsWith(${v(t.value)}, ${v(t.message)})`;case"endsWith":return`.endsWith(${v(t.value)}, ${v(t.message)})`;case"regex":return`.regex(${String(t.regex)}, ${v(t.message)})`;case"trim":return".trim()";case"toLowerCase":return".toLowerCase()";case"toUpperCase":return".toUpperCase()";case"datetime":let r=t.precision===null?void 0:t.precision;return`.datetime(${rt({message:t.message,precision:r,offset:t.offset})})`;case"ip":return`.ip(${rt({message:t.message,version:t.version})})`;default:return""}},"_generateStringCheck"),{zuiKey:ee}=Pe;function ei(t){return R(t)}o(ei,"toTypescriptSchema");function R(t){let e=t;switch(e.typeName){case"ZodString":return`z.string()${Xh(e._def)}${E(e._def)}`.trim();case"ZodNumber":return`z.number()${Gh(e._def)}${E(e._def)}`.trim();case"ZodNaN":return`z.nan()${E(e._def)}`.trim();case"ZodBigInt":return`z.bigint()${Lh(e._def)}${E(e._def)}`.trim();case"ZodBoolean":return`z.boolean()${E(e._def)}`.trim();case"ZodDate":return`z.date()${qh(e._def)}${E(e._def)}`.trim();case"ZodUndefined":return`z.undefined()${E(e._def)}`.trim();case"ZodNull":return`z.null()${E(e._def)}`.trim();case"ZodAny":return`z.any()${E(e._def)}`.trim();case"ZodUnknown":return`z.unknown()${E(e._def)}`.trim();case"ZodNever":return`z.never()${E(e._def)}`.trim();case"ZodVoid":return`z.void()${E(e._def)}`.trim();case"ZodArray":return`z.array(${R(e._def.type)})${Wh(e._def)}${E(e._def,e._def.type)}`;case"ZodObject":let n=xg(e.shape,R),r=e.additionalProperties(),i=r?`.catchall(${R(r)})`:"";return["z.object({",...Object.entries(n).map(([hc,yc])=>` ${hc}: ${yc},`),`})${i}${E(e._def)}`].join(`
72
+ `).trim();case"ZodUnion":return`z.union([${e._def.options.map(R).join(", ")}])${E(e._def)}`.trim();case"ZodDiscriminatedUnion":let a=e._def.options.map(R);return`z.discriminatedUnion(${v(e._def.discriminator)}, [${a.join(", ")}])${E(e._def)}`.trim();case"ZodIntersection":let u=R(e._def.left),d=R(e._def.right);return`z.intersection(${u}, ${d})${E(e._def)}`.trim();case"ZodTuple":return`z.tuple([${e._def.items.map(R).join(", ")}])${E(e._def)}`.trim();case"ZodRecord":let g=R(e._def.keyType),h=R(e._def.valueType);return`z.record(${g}, ${h})${E(e._def)}`.trim();case"ZodMap":let w=R(e._def.keyType),T=R(e._def.valueType);return`z.map(${w}, ${T})${E(e._def)}`.trim();case"ZodSet":return`z.set(${R(e._def.valueType)})${Yh(e._def)}${E(e._def)}`.trim();case"ZodFunction":let N=e._def.args.items.map(R),F=N.length?`.args(${N.join(", ")})`:"",J=R(e._def.returns);return`z.function()${F}.returns(${J})${E(e._def)}`.trim();case"ZodLazy":return`z.lazy(() => ${R(e._def.getter())})${E(e._def)}`.trim();case"ZodLiteral":return`z.literal(${v(e._def.value)})${E(e._def)}`.trim();case"ZodEnum":return`z.enum([${e._def.values.map(v).join(", ")}])${E(e._def)}`.trim();case"ZodEffects":throw new De("ZodEffects");case"ZodNativeEnum":throw new De("ZodNativeEnum");case"ZodOptional":return`z.optional(${R(e._def.innerType)})${E(e._def,e._def.innerType)}`.trim();case"ZodNullable":return`z.nullable(${R(e._def.innerType)})${E(e._def,e._def.innerType)}`.trim();case"ZodDefault":let D=rt(e._def.defaultValue());return`z.default(${R(e._def.innerType)}, ${D})${E(e._def,e._def.innerType)}`.trim();case"ZodCatch":throw new De("ZodCatch");case"ZodPromise":return`z.promise(${R(e._def.type)})${E(e._def,e._def.type)}`.trim();case"ZodBranded":throw new De("ZodBranded");case"ZodPipeline":throw new De("ZodPipeline");case"ZodSymbol":throw new De("ZodSymbol");case"ZodReadonly":return`z.readonly(${R(e._def.innerType)})${E(e._def,e._def.innerType)}`.trim();case"ZodRef":return`z.ref(${v(e._def.uri)})${E(e._def)}`.trim();default:ue.assertNever(e)}}o(R,"sUnwrapZod");var E=o((t,e)=>{let n=e?._def;return`${ty(t,n)}${ey(t,n)}`},"_addMetadata"),ey=o((t,e)=>!t.description||e&&e.description===t.description?"":`.describe(${v(t.description)})`,"_maybeDescribe"),ty=o((t,e)=>`${ny(t,e)}${ry(t,e)}${iy(t,e)}${sy(t,e)}${ay(t,e)}${oy(t,e)}${ly(t,e)}`,"_addZuiExtensions"),ny=o((t,e)=>{var n,r;let i=(n=t[ee])==null?void 0:n.title;return!i||e&&((r=e[ee])==null?void 0:r.title)===i?"":`.title(${v(i)})`},"_maybeTitle"),ry=o((t,e)=>{var n,r;let i=(n=t[ee])==null?void 0:n.displayAs;return!i||e&&Ie((r=e[ee])==null?void 0:r.displayAs,i)?"":`.displayAs(${Bu({id:i[0],params:i[1]})})`},"_maybeDisplayAs"),iy=o((t,e)=>{var n,r;let i=(n=t[ee])==null?void 0:n.disabled;return!i||e&&((r=e[ee])==null?void 0:r.disabled)===i?"":`.disabled(${i})`},"_maybeDisabled"),sy=o((t,e)=>{var n,r;let i=(n=t[ee])==null?void 0:n.hidden;return!i||e&&((r=e[ee])==null?void 0:r.hidden)===i?"":`.hidden(${i})`},"_maybeHidden"),ay=o((t,e)=>{var n,r;let i=(n=t[ee])==null?void 0:n.placeholder;return!i||e&&((r=e[ee])==null?void 0:r.placeholder)===i?"":`.placeholder(${v(i)})`},"_maybePlaceholder"),oy=o((t,e)=>{var n,r;let i=(n=t[ee])==null?void 0:n.secret;return!i||e&&((r=e[ee])==null?void 0:r.secret)===i?"":".secret()"},"_maybeSecret"),ly=o((t,e)=>{var n,r;let i=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],s=Object.entries((n=t[ee])!=null?n:{}).filter(([a])=>!i.includes(a));if(s.length===0)return"";if(e){let a=Object.entries((r=e[ee])!=null?r:{}).filter(([l])=>!i.includes(l));if(Ie(Object.fromEntries(s),Object.fromEntries(a)))return""}return`.metadata(${Bu(Object.fromEntries(s))})`},"_maybeSetMetadata"),uy={};x.prototype.toJSONSchema=function(){return L(this)};x.prototype.toTypescriptType=function(t){return Qr(this,t)};x.prototype.toTypescriptSchema=function(){return ei(this)};var W=y.string().min(1),ju=y.object({text:W}),$u=y.object({markdown:W}),Uu=y.object({imageUrl:W,title:W.optional()}),zu=y.object({audioUrl:W,title:W.optional()}),Ku=y.object({videoUrl:W,title:W.optional()}),Wu=y.object({fileUrl:W,title:W.optional()}),Lu=y.object({latitude:y.number(),longitude:y.number(),address:y.string().optional(),title:y.string().optional()}),Fu=y.object({title:W,subtitle:W.optional(),imageUrl:W.optional(),actions:y.array(y.object({action:y.enum(["postback","url","say"]),label:W,value:W}))}),Mu=y.object({text:W,options:y.array(y.object({label:W,value:W}))}),cy=y.object({items:y.array(Fu)}),qu=y.union([y.object({type:y.literal("text"),payload:ju}),y.object({type:y.literal("image"),payload:Uu}),y.object({type:y.literal("audio"),payload:zu}),y.object({type:y.literal("video"),payload:Ku}),y.object({type:y.literal("file"),payload:Wu}),y.object({type:y.literal("location"),payload:Lu})]),dy=y.object({items:y.array(qu)}),py={schema:$u},fy={schema:y.object({items:y.array(y.union([...qu.options,y.object({type:y.literal("markdown"),payload:$u})]))})},gy={text:{schema:ju},image:{schema:Uu},audio:{schema:zu},video:{schema:Ku},file:{schema:Wu},location:{schema:Lu},carousel:{schema:cy},card:{schema:Fu},dropdown:{schema:Mu},choice:{schema:Mu},bloc:{schema:dy}};var my={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};var Vu=require("browser-or-node");var ni=console;function ne(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function Ut(t,e=8072,n=_y){if(!Vu.isNode)throw new Error("This function can only be called in Node.js");let i=require("http").createServer(async(s,a)=>{try{let l=await hy(s);if(l.path==="/health"){a.writeHead(200).end("ok");return}let u=await t(l);a.writeHead(u?.status??200,u?.headers??{}).end(u?.body??"{}")}catch(l){let u=l instanceof Error?l.message:String(l);ni.error("Error while handling request",{error:u??"Internal error occured"}),a.writeHead(500).end(JSON.stringify({error:u??"Internal error occured"}))}});return i.listen(e,()=>n(e)),i}async function hy(t){let e=await vy(t),n={};for(let i=0;i<t.rawHeaders.length;i+=2){let s=t.rawHeaders[i].toLowerCase(),a=t.rawHeaders[i+1];n[s]=a}let r=new URL(t.url??"",t.headers.host?`http://${t.headers.host}`:"http://botpress.cloud");return{body:e,path:r.pathname,query:yy(r.search,"?"),headers:n,method:t.method?.toUpperCase()??"GET"}}function yy(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function vy(t){return new Promise((e,n)=>{if(t.method!=="POST"&&t.method!=="PUT"&&t.method!=="PATCH")return e(void 0);let r="";t.on("data",i=>r+=i.toString()),t.on("error",i=>n(i)),t.on("end",()=>e(r))})}function _y(t){ni.info(`Listening on port ${t}`)}var zn=require("@botpress/client");var Z={};Xe(Z,{mapKeys:()=>wy,mapValues:()=>by,mergeRecords:()=>xy,pairs:()=>En,stripUndefinedProps:()=>Py,values:()=>Ty});var En=t=>Object.entries(t),Ty=t=>Object.values(t),by=(t,e)=>Object.fromEntries(En(t).map(([n,r])=>[n,e(r,n)])),wy=(t,e)=>Object.fromEntries(En(t).map(([n,r])=>[e(n),r])),Py=t=>Object.fromEntries(En(t).filter(([,e])=>e!==void 0)),xy=(t,e,n)=>{let r=[...Object.keys(t),...Object.keys(e)],i=[...new Set(r)],s={};for(let a of i){let l=t[a],u=e[a];l&&u?s[a]=n(l,u):l?s[a]=l:u&&(s[a]=u)}return s};var b={};Xe(b,{safePush:()=>ky,unique:()=>Sy});var ky=(t,...e)=>t?[...t,...e]:[...e],Sy=t=>Array.from(new Set(t));var V={};Xe(V,{setName:()=>Oy});var Oy=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var Gu=t=>{let{name:e,version:n}=t,r={actions:{},events:{},channels:{}},i={name:e,version:n,entities:Z.mapValues(t.entities,a=>({name:a.name})),actions:{},events:{},channels:{}},s=Z.mapValues(t.entities,a=>a.schema);for(let[a,l]of Object.entries(t.definition.actions??{})){let u=l.input.schema.dereference(s),d=l.output.schema.dereference(s),f=t.actions?.[a]?.name??a;r.actions[f]={...l,...t.actions?.[a]??{},input:{schema:u},output:{schema:d}},i.actions[a]={name:f}}for(let[a,l]of Object.entries(t.definition.events??{})){let u=l.schema.dereference(s),d=t.events?.[a]?.name??a;r.events[d]={...l,...t.events?.[a]??{},schema:u},i.events[a]={name:d}}for(let[a,l]of Object.entries(t.definition.channels??{})){let u={};for(let[f,g]of Object.entries(l.messages)){let h=g.schema.dereference(s);u[f]={...g,schema:h}}let d=t.channels?.[a]?.name??a;r.channels[d]={...l,...t.channels?.[a]??{},message:{...l.message??{},tags:{...l.message?.tags??{},...t.channels?.[a]?.message?.tags??{}}},conversation:{...l.conversation??{},tags:{...l.conversation?.tags??{},...t.channels?.[a]?.conversation?.tags??{}}},messages:u},i.channels[a]={name:d}}return{resolved:r,statement:i}};var Ju="5.5.0";var Ae=Ju;var In=Symbol("schemaName"),Yu=t=>t?Z.mapValues(t,(n,r)=>({...n,[In]:r})):{},Xu=t=>In in t&&t[In]!==void 0,Qu=t=>t[In];var Bn=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;get metadata(){return{sdkVersion:Ae}}extend(e,n){let{entities:r,actions:i,events:s,channels:a}=this._callBuilder(e,n),l=this;l.interfaces??={};let u=Object.values(r).map(h=>h.name),d=u.length===0?e.name:`${e.name}<${u.join(",")}>`,{resolved:f,statement:g}=Gu({...e,entities:r,actions:Z.stripUndefinedProps(i),events:Z.stripUndefinedProps(s),channels:Z.stripUndefinedProps(a)});return l.actions=Z.mergeRecords(l.actions??{},f.actions,this._mergeActions),l.channels=Z.mergeRecords(l.channels??{},f.channels,this._mergeChannels),l.events=Z.mergeRecords(l.events??{},f.events,this._mergeEvents),l.interfaces[d]={id:e.id,...g},this}_callBuilder(e,n){let i={entities:Yu(this.entities)},s=n(i),a=Z.pairs(s.entities).find(([u,d])=>!Xu(d));if(a)throw new Error(`Cannot extend interface "${e.name}" with entity "${a[0]}"; the provided schema is not part of the integration's entities.`);return{entities:Z.mapValues(s.entities,u=>({name:Qu(u),schema:u.schema})),actions:s.actions??{},events:s.events??{},channels:s.channels??{}}}_mergeActions=(e,n)=>({...e,...n,input:{schema:this._mergeObjectSchemas(e.input.schema,n.input.schema)},output:{schema:this._mergeObjectSchemas(e.output.schema,n.output.schema)}});_mergeEvents=(e,n)=>({...e,...n,schema:this._mergeObjectSchemas(e.schema,n.schema)});_mergeChannels=(e,n)=>{let r=Z.mergeRecords(e.messages,n.messages,this._mergeMessage),i;(e.conversation||n.conversation)&&(i={tags:{...e.conversation?.tags,...n.conversation?.tags}});let s;return(e.message||n.message)&&(s={tags:{...e.message?.tags,...n.message?.tags}}),{...e,...n,messages:r,conversation:i,message:s}};_mergeMessage=(e,n)=>({schema:this._mergeObjectSchemas(e.schema,n.schema)});_mergeObjectSchemas=(e,n)=>{let r=e._def,i=n._def;if(r.typeName==="ZodObject"&&i.typeName==="ZodObject"){let s=r.shape(),a=i.shape();return y.object({...s,...a})}if(r.typeName==="ZodRecord"&&i.typeName==="ZodRecord")return y.record(y.intersection(r.valueType,i.valueType));throw new Error("Cannot merge object schemas with record schemas")}};var ke=require("@botpress/client");var ec=Kn(require("@botpress/client")),Cn={retries:3,retryCondition:t=>ec.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(Iy(e.response?.headers??{})??t)*1e3},Iy=t=>{let e=["RateLimit-Reset","X-RateLimit-Reset","Retry-After","ratelimit-reset","x-ratelimit-reset","retry-after"];for(let n of e){let r=t[n];if(r!==void 0)return By(String(r))}},By=t=>{let e=Cy(t)?Ay(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},Cy=t=>t.includes(" "),Ay=t=>{let e=Zy(t);if(!e)return;let n=new Date;return Math.max(0,Math.floor((e.getTime()-n.getTime())/1e3))},Zy=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};var lt=class{constructor(e){this._client=e}get _inner(){return this._client}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).then(n=>n));updateMessage=(e=>this._client.updateMessage(e).then(n=>n));listMessages=(e=>this._client.listMessages(e));deleteMessage=(e=>this._client.deleteMessage(e));initializeIncomingMessage=(e=>this._client.initializeIncomingMessage(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 An=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};var de="#",Zn="x-bot-id",tc="x-bot-user-id",nc="x-integration-id",rc="x-integration-alias",ic="x-webhook-id",sc="x-bp-configuration-type",Rn="x-bp-configuration",Nn="x-bp-operation",ac="x-bp-type";var re=t=>{throw t instanceof Error?t:new Error(t)};var a_=y.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),oc=t=>({botId:t[Zn]||re("Missing bot header"),botUserId:t[tc]||re("Missing bot user header"),integrationId:t[nc]||re("Missing integration header"),integrationAlias:t[rc]||re("Missing integration alias header"),webhookId:t[ic]||re("Missing webhook header"),operation:t[Nn]||re("Missing operation header"),configurationType:t[sc]??null,configuration:JSON.parse(Buffer.from(t[Rn]||re("Missing configuration header"),"base64").toString("utf-8"))});var lc=Kn(require("util")),ut=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)}issue(e){console.info(JSON.stringify(e))}_log(e,n){this._getConsoleMethod(e)(this._serializeMessage(n))}_serializeMessage(e){let n=lc.default.format(...e);return process.env.BP_LOG_FORMAT==="json"?this.getJsonMessage(n):n}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 ct=class t extends ut{constructor(e){super({visibleToBotOwners:!1,hiddenToIntegrationOwners:!1,...e})}with(e){return new t({...this.defaultOptions,...e})}withUserId(e){return this.with({userId:e})}withConversationId(e){return this.with({conversationId:e})}withVisibleToBotOwners(e){return this.with({visibleToBotOwners:e})}withHiddenToIntegrationOwners(e){return this.with({hiddenToIntegrationOwners:e})}forBot(){return this.with({hiddenToIntegrationOwners:!1,visibleToBotOwners:!0})}forBotOnly(){return this.with({hiddenToIntegrationOwners:!0,visibleToBotOwners:!0})}getJsonMessage(e){return JSON.stringify({msg:e,visible_to_bot_owner:this.defaultOptions.visibleToBotOwners,hidden_to_integration_owner:this.defaultOptions.hiddenToIntegrationOwners,options:this.defaultOptions})}};var Ry=t=>["traceparent","tracestate","sentry-trace"].reduce((e,n)=>(t[n]&&(e[n]=t[n]),e),{}),Ny=(t,e,n)=>{let[,r]=(e.headers.traceparent||"").split("-"),i=new ke.Client({botId:t.botId,integrationId:t.integrationId,integrationAlias:t.integrationAlias,retry:Cn,headers:Ry(e.headers)}),s=new lt(i),a=new ct({traceId:r});return{ctx:t,req:e,client:s,logger:a,instance:n}},Dy=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await My(t);case"register":return await jy(t);case"unregister":return await $y(t);case"message_created":return await Ky(t);case"action_triggered":return await Wy(t);case"ping":return await Hy(t);case"create_user":return await Uy(t);case"create_conversation":return await zy(t);default:throw new ke.InvalidPayloadError(`Unknown operation ${e.operation}`)}},uc=t=>async e=>{let n=oc(e.headers),r=Ny(n,e,t),{logger:i}=r;try{let s;return s=await Ly(r),s?{...s,status:s.status??200}:(s=await Dy(r),s?{...s,status:s.status??200}:{status:200})}catch(s){if((0,ke.isApiError)(s)){let l=s.type==="Runtime"?s:new ke.RuntimeError(s.message,s);return i.forBot().error(l.message),{status:l.code,body:JSON.stringify(l.toJSON())}}console.error(s);let a=new ke.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 i.forBot().error(a.message),{status:a.code,body:JSON.stringify(a.toJSON())}}},Hy=async t=>{},My=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{let{req:s}=ne(n);return i.webhook({client:t,ctx:e,req:s,logger:r})},jy=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.register)return;let{webhookUrl:s}=ne(n);await i.register({client:t,ctx:e,webhookUrl:s,logger:r})},$y=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.unregister)return;let{webhookUrl:s}=ne(n);await i.unregister({ctx:e,webhookUrl:s,client:t,logger:r})},Uy=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.createUser)return;let{tags:s}=ne(n);return await i.createUser({ctx:e,client:t,tags:s,logger:r})},zy=async({client:t,ctx:e,req:n,logger:r,instance:i})=>{if(!i.createConversation)return;let{channel:s,tags:a}=ne(n);return await i.createConversation({ctx:e,client:t,channel:s,tags:a,logger:r})},Ky=async({ctx:t,req:e,client:n,logger:r,instance:i})=>{let{conversation:s,user:a,type:l,payload:u,message:d}=ne(e),f=i.channels[s.channel];if(!f)throw new Error(`Channel ${s.channel} not found`);let g=f.messages[l];if(!g)throw new Error(`Message of type ${l} not found in channel ${s.channel}`);await g({ctx:t,conversation:s,message:d,user:a,type:l,client:n,payload:u,ack:async({tags:w})=>{await n.updateMessage({id:d.id,tags:w})},logger:r})},Wy=async({req:t,ctx:e,client:n,logger:r,instance:i})=>{let{input:s,type:a}=ne(t);if(!a)throw new Error("Missing action type");let l=i.actions[a];if(!l)throw new Error(`Action ${a} not found`);let u=new An,f={output:await l({ctx:e,input:s,client:n,type:a,logger:r,metadata:u}),meta:u.toJSON()};return{body:JSON.stringify(f)}},Ly=async({instance:t,client:e,ctx:n,logger:r,req:i})=>{let s=t.unknownOperationHandler;if(s)return await s({client:e,ctx:n,logger:r,req:i})};var Dn=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.unknownOperationHandler=e.__advanced?.unknownOperationHandler}actions;channels;register;unregister;createUser;createConversation;webhook;unknownOperationHandler;handler=uc(this);start=e=>Ut(this.handler,e)};var Hn=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,this.__advanced=e.__advanced,this.withPlugins={user:e.user,conversation:e.conversation,message:e.message,states:e.states,events:e.events,recurringEvents:e.recurringEvents,actions:e.actions,tables:e.tables,workflows:e.workflows}}integrations;plugins;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;attributes;__advanced;withPlugins;get metadata(){return{sdkVersion:Ae}}addIntegration(e,n){let r=this;r.integrations||(r.integrations={});let i=n?.alias??e.name;if(r.integrations[i])throw new Error(`Another integration with alias "${i}" is already installed in the bot`);return r.integrations[i]={...e,alias:i,enabled:n?.enabled,configurationType:n&&"configurationType"in n?n.configurationType:void 0,configuration:n&&"configuration"in n?n.configuration??{}:{},disabledChannels:n?.disabledChannels},this}addPlugin(e,n){let r=this;r.plugins||(r.plugins={});let i=n.alias??e.name;if(r.plugins[i])throw new Error(`Another plugin with alias "${i}" is already installed in the bot`);let s=Object.fromEntries(Object.entries(n.dependencies??{}).filter(([l,u])=>"integrationInterfaceAlias"in u).map(([l,u])=>{let d=this.integrations?.[u.integrationAlias];if(!d){let g=Object.keys(this.integrations??{}).join(", ")||"(none)";throw new Error(`Interface with alias "${l}" of plugin with alias "${i}" references integration with alias "${u.integrationAlias}" which is not installed. Please make sure to add the integration via addIntegration() before calling addPlugin().
73
+ Available integration aliases: ${g}`)}let f=d.definition.interfaces?.[u.integrationInterfaceAlias];if(!f){let g=Object.keys(d.definition.interfaces??{}).join(", ")||"(none)";throw new Error(`Interface with alias "${u.integrationInterfaceAlias}" does not exist in integration "${d.name}" referenced by interface with alias "${l}" of plugin with alias "${i}".
74
+ Available interface aliases: ${g}`)}return[l,{...f,id:d.id,name:d.name,version:d.version,...u}]})),a=Object.fromEntries(Object.entries(n.dependencies??{}).filter(([l,u])=>!("integrationInterfaceAlias"in u)).map(([l,u])=>{let d=this.integrations?.[u.integrationAlias];if(!d){let f=Object.keys(this.integrations??{}).join(", ")||"(none)";throw new Error(`Integration with alias "${l}" of plugin with alias "${i}" references integration with alias "${u.integrationAlias}" which is not installed. Please make sure to add the integration via addIntegration() before calling addPlugin().
75
+ Available integration aliases: ${f}`)}return[l,{...d,...u}]}));return r.plugins[i]={...e,alias:i,configuration:n.configuration??{},interfaces:s,integrations:a},r.withPlugins.user=this._mergeUser(r.withPlugins.user,e.definition.user),r.withPlugins.conversation=this._mergeConversation(r.withPlugins.conversation,e.definition.conversation),r.withPlugins.message=this._mergeMessage(r.withPlugins.message,e.definition.message),r.withPlugins.recurringEvents=this._mergeRecurringEvents(r.withPlugins.recurringEvents,e.definition.recurringEvents),r.withPlugins.tables=this._mergeTables(r.withPlugins.tables,e.definition.tables),r.withPlugins.workflows=this._mergeWorkflows(r.withPlugins.workflows,e.definition.workflows),r.withPlugins.states=this._mergeStates(r.withPlugins.states,this._prefixKeysWithPluginAlias(e.definition.states,i)),r.withPlugins.events=this._mergeEvents(r.withPlugins.events,this._prefixKeysWithPluginAlias(e.definition.events,i)),r.withPlugins.actions=this._mergeActions(r.withPlugins.actions,this._prefixKeysWithPluginAlias(e.definition.actions,i)),this}_mergeUser=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeConversation=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeMessage=(e,n)=>({tags:{...e?.tags,...n?.tags}});_mergeStates=(e,n)=>({...e,...n});_mergeEvents=(e,n)=>({...e,...n});_mergeRecurringEvents=(e,n)=>({...e,...n});_mergeActions=(e,n)=>({...e,...n});_mergeTables=(e,n)=>({...e,...n});_mergeWorkflows=(e,n)=>({...e,...n});_prefixKeysWithPluginAlias=(e,n)=>Z.mapKeys(e??{},r=>`${n}${de}${r}`);dereferencePluginEntities(){let e=this._buildZuiReferenceMap();return{...this,withPlugins:{...this.withPlugins,events:this._dereferenceDefinitionSchemas(this.withPlugins.events,e),states:this._dereferenceDefinitionSchemas(this.withPlugins.states,e),tables:this._dereferenceDefinitionSchemas(this.withPlugins.tables,e),actions:this._dereferenceActionDefinitionSchemas(this.withPlugins.actions,e)},plugins:Object.fromEntries(Object.entries(this.plugins??{}).map(([n,r])=>[n,{...r,definition:{...r.definition,configuration:this._dereferenceDefinitionSchema(r.definition.configuration,e),events:this._dereferenceDefinitionSchemas(r.definition.events,e),states:this._dereferenceDefinitionSchemas(r.definition.states,e),tables:this._dereferenceDefinitionSchemas(r.definition.tables,e),actions:this._dereferenceActionDefinitionSchemas(r.definition.actions,e)}}]))}}_buildZuiReferenceMap(){let e={},n=Object.entries(this.plugins??{});for(let[r,i]of n){let s=Object.entries(i.interfaces??{});for(let[a,l]of s){let u=this.integrations?.[l.integrationAlias];if(!u)throw new Error(`Interface with alias "${a}" of plugin with alias "${r}" references integration "${l.name}" which is not installed`);let d=Object.entries(l.entities??{});for(let[f,{name:g}]of d){let h=u.definition.entities?.[g]?.schema;if(!h)throw new Error(`Interface entity "${g}" does not exist in integration "${u.name}"`);e[`interface:${a}/entities/${f}`]=h}}}return e}_dereferenceZuiSchema(e,n){return e.dereference(n)}_dereferenceDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,this._dereferenceDefinitionSchema(i,n)]))}_dereferenceDefinitionSchema(e,n){return e&&{...e,schema:this._dereferenceZuiSchema(e.schema,n)}}_dereferenceActionDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,{...i,input:{schema:this._dereferenceZuiSchema(i.input.schema,n)},output:{schema:this._dereferenceZuiSchema(i.output.schema,n)}}]))}};var Ye=require("@botpress/client");var dt=class t extends ut{constructor(e){super({...e})}with(e){return new t({...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 me=class{constructor(e,n={before:{},after:{}}){this._client=e;this._hooks=n}get _inner(){return this._client}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));getOrCreateWorkflow=(e=>this._run("getOrCreateWorkflow",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,n)=>{let r=this._hooks.before[e];r&&(n=await r(n));let i=await this._client[e](n),s=this._hooks.after[e];return s&&(i=await s(i,n)),i}};var Fy=y.enum(["event_received","register","unregister","ping","action_triggered"]),cc=t=>({botId:t[Zn]||re("Missing bot id header"),operation:Fy.parse(t[Nn]),type:t[ac]||re("Missing type header"),configuration:JSON.parse(Buffer.from(t[Rn]||re("Missing configuration header"),"base64").toString("utf-8"))});var G={status:200};var ii=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 qy=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],dc=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!qy.includes(e.payload.type))throw new Error("Unexpected event type");let n={...t,logger:Vy(t,e)};if(!e.payload.workflow.name)return n.logger.warn("Received workflow update event without a workflow name. Assuming this workflow was not defined by the bot.",e.payload.workflow),G;switch(e.payload.type){case"child_workflow_deleted":case"child_workflow_finished":n.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 Gy(n,e);default:e.payload.type}return G},Vy=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),Gy=async(t,e)=>{let n=ii(e.payload.type),r=t.self.workflowHandlers[n]?.[e.payload.workflow.name];if(!r||r.length===0)return t.logger.warn(`No ${n} handler found for workflow "${e.payload.workflow.name}"`),G;let{updatedWorkflow:i}=await Jy(t,e);return i.status==="pending"&&t.logger.warn(`Workflow "${e.payload.workflow.name}" is still in pending status after processing "${n}" event. This may indicate that the workflow was not properly acknowledged or terminated by the handler. `),G},Jy=async(t,e)=>{let n=ii(e.payload.type),r=t.self.workflowHandlers[n]?.[e.payload.workflow.name],i=structuredClone(e.payload.workflow);for(let s of r??[])i=await s({...t,event:e,conversation:e.payload.conversation,user:e.payload.user,workflow:i});return{updatedWorkflow:i}};var pc=t=>async e=>{let n=cc(e.headers),r=new dt,i=new Ye.Client({botId:n.botId,retry:Cn}),s=new me(i,{before:{createMessage:async l=>{let u=t.hookHandlers.before_outgoing_message[l.type]??[];for(let d of u){let f=new me(i);l=(await d({client:f,ctx:n,logger:r.with({conversationId:l.conversationId,userId:l.userId}),data:l}))?.data??l}return l},callAction:async l=>{let u=t.hookHandlers.before_outgoing_call_action[l.type]??[];for(let d of u){let f=new me(i);l=(await d({client:f,ctx:n,logger:r,data:l}))?.data??l}return l}},after:{createMessage:async l=>{let u=t.hookHandlers.after_outgoing_message[l.message.type]??[];for(let d of u){let f=new me(i);l=(await d({client:f,ctx:n,logger:r.with({messageId:l.message.id,conversationId:l.message.conversationId,userId:l.message.userId}),data:l}))?.data??l}return l},callAction:async(l,u)=>{let{type:d}=u,f=t.hookHandlers.after_outgoing_call_action[d]??[];for(let g of f){let h=new me(i);l=(await g({client:h,ctx:n,logger:r,data:{type:d,...l}}))?.data??l}return l}}}),a={req:e,ctx:n,logger:r,client:s,self:t};try{switch(n.operation){case"action_triggered":return await tv(a);case"event_received":return await ev(a);case"register":return await Xy(a);case"unregister":return await Qy(a);case"ping":return await Yy(a);default:throw new Error(`Unknown operation ${n.operation}`)}}catch(l){let u=l instanceof Error?l:new Error(String(l));if((0,Ye.isApiError)(u)){let f=u.type==="Runtime"?u:new Ye.RuntimeError(u.message,u);return r.error(f.message),{status:f.code,body:JSON.stringify(f.toJSON())}}let d=new Ye.RuntimeError("An unexpected error occurred in the bot.",u);return r.error(d.message,u),{status:d.code,body:JSON.stringify(d.toJSON())}}},Yy=async t=>G,Xy=async t=>(await t.self.registerHandler?.({client:t.client,ctx:t.ctx,logger:t.logger}),G),Qy=async t=>G,ev=async t=>{let{ctx:e,logger:n,req:r,client:i,self:s}=t,a={client:i,ctx:e,logger:n},l=ne(r);if(a.logger=a.logger.with({eventId:l.event.id,messageId:l.event.messageId,conversationId:l.event.conversationId,userId:l.event.userId}),e.type==="workflow_update")return await dc(t,l.event);if(e.type==="message_created"){let w=l.event,T=w.payload.message;a.logger=a.logger.with({messageId:T.id,conversationId:T.conversationId,userId:T.userId});let N=s.hookHandlers.before_incoming_message[T.type]??[];for(let oe of N){let D=await oe({...a,data:T});if(T=D?.data??T,D?.stop)return G}let F={...a,user:w.payload.user,conversation:w.payload.conversation,message:T,event:w},J=s.messageHandlers[T.type]??[];for(let oe of J)await oe(F);let ae=s.hookHandlers.after_incoming_message[T.type]??[];for(let oe of ae){let D=await oe({...a,data:T});if(T=D?.data??T,D?.stop)return G}return G}if(e.type==="state_expired"){let T=l.event.payload.state,N={...a,state:T},F=s.stateExpiredHandlers[T.name]??[];for(let J of F)await J(N);return G}let u=l.event,d=s.hookHandlers.before_incoming_event[u.type]??[];for(let w of d){let T=await w({...a,data:u});if(u=T?.data??u,T?.stop)return G}let f={...a,event:u},g=s.eventHandlers[u.type]??[];for(let w of g)await w(f);let h=s.hookHandlers.after_incoming_event[u.type]??[];for(let w of h){let T=await w({...a,data:u});if(u=T?.data??u,T?.stop)return G}return G},tv=async({ctx:t,logger:e,req:n,client:r,self:i})=>{let{input:s,type:a}=ne(n);if(!a)throw new Error("Missing action type");let l=i.hookHandlers.before_incoming_call_action[a]??[];for(let h of l){let w=await h({ctx:t,logger:e,client:r,data:{type:a,input:s}});s=w?.data?.input??s,a=w?.data?.type??a}let u=i.actionHandlers[a];if(!u)throw new Error(`Action ${a} not found`);let d=await u({ctx:t,logger:e,input:s,client:r,type:a}),f=i.hookHandlers.after_incoming_call_action[a]??[];for(let h of f){let w=await h({ctx:t,logger:e,client:r,data:{type:a,output:d}});a=w?.data?.type??a,d=w?.data?.output??d}return{status:200,body:JSON.stringify({output:d})}};var he=(t,{alias:e})=>{if(!("tags"in t)||!e)return t;let n=`${e}${de}`,r=Object.fromEntries(Object.entries(t.tags??{}).flatMap(([i,s])=>i.startsWith(n)?[[i.slice(n.length),s]]:[]));return{...t,tags:r}},X=(t,{alias:e})=>{if(!("tags"in t)||!e)return t;let n=`${e}${de}`,r=Object.fromEntries(Object.entries(t.tags??{}).map(([i,s])=>[i.startsWith(n)?i:`${n}${i}`,s]));return{...t,tags:r}};var si=class{constructor(e){this._list=e}_nextToken;_elementsBuffer=[];_isExhausted=!1;[Symbol.asyncIterator](){return this}async next(){return this._bufferIsEmpty&&!this._isExhausted&&await this._fetchNextPageIntoBuffer(),this._bufferIsEmpty?{done:!0,value:void 0}:{done:!1,value:this._elementsBuffer.shift()}}async take(e){let n=[];for(let r=0;r<e;++r){let i=await this.next();if(i.done)break;n.push(i.value)}return n}async takePage(e){for(let r=0;r<e;++r)this._isExhausted||await this._fetchNextPageIntoBuffer();let n=[...this._elementsBuffer];return this._elementsBuffer.length=0,n}async takeAll(){return this.take(Number.POSITIVE_INFINITY)}get isExhausted(){return this._isExhausted}async _fetchNextPageIntoBuffer(){let{items:e,meta:n}=await this._list({nextToken:this._nextToken});this._elementsBuffer.push(...e),this._nextToken=n.nextToken,n.nextToken||(this._isExhausted=!0)}get _bufferIsEmpty(){return this._elementsBuffer.length===0}},ie=t=>new si(t);var Se=t=>new Proxy({},{get:(e,n)=>({listInstances:r=>ie(({nextToken:i})=>t.client.listWorkflows({...r,name:n,nextToken:i}).then(({meta:s,workflows:a})=>({meta:s,items:a.map(l=>se({...t,workflow:l}))}))),startNewInstance:async r=>{let{workflow:i}=await t.client.createWorkflow({name:n,status:"pending",...X(r,{alias:void 0})});return{workflow:se({...t,workflow:i})}}})}),se=t=>{let e=!1;return{...he(t.workflow,{alias:void 0}),async update(n){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,...X(n,{alias:void 0})});return await t.onWorkflowUpdate?.(r),{workflow:se({...t,workflow:r})}},async acknowledgeStartOfProcessing(){if(!t.event||t.workflow.status!=="pending"||e)return{workflow:se(t)};let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"in_progress",eventId:t.event.id});return e=!0,await t.onWorkflowUpdate?.(n),{workflow:se({...t,workflow:n})}},async setFailed({failureReason:n}){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"failed",failureReason:n});return await t.onWorkflowUpdate?.(r),{workflow:se({...t,workflow:r})}},async setCompleted({output:n}={}){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"completed",output:n});return await t.onWorkflowUpdate?.(r),{workflow:se({...t,workflow:r})}},async cancel(){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return await t.onWorkflowUpdate?.(n),{workflow:se({...t,workflow:n})}}}};var Mn=class{constructor(e){this.props=e;this._registerHandler=e.register,this._actionHandlers=e.actions,this._plugins=e.plugins}_registerHandler;_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 registerHandler(){return this._registerHandler}get actionHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._actionHandlers[n];if(r)return V.setName(i=>r({...i,workflows:Se(i)}),r.name);for(let[i,s]of Object.entries(this._plugins)){let[a,l]=n.split(de);if(!(a!==i||!l))return s.actionHandlers[l]}}})}get messageHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(l=>l.messageHandlers[n]??[]),i=n==="*"?[]:this._messageHandlers[n]??[],s=this._messageHandlers["*"]??[],a=[...i,...s].sort((l,u)=>l.order-u.order).map(({handler:l})=>V.setName(u=>l({...u,workflows:Se(u)}),l.name));return b.unique([...r,...a])}})}get eventHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(l=>l.eventHandlers[n]??[]),i=n==="*"?[]:this._eventHandlers[n]??[],s=this._eventHandlers["*"]??[],a=[...i,...s].sort((l,u)=>l.order-u.order).map(({handler:l})=>V.setName(u=>l({...u,workflows:Se(u)}),l.name));return b.unique([...r,...a])}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,n)=>{let r=Object.values(this._plugins).flatMap(l=>l.stateExpiredHandlers[n]??[]),i=n==="*"?[]:this._stateExpiredHandlers[n]??[],s=this._stateExpiredHandlers["*"]??[],a=[...i,...s].sort((l,u)=>l.order-u.order).map(({handler:l})=>V.setName(u=>l({...u,workflows:Se(u)}),l.name));return b.unique([...r,...a])}})}get hookHandlers(){return new Proxy({},{get:(e,n)=>{if(this._hookHandlers[n])return new Proxy({},{get:(i,s)=>{let a=Object.values(this._plugins).flatMap(g=>g.hookHandlers[n]?.[s]??[]),l=this._hookHandlers[n]??{},u=s==="*"?[]:l[s]??[],d=l["*"]??[],f=[...u,...d].sort((g,h)=>g.order-h.order).map(({handler:g})=>V.setName(h=>g({...h,workflows:Se(h)}),g.name));return b.unique([...a,...f])}})}})}get workflowHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._workflowHandlers[n];if(r)return new Proxy({},{get:(i,s)=>{let a=r[s]?.sort((u,d)=>u.order-d.order).map(({handler:u})=>V.setName(async d=>{let f=d.workflow;return await u({...d,workflow:se({...d,onWorkflowUpdate(g){f=g}}),workflows:Se(d)}),f},u.name))??[],l=Object.values(this._plugins).flatMap(u=>u.workflowHandlers[n]?.[s]??[]);return b.unique([...a,...l])}})}})}on={message:(e,n)=>{this._messageHandlers[e]=b.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=b.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=b.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=b.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=b.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=b.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=b.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=b.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=b.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=b.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=b.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=b.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=b.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=b.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=b.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=b.safePush(this._workflowHandlers.timed_out[e],{handler:n,order:this._registerOrder++})}};handler=pc(this);start=e=>Ut(this.handler,e)};var jn=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,this.__advanced=e.__advanced;let n=this._getEntityReference(this.entities),r=e.events===void 0?{}:Z.mapValues(e.events,a=>({...a,schema:a.schema(n)})),i=e.actions===void 0?{}:Z.mapValues(e.actions,a=>({...a,input:{...a.input,schema:a.input.schema(n)},output:{...a.output,schema:a.output.schema(n)}})),s=e.channels===void 0?{}:Z.mapValues(e.channels,a=>({...a,messages:Z.mapValues(a.messages,l=>({...l,schema:l.schema(n)}))}));this.events=r,this.actions=i,this.channels=s}name;version;title;description;icon;readme;attributes;entities;events;actions;channels;__advanced;get metadata(){return{sdkVersion:Ae}}_getEntityReference=e=>{let n={};for(let[r,i]of Object.entries(e)){let s=i.schema._def["x-zui"]?.title,a=i.schema._def.description,l=y.ref(r);s&&l.title(s),a&&l.describe(a),n[r]=l}return n}};var $n=class{constructor(e){this.props=e;let n=Object.fromEntries(Object.entries(e.interfaces??{}).map(([i,s])=>[i,Object.fromEntries(Object.entries(s.definition.entities??{}).map(([a])=>[a,y.ref(`interface:${i}/entities/${a}`)]))]));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.recurringEvents=e.recurringEvents,this.workflows=e.workflows,this.attributes=e.attributes,this.__advanced=e.__advanced;let r=new Set;for(let i of[...Object.keys(e.integrations??{}),...Object.keys(e.interfaces??{})]){if(r.has(i))throw new Error(`Duplicate interface or integration alias detected in plugin definition: '${i}'. Please use unique aliases for each interface and integration.`);r.add(i)}this.configuration=e.configuration?{...e.configuration,schema:typeof e.configuration.schema=="object"?e.configuration.schema:e.configuration.schema({entities:n})}:void 0,this.states=Object.fromEntries(Object.entries(e.states??{}).map(([i,s])=>[i,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:n})}])),this.events=Object.fromEntries(Object.entries(e.events??{}).map(([i,s])=>[i,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:n})}])),this.actions=Object.fromEntries(Object.entries(e.actions??{}).map(([i,s])=>[i,{...s,input:{...s.input,schema:typeof s.input.schema=="object"?s.input.schema:s.input.schema({entities:n})},output:{...s.output,schema:typeof s.output.schema=="object"?s.output.schema:s.output.schema({entities:n})}}])),this.tables=Object.fromEntries(Object.entries(e.tables??{}).map(([i,s])=>[i,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:n})}]))}name;version;title;description;icon;readme;attributes;integrations;interfaces;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;__advanced;get metadata(){return{sdkVersion:Ae}}dereferenceEntities({intersectWithUnknownRecord:e}={intersectWithUnknownRecord:!0}){let n=this._buildZuiReferenceMap(e);return{...this,configuration:this.configuration?{...this.configuration,schema:this._dereferenceZuiSchema(this.configuration.schema,n)}:void 0,events:this._dereferenceDefinitionSchemas(this.events,n),states:this._dereferenceDefinitionSchemas(this.states,n),tables:this._dereferenceDefinitionSchemas(this.tables,n),actions:this._dereferenceActionDefinitionSchemas(this.actions,n)}}_buildZuiReferenceMap(e){return Object.fromEntries(Object.entries(this.interfaces??{}).flatMap(([n,r])=>Object.entries(r.definition.entities??{}).map(([i,s])=>[`interface:${n}/entities/${i}`,e?s.schema.and(y.record(y.string(),y.unknown())):s.schema])))}_dereferenceZuiSchema(e,n){return e.dereference(n)}_dereferenceDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,{...i,schema:this._dereferenceZuiSchema(i.schema,n)}]))}_dereferenceActionDefinitionSchemas(e,n){return Object.fromEntries(Object.entries(e??{}).map(([r,i])=>[r,{...i,input:{schema:this._dereferenceZuiSchema(i.input.schema,n)},output:{schema:this._dereferenceZuiSchema(i.output.schema,n)}}]))}};var fc=(t,e)=>new Proxy({},{get:(n,r)=>new Proxy({},{get:(i,s)=>a=>{let l=(e.integrations[r]??e.interfaces[r])?.integrationAlias,u=e.interfaces[r]?.actions?.[s]?.name??s;return t.callAction({type:`${l}:${u}`,input:a}).then(d=>d.output)}})});var ai=t=>({async getById({id:e}){let n=await t.client.getMessage({id:e});return pe({...t,message:n.message})},list(e){return ie(({nextToken:n})=>t.client.listMessages({...X(e??{},{alias:t.plugin?.alias}),nextToken:n}).then(({meta:r,messages:i})=>({meta:r,items:i.map(s=>pe({...t,message:s}))})))}}),pe=t=>({...he(t.message,{alias:t.plugin?.alias}),async delete(){await t.client.deleteMessage({id:t.message.id})},async update(e){let{message:n}=await t.client.updateMessage({...X(e,{alias:t.plugin?.alias}),id:t.message.id});return pe({...t,message:n})}});var oi=t=>({list(e){return ie(({nextToken:n})=>t.client.listUsers({...X(e??{},{alias:t.pluginAlias}),nextToken:n}).then(({meta:r,users:i})=>({meta:r,items:i.map(s=>ye({...t,conversationId:e?.conversationId,user:s}))})))},async getById({id:e}){let n=await t.client.getUser({id:e});return ye({...t,user:n.user,conversationId:void 0})}}),ye=t=>{let e={...he(t.user,{alias:t.pluginAlias}),async update(n){let{user:r}=await t.client.updateUser({...X(n,{alias:t.pluginAlias}),id:t.user.id});return ye({...t,user:r})}};return t.conversationId?{...e,async removeFromConversation(){return await t.client.removeParticipant({id:t.conversationId,userId:t.user.id}),ye({...t,conversationId:void 0})}}:{...e,async addToConversation({conversationId:n}){let{participant:r}=await t.client.addParticipant({id:n,userId:t.user.id});return ye({...t,user:r,conversationId:n})}}};var li=t=>new Proxy({},{get:(e,n)=>new Proxy({},{get:(r,i)=>({list(s){let a=t.plugin?.interfaces[n]?.integrationAlias??t.plugin?.integrations[n]?.integrationAlias,l=t.plugin?.interfaces[n]?.channels?.[i]?.name??i;return ie(({nextToken:u})=>t.client.listConversations({...X(s??{},{alias:t.plugin?.alias}),channel:l==="*"?void 0:l,integrationName:a==="*"?void 0:a,nextToken:u}).then(({meta:d,conversations:f})=>({meta:d,items:f.map(g=>pt({...t,conversation:g}))})))},async getById({id:s}){let a=await t.client.getConversation({id:s});return pt({...t,conversation:a.conversation})}})})}),pt=t=>{let e=t.client;return{...he(t.conversation,{alias:t.plugin?.alias}),async delete(){await e.deleteConversation({id:t.conversation.id})},async update(n){let{conversation:r}=await e.updateConversation({...X(n,{alias:t.plugin?.alias}),id:t.conversation.id});return pt({...t,conversation:r})},async getMessage({id:n}){let r=await e.getMessage({id:n});return pe({...t,message:r.message})},async getOrCreateMessage(n){let{message:r}=await e.getOrCreateMessage({...X(n,{alias:t.plugin?.alias}),conversationId:t.conversation.id});return pe({...t,message:r})},async createMessage(n){let{message:r}=await e.createMessage({...X(n,{alias:t.plugin?.alias}),conversationId:t.conversation.id});return pe({...t,message:r})},listMessages(n){return ie(({nextToken:r})=>e.listMessages({...X(n??{},{alias:t.plugin?.alias}),conversationId:t.conversation.id,nextToken:r}).then(({meta:i,messages:s})=>({meta:i,items:s.map(a=>pe({...t,message:a}))})))},listParticipants(){return ie(({nextToken:n})=>e.listParticipants({id:t.conversation.id,nextToken:n}).then(({meta:r,participants:i})=>({meta:r,items:i.map(s=>ye({...t,user:s,conversationId:t.conversation.id}))})))}}};var ui=class t{constructor(e){this._props=e}async emit(e){let{conversationId:n,userId:r,messageId:i}=this._props,{event:s}=await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:n,userId:r,messageId:i});return s}async schedule(e,n){let{conversationId:r,userId:i,messageId:s}=this._props,{event:a}=await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:r,userId:i,messageId:s,schedule:n});return a}withConversationId(e){return new t({...this._props,conversationId:e})}withUserId(e){return new t({...this._props,userId:e})}withMessageId(e){return new t({...this._props,messageId:e})}async getById(e){return(await this._props.client.getEvent({id:e.id})).event}list(e){return ie(({nextToken:n})=>this._props.client.listEvents({...e,type:this._props.eventName,conversationId:this._props.conversationId,userId:this._props.userId,messageId:this._props.messageId,nextToken:n}).then(({meta:r,events:i})=>({meta:r,items:i})))}},gc=(t,e)=>new Proxy({},{get:(n,r)=>{let i=e.alias!==void 0?`${e.alias}${de}${r}`:r;return new ui({client:t,eventName:i})}});var ci=class{constructor(e,n,r){this._client=e;this._stateType=n;this._stateName=r}async get(e){return await this._client.getState({type:this._stateType,name:this._stateName,id:e}).then(n=>n.state.payload)}async set(e,n,r){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:n,expiry:r?.expiryMs})}async getOrSet(e,n,r){return await this._client.getOrSetState({type:this._stateType,name:this._stateName,id:e,payload:n,expiry:r?.expiryMs}).then(i=>i.state.payload)}async delete(e){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:null})}async patch(e,n){await this._client.patchState({type:this._stateType,name:this._stateName,id:e,payload:n})}},mc=(t,e)=>new Proxy({},{get:(n,r)=>new Proxy({},{get:(i,s)=>{let a=e.alias!==void 0?`${e.alias}${de}${s}`:s;return new ci(t,r,a)}})});var Un=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:n,interfaces:r,integrations:i,alias:s}=this._runtime,a=fc(e,this._runtime),l=mc(e,this._runtime),u=Se({client:e,pluginAlias:this._runtime.alias}),d=gc(e,this._runtime),f=oi({client:e,pluginAlias:this._runtime.alias}),g=li({client:e,plugin:this._runtime}),h=ai({client:e,plugin:this._runtime});return{configuration:n,interfaces:r,integrations:i,actions:a,states:l,alias:s,workflows:u,events:d,users:f,conversations:g,messages:h}}get actionHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=this._actionHandlers[n];if(r)return V.setName(i=>r({...i,...this._getTools(i.client)}),r.name)}})}get messageHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=n==="*"?[]:this._messageHandlers[n]??[],i=this._messageHandlers["*"]??[];return b.unique([...r,...i]).sort((a,l)=>a.order-l.order).map(({handler:a})=>V.setName(l=>a({...l,user:ye({...l,conversationId:l.conversation.id,pluginAlias:this._runtime.alias}),message:pe({...l,plugin:this._runtime,message:l.message}),conversation:pt({...l,plugin:this._runtime,conversation:l.conversation}),...this._getTools(l.client)}),a.name))}})}get eventHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=n==="*"?[]:this._eventHandlers[n]??[],i=Object.entries(this._eventHandlers).filter(([l])=>this._eventResolvesTo(l,n)).flatMap(([,l])=>l??[]),s=this._eventHandlers["*"]??[];return b.unique([...r,...i,...s]).sort((l,u)=>l.order-u.order).map(({handler:l})=>V.setName(u=>l({...u,...this._getTools(u.client)}),l.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,n)=>{n=this._stripAliasPrefix(n);let r=n==="*"?[]:this._stateExpiredHandlers[n]??[],i=this._stateExpiredHandlers["*"]??[];return b.unique([...r,...i]).sort((a,l)=>a.order-l.order).map(({handler:a})=>V.setName(l=>a({...l,...this._getTools(l.client)}),a.name))}})}get hookHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._hookHandlers[n];if(r)return new Proxy({},{get:(i,s)=>{s=this._stripAliasPrefix(s);let a=s==="*"?[]:r[s]??[],l=Object.entries(r).filter(([f])=>this._eventResolvesTo(f,s)).flatMap(([,f])=>f??[]),u=r["*"]??[];return b.unique([...a,...l,...u]).sort((f,g)=>f.order-g.order).map(({handler:f})=>V.setName(g=>f({...g,data:he(g.data,{alias:this._runtime.alias}),...this._getTools(g.client)}),f.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,n)=>{let r=this._workflowHandlers[n];if(r)return new Proxy({},{get:(i,s)=>(r[s]?.sort((l,u)=>l.order-u.order)??[]).map(({handler:l})=>V.setName(async u=>{let d=u.workflow;return await l({...u,workflow:se({...u,workflow:d,onWorkflowUpdate(f){d=f},pluginAlias:this._runtime.alias}),...this._getTools(u.client)}),d},l.name))})}})}on={message:(e,n)=>{this._messageHandlers[e]=b.safePush(this._messageHandlers[e],{handler:n,order:this._registerOrder++})},event:(e,n)=>{this._eventHandlers[e]=b.safePush(this._eventHandlers[e],{handler:n,order:this._registerOrder++})},stateExpired:(e,n)=>{this._stateExpiredHandlers[e]=b.safePush(this._stateExpiredHandlers[e],{handler:n,order:this._registerOrder++})},beforeIncomingEvent:(e,n)=>{this._hookHandlers.before_incoming_event[e]=b.safePush(this._hookHandlers.before_incoming_event[e],{handler:n,order:this._registerOrder++})},beforeIncomingMessage:(e,n)=>{this._hookHandlers.before_incoming_message[e]=b.safePush(this._hookHandlers.before_incoming_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingMessage:(e,n)=>{this._hookHandlers.before_outgoing_message[e]=b.safePush(this._hookHandlers.before_outgoing_message[e],{handler:n,order:this._registerOrder++})},beforeOutgoingCallAction:(e,n)=>{this._hookHandlers.before_outgoing_call_action[e]=b.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},beforeIncomingCallAction:(e,n)=>{this._hookHandlers.before_incoming_call_action[e]=b.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingEvent:(e,n)=>{this._hookHandlers.after_incoming_event[e]=b.safePush(this._hookHandlers.after_incoming_event[e],{handler:n,order:this._registerOrder++})},afterIncomingMessage:(e,n)=>{this._hookHandlers.after_incoming_message[e]=b.safePush(this._hookHandlers.after_incoming_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingMessage:(e,n)=>{this._hookHandlers.after_outgoing_message[e]=b.safePush(this._hookHandlers.after_outgoing_message[e],{handler:n,order:this._registerOrder++})},afterOutgoingCallAction:(e,n)=>{this._hookHandlers.after_outgoing_call_action[e]=b.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:n,order:this._registerOrder++})},afterIncomingCallAction:(e,n)=>{this._hookHandlers.after_incoming_call_action[e]=b.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:n,order:this._registerOrder++})},workflowStart:(e,n)=>{this._workflowHandlers.started[e]=b.safePush(this._workflowHandlers.started[e],{handler:n,order:this._registerOrder++})},workflowContinue:(e,n)=>{this._workflowHandlers.continued[e]=b.safePush(this._workflowHandlers.continued[e],{handler:n,order:this._registerOrder++})},workflowTimeout:(e,n)=>{this._workflowHandlers.timed_out[e]=b.safePush(this._workflowHandlers.timed_out[e],{handler:n,order:this._registerOrder++})}};_eventResolvesTo=(e,n)=>{let[i,s]=e.split(":");if(!i||!s)return!1;let a=this._runtime.interfaces[i];if(a&&n===`${a.integrationAlias}:${a?.events?.[s]?.name}`)return!0;let l=this._runtime.integrations[i];return!!(l&&n===`${l.integrationAlias}:${s}`)};_stripAliasPrefix=e=>{let{alias:n}=this._runtime;if(!n)return e;let r=`${n}#`;return e.startsWith(r)?e.slice(r.length):e}};var di={};Xe(di,{allWithinMajorOf:()=>nv,allWithinMinorOf:()=>rv});var zt=Kn(require("semver"));function nv(t){let e=zt.major(t.version);return{...t,version:`>=${e}.0.0 <${e+1}.0.0`}}function rv(t){let e=zt.major(t.version),n=zt.minor(t.version);return{...t,version:`>=${e}.${n}.0 <${e}.${n+1}.0`}}0&&(module.exports={Bot,BotDefinition,BotLogger,BotSpecificClient,Integration,IntegrationDefinition,IntegrationLogger,IntegrationSpecificClient,InterfaceDefinition,Plugin,PluginDefinition,RuntimeError,WELL_KNOWN_ATTRIBUTES,isApiError,messages,parseBody,serve,version,z});
76
76
  /*! Bundled license information:
77
77
 
78
78
  lodash-es/lodash.js: