@botpress/sdk 4.15.11 → 4.15.12
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/.turbo/turbo-build.log +5 -5
- package/dist/bot/implementation.d.ts +8 -8
- package/dist/bot/server/types.d.ts +49 -13
- package/dist/index.cjs +11 -11
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +36 -36
- package/dist/index.mjs.map +4 -4
- package/dist/plugin/implementation.d.ts +2 -2
- package/dist/plugin/server/types.d.ts +48 -13
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var du=Object.create;var Gt=Object.defineProperty;var uu=Object.getOwnPropertyDescriptor;var fu=Object.getOwnPropertyNames;var pu=Object.getPrototypeOf,gu=Object.prototype.hasOwnProperty;var mt=(t,e)=>{for(var r in e)Gt(t,r,{get:e[r],enumerable:!0})},Fs=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of fu(e))!gu.call(t,s)&&s!==r&&Gt(t,s,{get:()=>e[s],enumerable:!(n=uu(e,s))||n.enumerable});return t};var Ws=(t,e,r)=>(r=t!=null?du(pu(t)):{},Fs(e||!t||!t.__esModule?Gt(r,"default",{value:t,enumerable:!0}):r,t)),hu=t=>Fs(Gt({},"__esModule",{value:!0}),t);var qy={};mt(qy,{BRAND:()=>$l,Bot:()=>bn,BotDefinition:()=>Tn,BotLogger:()=>ht,BotSpecificClient:()=>ue,DIRTY:()=>Re,EMPTY_PATH:()=>Al,INVALID:()=>x,Integration:()=>_n,IntegrationDefinition:()=>mn,IntegrationLogger:()=>gt,IntegrationSpecificClient:()=>ft,InterfaceDefinition:()=>wn,NEVER:()=>rd,OK:()=>J,ParseInputLazyPath:()=>oe,ParseStatus:()=>re,Plugin:()=>xn,PluginDefinition:()=>Pn,RuntimeError:()=>kn.RuntimeError,Schema:()=>O,WELL_KNOWN_ATTRIBUTES:()=>ay,ZodAny:()=>at,ZodArray:()=>ot,ZodBigInt:()=>en,ZodBoolean:()=>tn,ZodBranded:()=>rn,ZodCatch:()=>nn,ZodDate:()=>sn,ZodDefault:()=>$t,ZodDiscriminatedUnion:()=>ds,ZodEffects:()=>xe,ZodEnum:()=>Le,ZodError:()=>de,ZodFirstPartyTypeKind:()=>as,ZodFunction:()=>fs,ZodIntersection:()=>an,ZodIssueCode:()=>h,ZodLazy:()=>on,ZodLiteral:()=>ln,ZodMap:()=>ps,ZodNaN:()=>gs,ZodNativeEnum:()=>cn,ZodNever:()=>dt,ZodNull:()=>dn,ZodNullable:()=>De,ZodNumber:()=>un,ZodObject:()=>Ne,ZodOptional:()=>he,ZodParsedType:()=>_,ZodPipeline:()=>fn,ZodPromise:()=>Ut,ZodReadonly:()=>zt,ZodRecord:()=>hs,ZodRef:()=>ms,ZodSchema:()=>O,ZodSet:()=>ys,ZodString:()=>X,ZodSymbol:()=>ks,ZodTransformer:()=>xe,ZodTuple:()=>Me,ZodType:()=>O,ZodUndefined:()=>Ft,ZodUnion:()=>pn,ZodUnknown:()=>rt,ZodVoid:()=>Ss,addIssueToContext:()=>v,agent:()=>dc,aimodel:()=>hc,any:()=>Sc,array:()=>Ic,bigint:()=>bc,boolean:()=>Zs,botIdHeader:()=>Wt,botUserIdHeader:()=>As,coerce:()=>td,configurationHeader:()=>Lt,configurationTypeHeader:()=>Ds,conversation:()=>oc,createZodEnum:()=>Kt,cuid2Regex:()=>_s,cuidRegex:()=>vs,custom:()=>cs,datasource:()=>mc,date:()=>wc,discriminatedUnion:()=>Rc,effect:()=>Un,emailRegex:()=>ws,enum:()=>Wc,errorUtil:()=>w,event:()=>uc,function:()=>Uc,getErrorMap:()=>st,getParsedType:()=>ge,instanceof:()=>_c,integrationIdHeader:()=>Rs,intent:()=>gc,intersection:()=>Hc,ipv4Regex:()=>Ps,ipv6Regex:()=>xs,isAborted:()=>dr,isApiError:()=>kn.isApiError,isAsync:()=>Nt,isDirty:()=>ur,isEmojiRegex:()=>ec,isValid:()=>it,knowledgebase:()=>yc,late:()=>vc,lazy:()=>zc,literal:()=>Fc,makeIssue:()=>Dt,map:()=>$c,mergeObjectSchemas:()=>ut,message:()=>cc,messages:()=>Cs,nan:()=>Tc,nativeEnum:()=>Lc,never:()=>Ec,null:()=>kc,nullable:()=>Gc,number:()=>Es,object:()=>Bc,objectUtil:()=>lr,oboolean:()=>ed,onumber:()=>Qc,operationHeader:()=>qt,optional:()=>Vc,ostring:()=>Yc,parseBody:()=>le,pipeline:()=>Xc,preprocess:()=>Jc,processCreateParams:()=>k,promise:()=>qc,quotelessJson:()=>Il,readonly:()=>jc,record:()=>Nc,ref:()=>Mc,serve:()=>Vt,set:()=>Kc,setErrorMap:()=>ls,strictObject:()=>Cc,string:()=>Os,symbol:()=>Pc,table:()=>fc,tablerow:()=>pc,transformer:()=>Un,transforms:()=>Bi,tuple:()=>Dc,typeHeader:()=>Ns,ulidRegex:()=>Ts,undefined:()=>xc,union:()=>Ac,unknown:()=>Oc,user:()=>lc,util:()=>Z,uuidRegex:()=>bs,variable:()=>ac,void:()=>Zc,webhookIdHeader:()=>Hs,z:()=>y});module.exports=hu(qy);var Cs={};mt(Cs,{defaults:()=>iy,markdown:()=>sy});var Wn=Object.defineProperty,mu=Object.defineProperties,yu=Object.getOwnPropertyDescriptors,or=Object.getOwnPropertySymbols,Ei=Object.prototype.hasOwnProperty,Zi=Object.prototype.propertyIsEnumerable,Ls=(t,e,r)=>e in t?Wn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,c=(t,e)=>{for(var r in e||(e={}))Ei.call(e,r)&&Ls(t,r,e[r]);if(or)for(var r of or(e))Zi.call(e,r)&&Ls(t,r,e[r]);return t},f=(t,e)=>mu(t,yu(e)),a=(t,e)=>Wn(t,"name",{value:e,configurable:!0}),Ii=(t,e)=>{var r={};for(var n in t)Ei.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&or)for(var n of or(t))e.indexOf(n)<0&&Zi.call(t,n)&&(r[n]=t[n]);return r},zr=(t,e)=>{for(var r in e)Wn(t,r,{get:e[r],enumerable:!0})},Bi={};zr(Bi,{errors:()=>Hi,fromJSONSchema:()=>ad,fromJSONSchemaLegacy:()=>Em,fromObject:()=>zn,toJSONSchema:()=>V,toJSONSchemaLegacy:()=>ey,toTypescriptSchema:()=>ns,toTypescriptType:()=>Ln});var y={};zr(y,{BRAND:()=>$l,DIRTY:()=>Re,EMPTY_PATH:()=>Al,INVALID:()=>x,NEVER:()=>rd,OK:()=>J,ParseInputLazyPath:()=>oe,ParseStatus:()=>re,Schema:()=>O,ZodAny:()=>at,ZodArray:()=>ot,ZodBigInt:()=>en,ZodBoolean:()=>tn,ZodBranded:()=>rn,ZodCatch:()=>nn,ZodDate:()=>sn,ZodDefault:()=>$t,ZodDiscriminatedUnion:()=>ds,ZodEffects:()=>xe,ZodEnum:()=>Le,ZodError:()=>de,ZodFirstPartyTypeKind:()=>as,ZodFunction:()=>fs,ZodIntersection:()=>an,ZodIssueCode:()=>h,ZodLazy:()=>on,ZodLiteral:()=>ln,ZodMap:()=>ps,ZodNaN:()=>gs,ZodNativeEnum:()=>cn,ZodNever:()=>dt,ZodNull:()=>dn,ZodNullable:()=>De,ZodNumber:()=>un,ZodObject:()=>Ne,ZodOptional:()=>he,ZodParsedType:()=>_,ZodPipeline:()=>fn,ZodPromise:()=>Ut,ZodReadonly:()=>zt,ZodRecord:()=>hs,ZodRef:()=>ms,ZodSchema:()=>O,ZodSet:()=>ys,ZodString:()=>X,ZodSymbol:()=>ks,ZodTransformer:()=>xe,ZodTuple:()=>Me,ZodType:()=>O,ZodUndefined:()=>Ft,ZodUnion:()=>pn,ZodUnknown:()=>rt,ZodVoid:()=>Ss,addIssueToContext:()=>v,agent:()=>dc,aimodel:()=>hc,any:()=>Sc,array:()=>Ic,bigint:()=>bc,boolean:()=>Zs,coerce:()=>td,conversation:()=>oc,createZodEnum:()=>Kt,cuid2Regex:()=>_s,cuidRegex:()=>vs,custom:()=>cs,datasource:()=>mc,date:()=>wc,default:()=>sm,discriminatedUnion:()=>Rc,effect:()=>Un,emailRegex:()=>ws,enum:()=>Wc,errorUtil:()=>w,event:()=>uc,function:()=>Uc,getErrorMap:()=>st,getParsedType:()=>ge,instanceof:()=>_c,intent:()=>gc,intersection:()=>Hc,ipv4Regex:()=>Ps,ipv6Regex:()=>xs,isAborted:()=>dr,isAsync:()=>Nt,isDirty:()=>ur,isEmojiRegex:()=>ec,isValid:()=>it,knowledgebase:()=>yc,late:()=>vc,lazy:()=>zc,literal:()=>Fc,makeIssue:()=>Dt,map:()=>$c,message:()=>cc,nan:()=>Tc,nativeEnum:()=>Lc,never:()=>Ec,null:()=>kc,nullable:()=>Gc,number:()=>Es,object:()=>Bc,objectUtil:()=>lr,oboolean:()=>ed,onumber:()=>Qc,optional:()=>Vc,ostring:()=>Yc,pipeline:()=>Xc,preprocess:()=>Jc,processCreateParams:()=>k,promise:()=>qc,quotelessJson:()=>Il,readonly:()=>jc,record:()=>Nc,ref:()=>Mc,set:()=>Kc,setErrorMap:()=>ls,strictObject:()=>Cc,string:()=>Os,symbol:()=>Pc,table:()=>fc,tablerow:()=>pc,transformer:()=>Un,tuple:()=>Dc,ulidRegex:()=>Ts,undefined:()=>xc,union:()=>Ac,unknown:()=>Oc,user:()=>lc,util:()=>Z,uuidRegex:()=>bs,variable:()=>ac,void:()=>Zc});var b="x-zui";function Ci(t){return typeof t=="symbol"?"symbol":typeof t=="bigint"?`${t.toString()}n`:T(t)}a(Ci,"primitiveToTypscriptLiteralType");function T(t){return typeof t>"u"?"undefined":typeof t=="symbol"?t.description?`Symbol(${T(t.description)})`:"Symbol()":typeof t=="bigint"?`BigInt(${t.toString()})`:JSON.stringify(t)}a(T,"primitiveToTypescriptValue");function et(t){return typeof t>"u"?"undefined":JSON.stringify(t)}a(et,"unknownToTypescriptValue");var Ai=a((t,e)=>{let r=Object.entries(t),n=e?" as const":"";return`{ ${r.map(([s,i])=>`${Cn(s)}: ${et(i)}`).join(", ")} }${n}`},"recordOfUnknownToTypescriptRecord"),Cn=a(t=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t)?t:T(t),"toPropertyKey"),vu=a(t=>t.charAt(0).toUpperCase()+t.slice(1),"capitalize"),Ri=a(t=>{let e=/[^a-zA-Z0-9_]/g;return t.split(e).map(vu).filter(n=>!!n).join("")},"toTypeArgumentName"),z=a(t=>{let e=(t??"").split(`
|
|
2
2
|
`).filter(r=>r.trim().length>0);return e.length===0?"":e.length===1?`/** ${e[0]} */`:`/**
|
|
3
3
|
* ${e.join(`
|
|
4
4
|
* `)}
|
|
5
|
-
*/`},"getMultilineComment"),
|
|
6
|
-
`:"",g=t.value.describe(""),P=t.optional||t.value.isOptional()?"?":"";return`${
|
|
5
|
+
*/`},"getMultilineComment"),Hi={};zr(Hi,{JSONSchemaToZuiError:()=>Fr,ObjectToZuiError:()=>An,UnrepresentableGenericError:()=>Rn,UnsupportedJSONSchemaToZuiError:()=>be,UnsupportedZuiCheckToJSONSchemaError:()=>Ui,UnsupportedZuiToJSONSchemaError:()=>te,UnsupportedZuiToTypescriptSchemaError:()=>Ee,UnsupportedZuiToTypescriptTypeError:()=>Gi,UntitledDeclarationError:()=>Xi,ZuiToJSONSchemaError:()=>Wr,ZuiToTypescriptSchemaError:()=>Wi,ZuiToTypescriptTypeError:()=>Lr,ZuiTransformError:()=>ct});var Di=class extends Error{constructor(e,r){super(r),this.transform=e}};a(Di,"ZuiTransformError");var ct=Di,Ni=class extends ct{constructor(e){super("json-schema-to-zui",e)}};a(Ni,"JSONSchemaToZuiError");var Fr=Ni,Mi=class extends ct{constructor(e){super("object-to-zui",e)}};a(Mi,"ObjectToZuiError");var An=Mi,ji=class extends ct{constructor(e){super("zui-to-json-schema",e)}};a(ji,"ZuiToJSONSchemaError");var Wr=ji,$i=class extends Wr{constructor(e,{suggestedAlternative:r}={}){super(`Zod type ${e} cannot be transformed to JSON Schema.`+(r?` Suggested alternative: ${r}`:""))}};a($i,"UnsupportedZuiToJSONSchemaError");var te=$i,Ki=class extends Wr{constructor({zodType:e,checkKind:r}){super(`Zod check .${r}() of type ${e} cannot be transformed to JSON Schema.`)}};a(Ki,"UnsupportedZuiCheckToJSONSchemaError");var Ui=Ki,zi=class extends Fr{constructor(e){super(`JSON Schema ${JSON.stringify(e)} cannot be transformed to ZUI type.`)}};a(zi,"UnsupportedJSONSchemaToZuiError");var be=zi,Fi=class extends ct{constructor(e){super("zui-to-typescript-schema",e)}};a(Fi,"ZuiToTypescriptSchemaError");var Wi=Fi,Li=class extends Wi{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript schema.`)}};a(Li,"UnsupportedZuiToTypescriptSchemaError");var Ee=Li,qi=class extends ct{constructor(e){super("zui-to-typescript-type",e)}};a(qi,"ZuiToTypescriptTypeError");var Lr=qi,Vi=class extends Lr{constructor(e){super(`Zod type ${e} cannot be transformed to TypeScript type.`)}};a(Vi,"UnsupportedZuiToTypescriptTypeError");var Gi=Vi,Ji=class extends Lr{constructor(){super("Schema must have a title to be transformed to a TypeScript type with a declaration.")}};a(Ji,"UntitledDeclarationError");var Xi=Ji,Yi=class extends Lr{constructor(){super('ZodRef can only be transformed to a TypeScript type with a "type" declaration.')}};a(Yi,"UnrepresentableGenericError");var Rn=Yi,Qi=["string","number","boolean","unknown","void","any","null","undefined","never","bigint","symbol","object"],_u=a(t=>Qi.includes(t),"isPrimitive"),Tu=a(t=>Qi.map(e=>`${e}[]`).includes(t),"isArrayOfPrimitives"),qs=a(t=>t.replace(/ +/g," ").trim(),"stripSpaces"),ea=class{constructor(e,r,n=!1){this.key=e,this.value=r,this.optional=n}};a(ea,"KeyValue");var Jt=ea,ta=class{constructor(e){this.schema=e}};a(ta,"FnParameters");var Vs=ta,ra=class{constructor(e){this.schema=e}};a(ra,"FnReturn");var Gs=ra,na=class{constructor(e){this.props=e}};a(na,"Declaration");var Yt=na;function Ln(t,e={}){let r=Pu(t,e),n=B(r,{});return e.formatter&&(n=e.formatter(n)),n}a(Ln,"toTypescriptType");function B(t,e){var r,n,s;let i=f(c({},e),{parent:t});if(t===null)return"";if(t instanceof Yt)return bu(t,i);if(t instanceof Jt){if(t.value instanceof u.ZodOptional){let E=t.value._def.innerType;return B(new Jt(t.key,E,!0),i)}let d=z(t.value.description),p=d?.trim().length>0?`
|
|
6
|
+
`:"",g=t.value.describe(""),P=t.optional||t.value.isOptional()?"?":"";return`${p}${d}${p}${t.key}${P}: ${B(g,i)}${p}`}if(t instanceof Vs){if(t.schema instanceof u.ZodTuple){let g="";for(let m=0;m<t.schema.items.length;m++){let P=(s=(n=(r=t.schema.items[m])==null?void 0:r.ui)==null?void 0:n.title)!=null?s:`arg${m}`,E=t.schema.items[m];g+=`${B(new Jt(Cn(P),E),i)}${m<t.schema.items.length-1?", ":""} `}return g}let d=B(t.schema,i);return d.startsWith("{")&&d.endsWith("}")||d.startsWith("[")&&d.endsWith("]")||d.startsWith("(")&&d.endsWith(")")||d.startsWith("Array<")&&d.endsWith(">")||d.startsWith("Record<")&&d.endsWith(">")||Tu(d)?`args: ${d}`:d}if(t instanceof Gs)return t.schema instanceof u.ZodOptional?`${B(t.schema.unwrap(),i)} | undefined`:B(t.schema,i);let o=t,l=o._def;switch(l.typeName){case u.ZodFirstPartyTypeKind.ZodString:return`${z(o.description)} string`.trim();case u.ZodFirstPartyTypeKind.ZodNumber:case u.ZodFirstPartyTypeKind.ZodNaN:case u.ZodFirstPartyTypeKind.ZodBigInt:return`${z(o.description)} number`.trim();case u.ZodFirstPartyTypeKind.ZodBoolean:return`${z(o.description)} boolean`.trim();case u.ZodFirstPartyTypeKind.ZodDate:return`${z(o.description)} Date`.trim();case u.ZodFirstPartyTypeKind.ZodUndefined:return`${z(o.description)} undefined`.trim();case u.ZodFirstPartyTypeKind.ZodNull:return`${z(o.description)} null`.trim();case u.ZodFirstPartyTypeKind.ZodAny:return`${z(o.description)} any`.trim();case u.ZodFirstPartyTypeKind.ZodUnknown:return`${z(o.description)} unknown`.trim();case u.ZodFirstPartyTypeKind.ZodNever:return`${z(o.description)} never`.trim();case u.ZodFirstPartyTypeKind.ZodVoid:return`${z(o.description)} void`.trim();case u.ZodFirstPartyTypeKind.ZodArray:let d=B(l.type,i);return _u(d)?`${d}[]`:`Array<${d}>`;case u.ZodFirstPartyTypeKind.ZodObject:return`{ ${Object.entries(l.shape()).map(([q,ie])=>B(new Jt(Cn(q),ie),i)).join("; ")} }`;case u.ZodFirstPartyTypeKind.ZodUnion:let g=l.options.map(q=>B(q,i));return`${z(o.description)}
|
|
7
7
|
${g.join(" | ")}`;case u.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let m=l.options.map(q=>B(q,i));return`${z(o.description)}
|
|
8
|
-
${m.join(" | ")}`;case u.ZodFirstPartyTypeKind.ZodIntersection:return`${B(l.left,i)} & ${B(l.right,i)}`;case u.ZodFirstPartyTypeKind.ZodTuple:return l.items.length===0?"":`[${l.items.map(q=>B(q,i)).join(", ")}]`;case u.ZodFirstPartyTypeKind.ZodRecord:let E=B(l.keyType,i),I=B(l.valueType,i);return`${z(o.description)} { [key: ${E}]: ${I} }`;case u.ZodFirstPartyTypeKind.ZodMap:return`Map<${B(l.keyType,i)}, ${B(l.valueType,i)}>`;case u.ZodFirstPartyTypeKind.ZodSet:return`Set<${B(l.valueType,i)}>`;case u.ZodFirstPartyTypeKind.ZodFunction:let U=B(new
|
|
9
|
-
(${U}) => ${L}`;case u.ZodFirstPartyTypeKind.ZodLazy:return B(l.getter(),i);case u.ZodFirstPartyTypeKind.ZodLiteral:let
|
|
10
|
-
${Q}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(T).join(" | ");case u.ZodFirstPartyTypeKind.ZodEffects:return B(l.schema,i);case u.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Ji(u.ZodFirstPartyTypeKind.ZodNativeEnum);case u.ZodFirstPartyTypeKind.ZodOptional:return`${B(l.innerType,i)} | undefined`;case u.ZodFirstPartyTypeKind.ZodNullable:return`${B(l.innerType,i)} | null`;case u.ZodFirstPartyTypeKind.ZodDefault:return B(l.innerType,i);case u.ZodFirstPartyTypeKind.ZodCatch:return B(l.innerType,i);case u.ZodFirstPartyTypeKind.ZodPromise:return`Promise<${B(l.type,i)}>`;case u.ZodFirstPartyTypeKind.ZodBranded:return B(l.type,i);case u.ZodFirstPartyTypeKind.ZodPipeline:return B(l.in,i);case u.ZodFirstPartyTypeKind.ZodSymbol:return`${z(o.description)} symbol`.trim();case u.ZodFirstPartyTypeKind.ZodReadonly:return`Readonly<${B(l.innerType,i)}>`;case u.ZodFirstPartyTypeKind.ZodRef:return Hi(l.uri);default:Z.assertNever(l)}}a(B,"sUnwrapZod");var wu=a((t,e)=>{if(t.props.type==="none")return B(t.props.schema,e);let r=z(t.props.schema.description),n=t.props.schema.describe(""),s=B(n,e);if(t.props.type==="variable")return Vs(`${r}declare const ${t.props.identifier}: ${s};`);let i=t.props.args.length>0?`<${t.props.args.map(Hi).join(", ")}>`:"";return Vs(`${r}type ${t.props.identifier}${i} = ${s};`)},"unwrapDeclaration"),Pu=a(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),xu=a((t,e)=>{let r=Pu(e),n=t.getReferences();if(r==="none"){if(n.length>0)throw new Hn;return new Qt({type:"none",schema:t})}let s="title"in t.ui?t.ui.title:null;if(!s)throw new Yi;if(r==="variable"){if(n.length>0)throw new Hn;return new Qt({type:"variable",identifier:s,schema:t})}return new Qt({type:"type",identifier:s,schema:t,args:n})},"getDeclarationProps"),ku=typeof global=="object"&&global&&global.Object===Object&&global,ia=ku,Su=typeof self=="object"&&self&&self.Object===Object&&self,Ou=ia||Su||Function("return this")(),me=Ou,Eu=me.Symbol,be=Eu,aa=Object.prototype,Zu=aa.hasOwnProperty,Iu=aa.toString,vt=be?be.toStringTag:void 0;function oa(t){var e=Zu.call(t,vt),r=t[vt];try{t[vt]=void 0;var n=!0}catch{}var s=Iu.call(t);return n&&(e?t[vt]=r:delete t[vt]),s}a(oa,"getRawTag");var Bu=oa,Cu=Object.prototype,Au=Cu.toString;function la(t){return Au.call(t)}a(la,"objectToString");var Ru=la,Hu="[object Null]",Du="[object Undefined]",Xs=be?be.toStringTag:void 0;function ca(t){return t==null?t===void 0?Du:Hu:Xs&&Xs in Object(t)?Bu(t):Ru(t)}a(ca,"baseGetTag");var $e=ca;function da(t){return t!=null&&typeof t=="object"}a(da,"isObjectLike");var He=da,Mu="[object Symbol]";function ua(t){return typeof t=="symbol"||He(t)&&$e(t)==Mu}a(ua,"isSymbol");var Vn=ua;function pa(t,e){for(var r=-1,n=t==null?0:t.length,s=Array(n);++r<n;)s[r]=e(t[r],r,t);return s}a(pa,"arrayMap");var fa=pa,Nu=Array.isArray,he=Nu,$u=1/0,Ys=be?be.prototype:void 0,Qs=Ys?Ys.toString:void 0;function Gn(t){if(typeof t=="string")return t;if(he(t))return fa(t,Gn)+"";if(Vn(t))return Qs?Qs.call(t):"";var e=t+"";return e=="0"&&1/t==-$u?"-0":e}a(Gn,"baseToString");var ju=Gn;function ga(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}a(ga,"isObject");var nt=ga;function ha(t){return t}a(ha,"identity");var Ku=ha,Uu="[object AsyncFunction]",zu="[object Function]",Fu="[object GeneratorFunction]",Wu="[object Proxy]";function ma(t){if(!nt(t))return!1;var e=$e(t);return e==zu||e==Fu||e==Uu||e==Wu}a(ma,"isFunction");var ya=ma,Lu=me["__core-js_shared__"],On=Lu,ei=(function(){var t=/[^.]+$/.exec(On&&On.keys&&On.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function va(t){return!!ei&&ei in t}a(va,"isMasked");var qu=va,Vu=Function.prototype,Gu=Vu.toString;function _a(t){if(t!=null){try{return Gu.call(t)}catch{}try{return t+""}catch{}}return""}a(_a,"toSource");var je=_a,Ju=/[\\^$.*+?()[\]{}|]/g,Xu=/^\[object .+?Constructor\]$/,Yu=Function.prototype,Qu=Object.prototype,ep=Yu.toString,tp=Qu.hasOwnProperty,rp=RegExp("^"+ep.call(tp).replace(Ju,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Ta(t){if(!nt(t)||qu(t))return!1;var e=ya(t)?rp:Xu;return e.test(je(t))}a(Ta,"baseIsNative");var np=Ta;function ba(t,e){return t?.[e]}a(ba,"getValue");var sp=ba;function wa(t,e){var r=sp(t,e);return np(r)?r:void 0}a(wa,"getNative");var Ke=wa,ip=Ke(me,"WeakMap"),Dn=ip,ap=(function(){try{var t=Ke(Object,"defineProperty");return t({},"",{}),t}catch{}})(),ti=ap,op=9007199254740991,lp=/^(?:0|[1-9]\d*)$/;function Pa(t,e){var r=typeof t;return e=e??op,!!e&&(r=="number"||r!="symbol"&&lp.test(t))&&t>-1&&t%1==0&&t<e}a(Pa,"isIndex");var Jn=Pa;function xa(t,e,r){e=="__proto__"&&ti?ti(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}a(xa,"baseAssignValue");var ka=xa;function Sa(t,e){return t===e||t!==t&&e!==e}a(Sa,"eq");var Xn=Sa,cp=Object.prototype,dp=cp.hasOwnProperty;function Oa(t,e,r){var n=t[e];(!(dp.call(t,e)&&Xn(n,r))||r===void 0&&!(e in t))&&ka(t,e,r)}a(Oa,"assignValue");var up=Oa,pp=9007199254740991;function Ea(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=pp}a(Ea,"isLength");var Yn=Ea;function Za(t){return t!=null&&Yn(t.length)&&!ya(t)}a(Za,"isArrayLike");var Ia=Za,fp=Object.prototype;function Ba(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||fp;return t===r}a(Ba,"isPrototype");var Ca=Ba;function Aa(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}a(Aa,"baseTimes");var gp=Aa,hp="[object Arguments]";function Ra(t){return He(t)&&$e(t)==hp}a(Ra,"baseIsArguments");var ri=Ra,Ha=Object.prototype,mp=Ha.hasOwnProperty,yp=Ha.propertyIsEnumerable,vp=ri((function(){return arguments})())?ri:function(t){return He(t)&&mp.call(t,"callee")&&!yp.call(t,"callee")},Da=vp;function Ma(){return!1}a(Ma,"stubFalse");var _p=Ma,Na=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ni=Na&&typeof module=="object"&&module&&!module.nodeType&&module,Tp=ni&&ni.exports===Na,si=Tp?me.Buffer:void 0,bp=si?si.isBuffer:void 0,wp=bp||_p,Mn=wp,Pp="[object Arguments]",xp="[object Array]",kp="[object Boolean]",Sp="[object Date]",Op="[object Error]",Ep="[object Function]",Zp="[object Map]",Ip="[object Number]",Bp="[object Object]",Cp="[object RegExp]",Ap="[object Set]",Rp="[object String]",Hp="[object WeakMap]",Dp="[object ArrayBuffer]",Mp="[object DataView]",Np="[object Float32Array]",$p="[object Float64Array]",jp="[object Int8Array]",Kp="[object Int16Array]",Up="[object Int32Array]",zp="[object Uint8Array]",Fp="[object Uint8ClampedArray]",Wp="[object Uint16Array]",Lp="[object Uint32Array]",D={};D[Np]=D[$p]=D[jp]=D[Kp]=D[Up]=D[zp]=D[Fp]=D[Wp]=D[Lp]=!0;D[Pp]=D[xp]=D[Dp]=D[kp]=D[Mp]=D[Sp]=D[Op]=D[Ep]=D[Zp]=D[Ip]=D[Bp]=D[Cp]=D[Ap]=D[Rp]=D[Hp]=!1;function $a(t){return He(t)&&Yn(t.length)&&!!D[$e(t)]}a($a,"baseIsTypedArray");var qp=$a;function ja(t){return function(e){return t(e)}}a(ja,"baseUnary");var Vp=ja,Ka=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Ct=Ka&&typeof module=="object"&&module&&!module.nodeType&&module,Gp=Ct&&Ct.exports===Ka,En=Gp&&ia.process,Jp=(function(){try{var t=Ct&&Ct.require&&Ct.require("util").types;return t||En&&En.binding&&En.binding("util")}catch{}})(),ii=Jp,ai=ii&&ii.isTypedArray,Xp=ai?Vp(ai):qp,Ua=Xp,Yp=Object.prototype,Qp=Yp.hasOwnProperty;function za(t,e){var r=he(t),n=!r&&Da(t),s=!r&&!n&&Mn(t),i=!r&&!n&&!s&&Ua(t),o=r||n||s||i,l=o?gp(t.length,String):[],d=l.length;for(var f in t)(e||Qp.call(t,f))&&!(o&&(f=="length"||s&&(f=="offset"||f=="parent")||i&&(f=="buffer"||f=="byteLength"||f=="byteOffset")||Jn(f,d)))&&l.push(f);return l}a(za,"arrayLikeKeys");var Fa=za;function Wa(t,e){return function(r){return t(e(r))}}a(Wa,"overArg");var La=Wa,ef=La(Object.keys,Object),tf=ef,rf=Object.prototype,nf=rf.hasOwnProperty;function qa(t){if(!Ca(t))return tf(t);var e=[];for(var r in Object(t))nf.call(t,r)&&r!="constructor"&&e.push(r);return e}a(qa,"baseKeys");var sf=qa;function Va(t){return Ia(t)?Fa(t):sf(t)}a(Va,"keys");var Qn=Va;function Ga(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}a(Ga,"nativeKeysIn");var af=Ga,of=Object.prototype,lf=of.hasOwnProperty;function Ja(t){if(!nt(t))return af(t);var e=Ca(t),r=[];for(var n in t)n=="constructor"&&(e||!lf.call(t,n))||r.push(n);return r}a(Ja,"baseKeysIn");var cf=Ja;function Xa(t){return Ia(t)?Fa(t,!0):cf(t)}a(Xa,"keysIn");var df=Xa,uf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,pf=/^\w*$/;function Ya(t,e){if(he(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||Vn(t)?!0:pf.test(t)||!uf.test(t)||e!=null&&t in Object(e)}a(Ya,"isKey");var es=Ya,ff=Ke(Object,"create"),Rt=ff;function Qa(){this.__data__=Rt?Rt(null):{},this.size=0}a(Qa,"hashClear");var gf=Qa;function eo(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}a(eo,"hashDelete");var hf=eo,mf="__lodash_hash_undefined__",yf=Object.prototype,vf=yf.hasOwnProperty;function to(t){var e=this.__data__;if(Rt){var r=e[t];return r===mf?void 0:r}return vf.call(e,t)?e[t]:void 0}a(to,"hashGet");var _f=to,Tf=Object.prototype,bf=Tf.hasOwnProperty;function ro(t){var e=this.__data__;return Rt?e[t]!==void 0:bf.call(e,t)}a(ro,"hashHas");var wf=ro,Pf="__lodash_hash_undefined__";function no(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=Rt&&e===void 0?Pf:e,this}a(no,"hashSet");var xf=no;function Ue(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(Ue,"Hash");Ue.prototype.clear=gf;Ue.prototype.delete=hf;Ue.prototype.get=_f;Ue.prototype.has=wf;Ue.prototype.set=xf;var oi=Ue;function so(){this.__data__=[],this.size=0}a(so,"listCacheClear");var kf=so;function io(t,e){for(var r=t.length;r--;)if(Xn(t[r][0],e))return r;return-1}a(io,"assocIndexOf");var Vr=io,Sf=Array.prototype,Of=Sf.splice;function ao(t){var e=this.__data__,r=Vr(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():Of.call(e,r,1),--this.size,!0}a(ao,"listCacheDelete");var Ef=ao;function oo(t){var e=this.__data__,r=Vr(e,t);return r<0?void 0:e[r][1]}a(oo,"listCacheGet");var Zf=oo;function lo(t){return Vr(this.__data__,t)>-1}a(lo,"listCacheHas");var If=lo;function co(t,e){var r=this.__data__,n=Vr(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}a(co,"listCacheSet");var Bf=co;function ze(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(ze,"ListCache");ze.prototype.clear=kf;ze.prototype.delete=Ef;ze.prototype.get=Zf;ze.prototype.has=If;ze.prototype.set=Bf;var Gr=ze,Cf=Ke(me,"Map"),Ht=Cf;function uo(){this.size=0,this.__data__={hash:new oi,map:new(Ht||Gr),string:new oi}}a(uo,"mapCacheClear");var Af=uo;function po(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}a(po,"isKeyable");var Rf=po;function fo(t,e){var r=t.__data__;return Rf(e)?r[typeof e=="string"?"string":"hash"]:r.map}a(fo,"getMapData");var Jr=fo;function go(t){var e=Jr(this,t).delete(t);return this.size-=e?1:0,e}a(go,"mapCacheDelete");var Hf=go;function ho(t){return Jr(this,t).get(t)}a(ho,"mapCacheGet");var Df=ho;function mo(t){return Jr(this,t).has(t)}a(mo,"mapCacheHas");var Mf=mo;function yo(t,e){var r=Jr(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}a(yo,"mapCacheSet");var Nf=yo;function Fe(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(Fe,"MapCache");Fe.prototype.clear=Af;Fe.prototype.delete=Hf;Fe.prototype.get=Df;Fe.prototype.has=Mf;Fe.prototype.set=Nf;var Xr=Fe,$f="Expected a function";function Yr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError($f);var r=a(function(){var n=arguments,s=e?e.apply(this,n):n[0],i=r.cache;if(i.has(s))return i.get(s);var o=t.apply(this,n);return r.cache=i.set(s,o)||i,o},"memoized");return r.cache=new(Yr.Cache||Xr),r}a(Yr,"memoize");Yr.Cache=Xr;var jf=Yr,Kf=500;function vo(t){var e=jf(t,function(n){return r.size===Kf&&r.clear(),n}),r=e.cache;return e}a(vo,"memoizeCapped");var Uf=vo,zf=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ff=/\\(\\)?/g,Wf=Uf(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(zf,function(r,n,s,i){e.push(s?i.replace(Ff,"$1"):n||r)}),e}),Lf=Wf;function _o(t){return t==null?"":ju(t)}a(_o,"toString");var qf=_o;function To(t,e){return he(t)?t:es(t,e)?[t]:Lf(qf(t))}a(To,"castPath");var Qr=To,Vf=1/0;function bo(t){if(typeof t=="string"||Vn(t))return t;var e=t+"";return e=="0"&&1/t==-Vf?"-0":e}a(bo,"toKey");var jt=bo;function wo(t,e){e=Qr(e,t);for(var r=0,n=e.length;t!=null&&r<n;)t=t[jt(e[r++])];return r&&r==n?t:void 0}a(wo,"baseGet");var ts=wo;function Po(t,e,r){var n=t==null?void 0:ts(t,e);return n===void 0?r:n}a(Po,"get");var Gf=Po;function xo(t,e){for(var r=-1,n=e.length,s=t.length;++r<n;)t[s+r]=e[r];return t}a(xo,"arrayPush");var ko=xo,Jf=La(Object.getPrototypeOf,Object),So=Jf,Xf="[object Object]",Yf=Function.prototype,Qf=Object.prototype,Oo=Yf.toString,eg=Qf.hasOwnProperty,tg=Oo.call(Object);function Eo(t){if(!He(t)||$e(t)!=Xf)return!1;var e=So(t);if(e===null)return!0;var r=eg.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&Oo.call(r)==tg}a(Eo,"isPlainObject");var li=Eo;function Zo(){this.__data__=new Gr,this.size=0}a(Zo,"stackClear");var rg=Zo;function Io(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}a(Io,"stackDelete");var ng=Io;function Bo(t){return this.__data__.get(t)}a(Bo,"stackGet");var sg=Bo;function Co(t){return this.__data__.has(t)}a(Co,"stackHas");var ig=Co,ag=200;function Ao(t,e){var r=this.__data__;if(r instanceof Gr){var n=r.__data__;if(!Ht||n.length<ag-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Xr(n)}return r.set(t,e),this.size=r.size,this}a(Ao,"stackSet");var og=Ao;function We(t){var e=this.__data__=new Gr(t);this.size=e.size}a(We,"Stack");We.prototype.clear=rg;We.prototype.delete=ng;We.prototype.get=sg;We.prototype.has=ig;We.prototype.set=og;var er=We;function Ro(t,e){for(var r=-1,n=t==null?0:t.length,s=0,i=[];++r<n;){var o=t[r];e(o,r,t)&&(i[s++]=o)}return i}a(Ro,"arrayFilter");var lg=Ro;function Ho(){return[]}a(Ho,"stubArray");var Do=Ho,cg=Object.prototype,dg=cg.propertyIsEnumerable,ci=Object.getOwnPropertySymbols,ug=ci?function(t){return t==null?[]:(t=Object(t),lg(ci(t),function(e){return dg.call(t,e)}))}:Do,Mo=ug,pg=Object.getOwnPropertySymbols,fg=pg?function(t){for(var e=[];t;)ko(e,Mo(t)),t=So(t);return e}:Do,gg=fg;function No(t,e,r){var n=e(t);return he(t)?n:ko(n,r(t))}a(No,"baseGetAllKeys");var $o=No;function jo(t){return $o(t,Qn,Mo)}a(jo,"getAllKeys");var di=jo;function Ko(t){return $o(t,df,gg)}a(Ko,"getAllKeysIn");var hg=Ko,mg=Ke(me,"DataView"),Nn=mg,yg=Ke(me,"Promise"),$n=yg,vg=Ke(me,"Set"),jn=vg,ui="[object Map]",_g="[object Object]",pi="[object Promise]",fi="[object Set]",gi="[object WeakMap]",hi="[object DataView]",Tg=je(Nn),bg=je(Ht),wg=je($n),Pg=je(jn),xg=je(Dn),Ze=$e;(Nn&&Ze(new Nn(new ArrayBuffer(1)))!=hi||Ht&&Ze(new Ht)!=ui||$n&&Ze($n.resolve())!=pi||jn&&Ze(new jn)!=fi||Dn&&Ze(new Dn)!=gi)&&(Ze=a(function(t){var e=$e(t),r=e==_g?t.constructor:void 0,n=r?je(r):"";if(n)switch(n){case Tg:return hi;case bg:return ui;case wg:return pi;case Pg:return fi;case xg:return gi}return e},"getTag"));var mi=Ze,kg=me.Uint8Array,yi=kg,Sg="__lodash_hash_undefined__";function Uo(t){return this.__data__.set(t,Sg),this}a(Uo,"setCacheAdd");var Og=Uo;function zo(t){return this.__data__.has(t)}a(zo,"setCacheHas");var Eg=zo;function Dt(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Xr;++e<r;)this.add(t[e])}a(Dt,"SetCache");Dt.prototype.add=Dt.prototype.push=Og;Dt.prototype.has=Eg;var Zg=Dt;function Fo(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}a(Fo,"arraySome");var Ig=Fo;function Wo(t,e){return t.has(e)}a(Wo,"cacheHas");var Bg=Wo,Cg=1,Ag=2;function Lo(t,e,r,n,s,i){var o=r&Cg,l=t.length,d=e.length;if(l!=d&&!(o&&d>l))return!1;var f=i.get(t),g=i.get(e);if(f&&g)return f==e&&g==t;var m=-1,P=!0,E=r&Ag?new Zg:void 0;for(i.set(t,e),i.set(e,t);++m<l;){var I=t[m],U=e[m];if(n)var L=o?n(U,I,m,e,t,i):n(I,U,m,t,e,i);if(L!==void 0){if(L)continue;P=!1;break}if(E){if(!Ig(e,function(Q,ie){if(!Bg(E,ie)&&(I===Q||s(I,Q,r,n,i)))return E.push(ie)})){P=!1;break}}else if(!(I===U||s(I,U,r,n,i))){P=!1;break}}return i.delete(t),i.delete(e),P}a(Lo,"equalArrays");var qo=Lo;function Vo(t){var e=-1,r=Array(t.size);return t.forEach(function(n,s){r[++e]=[s,n]}),r}a(Vo,"mapToArray");var Rg=Vo;function Go(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}a(Go,"setToArray");var Hg=Go,Dg=1,Mg=2,Ng="[object Boolean]",$g="[object Date]",jg="[object Error]",Kg="[object Map]",Ug="[object Number]",zg="[object RegExp]",Fg="[object Set]",Wg="[object String]",Lg="[object Symbol]",qg="[object ArrayBuffer]",Vg="[object DataView]",vi=be?be.prototype:void 0,Zn=vi?vi.valueOf:void 0;function Jo(t,e,r,n,s,i,o){switch(r){case Vg:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case qg:return!(t.byteLength!=e.byteLength||!i(new yi(t),new yi(e)));case Ng:case $g:case Ug:return Xn(+t,+e);case jg:return t.name==e.name&&t.message==e.message;case zg:case Wg:return t==e+"";case Kg:var l=Rg;case Fg:var d=n&Dg;if(l||(l=Hg),t.size!=e.size&&!d)return!1;var f=o.get(t);if(f)return f==e;n|=Mg,o.set(t,e);var g=qo(l(t),l(e),n,s,i,o);return o.delete(t),g;case Lg:if(Zn)return Zn.call(t)==Zn.call(e)}return!1}a(Jo,"equalByTag");var Gg=Jo,Jg=1,Xg=Object.prototype,Yg=Xg.hasOwnProperty;function Xo(t,e,r,n,s,i){var o=r&Jg,l=di(t),d=l.length,f=di(e),g=f.length;if(d!=g&&!o)return!1;for(var m=d;m--;){var P=l[m];if(!(o?P in e:Yg.call(e,P)))return!1}var E=i.get(t),I=i.get(e);if(E&&I)return E==e&&I==t;var U=!0;i.set(t,e),i.set(e,t);for(var L=o;++m<d;){P=l[m];var Q=t[P],ie=e[P];if(n)var q=o?n(ie,Q,P,e,t,i):n(Q,ie,P,t,e,i);if(!(q===void 0?Q===ie||s(Q,ie,r,n,i):q)){U=!1;break}L||(L=P=="constructor")}if(U&&!L){var se=t.constructor,Ge=e.constructor;se!=Ge&&"constructor"in t&&"constructor"in e&&!(typeof se=="function"&&se instanceof se&&typeof Ge=="function"&&Ge instanceof Ge)&&(U=!1)}return i.delete(t),i.delete(e),U}a(Xo,"equalObjects");var Qg=Xo,eh=1,_i="[object Arguments]",Ti="[object Array]",Yt="[object Object]",th=Object.prototype,bi=th.hasOwnProperty;function Yo(t,e,r,n,s,i){var o=he(t),l=he(e),d=o?Ti:mi(t),f=l?Ti:mi(e);d=d==_i?Yt:d,f=f==_i?Yt:f;var g=d==Yt,m=f==Yt,P=d==f;if(P&&Mn(t)){if(!Mn(e))return!1;o=!0,g=!1}if(P&&!g)return i||(i=new er),o||Ua(t)?qo(t,e,r,n,s,i):Gg(t,e,d,r,n,s,i);if(!(r&eh)){var E=g&&bi.call(t,"__wrapped__"),I=m&&bi.call(e,"__wrapped__");if(E||I){var U=E?t.value():t,L=I?e.value():e;return i||(i=new er),s(U,L,r,n,i)}}return P?(i||(i=new er),Qg(t,e,r,n,s,i)):!1}a(Yo,"baseIsEqualDeep");var rh=Yo;function rs(t,e,r,n,s){return t===e?!0:t==null||e==null||!He(t)&&!He(e)?t!==t&&e!==e:rh(t,e,r,n,rs,s)}a(rs,"baseIsEqual");var en=rs,nh=1,sh=2;function Qo(t,e,r,n){var s=r.length,i=s,o=!n;if(t==null)return!i;for(t=Object(t);s--;){var l=r[s];if(o&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++s<i;){l=r[s];var d=l[0],f=t[d],g=l[1];if(o&&l[2]){if(f===void 0&&!(d in t))return!1}else{var m=new er;if(n)var P=n(f,g,d,t,e,m);if(!(P===void 0?en(g,f,nh|sh,n,m):P))return!1}}return!0}a(Qo,"baseIsMatch");var ih=Qo;function el(t){return t===t&&!nt(t)}a(el,"isStrictComparable");var tl=el;function rl(t){for(var e=Qn(t),r=e.length;r--;){var n=e[r],s=t[n];e[r]=[n,s,tl(s)]}return e}a(rl,"getMatchData");var ah=rl;function nl(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}a(nl,"matchesStrictComparable");var sl=nl;function il(t){var e=ah(t);return e.length==1&&e[0][2]?sl(e[0][0],e[0][1]):function(r){return r===t||ih(r,t,e)}}a(il,"baseMatches");var oh=il;function al(t,e){return t!=null&&e in Object(t)}a(al,"baseHasIn");var lh=al;function ol(t,e,r){e=Qr(e,t);for(var n=-1,s=e.length,i=!1;++n<s;){var o=jt(e[n]);if(!(i=t!=null&&r(t,o)))break;t=t[o]}return i||++n!=s?i:(s=t==null?0:t.length,!!s&&Yn(s)&&Jn(o,s)&&(he(t)||Da(t)))}a(ol,"hasPath");var ch=ol;function ll(t,e){return t!=null&&ch(t,e,lh)}a(ll,"hasIn");var dh=ll,uh=1,ph=2;function cl(t,e){return es(t)&&tl(e)?sl(jt(t),e):function(r){var n=Gf(r,t);return n===void 0&&n===e?dh(r,t):en(e,n,uh|ph)}}a(cl,"baseMatchesProperty");var fh=cl;function dl(t){return function(e){return e?.[t]}}a(dl,"baseProperty");var gh=dl;function ul(t){return function(e){return ts(e,t)}}a(ul,"basePropertyDeep");var hh=ul;function pl(t){return es(t)?gh(jt(t)):hh(t)}a(pl,"property");var mh=pl;function fl(t){return typeof t=="function"?t:t==null?Ku:typeof t=="object"?he(t)?fh(t[0],t[1]):oh(t):mh(t)}a(fl,"baseIteratee");var ns=fl;function gl(t){return function(e,r,n){for(var s=-1,i=Object(e),o=n(e),l=o.length;l--;){var d=o[t?l:++s];if(r(i[d],d,i)===!1)break}return e}}a(gl,"createBaseFor");var yh=gl,vh=yh(),_h=vh;function hl(t,e){return t&&_h(t,e,Qn)}a(hl,"baseForOwn");var Th=hl;function ml(t,e){return en(t,e)}a(ml,"isEqual");var tt=ml;function yl(t,e,r){r=typeof r=="function"?r:void 0;var n=r?r(t,e):void 0;return n===void 0?en(t,e,void 0,r):!!n}a(yl,"isEqualWith");var bh=yl;function vl(t){return t===void 0}a(vl,"isUndefined");var wi=vl;function _l(t,e){var r={};return e=ns(e,3),Th(t,function(n,s,i){ka(r,s,e(n,s,i))}),r}a(_l,"mapValues");var wh=_l,Ph="Expected a function";function Tl(t){if(typeof t!="function")throw new TypeError(Ph);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)}}a(Tl,"negate");var xh=Tl;function bl(t,e,r,n){if(!nt(t))return t;e=Qr(e,t);for(var s=-1,i=e.length,o=i-1,l=t;l!=null&&++s<i;){var d=jt(e[s]),f=r;if(d==="__proto__"||d==="constructor"||d==="prototype")return t;if(s!=o){var g=l[d];f=n?n(g,d,l):void 0,f===void 0&&(f=nt(g)?g:Jn(e[s+1])?[]:{})}up(l,d,f),l=l[d]}return t}a(bl,"baseSet");var kh=bl;function wl(t,e,r){for(var n=-1,s=e.length,i={};++n<s;){var o=e[n],l=ts(t,o);r(l,o)&&kh(i,Qr(o,t),l)}return i}a(wl,"basePickBy");var Sh=wl;function Pl(t,e){if(t==null)return{};var r=fa(hg(t),function(n){return[n]});return e=ns(e),Sh(t,r,function(n,s){return e(n,s[0])})}a(Pl,"pickBy");var Oh=Pl;function xl(t,e){return Oh(t,xh(ns(e)))}a(xl,"omitBy");var Pi=xl,Eh=a(t=>{let e=t.checks;return e.length===0?"":e.map(Zh).join("")},"generateStringChecks"),Zh=a(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"length":return`.length(${T(t.value)}, ${T(t.message)})`;case"email":return`.email(${T(t.message)})`;case"url":return`.url(${T(t.message)})`;case"emoji":return`.emoji(${T(t.message)})`;case"uuid":return`.uuid(${T(t.message)})`;case"cuid":return`.cuid(${T(t.message)})`;case"cuid2":return`.cuid2(${T(t.message)})`;case"ulid":return`.ulid(${T(t.message)})`;case"includes":let e=et({message:t.message,position:t.position});return`.includes(${T(t.value)}, ${e})`;case"startsWith":return`.startsWith(${T(t.value)}, ${T(t.message)})`;case"endsWith":return`.endsWith(${T(t.value)}, ${T(t.message)})`;case"regex":return`.regex(${String(t.regex)}, ${T(t.message)})`;case"trim":return".trim()";case"toLowerCase":return".toLowerCase()";case"toUpperCase":return".toUpperCase()";case"datetime":let n=t.precision===null?void 0:t.precision;return`.datetime(${et({message:t.message,precision:n,offset:t.offset})})`;case"ip":return`.ip(${et({message:t.message,version:t.version})})`;default:return""}},"_generateStringCheck"),Ih=a(t=>{let e=t.checks;return e.length===0?"":e.map(Bh).join("")},"generateNumberChecks"),Bh=a(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"int":return`.int(${T(t.message)})`;case"multipleOf":return`.multipleOf(${T(t.value)}, ${T(t.message)})`;case"finite":return`.finite(${T(t.message)})`;default:return""}},"_generateNumberCheck"),Ch=a(t=>{let e=t.checks;return e.length===0?"":e.map(Ah).join("")},"generateBigIntChecks"),Ah=a(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"multipleOf":return`.multipleOf(${T(t.value)}, ${T(t.message)})`;default:return""}},"_generateBigIntCheck"),Rh=a(t=>{let e=t.checks;return e.length===0?"":e.map(Hh).join("")},"generateDateChecks"),Hh=a(t=>{switch(t.kind){case"min":return`.min(${xi(t.value)}, ${T(t.message)})`;case"max":return`.max(${xi(t.value)}, ${T(t.message)})`;default:return""}},"_generateDateCheck"),xi=a(t=>`new Date(${t})`,"dateTs"),Dh=a(t=>{let e=[];if(t.exactLength){let{value:r,message:n}=t.exactLength;e.push(`.length(${T(r)}, ${T(n)})`)}if(t.minLength){let{value:r,message:n}=t.minLength;e.push(`.min(${T(r)}, ${T(n)})`)}if(t.maxLength){let{value:r,message:n}=t.maxLength;e.push(`.max(${T(r)}, ${T(n)})`)}return e.join("")},"generateArrayChecks"),Mh=a(t=>{let e=[];if(t.minSize){let{value:r,message:n}=t.minSize;e.push(`.min(${T(r)}, ${T(n)})`)}if(t.maxSize){let{value:r,message:n}=t.maxSize;e.push(`.max(${T(r)}, ${T(n)})`)}return e.join("")},"generateSetChecks");function ss(t){return N(t)}a(ss,"toTypescriptSchema");function N(t){let r=t._def;switch(r.typeName){case u.ZodFirstPartyTypeKind.ZodString:return`z.string()${Eh(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNumber:return`z.number()${Ih(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNaN:return`z.nan()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodBigInt:return`z.bigint()${Ch(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodBoolean:return`z.boolean()${R(r)}${A(t._def)}`.trim();case u.ZodFirstPartyTypeKind.ZodDate:return`z.date()${Rh(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodUndefined:return`z.undefined()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNull:return`z.null()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodAny:return`z.any()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodUnknown:return`z.unknown()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNever:return`z.never()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodVoid:return`z.void()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodArray:return`z.array(${N(r.type)})${Dh(r)}${R(r)}${A(r)}`;case u.ZodFirstPartyTypeKind.ZodObject:let n=wh(r.shape(),N),s=t.additionalProperties(),i=s?`.catchall(${N(s)})`:"";return["z.object({",...Object.entries(n).map(([cu,du])=>` ${cu}: ${du},`),`})${i}${R(r)}${A(r)}`].join(`
|
|
11
|
-
`).trim();case u.ZodFirstPartyTypeKind.ZodUnion:return`z.union([${r.options.map(N).join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let l=r.options.map(N);return`z.discriminatedUnion(${T(r.discriminator)}, [${l.join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodIntersection:let f=N(r.left),g=N(r.right);return`z.intersection(${f}, ${g})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodTuple:return`z.tuple([${r.items.map(N).join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodRecord:let P=N(r.keyType),E=N(r.valueType);return`z.record(${P}, ${E})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodMap:let I=N(r.keyType),U=N(r.valueType);return`z.map(${I}, ${U})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodSet:return`z.set(${N(r.valueType)})${Mh(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodFunction:let L=r.args.items.map(N),Q=L.length?`.args(${L.join(", ")})`:"",ie=N(r.returns);return`z.function()${Q}.returns(${ie})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodLazy:return`z.lazy(() => ${N(r.getter())})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodLiteral:return`z.literal(${T(r.value)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return`z.enum([${r.values.map(T).join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodEffects:throw new Ee(u.ZodFirstPartyTypeKind.ZodEffects);case u.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Ee(u.ZodFirstPartyTypeKind.ZodNativeEnum);case u.ZodFirstPartyTypeKind.ZodOptional:return`z.optional(${N(r.innerType)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNullable:return`z.nullable(${N(r.innerType)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodDefault:let Ge=et(r.defaultValue());return`z.default(${N(r.innerType)}, ${Ge})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodCatch:throw new Ee(u.ZodFirstPartyTypeKind.ZodCatch);case u.ZodFirstPartyTypeKind.ZodPromise:return`z.promise(${N(r.type)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodBranded:throw new Ee(u.ZodFirstPartyTypeKind.ZodBranded);case u.ZodFirstPartyTypeKind.ZodPipeline:throw new Ee(u.ZodFirstPartyTypeKind.ZodPipeline);case u.ZodFirstPartyTypeKind.ZodSymbol:throw new Ee(u.ZodFirstPartyTypeKind.ZodSymbol);case u.ZodFirstPartyTypeKind.ZodReadonly:return`z.readonly(${N(r.innerType)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodRef:return`z.ref(${T(r.uri)})${R(r)}${A(r)}`.trim();default:Z.assertNever(r)}}a(N,"sUnwrapZod");var A=a(t=>t.description?`.describe(${T(t.description)})`:"","_maybeDescribe"),R=a(t=>`${Nh(t)}${$h(t)}${jh(t)}${Kh(t)}${Uh(t)}${zh(t)}${Fh(t)}`,"_addZuiExtensions"),Nh=a(t=>{var e;return(e=t[b])!=null&&e.title?`.title(${T(t[b].title)})`:""},"_maybeTitle"),$h=a(t=>{var e;return(e=t[b])!=null&&e.displayAs?`.displayAs(${Ri({id:t[b].displayAs[0],params:t[b].displayAs[1]})})`:""},"_maybeDisplayAs"),jh=a(t=>{var e;return(e=t[b])!=null&&e.disabled?`.disabled(${t[b].disabled})`:""},"_maybeDisabled"),Kh=a(t=>{var e;return(e=t[b])!=null&&e.hidden?`.hidden(${t[b].hidden})`:""},"_maybeHidden"),Uh=a(t=>{var e;return(e=t[b])!=null&&e.placeholder?`.placeholder(${T(t[b].placeholder)})`:""},"_maybePlaceholder"),zh=a(t=>{var e;return(e=t[b])!=null&&e.secret?".secret()":""},"_maybeSecret"),Fh=a(t=>{var e;let r=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],n=Object.entries((e=t[b])!=null?e:{}).filter(([s])=>!r.includes(s));return n.length>0?`.metadata(${Ri(Object.fromEntries(n))})`:""},"_maybeSetMetadata"),Wh=a(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[b]&&(e[b]=t._def[b]);for(let r of t._def.checks)switch(r.kind){case"min":{let n=r.inclusive?"minimum":"exclusiveMinimum",s=r.inclusive?"exclusiveMinimum":"minimum";e[n]=r.value,delete e[s];break}case"max":{let n=r.inclusive?"maximum":"exclusiveMaximum",s=r.inclusive?"exclusiveMaximum":"maximum";e[n]=r.value,delete e[s];break}case"int":e.type="integer";break;case"finite":{e.format="finite";break}case"multipleOf":e.multipleOf=r.value;break;default:}return e},"zodNumberToJsonNumber"),kl="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",Sl="(([+-]\\d{2}(:?\\d{2})?)|Z)",Lh="Z",Ol="(\\.\\d+)?",Kn="\\.\\d{",qh="}",El=a(t=>{let e=t.precision?Kn+t.precision+qh:t.precision===0?"":Ol,r=t.offset?Sl:Lh;return new RegExp(`^${kl}${e}${r}$`)},"generateDatetimeRegex"),Vh=a(t=>({precision:Gh(t),offset:t.endsWith(`${Sl}$`)}),"extractPrecisionAndOffset"),Gh=a(t=>{let e=t.slice(1+kl.length);return e.startsWith(Ol)?null:e.startsWith(Kn)?parseInt(e.slice(Kn.length)):0},"_extractPrecision"),At={};Fr(At,{escapeSpecialChars:()=>Jh});var Jh=a(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function is(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage=p(c({},t.errorMessage),{[e]:r}))}a(is,"addErrorMessage");function H(t,e,r,n,s){t[e]=r,is(t,e,n,s)}a(H,"setResponseValueAndErrors");var j={cuid:"^[cC][^\\s-]{8,}$",cuid2:"^[a-z][a-z0-9]*$",ulid:"^[0-9A-HJKMNP-TV-Z]{26}$",email:"^(?!\\.)(?!.*\\.\\.)([a-zA-Z0-9_+-\\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\\-]*\\.)+[a-zA-Z]{2,}$",emoji:"^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",uuid:"^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$",ipv4:"^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$",ipv6:"^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$"};function as(t,e){let r=c({type:"string"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});function n(s){return e.patternStrategy==="escape"?At.escapeSpecialChars(s):s}if(a(n,"processPattern"),t.checks)for(let s of t.checks)switch(s.kind){case"min":H(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e);break;case"max":H(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Oe(r,"email",s.message,e);break;case"format:idn-email":Oe(r,"idn-email",s.message,e);break;case"pattern:zod":ue(r,j.email,s.message,e);break}break;case"url":Oe(r,"uri",s.message,e);break;case"uuid":Oe(r,"uuid",s.message,e);break;case"regex":ue(r,s.regex.source,s.message,e);break;case"cuid":ue(r,j.cuid,s.message,e);break;case"cuid2":ue(r,j.cuid2,s.message,e);break;case"startsWith":ue(r,"^"+n(s.value),s.message,e);break;case"endsWith":ue(r,n(s.value)+"$",s.message,e);break;case"datetime":Oe(r,"date-time",s.message,e);break;case"length":H(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e),H(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"includes":{ue(r,n(s.value),s.message,e);break}case"ip":{s.version!=="v6"&&Oe(r,"ipv4",s.message,e),s.version!=="v4"&&Oe(r,"ipv6",s.message,e);break}case"emoji":ue(r,j.emoji,s.message,e);break;case"ulid":{ue(r,j.ulid,s.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}a(as,"parseStringDef");var Oe=a((t,e,r,n)=>{var s;t.format||(s=t.anyOf)!=null&&s.some(i=>i.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push(c({format:t.format},t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}})),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push(c({format:e},r&&n.errorMessages&&{errorMessage:{format:r}}))):H(t,"format",e,r,n)},"addFormat"),ue=a((t,e,r,n)=>{var s;t.pattern||(s=t.allOf)!=null&&s.some(i=>i.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push(c({pattern:t.pattern},t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}})),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push(c({pattern:e},r&&n.errorMessages&&{errorMessage:{pattern:r}}))):H(t,"pattern",e,r,n)},"addPattern"),Xh=a(t=>{let e={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[b]&&(e[b]=t._def[b]);for(let r of t._def.checks)switch(r.kind){case"cuid":e.format="cuid",e.pattern=j.cuid;break;case"cuid2":e.format="cuid2",e.pattern=j.cuid2;break;case"ulid":e.format="ulid",e.pattern=j.ulid;break;case"uuid":e.format="uuid",e.pattern=j.uuid;break;case"emoji":e.format="emoji",e.pattern=j.emoji;break;case"email":e.format="email",e.pattern=j.email;break;case"ip":e.format=r.version==="v6"?"ipv6":"ipv4",e.pattern=r.version==="v6"?j.ipv6:j.ipv4;break;case"datetime":e.format="date-time",e.pattern=El(r).source,e[b]=p(c({},e[b]),{precision:r.precision,offset:r.offset});break;case"url":e.format="uri";break;case"endsWith":e.pattern=`${At.escapeSpecialChars(r.value)}$`;break;case"startsWith":e.pattern=`^${At.escapeSpecialChars(r.value)}`;break;case"includes":let n=r.position&&r.position>=1?`^(?:.{${r.position}}).*`:"";e.pattern=`${n}${At.escapeSpecialChars(r.value)}`;break;case"regex":e.pattern=r.regex.source;break;case"length":e.minLength=e.maxLength=Math.max(0,r.value);break;case"min":e.minLength=Math.max(0,r.value);break;case"max":e.maxLength=Math.max(0,r.value);break;default:throw new zi({zodType:u.ZodFirstPartyTypeKind.ZodString,checkKind:r.kind})}return e},"zodStringToJsonString"),Yh=a((t,e)=>{let r={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[b]&&(r[b]=t._def[b]),t._def.minLength&&(r.minItems=t._def.minLength.value),t._def.maxLength&&(r.maxItems=t._def.maxLength.value),t._def.exactLength&&(r.minItems=t._def.exactLength.value,r.maxItems=t._def.exactLength.value),r},"zodArrayToJsonArray"),Qh=a((t,e)=>{let r={type:"array",description:t.description,uniqueItems:!0,items:e(t._def.valueType),"x-zui":t._def["x-zui"]};return t._def[b]&&(r[b]=t._def[b]),t._def.minSize&&(r.minItems=t._def.minSize.value),t._def.maxSize&&(r.maxItems=t._def.maxSize.value),r},"zodSetToJsonSet"),em=a((t,e)=>{let r={type:"array",description:t.description,items:t._def.items.map(n=>e(n))};return t._def[b]&&(r[b]=t._def[b]),t._def.rest&&(r.additionalItems=e(t._def.rest)),r},"zodTupleToJsonTuple");function V(t){let e=t,r=e._def;switch(r.typeName){case u.ZodFirstPartyTypeKind.ZodString:return Xh(e);case u.ZodFirstPartyTypeKind.ZodNumber:return Wh(e);case u.ZodFirstPartyTypeKind.ZodNaN:throw new ee(u.ZodFirstPartyTypeKind.ZodNaN);case u.ZodFirstPartyTypeKind.ZodBigInt:throw new ee(u.ZodFirstPartyTypeKind.ZodBigInt,{suggestedAlternative:"serialize bigint to string"});case u.ZodFirstPartyTypeKind.ZodBoolean:return{type:"boolean",description:r.description,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodDate:throw new ee(u.ZodFirstPartyTypeKind.ZodDate,{suggestedAlternative:"use z.string().datetime() instead"});case u.ZodFirstPartyTypeKind.ZodUndefined:return In(r);case u.ZodFirstPartyTypeKind.ZodNull:return Bn(r);case u.ZodFirstPartyTypeKind.ZodAny:return{description:r.description,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodUnknown:return{description:r.description,"x-zui":p(c({},r["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodUnknown}})};case u.ZodFirstPartyTypeKind.ZodNever:return{not:!0,description:r.description,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodVoid:throw new ee(u.ZodFirstPartyTypeKind.ZodVoid);case u.ZodFirstPartyTypeKind.ZodArray:return Yh(e,V);case u.ZodFirstPartyTypeKind.ZodObject:let n=Object.entries(r.shape()),s=n.filter(([g,m])=>!m.isOptional()),i=s.length?s.map(([g])=>g):void 0,o=n.map(([g,m])=>[g,m.mandatory()]).map(([g,m])=>[g,V(m)]),l=!1;return r.unknownKeys instanceof u.ZodType?l=V(r.unknownKeys):r.unknownKeys==="passthrough"&&(l=!0),{type:"object",description:r.description,properties:Object.fromEntries(o),required:i,additionalProperties:l,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodUnion:return{description:r.description,anyOf:r.options.map(g=>V(g)),"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return{description:r.description,anyOf:r.options.map(g=>V(g)),"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodIntersection:let d=V(r.left),f=V(r.right);return"additionalProperties"in d&&delete d.additionalProperties,"additionalProperties"in f&&delete f.additionalProperties,{description:r.description,allOf:[d,f],"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodTuple:return em(e,V);case u.ZodFirstPartyTypeKind.ZodRecord:return{type:"object",description:r.description,additionalProperties:V(r.valueType),"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodMap:throw new ee(u.ZodFirstPartyTypeKind.ZodMap);case u.ZodFirstPartyTypeKind.ZodSet:return Qh(e,V);case u.ZodFirstPartyTypeKind.ZodFunction:throw new ee(u.ZodFirstPartyTypeKind.ZodFunction);case u.ZodFirstPartyTypeKind.ZodLazy:throw new ee(u.ZodFirstPartyTypeKind.ZodLazy);case u.ZodFirstPartyTypeKind.ZodLiteral:if(typeof r.value=="string")return{type:"string",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="number")return{type:"number",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="boolean")return{type:"boolean",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(r.value===null)return Bn(r);if(r.value===void 0)return In(r);{u.util.assertEqual(!0);let g=typeof r.value;throw new Lr(`Unsupported literal type: "${g}"`)}case u.ZodFirstPartyTypeKind.ZodEnum:return{type:"string",description:r.description,enum:r.values,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodEffects:throw new ee(u.ZodFirstPartyTypeKind.ZodEffects);case u.ZodFirstPartyTypeKind.ZodNativeEnum:throw new ee(u.ZodFirstPartyTypeKind.ZodNativeEnum);case u.ZodFirstPartyTypeKind.ZodOptional:return{description:r.description,anyOf:[V(r.innerType),In()],"x-zui":p(c({},r["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodOptional}})};case u.ZodFirstPartyTypeKind.ZodNullable:return{anyOf:[V(r.innerType),Bn()],"x-zui":p(c({},r["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodNullable}})};case u.ZodFirstPartyTypeKind.ZodDefault:return p(c({},V(r.innerType)),{default:r.defaultValue()});case u.ZodFirstPartyTypeKind.ZodCatch:throw new ee(u.ZodFirstPartyTypeKind.ZodCatch);case u.ZodFirstPartyTypeKind.ZodPromise:throw new ee(u.ZodFirstPartyTypeKind.ZodPromise);case u.ZodFirstPartyTypeKind.ZodBranded:throw new ee(u.ZodFirstPartyTypeKind.ZodBranded);case u.ZodFirstPartyTypeKind.ZodPipeline:throw new ee(u.ZodFirstPartyTypeKind.ZodPipeline);case u.ZodFirstPartyTypeKind.ZodSymbol:throw new ee(u.ZodFirstPartyTypeKind.ZodPipeline);case u.ZodFirstPartyTypeKind.ZodReadonly:return p(c({},V(r.innerType)),{readOnly:!0});case u.ZodFirstPartyTypeKind.ZodRef:return{$ref:r.uri,description:r.description,"x-zui":r["x-zui"]};default:u.util.assertNever(r)}}a(V,"toJSONSchema");var In=a(t=>({not:!0,description:t?.description,"x-zui":p(c({},t?.["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodUndefined}})}),"undefinedSchema"),Bn=a(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),Zl=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};a(Zl,"ParseInputLazyPath");var ae=Zl,ki=a((t,e)=>{if(it(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new le(t.common.issues);return this._error=r,this._error}}},"handleResult"),Il=class{constructor(e){this.__type__="ZuiType",this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._metadataRoot._def.description}dereference(e){return this}getReferences(){return[]}clone(){let e=this.constructor;return new e(c({},this._def))}_getType(e){return fe(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:fe(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:fe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Nt(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;let s={common:{issues:[],async:(n=r?.async)!=null?n:!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:fe(e)},i=this._parseSync({data:e,path:s.path,parent:s});return ki(s,i)}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:fe(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Nt(s)?s:Promise.resolve(s));return ki(n,i)}refine(e,r){let n=a(s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r,"getIssueProperties");return this._refinement((s,i)=>{let o=e(s),l=a(()=>i.addIssue(c({code:h.custom},n(s))),"setError");return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new Pe({schema:this,typeName:"ZodEffects",effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ge.create(this,this._def)}nullable(){return De.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ot.create(this,this._def)}promise(){return zt.create(this,this._def)}mandatory(){return this}or(e){return gn.create([this,e],this._def)}and(e){return on.create(this,e,this._def)}transform(e){return new Pe(p(c({},k(this._def)),{schema:this,typeName:"ZodEffects",effect:{type:"transform",transform:e}}))}default(e){let r=typeof e=="function"?e:()=>e;return new Kt(p(c({},k(this._def)),{innerType:this,defaultValue:r,typeName:"ZodDefault"}))}brand(){return new nn(c({typeName:"ZodBranded",type:this},k(this._def)))}catch(e){let r=typeof e=="function"?e:()=>e;return new sn(p(c({},k(this._def)),{innerType:this,catchValue:r,typeName:"ZodCatch"}))}describe(e){let r=this.clone();return r._metadataRoot._def.description=e,r}pipe(e){return fn.create(this,e)}readonly(){return Ft.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}metadata(e){var r,n,s;let i=this.clone(),o=i._metadataRoot;(s=(r=o._def)[n=b])!=null||(r[n]={});for(let[l,d]of Object.entries(e))o._def[b]=p(c({},o._def[b]),{[l]:d});return i}getMetadata(){return c({},this._metadataRoot._def[b])}setMetadata(e){this._metadataRoot._def[b]=c({},e)}get ui(){return c({},this._metadataRoot._def[b])}get _metadataRoot(){return this.naked()}displayAs(e){return this.metadata({displayAs:[e.id,e.params]})}title(e){return this.metadata({title:e})}hidden(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({hidden:r})}disabled(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({disabled:r})}placeholder(e){return this.metadata({placeholder:e})}toJSONSchema(){return V(this)}toTypescriptType(e){return qn(this,e)}toTypescriptSchema(){return ss(this)}naked(){return this}};a(Il,"ZodType");var O=Il,os=(t=>(t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodRef="ZodRef",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly",t))(os||{}),Z;(t=>{t.assertEqual=a(s=>s,"assertEqual");function e(s){}t.assertIs=e,a(e,"assertIs");function r(s){throw new Error("assertNever called")}t.assertNever=r,a(r,"assertNever"),t.arrayToEnum=a(s=>{let i={};for(let o of s)i[o]=o;return i},"arrayToEnum"),t.getValidEnumValues=a(s=>{let i=(0,t.objectKeys)(s).filter(l=>typeof s[s[l]]!="number"),o={};for(let l of i)o[l]=s[l];return(0,t.objectValues)(o)},"getValidEnumValues"),t.objectValues=a(s=>(0,t.objectKeys)(s).map(function(i){return s[i]}),"objectValues"),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=a((s,i)=>{for(let o of s)if(i(o))return o},"find"),t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=n,a(n,"joinValues"),t.jsonStringifyReplacer=a((s,i)=>typeof i=="bigint"?i.toString():i,"jsonStringifyReplacer"),t.compareFunctions=a((s,i)=>s.toString()===i.toString(),"compareFunctions"),t.mock=a(()=>({}),"mock")})(Z||(Z={}));var cr;(t=>{t.mergeShapes=a((e,r)=>c(c({},e),r),"mergeShapes")})(cr||(cr={}));var _=Z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),fe=a(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 k(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s,supportsExtensions:i,[b]:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);let l=o?Object.fromEntries(Object.entries(o).filter(([f])=>f!=="secret"||i?.includes("secret"))):void 0;return e?{errorMap:e,description:s,[b]:l}:{errorMap:a((f,g)=>f.code!=="invalid_type"?{message:g.defaultError}:typeof g.data>"u"?{message:n??g.defaultError}:{message:r??g.defaultError},"customMap"),description:s,[b]:l}}a(k,"processCreateParams");var ls=a((t,e)=>{let r;switch(t.code){case h.invalid_type:t.received===_.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case h.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Z.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:r=`Unrecognized key(s) in object: ${Z.joinValues(t.keys,", ")}`;break;case h.invalid_union:r="Invalid input";break;case h.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Z.joinValues(t.options)}`;break;case h.invalid_enum_value:r=`Invalid enum value. Expected ${Z.joinValues(t.options)}, received '${t.received}'`;break;case h.invalid_arguments:r="Invalid function arguments";break;case h.invalid_return_type:r="Invalid function return type";break;case h.invalid_date:r="Invalid date";break;case h.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Z.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case h.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case h.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case h.custom:r="Invalid input";break;case h.invalid_intersection_types:r="Intersection results could not be merged";break;case h.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case h.not_finite:r="Number must be finite";break;case h.unresolved_reference:r="Unresolved reference";break;default:r=e.defaultError,Z.assertNever(t)}return{message:r}},"errorMap"),Si=ls,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"]),Bl=a(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),dr=class Cl extends Error{constructor(e){super(),this.issues=[],this.addIssue=a(n=>{this.issues=[...this.issues,n]},"addIssue"),this.addIssues=a((n=[])=>{this.issues=[...this.issues,...n]},"addIssues");let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let r=e||function(i){return i.message},n={_errors:[]},s=a(i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let l=n,d=0;for(;d<o.path.length;){let f=o.path[d];d===o.path.length-1?(l[f]=l[f]||{_errors:[]},l[f]._errors.push(r(o))):l[f]=l[f]||{_errors:[]},l=l[f],d++}}},"processError");return s(this),n}static assert(e){if(!(e instanceof Cl))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Z.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};a(dr,"ZodError");dr.create=a(t=>new dr(t),"create");var le=dr,Al=ls;function cs(t){Al=t}a(cs,"setErrorMap");function st(){return Al}a(st,"getErrorMap");var Mt=a(t=>{var e;let{data:r,path:n,errorMaps:s,issueData:i}=t,o=[...n,...i.path||[]],l=p(c({},i),{path:o}),d="",f=s.filter(g=>!!g).slice().reverse();for(let g of f)d=g(l,{data:r,defaultError:d}).message;return p(c({},i),{path:o,message:(e=i.message)!=null?e:d})},"makeIssue"),Rl=[];function v(t,e){let r=Mt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,st(),ls].filter(n=>!!n)});t.common.issues.push(r)}a(v,"addIssueToContext");var Hl=class Dl{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return x;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r)n.push({key:await s.key,value:await s.value});return Dl.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return x;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}};a(Hl,"ParseStatus");var te=Hl,x=Object.freeze({status:"aborted"}),Re=a(t=>({status:"dirty",value:t}),"DIRTY"),J=a(t=>({status:"valid",value:t}),"OK"),ur=a(t=>t.status==="aborted","isAborted"),pr=a(t=>t.status==="dirty","isDirty"),it=a(t=>t.status==="valid","isValid"),Nt=a(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),w;(t=>{t.errToObj=a(e=>typeof e=="string"?{message:e}:e||{},"errToObj"),t.toString=a(e=>typeof e=="string"?e:e?.message,"toString")})(w||(w={}));var fr=class Ml extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return J(e.data)}isEqual(e){return e instanceof Ml}};a(fr,"ZodAny");fr.create=a(t=>new fr(c({typeName:"ZodAny"},k(t))),"create");var at=fr,gr=class Ie extends O{dereference(e){return new Ie(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Ie(p(c({},this._def),{type:this._def.type.clone()}))}isEqual(e){var r,n,s,i,o,l;return e instanceof Ie?tt((r=this._def.exactLength)==null?void 0:r.value,(n=e._def.exactLength)==null?void 0:n.value)&&tt((s=this._def.maxLength)==null?void 0:s.value,(i=e._def.maxLength)==null?void 0:i.value)&&tt((o=this._def.minLength)==null?void 0:o.value,(l=e._def.minLength)==null?void 0:l.value)&&this._def.type.isEqual(e._def.type):!1}_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==_.array)return v(r,{code:h.invalid_type,expected:_.array,received:r.parsedType}),x;if(s.exactLength!==null){let o=r.data.length>s.exactLength.value,l=r.data.length<s.exactLength.value;(o||l)&&(v(r,{code:o?h.too_big:h.too_small,minimum:l?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(v(r,{code:h.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(v(r,{code:h.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,l)=>s.type._parseAsync(new ae(r,o,r.path,l)))).then(o=>te.mergeArray(n,o));let i=[...r.data].map((o,l)=>s.type._parseSync(new ae(r,o,r.path,l)));return te.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new Ie(p(c({},this._def),{minLength:{value:e,message:w.toString(r)}}))}max(e,r){return new Ie(p(c({},this._def),{maxLength:{value:e,message:w.toString(r)}}))}length(e,r){return new Ie(p(c({},this._def),{exactLength:{value:e,message:w.toString(r)}}))}nonempty(e){return this.min(1,e)}};a(gr,"ZodArray");gr.create=a((t,e)=>new gr(c({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},k(e))),"create");var ot=gr,tm=a((t,e)=>Nl(t,e,new WeakSet),"isEqual"),Nl=a((t,e,r)=>bh(t,e,rm(r)),"_isEqualWithVisitedTracking"),rm=a(t=>(e,r)=>{if(li(e)&&!t.has(e)&&li(r)&&!t.has(r)){let n=Pi(e,wi),s=Pi(r,wi);return t.add(n).add(s).add(e).add(r),Nl(n,s,t)}},"_customizerWithVisitedTracking"),nm={compare:tm},$l=class{constructor(e=[],r={}){this._options=c(c({},nm),r),this._items=[];for(let n of e)this.add(n)}get items(){return[...this._items]}get size(){return this._items.length}has(e){return this._items.some(r=>this._options.compare(r,e))}add(e){this.has(e)||this._items.push(e)}isEqual(e){return this.size!==e.size?!1:this.isSubsetOf(e)&&e.isSubsetOf(this)}isSubsetOf(e){return this.size>e.size?!1:this._items.every(r=>e.has(r))}};a($l,"CustomSet");var K=$l,hr=class tr extends O{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 i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.bigint,received:i.parsedType}),x}let n,s=new te;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Z.assertNever(i);return{status:s.value,value:e.data}}isEqual(e){if(!(e instanceof tr)||this._def.coerce!==e._def.coerce)return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}gte(e,r){return this.setLimit("min",e,!0,w.toString(r))}gt(e,r){return this.setLimit("min",e,!1,w.toString(r))}lte(e,r){return this.setLimit("max",e,!0,w.toString(r))}lt(e,r){return this.setLimit("max",e,!1,w.toString(r))}setLimit(e,r,n,s){return new tr(p(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:w.toString(s)}]}))}_addCheck(e){return new tr(p(c({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};a(hr,"ZodBigInt");hr.create=a(t=>{var e;return new hr(c({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},k(t)))},"create");var tn=hr,mr=class jl extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.boolean,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof jl?this._def.coerce===e._def.coerce:!1}};a(mr,"ZodBoolean");mr.create=a(t=>new mr(c({typeName:"ZodBoolean",coerce:t?.coerce||!1},k(t))),"create");var rn=mr,Kl=Symbol("zod_brand"),Ul=class Tt extends O{dereference(e){return new Tt(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Tt(p(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}isEqual(e){return e instanceof Tt?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new Tt(p(c({},this._def),{type:this._def.type.mandatory()}))}};a(Ul,"ZodBranded");var nn=Ul,yr=class bt extends O{_parse(e){let{ctx:r}=this._processInputParams(e),n=p(c({},r),{common:p(c({},r.common),{issues:[]})}),s=this._def.innerType._parse({data:n.data,path:n.path,parent:c({},n)});return Nt(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new le(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new le(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof bt?this._def.innerType.isEqual(e._def.innerType)&&Z.compareFunctions(this._def.catchValue,e._def.catchValue):!1}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()}))}naked(){return this._def.innerType.naked()}mandatory(){return new bt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(yr,"ZodCatch");yr.create=a((t,e)=>new yr(c({innerType:t,typeName:"ZodCatch",catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},k(e))),"create");var sn=yr,ds=a((t,e={},r)=>t?at.create().superRefine((n,s)=>{var i,o;if(!t(n)){let l=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,d=(o=(i=l.fatal)!=null?i:r)!=null?o:!0,f=typeof l=="string"?{message:l}:l;s.addIssue(p(c({code:"custom"},f),{fatal:d}))}}):at.create(),"custom"),vr=class Un extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.date,received:i.parsedType}),x}if(isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_date}),x}let n=new te,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Z.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Un(p(c({},this._def),{checks:[...this._def.checks,e]}))}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}isEqual(e){if(!(e instanceof Un))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)&&this._def.coerce===e._def.coerce}};a(vr,"ZodDate");vr.create=a(t=>new vr(c({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},k(t))),"create");var an=vr,_r=class wt extends O{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===_.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}dereference(e){return new 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()}))}isEqual(e){return e instanceof wt?this._def.innerType.isEqual(e._def.innerType)&&tt(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new wt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(_r,"ZodDefault");_r.create=a((t,e,r)=>new _r(c({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},k(r))),"create");var Kt=_r,ye=a(t=>Array.from(new Set(t)),"unique"),pe=a(t=>t instanceof ln?pe(t.schema):t instanceof Pe?pe(t.innerType()):t instanceof cn?[t.value]:t instanceof Le?t.options:t instanceof dn?Z.objectValues(t.enum):t instanceof Kt?pe(t._def.innerType):t instanceof Wt?[void 0]:t instanceof un?[null]:t instanceof ge?[void 0,...pe(t.unwrap())]:t instanceof De?[null,...pe(t.unwrap())]:t instanceof nn||t instanceof Ft?pe(t.unwrap()):t instanceof sn?pe(t._def.innerType):[],"getDiscriminator"),zl=class Be extends O{dereference(e){let r=this.options.map(s=>s.dereference(e)),n=Be._getOptionsMap(this.discriminator,r);return new Be(p(c({},this._def),{options:r,optionsMap:n}))}getReferences(){return ye(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(r=>r.clone());return new Be(p(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.object)return v(r,{code:h.invalid_type,expected:_.object,received:r.parsedType}),x;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(v(r,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=Be._getOptionsMap(e,r);return new Be(c({typeName:"ZodDiscriminatedUnion",discriminator:e,options:r,optionsMap:s},k(n)))}static _getOptionsMap(e,r){let n=new Map;for(let s of r){let i=pe(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,s)}}return n}isEqual(e){if(!(e instanceof Be)||this._def.discriminator!==e._def.discriminator)return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K(this._def.options,{compare:r}),s=new K(e._def.options,{compare:r});return n.isEqual(s)}};a(zl,"ZodDiscriminatedUnion");var us=zl;function Ut(t,e){return new Le(c({values:t,typeName:"ZodEnum"},k(e)))}a(Ut,"createZodEnum");var ps=class rr extends O{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return v(r,{expected:Z.joinValues(n),received:r.parsedType,code:h.invalid_type}),x}if(this._def.values.indexOf(e.data)===-1){let r=this._getOrReturnCtx(e),n=this._def.values;return v(r,{received:r.data,code:h.invalid_enum_value,options:n}),x}return J(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return rr.create(e,c(c({},this._def),r))}exclude(e,r=this._def){return rr.create(this.options.filter(n=>!e.includes(n)),c(c({},this._def),r))}isEqual(e){if(!(e instanceof rr))return!1;let r=new K(this._def.values),n=new K(e._def.values);return r.isEqual(n)}};a(ps,"ZodEnum");ps.create=Ut;var Le=ps,Fl=class Ce extends O{constructor(){super(...arguments),this.validate=this.implement}dereference(e){let r=this._def.args.dereference(e),n=this._def.returns.dereference(e);return new Ce(p(c({},this._def),{args:r,returns:n}))}getReferences(){return ye([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new Ce(p(c({},this._def),{args:this._def.args.clone(),returns:this._def.returns.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.function)return v(r,{code:h.invalid_type,expected:_.function,received:r.parsedType}),x;function n(l,d){return Mt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,st(),Si].filter(f=>!!f),issueData:{code:h.invalid_arguments,argumentsError:d}})}a(n,"makeArgsIssue");function s(l,d){return Mt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,st(),Si].filter(f=>!!f),issueData:{code:h.invalid_return_type,returnTypeError:d}})}a(s,"makeReturnsIssue");let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof zt){let l=this;return J(async function(...d){let f=new le([]),g=await l._def.args.parseAsync(d,i).catch(E=>{throw f.addIssue(n(d,E)),f}),m=await Reflect.apply(o,this,g);return await l._def.returns._def.type.parseAsync(m,i).catch(E=>{throw f.addIssue(s(m,E)),f})})}else{let l=this;return J(function(...d){let f=l._def.args.safeParse(d,i);if(!f.success)throw new le([n(d,f.error)]);let g=Reflect.apply(o,this,f.data),m=l._def.returns.safeParse(g,i);if(!m.success)throw new le([s(g,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ce(p(c({},this._def),{args:Ne.create(e).rest(rt.create())}))}returns(e){return new Ce(p(c({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Ce(c({args:e||Ne.create([]).rest(rt.create()),returns:r||rt.create(),typeName:"ZodFunction"},k(n)))}isEqual(e){return e instanceof Ce&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};a(Fl,"ZodFunction");var fs=Fl;function Tr(t,e){let r=fe(t),n=fe(e);if(t===e)return{valid:!0,data:t};if(r===_.object&&n===_.object){let s=Z.objectKeys(e),i=Z.objectKeys(t).filter(l=>s.indexOf(l)!==-1),o=c(c({},t),e);for(let l of i){let d=Tr(t[l],e[l]);if(!d.valid)return{valid:!1};o[l]=d.data}return{valid:!0,data:o}}else if(r===_.array&&n===_.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],l=e[i],d=Tr(o,l);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return r===_.date&&n===_.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}a(Tr,"mergeValues");var br=class nr extends O{dereference(e){return new nr(p(c({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return ye([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new nr(p(c({},this._def),{left:this._def.left.clone(),right:this._def.right.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=a((i,o)=>{if(ur(i)||ur(o))return x;let l=Tr(i.value,o.value);return l.valid?((pr(i)||pr(o))&&r.dirty(),{status:r.value,value:l.data}):(v(n,{code:h.invalid_intersection_types}),x)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}isEqual(e){if(!(e instanceof nr))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K([this._def.left,this._def.right],{compare:r}),s=new K([e._def.left,e._def.right],{compare:r});return n.isEqual(s)}};a(br,"ZodIntersection");br.create=a((t,e,r)=>new br(c({left:t,right:e,typeName:"ZodIntersection"},k(r))),"create");var on=br,wr=class Pt extends O{get schema(){return this._def.getter()}dereference(e){return new Pt(p(c({},this._def),{getter:a(()=>this._def.getter().dereference(e),"getter")}))}getReferences(){return this._def.getter().getReferences()}clone(){return new Pt(p(c({},this._def),{getter:a(()=>this._def.getter().clone(),"getter")}))}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}isEqual(e){return e instanceof Pt?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new Pt(p(c({},this._def),{getter:a(()=>this._def.getter().mandatory(),"getter")}))}};a(wr,"ZodLazy");wr.create=a((t,e)=>new wr(c({getter:t,typeName:"ZodLazy"},k(e))),"create");var ln=wr,Pr=class Wl extends O{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return v(r,{received:r.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 Wl?tt(this._def.value,e._def.value):!1}};a(Pr,"ZodLiteral");Pr.create=a((t,e)=>new Pr(c({value:t,typeName:"ZodLiteral"},k(e))),"create");var cn=Pr,xr=class sr extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new sr(p(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return ye([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new sr(p(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.map)return v(n,{code:h.invalid_type,expected:_.map,received:n.parsedType}),x;let s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([l,d],f)=>({key:s._parse(new ae(n,l,n.path,[f,"key"])),value:i._parse(new ae(n,d,n.path,[f,"value"]))}));if(n.common.async){let l=new Map;return Promise.resolve().then(async()=>{for(let d of o){let f=await d.key,g=await d.value;if(f.status==="aborted"||g.status==="aborted")return x;(f.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(f.value,g.value)}return{status:r.value,value:l}})}else{let l=new Map;for(let d of o){let f=d.key,g=d.value;if(f.status==="aborted"||g.status==="aborted")return x;(f.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(f.value,g.value)}return{status:r.value,value:l}}}isEqual(e){return!(!(e instanceof sr)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};a(xr,"ZodMap");xr.create=a((t,e,r)=>new xr(c({valueType:e,keyType:t,typeName:"ZodMap"},k(r))),"create");var gs=xr,kr=class Ll extends O{_parse(e){if(this._getType(e)!==_.nan){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.nan,received:n.parsedType}),x}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Ll}};a(kr,"ZodNaN");kr.create=a(t=>new kr(c({typeName:"ZodNaN"},k(t))),"create");var hs=kr,Sr=class ql extends O{_parse(e){let r=Z.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==_.string&&n.parsedType!==_.number){let s=Z.objectValues(r);return v(n,{expected:Z.joinValues(s),received:n.parsedType,code:h.invalid_type}),x}if(r.indexOf(e.data)===-1){let s=Z.objectValues(r);return v(n,{received:n.data,code:h.invalid_enum_value,options:s}),x}return J(e.data)}get enum(){return this._def.values}isEqual(e){return e instanceof ql?tt(this._def.values,e._def.values):!1}};a(Sr,"ZodNativeEnum");Sr.create=a((t,e)=>new Sr(c({values:t,typeName:"ZodNativeEnum"},k(e))),"create");var dn=Sr,Or=class Vl extends O{_parse(e){let r=this._getOrReturnCtx(e);return v(r,{code:h.invalid_type,expected:_.never,received:r.parsedType}),x}isEqual(e){return e instanceof Vl}};a(Or,"ZodNever");Or.create=a(t=>new Or(c({typeName:"ZodNever"},k(t))),"create");var dt=Or,Er=class Gl extends O{_parse(e){if(this._getType(e)!==_.null){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.null,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof Gl}};a(Er,"ZodNull");Er.create=a(t=>new Er(c({typeName:"ZodNull"},k(t))),"create");var un=Er,Zr=class xt extends O{dereference(e){return new xt(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new xt(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.null?J(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof xt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new xt(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Zr,"ZodNullable");Zr.create=a((t,e)=>new Zr(c({innerType:t,typeName:"ZodNullable"},k(e))),"create");var De=Zr;function Jl(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=parseInt(t.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return i%o/Math.pow(10,s)}a(Jl,"floatSafeRemainder");var Ir=class ir extends O{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 i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.number,received:i.parsedType}),x}let n,s=new te;for(let i of this._def.checks)i.kind==="int"?Z.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:h.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Jl(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:h.not_finite,message:i.message}),s.dirty()):Z.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,w.toString(r))}gt(e,r){return this.setLimit("min",e,!1,w.toString(r))}lte(e,r){return this.setLimit("max",e,!0,w.toString(r))}lt(e,r){return this.setLimit("max",e,!1,w.toString(r))}setLimit(e,r,n,s){return new ir(p(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:w.toString(s)}]}))}_addCheck(e){return new ir(p(c({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Z.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}isEqual(e){if(!(e instanceof ir))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}};a(Ir,"ZodNumber");Ir.create=a(t=>new Ir(c({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},k(t))),"create");var pn=Ir;function Ae(t){if(t instanceof Me){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=ge.create(Ae(n))}return new Me(p(c({},t._def),{shape:a(()=>e,"shape")}))}else return t instanceof ot?new ot(p(c({},t._def),{type:Ae(t.element)})):t instanceof ge?ge.create(Ae(t.unwrap())):t instanceof De?De.create(Ae(t.unwrap())):t instanceof Ne?Ne.create(t.items.map(e=>Ae(e))):t}a(Ae,"deepPartialify");var we=class ne extends O{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Z.objectKeys(e);return this._cached={shape:e,keys:r}}dereference(e){let r=this._def.shape(),n={};for(let s in r)n[s]=r[s].dereference(e);return new ne(p(c({},this._def),{shape:a(()=>n,"shape")}))}getReferences(){let e=this._def.shape(),r=[];for(let n in e)r.push(...e[n].getReferences());return ye(r)}clone(){let e={},r=this._def.shape();for(let[n,s]of Object.entries(r))e[n]=s.clone();return new ne(p(c({},this._def),{shape:a(()=>e,"shape")}))}_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:n,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),l=[];if(this._def.unknownKeys!=="strip")for(let g in s.data)o.includes(g)||l.push(g);let d=[];for(let g of o){let m=i[g],P=s.data[g];d.push({key:{status:"valid",value:g},value:m._parse(new ae(s,P,s.path,g)),alwaysSet:g in s.data})}let f=this._def.unknownKeys;if(f==="passthrough")for(let g of l)d.push({key:{status:"valid",value:g},value:{status:"valid",value:s.data[g]}});else if(f==="strict")l.length>0&&(v(s,{code:h.unrecognized_keys,keys:l}),n.dirty());else if(f!=="strip")for(let g of l){let m=s.data[g];d.push({key:{status:"valid",value:g},value:f._parse(new ae(s,m,s.path,g)),alwaysSet:g in s.data})}return s.common.async?Promise.resolve().then(async()=>{let g=[];for(let m of d){let P=await m.key;g.push({key:P,value:await m.value,alwaysSet:m.alwaysSet})}return g}).then(g=>te.mergeObjectSync(n,g)):te.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new ne(c(p(c({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:a((r,n)=>{var s,i,o,l;let d=(o=(i=(s=this._def).errorMap)==null?void 0:i.call(s,r,n).message)!=null?o:n.defaultError;return r.code==="unrecognized_keys"?{message:(l=w.errToObj(e).message)!=null?l:d}:{message:d}},"errorMap")}:{}))}strip(){return new ne(p(c({},this._def),{unknownKeys:"strip"}))}passthrough(){return new ne(p(c({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(this._def.unknownKeys instanceof O)return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return at.create();if(this._def.unknownKeys==="strict")return dt.create()}extend(e){return new ne(p(c({},this._def),{shape:a(()=>c(c({},this._def.shape()),e),"shape")}))}merge(e){return new ne({unknownKeys:e._def.unknownKeys,shape:a(()=>c(c({},this._def.shape()),e._def.shape()),"shape"),typeName:"ZodObject"})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new ne(p(c({},this._def),{unknownKeys:e}))}pick(e){let r={};return Z.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new ne(p(c({},this._def),{shape:a(()=>r,"shape")}))}omit(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new ne(p(c({},this._def),{shape:a(()=>r,"shape")}))}deepPartial(){return Ae(this)}partial(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s?.optional()}),new ne(p(c({},this._def),{shape:a(()=>r,"shape")}))}required(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof ge;)i=i._def.innerType;r[n]=i}}),new ne(p(c({},this._def),{shape:a(()=>r,"shape")}))}keyof(){return Ut(Z.objectKeys(this.shape))}isEqual(e){if(!(e instanceof ne)||!this._unknownKeysEqual(e))return!1;let r=this._def.shape(),n=e._def.shape(),s=a((l,d)=>l[0]===d[0]&&l[1].isEqual(d[1]),"compare"),i=new K(Object.entries(r),{compare:s}),o=new K(Object.entries(n),{compare:s});return i.isEqual(o)}_unknownKeysEqual(e){let r=this.additionalProperties(),n=e.additionalProperties();return r===void 0||n===void 0?r===n:r.isEqual(n)}};a(we,"ZodObject");we.create=a((t,e)=>new we(c({shape:a(()=>t,"shape"),unknownKeys:"strip",typeName:"ZodObject"},k(e))),"create");we.strictCreate=a((t,e)=>new we(c({shape:a(()=>t,"shape"),unknownKeys:"strict",typeName:"ZodObject"},k(e))),"strictCreate");we.lazycreate=a((t,e)=>new we(c({shape:t,unknownKeys:"strip",typeName:"ZodObject"},k(e))),"lazycreate");var Me=we,Br=class ar extends O{dereference(e){return new ar(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new ar(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.undefined?J(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof ar?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return this._def.innerType.mandatory()}};a(Br,"ZodOptional");Br.create=a((t,e)=>new Br(c({innerType:t,typeName:"ZodOptional"},k(e))),"create");var ge=Br,Xl=class kt extends O{dereference(e){return new kt(p(c({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return ye([...this._def.in.getReferences(),...this._def.out.getReferences()])}clone(){return new kt(p(c({},this._def),{in:this._def.in.clone(),out:this._def.out.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return a(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?x:i.status==="dirty"?(r.dirty(),Re(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})},"handleAsync")();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?x:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new kt({in:e,out:r,typeName:"ZodPipeline"})}isEqual(e){return!(!(e instanceof kt)||!this._def.in.isEqual(e._def.in)||!this._def.out.isEqual(e._def.out))}};a(Xl,"ZodPipeline");var fn=Xl,Cr=class or extends O{unwrap(){return this._def.type}dereference(e){return new or(p(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new or(p(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.promise&&r.common.async===!1)return v(r,{code:h.invalid_type,expected:_.promise,received:r.parsedType}),x;let n=r.parsedType===_.promise?r.data:Promise.resolve(r.data);return J(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}isEqual(e){return e instanceof or?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}};a(Cr,"ZodPromise");Cr.create=a((t,e)=>new Cr(c({type:t,typeName:"ZodPromise"},k(e))),"create");var zt=Cr,Ar=class St extends O{dereference(e){return new St(p(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new St(p(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){let r=this._def.innerType._parse(e);return it(r)&&(r.value=Object.freeze(r.value)),r}unwrap(){return this._def.innerType}isEqual(e){return e instanceof St?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new St(p(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Ar,"ZodReadonly");Ar.create=a((t,e)=>new Ar(c({innerType:t,typeName:"ZodReadonly"},k(e))),"create");var Ft=Ar,Yl=class Xe extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new Xe(p(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return ye([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new Xe(p(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.object)return v(n,{code:h.invalid_type,expected:_.object,received:n.parsedType}),x;let s=[],i=this._def.keyType,o=this._def.valueType;for(let l in n.data)s.push({key:i._parse(new ae(n,l,n.path,l)),value:o._parse(new ae(n,n.data[l],n.path,l))});return n.common.async?te.mergeObjectAsync(r,s):te.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof O?new Xe(c({keyType:e,valueType:r,typeName:"ZodRecord"},k(n))):new Xe(c({keyType:X.create(),valueType:e,typeName:"ZodRecord"},k(r)))}isEqual(e){return!(!(e instanceof Xe)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};a(Yl,"ZodRecord");var ms=Yl,Rr=class Ql extends O{dereference(e){let r=e[this._def.uri];return r||this}getReferences(){return[this._def.uri]}_parse(e){let r=this._getOrReturnCtx(e);return v(r,{code:h.unresolved_reference}),x}isOptional(){return!1}isNullable(){return!1}isEqual(e){return e instanceof Ql?this._def.uri===e._def.uri:!1}};a(Rr,"ZodRef");Rr.create=a(t=>new Rr({typeName:"ZodRef",uri:t}),"create");var ys=Rr,Hr=class Ye extends O{dereference(e){return new Ye(p(c({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new Ye(p(c({},this._def),{valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.set)return v(n,{code:h.invalid_type,expected:_.set,received:n.parsedType}),x;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(v(n,{code:h.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(v(n,{code:h.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function o(d){let f=new Set;for(let g of d){if(g.status==="aborted")return x;g.status==="dirty"&&r.dirty(),f.add(g.value)}return{status:r.value,value:f}}a(o,"finalizeSet");let l=[...n.data.values()].map((d,f)=>i._parse(new ae(n,d,n.path,f)));return n.common.async?Promise.all(l).then(d=>o(d)):o(l)}min(e,r){return new Ye(p(c({},this._def),{minSize:{value:e,message:w.toString(r)}}))}max(e,r){return new Ye(p(c({},this._def),{maxSize:{value:e,message:w.toString(r)}}))}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}isEqual(e){var r,n,s,i;if(!(e instanceof Ye))return!1;let o=(r=this._def.minSize)==null?void 0:r.value,l=(n=e._def.minSize)==null?void 0:n.value;if(o!==l)return!1;let d=(s=this._def.maxSize)==null?void 0:s.value,f=(i=e._def.maxSize)==null?void 0:i.value;return d!==f?!1:this._def.valueType.isEqual(e._def.valueType)}};a(Hr,"ZodSet");Hr.create=a((t,e)=>new Hr(c({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},k(e))),"create");var vs=Hr,_s=/^c[^\s-]{8,}$/i,Ts=/^[a-z][a-z0-9]*$/,bs=/^[0-9A-HJKMNP-TV-Z]{26}$/,ws=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Ps=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ec="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",tc=a(t=>t===ec,"isEmojiRegex"),Cn,xs=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,ks=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;function rc(t,e){return!!((e==="v4"||!e)&&xs.test(t)||(e==="v6"||!e)&&ks.test(t))}a(rc,"isValidIP");var Dr=class Qe extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.string,received:i.parsedType}),x}let n=new te,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,l=e.data.length<i.value;(o||l)&&(s=this._getOrReturnCtx(e,s),o?v(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&v(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")Ps.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"email",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Cn||(Cn=new RegExp(ec,"u")),Cn.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"emoji",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")ws.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"uuid",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")_s.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"cuid",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")Ts.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"cuid2",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")bs.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ulid",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),v(s,{validation:"url",code:h.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"regex",code:h.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?El(i).test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="ip"?rc(e.data,i.version)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ip",code:h.invalid_string,message:i.message}),n.dirty()):Z.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),c({validation:r,code:h.invalid_string},w.errToObj(n)))}_addCheck(e){return new Qe(p(c({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(c({kind:"email"},w.errToObj(e)))}url(e){return this._addCheck(c({kind:"url"},w.errToObj(e)))}emoji(e){return this._addCheck(c({kind:"emoji"},w.errToObj(e)))}uuid(e){return this._addCheck(c({kind:"uuid"},w.errToObj(e)))}cuid(e){return this._addCheck(c({kind:"cuid"},w.errToObj(e)))}cuid2(e){return this._addCheck(c({kind:"cuid2"},w.errToObj(e)))}ulid(e){return this._addCheck(c({kind:"ulid"},w.errToObj(e)))}ip(e){return this._addCheck(c({kind:"ip"},w.errToObj(e)))}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck(c({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(r=e?.offset)!=null?r:!1},w.errToObj(e?.message)))}regex(e,r){return this._addCheck(c({kind:"regex",regex:e},w.errToObj(r)))}includes(e,r){return this._addCheck(c({kind:"includes",value:e,position:r?.position},w.errToObj(r?.message)))}startsWith(e,r){return this._addCheck(c({kind:"startsWith",value:e},w.errToObj(r)))}endsWith(e,r){return this._addCheck(c({kind:"endsWith",value:e},w.errToObj(r)))}min(e,r){return this._addCheck(c({kind:"min",value:e},w.errToObj(r)))}max(e,r){return this._addCheck(c({kind:"max",value:e},w.errToObj(r)))}length(e,r){return this._addCheck(c({kind:"length",value:e},w.errToObj(r)))}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new Qe(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 Qe(p(c({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new Qe(p(c({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}isEqual(e){if(!(e instanceof Qe))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}};a(Dr,"ZodString");Dr.create=a(t=>{var e;return new Dr(c({checks:[],typeName:"ZodString",coerce:(e=t?.coerce)!=null?e:!1},k(p(c({},t),{supportsExtensions:["secret"]}))))},"create");var X=Dr,Mr=class nc extends O{_parse(e){if(this._getType(e)!==_.symbol){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.symbol,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof nc}};a(Mr,"ZodSymbol");Mr.create=a(t=>new Mr(c({typeName:"ZodSymbol"},k(t))),"create");var Ss=Mr,lt=class Ot extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName==="ZodEffects"?this._def.schema.sourceType():this._def.schema}dereference(e){return new Ot(p(c({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new Ot(p(c({},this._def),{schema:this._def.schema.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a(o=>{v(n,o),o.fatal?r.abort():r.dirty()},"addIssue"),get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async l=>{if(r.value==="aborted")return x;let d=await this._def.schema._parseAsync({data:l,path:n.path,parent:n});return d.status==="aborted"?x:d.status==="dirty"||r.value==="dirty"?Re(d.value):d});{if(r.value==="aborted")return x;let l=this._def.schema._parseSync({data:o,path:n.path,parent:n});return l.status==="aborted"?x:l.status==="dirty"||r.value==="dirty"?Re(l.value):l}}if(s.type==="refinement"){let o=a(l=>{let d=s.refinement(l,i);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l},"executeRefinement");if(n.common.async===!1){let l=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return l.status==="aborted"?x:(l.status==="dirty"&&r.dirty(),o(l.value),{status:r.value,value:l.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>l.status==="aborted"?x:(l.status==="dirty"&&r.dirty(),o(l.value).then(()=>({status:r.value,value:l.value}))))}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!it(o))return o;let l=s.transform(o.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:l}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>it(o)?Promise.resolve(s.transform(o.value,i)).then(l=>({status:r.value,value:l})):o);Z.assertNever(s)}isEqual(e){return!(e instanceof Ot)||!this._def.schema.isEqual(e._def.schema)?!1:this._def.effect.type==="refinement"?e._def.effect.type!=="refinement"?!1:Z.compareFunctions(this._def.effect.refinement,e._def.effect.refinement):this._def.effect.type==="transform"?e._def.effect.type!=="transform"?!1:Z.compareFunctions(this._def.effect.transform,e._def.effect.transform):this._def.effect.type==="preprocess"?e._def.effect.type!=="preprocess"?!1:Z.compareFunctions(this._def.effect.transform,e._def.effect.transform):!1}naked(){return this._def.schema.naked()}mandatory(){return new Ot(p(c({},this._def),{schema:this._def.schema.mandatory()}))}};a(lt,"ZodEffects");lt.create=a((t,e,r)=>new lt(c({schema:t,typeName:"ZodEffects",effect:e},k(r))),"create");lt.createWithPreprocess=a((t,e,r)=>new lt(c({schema:e,effect:{type:"preprocess",transform:t},typeName:"ZodEffects"},k(r))),"createWithPreprocess");var Pe=lt,Nr=class Et extends O{dereference(e){let r=this._def.items.map(s=>s.dereference(e)),n=this._def.rest?this._def.rest.dereference(e):null;return new Et(p(c({},this._def),{items:r,rest:n}))}getReferences(){return ye([...this._def.items.flatMap(e=>e.getReferences()),...this._def.rest?this._def.rest.getReferences():[]])}clone(){let e=this._def.items.map(n=>n.clone()),r=this._def.rest?this._def.rest.clone():null;return new Et(p(c({},this._def),{items:e,rest:r}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.array)return v(n,{code:h.invalid_type,expected:_.array,received:n.parsedType}),x;if(n.data.length<this._def.items.length)return v(n,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&n.data.length>this._def.items.length&&(v(n,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((o,l)=>{let d=this._def.items[l]||this._def.rest;return d?d._parse(new ae(n,o,n.path,l)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>te.mergeArray(r,o)):te.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new Et(p(c({},this._def),{rest:e}))}isEqual(e){if(!(e instanceof Et)||!this._restEquals(e))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K(this._def.items,{compare:r}),s=new K(e._def.items,{compare:r});return n.isEqual(s)}_restEquals(e){return this._def.rest===null?e._def.rest===null:e._def.rest!==null&&this._def.rest.isEqual(e._def.rest)}};a(Nr,"ZodTuple");Nr.create=a((t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Nr(c({items:t,typeName:"ZodTuple",rest:null},k(e)))},"create");var Ne=Nr,$r=class sc extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.undefined,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof sc}mandatory(){return dt.create(c({},this._def))}};a($r,"ZodUndefined");$r.create=a(t=>new $r(c({typeName:"ZodUndefined"},k(t))),"create");var Wt=$r,jr=class Zt extends O{dereference(e){let r=this._def.options.map(n=>n.dereference(e));return new Zt(p(c({},this._def),{options:r}))}getReferences(){return ye(this._def.options.reduce((e,r)=>[...e,...r.getReferences()],[]))}clone(){let e=this._def.options.map(r=>r.clone());return new Zt(p(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(let l of i)if(l.result.status==="valid")return l.result;for(let l of i)if(l.result.status==="dirty")return r.common.issues.push(...l.ctx.common.issues),l.result;let o=i.map(l=>new le(l.ctx.common.issues));return v(r,{code:h.invalid_union,unionErrors:o}),x}if(a(s,"handleResults"),r.common.async)return Promise.all(n.map(async i=>{let o=p(c({},r),{common:p(c({},r.common),{issues:[]}),parent:null});return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let d of n){let f=p(c({},r),{common:p(c({},r.common),{issues:[]}),parent:null}),g=d._parseSync({data:r.data,path:r.path,parent:f});if(g.status==="valid")return g;g.status==="dirty"&&!i&&(i={result:g,ctx:f}),f.common.issues.length&&o.push(f.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let l=o.map(d=>new le(d));return v(r,{code:h.invalid_union,unionErrors:l}),x}}get options(){return this._def.options}isEqual(e){if(!(e instanceof Zt))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K([...this._def.options],{compare:r}),s=new K([...e._def.options],{compare:r});return n.isEqual(s)}mandatory(){let e=this._def.options.filter(i=>!(i instanceof Wt)).map(i=>i.mandatory()),[r,n,...s]=e;return r?n?new Zt(p(c({},this._def),{options:[r,n,...s]})):r:dt.create(c({},this._def))}};a(jr,"ZodUnion");jr.create=a((t,e)=>new jr(c({options:t,typeName:"ZodUnion"},k(e))),"create");var gn=jr,Kr=class ic extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return J(e.data)}isEqual(e){return e instanceof ic}};a(Kr,"ZodUnknown");Kr.create=a(t=>new Kr(c({typeName:"ZodUnknown"},k(t))),"create");var rt=Kr,Ur=class ac extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.void,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof ac}};a(Ur,"ZodVoid");Ur.create=a(t=>new Ur(c({typeName:"ZodVoid"},k(t))),"create");var Os=Ur,sm=["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"],yv=Le.create(["any","string","number","boolean","object","pattern","date","array","target","time","enum"]),oc=a(t=>X.create().displayAs({id:"variable",params:c({type:t?.type||"any"},t?.params)}),"variable"),lc=a(t=>X.create().displayAs({id:"conversation",params:c({},t?.params)}),"conversation"),cc=a(t=>X.create().displayAs({id:"user",params:c({},t?.params)}),"user"),dc=a(t=>X.create().displayAs({id:"message",params:c({},t?.params)}),"message"),uc=a(t=>X.create().displayAs({id:"agent",params:c({},t?.params)}),"agent"),pc=a(t=>X.create().displayAs({id:"event",params:c({},t?.params)}),"event"),fc=a(t=>X.create().displayAs({id:"table",params:c({},t?.params)}),"table"),gc=a(t=>X.create().displayAs({id:"tablerow",params:c({},t?.params)}),"tablerow"),hc=a(t=>X.create().displayAs({id:"intent",params:c({},t?.params)}),"intent"),mc=a(()=>Le.create(sm).displayAs({id:"dropdown",params:{}}),"aimodel"),yc=a(t=>X.create().displayAs({id:"datasource",params:c({},t)}),"datasource"),vc=a(t=>X.create().displayAs({id:"knowledgebase",params:c({},t)}),"knowledgebase"),_c={object:Me.lazycreate},Tc=a((t,e={message:`Input not instance of ${t.name}`})=>ds(r=>r instanceof t,e),"instanceOfType"),Es=X.create,Zs=pn.create,bc=hs.create,wc=tn.create,Is=rn.create,Pc=an.create,xc=Ss.create,kc=Wt.create,Sc=un.create,Oc=at.create,Ec=rt.create,Zc=dt.create,Ic=Os.create,Bc=ot.create,Cc=Me.create,Ac=Me.strictCreate,Rc=gn.create,Hc=us.create,Dc=on.create,Mc=Ne.create,Nc=ms.create,$c=ys.create,jc=Ft.create,Kc=gs.create,Uc=vs.create,zc=fs.create,Fc=ln.create,Wc=cn.create,Lc=Le.create,qc=dn.create,Vc=zt.create,zn=Pe.create,Gc=ge.create,Jc=De.create,im=Kt.create,Xc=Pe.createWithPreprocess,Yc=fn.create,Qc=a(()=>Es().optional(),"ostring"),ed=a(()=>Zs().optional(),"onumber"),td=a(()=>Is().optional(),"oboolean"),rd={string:a(t=>X.create(p(c({},t),{coerce:!0})),"string"),number:a(t=>pn.create(p(c({},t),{coerce:!0})),"number"),boolean:a(t=>rn.create(p(c({},t),{coerce:!0})),"boolean"),bigint:a(t=>tn.create(p(c({},t),{coerce:!0})),"bigint"),date:a(t=>an.create(p(c({},t),{coerce:!0})),"date")},nd=x,u=y,sd=a((t,e)=>t.anyOf.length?t.anyOf.length===1?W(t.anyOf[0],p(c({},e),{path:[...e.path,"anyOf",0]})):`z.union([${t.anyOf.map((r,n)=>W(r,p(c({},e),{path:[...e.path,"anyOf",n]}))).join(", ")}])`:"z.any()","parseAnyOf"),am=a(t=>{var e;return(e=t[b])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),om=a(t=>"z.any()","parseDefault"),lm=a((t,e)=>`z.union([${t.type.map(r=>W(p(c({},t),{type:r}),e)).join(", ")}])`,"parseMultipleType"),cm=a((t,e)=>`z.any().refine((value) => !${W(t.not,p(c({},e),{path:[...e.path,"not"]}))}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`,"parseNot"),dm=a(t=>"z.null()","parseNull"),um=a(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),pm=a((t,...e)=>Object.keys(t).reduce((r,n)=>(e.includes(n)||(r[n]=t[n]),r),{}),"omit");function G(t,e,r){var n;let s=t[e],i="";if(s!==void 0){let o=r({value:s,json:JSON.stringify(s)});if(o){let l=o[0],d=o.length===3?o[1]:"",f=o.length===3?o[2]:o[1];i+=l,((n=t.errorMessage)==null?void 0:n[e])!==void 0&&(i+=d+JSON.stringify(t.errorMessage[e])),i+=f}}return i}a(G,"withMessage");var It=Symbol("Original index"),fm=a(t=>{let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(typeof n=="boolean")e.push(n?{[It]:r}:{[It]:r,not:{}});else{if(It in n)return t;e.push(p(c({},n),{[It]:r}))}}return e},"ensureOriginalIndex");function $t(t,e){if(t.allOf.length===0)return"z.never()";if(t.allOf.length===1){let r=t.allOf[0];return W(r,p(c({},e),{path:[...e.path,"allOf",r[It]]}))}else{let[r,n]=um(fm(t.allOf));return`z.intersection(${$t({allOf:r},e)}, ${$t({allOf:n},e)})`}}a($t,"parseAllOf");var gm=a((t,e)=>{if(Array.isArray(t.items))return`z.tuple([${t.items.map((n,s)=>W(n,p(c({},e),{path:[...e.path,"items",s]})))}])`;let r=t.items?`z.array(${W(t.items,p(c({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return r+=G(t,"minItems",({json:n})=>[`.min(${n}`,", ",")"]),r+=G(t,"maxItems",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseArray"),hm=a(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),mm=a(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"),ym=a((t,e)=>{let r=W(t.if,p(c({},e),{path:[...e.path,"if"]})),n=W(t.then,p(c({},e),{path:[...e.path,"then"]})),s=W(t.else,p(c({},e),{path:[...e.path,"else"]}));return`z.union([${n}, ${s}]).superRefine((value,ctx) => {
|
|
8
|
+
${m.join(" | ")}`;case u.ZodFirstPartyTypeKind.ZodIntersection:return`${B(l.left,i)} & ${B(l.right,i)}`;case u.ZodFirstPartyTypeKind.ZodTuple:return l.items.length===0?"":`[${l.items.map(q=>B(q,i)).join(", ")}]`;case u.ZodFirstPartyTypeKind.ZodRecord:let E=B(l.keyType,i),I=B(l.valueType,i);return`${z(o.description)} { [key: ${E}]: ${I} }`;case u.ZodFirstPartyTypeKind.ZodMap:return`Map<${B(l.keyType,i)}, ${B(l.valueType,i)}>`;case u.ZodFirstPartyTypeKind.ZodSet:return`Set<${B(l.valueType,i)}>`;case u.ZodFirstPartyTypeKind.ZodFunction:let U=B(new Vs(l.args),i),L=B(new Gs(l.returns),i);return`${z(o.description)}
|
|
9
|
+
(${U}) => ${L}`;case u.ZodFirstPartyTypeKind.ZodLazy:return B(l.getter(),i);case u.ZodFirstPartyTypeKind.ZodLiteral:let ee=Ci(l.value);return`${z(o.description)}
|
|
10
|
+
${ee}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(T).join(" | ");case u.ZodFirstPartyTypeKind.ZodEffects:return B(l.schema,i);case u.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Gi(u.ZodFirstPartyTypeKind.ZodNativeEnum);case u.ZodFirstPartyTypeKind.ZodOptional:return`${B(l.innerType,i)} | undefined`;case u.ZodFirstPartyTypeKind.ZodNullable:return`${B(l.innerType,i)} | null`;case u.ZodFirstPartyTypeKind.ZodDefault:return B(l.innerType,i);case u.ZodFirstPartyTypeKind.ZodCatch:return B(l.innerType,i);case u.ZodFirstPartyTypeKind.ZodPromise:return`Promise<${B(l.type,i)}>`;case u.ZodFirstPartyTypeKind.ZodBranded:return B(l.type,i);case u.ZodFirstPartyTypeKind.ZodPipeline:return B(l.in,i);case u.ZodFirstPartyTypeKind.ZodSymbol:return`${z(o.description)} symbol`.trim();case u.ZodFirstPartyTypeKind.ZodReadonly:return`Readonly<${B(l.innerType,i)}>`;case u.ZodFirstPartyTypeKind.ZodRef:return Ri(l.uri);default:Z.assertNever(l)}}a(B,"sUnwrapZod");var bu=a((t,e)=>{if(t.props.type==="none")return B(t.props.schema,e);let r=z(t.props.schema.description),n=t.props.schema.describe(""),s=B(n,e);if(t.props.type==="variable")return qs(`${r}declare const ${t.props.identifier}: ${s};`);let i=t.props.args.length>0?`<${t.props.args.map(Ri).join(", ")}>`:"";return qs(`${r}type ${t.props.identifier}${i} = ${s};`)},"unwrapDeclaration"),wu=a(t=>t.declaration?t.declaration===!0?"variable":t.declaration:"none","getDeclarationType"),Pu=a((t,e)=>{let r=wu(e),n=t.getReferences();if(r==="none"){if(n.length>0)throw new Rn;return new Yt({type:"none",schema:t})}let s="title"in t.ui?t.ui.title:null;if(!s)throw new Xi;if(r==="variable"){if(n.length>0)throw new Rn;return new Yt({type:"variable",identifier:s,schema:t})}return new Yt({type:"type",identifier:s,schema:t,args:n})},"getDeclarationProps"),xu=typeof global=="object"&&global&&global.Object===Object&&global,sa=xu,ku=typeof self=="object"&&self&&self.Object===Object&&self,Su=sa||ku||Function("return this")(),ye=Su,Ou=ye.Symbol,we=Ou,ia=Object.prototype,Eu=ia.hasOwnProperty,Zu=ia.toString,yt=we?we.toStringTag:void 0;function aa(t){var e=Eu.call(t,yt),r=t[yt];try{t[yt]=void 0;var n=!0}catch{}var s=Zu.call(t);return n&&(e?t[yt]=r:delete t[yt]),s}a(aa,"getRawTag");var Iu=aa,Bu=Object.prototype,Cu=Bu.toString;function oa(t){return Cu.call(t)}a(oa,"objectToString");var Au=oa,Ru="[object Null]",Hu="[object Undefined]",Js=we?we.toStringTag:void 0;function la(t){return t==null?t===void 0?Hu:Ru:Js&&Js in Object(t)?Iu(t):Au(t)}a(la,"baseGetTag");var je=la;function ca(t){return t!=null&&typeof t=="object"}a(ca,"isObjectLike");var He=ca,Du="[object Symbol]";function da(t){return typeof t=="symbol"||He(t)&&je(t)==Du}a(da,"isSymbol");var qn=da;function ua(t,e){for(var r=-1,n=t==null?0:t.length,s=Array(n);++r<n;)s[r]=e(t[r],r,t);return s}a(ua,"arrayMap");var fa=ua,Nu=Array.isArray,me=Nu,Mu=1/0,Xs=we?we.prototype:void 0,Ys=Xs?Xs.toString:void 0;function Vn(t){if(typeof t=="string")return t;if(me(t))return fa(t,Vn)+"";if(qn(t))return Ys?Ys.call(t):"";var e=t+"";return e=="0"&&1/t==-Mu?"-0":e}a(Vn,"baseToString");var ju=Vn;function pa(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}a(pa,"isObject");var nt=pa;function ga(t){return t}a(ga,"identity");var $u=ga,Ku="[object AsyncFunction]",Uu="[object Function]",zu="[object GeneratorFunction]",Fu="[object Proxy]";function ha(t){if(!nt(t))return!1;var e=je(t);return e==Uu||e==zu||e==Ku||e==Fu}a(ha,"isFunction");var ma=ha,Wu=ye["__core-js_shared__"],Sn=Wu,Qs=(function(){var t=/[^.]+$/.exec(Sn&&Sn.keys&&Sn.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function ya(t){return!!Qs&&Qs in t}a(ya,"isMasked");var Lu=ya,qu=Function.prototype,Vu=qu.toString;function va(t){if(t!=null){try{return Vu.call(t)}catch{}try{return t+""}catch{}}return""}a(va,"toSource");var $e=va,Gu=/[\\^$.*+?()[\]{}|]/g,Ju=/^\[object .+?Constructor\]$/,Xu=Function.prototype,Yu=Object.prototype,Qu=Xu.toString,ef=Yu.hasOwnProperty,tf=RegExp("^"+Qu.call(ef).replace(Gu,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function _a(t){if(!nt(t)||Lu(t))return!1;var e=ma(t)?tf:Ju;return e.test($e(t))}a(_a,"baseIsNative");var rf=_a;function Ta(t,e){return t?.[e]}a(Ta,"getValue");var nf=Ta;function ba(t,e){var r=nf(t,e);return rf(r)?r:void 0}a(ba,"getNative");var Ke=ba,sf=Ke(ye,"WeakMap"),Hn=sf,af=(function(){try{var t=Ke(Object,"defineProperty");return t({},"",{}),t}catch{}})(),ei=af,of=9007199254740991,lf=/^(?:0|[1-9]\d*)$/;function wa(t,e){var r=typeof t;return e=e??of,!!e&&(r=="number"||r!="symbol"&&lf.test(t))&&t>-1&&t%1==0&&t<e}a(wa,"isIndex");var Gn=wa;function Pa(t,e,r){e=="__proto__"&&ei?ei(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}a(Pa,"baseAssignValue");var xa=Pa;function ka(t,e){return t===e||t!==t&&e!==e}a(ka,"eq");var Jn=ka,cf=Object.prototype,df=cf.hasOwnProperty;function Sa(t,e,r){var n=t[e];(!(df.call(t,e)&&Jn(n,r))||r===void 0&&!(e in t))&&xa(t,e,r)}a(Sa,"assignValue");var uf=Sa,ff=9007199254740991;function Oa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=ff}a(Oa,"isLength");var Xn=Oa;function Ea(t){return t!=null&&Xn(t.length)&&!ma(t)}a(Ea,"isArrayLike");var Za=Ea,pf=Object.prototype;function Ia(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||pf;return t===r}a(Ia,"isPrototype");var Ba=Ia;function Ca(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}a(Ca,"baseTimes");var gf=Ca,hf="[object Arguments]";function Aa(t){return He(t)&&je(t)==hf}a(Aa,"baseIsArguments");var ti=Aa,Ra=Object.prototype,mf=Ra.hasOwnProperty,yf=Ra.propertyIsEnumerable,vf=ti((function(){return arguments})())?ti:function(t){return He(t)&&mf.call(t,"callee")&&!yf.call(t,"callee")},Ha=vf;function Da(){return!1}a(Da,"stubFalse");var _f=Da,Na=typeof exports=="object"&&exports&&!exports.nodeType&&exports,ri=Na&&typeof module=="object"&&module&&!module.nodeType&&module,Tf=ri&&ri.exports===Na,ni=Tf?ye.Buffer:void 0,bf=ni?ni.isBuffer:void 0,wf=bf||_f,Dn=wf,Pf="[object Arguments]",xf="[object Array]",kf="[object Boolean]",Sf="[object Date]",Of="[object Error]",Ef="[object Function]",Zf="[object Map]",If="[object Number]",Bf="[object Object]",Cf="[object RegExp]",Af="[object Set]",Rf="[object String]",Hf="[object WeakMap]",Df="[object ArrayBuffer]",Nf="[object DataView]",Mf="[object Float32Array]",jf="[object Float64Array]",$f="[object Int8Array]",Kf="[object Int16Array]",Uf="[object Int32Array]",zf="[object Uint8Array]",Ff="[object Uint8ClampedArray]",Wf="[object Uint16Array]",Lf="[object Uint32Array]",D={};D[Mf]=D[jf]=D[$f]=D[Kf]=D[Uf]=D[zf]=D[Ff]=D[Wf]=D[Lf]=!0;D[Pf]=D[xf]=D[Df]=D[kf]=D[Nf]=D[Sf]=D[Of]=D[Ef]=D[Zf]=D[If]=D[Bf]=D[Cf]=D[Af]=D[Rf]=D[Hf]=!1;function Ma(t){return He(t)&&Xn(t.length)&&!!D[je(t)]}a(Ma,"baseIsTypedArray");var qf=Ma;function ja(t){return function(e){return t(e)}}a(ja,"baseUnary");var Vf=ja,$a=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Bt=$a&&typeof module=="object"&&module&&!module.nodeType&&module,Gf=Bt&&Bt.exports===$a,On=Gf&&sa.process,Jf=(function(){try{var t=Bt&&Bt.require&&Bt.require("util").types;return t||On&&On.binding&&On.binding("util")}catch{}})(),si=Jf,ii=si&&si.isTypedArray,Xf=ii?Vf(ii):qf,Ka=Xf,Yf=Object.prototype,Qf=Yf.hasOwnProperty;function Ua(t,e){var r=me(t),n=!r&&Ha(t),s=!r&&!n&&Dn(t),i=!r&&!n&&!s&&Ka(t),o=r||n||s||i,l=o?gf(t.length,String):[],d=l.length;for(var p in t)(e||Qf.call(t,p))&&!(o&&(p=="length"||s&&(p=="offset"||p=="parent")||i&&(p=="buffer"||p=="byteLength"||p=="byteOffset")||Gn(p,d)))&&l.push(p);return l}a(Ua,"arrayLikeKeys");var za=Ua;function Fa(t,e){return function(r){return t(e(r))}}a(Fa,"overArg");var Wa=Fa,ep=Wa(Object.keys,Object),tp=ep,rp=Object.prototype,np=rp.hasOwnProperty;function La(t){if(!Ba(t))return tp(t);var e=[];for(var r in Object(t))np.call(t,r)&&r!="constructor"&&e.push(r);return e}a(La,"baseKeys");var sp=La;function qa(t){return Za(t)?za(t):sp(t)}a(qa,"keys");var Yn=qa;function Va(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}a(Va,"nativeKeysIn");var ip=Va,ap=Object.prototype,op=ap.hasOwnProperty;function Ga(t){if(!nt(t))return ip(t);var e=Ba(t),r=[];for(var n in t)n=="constructor"&&(e||!op.call(t,n))||r.push(n);return r}a(Ga,"baseKeysIn");var lp=Ga;function Ja(t){return Za(t)?za(t,!0):lp(t)}a(Ja,"keysIn");var cp=Ja,dp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,up=/^\w*$/;function Xa(t,e){if(me(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||qn(t)?!0:up.test(t)||!dp.test(t)||e!=null&&t in Object(e)}a(Xa,"isKey");var Qn=Xa,fp=Ke(Object,"create"),At=fp;function Ya(){this.__data__=At?At(null):{},this.size=0}a(Ya,"hashClear");var pp=Ya;function Qa(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}a(Qa,"hashDelete");var gp=Qa,hp="__lodash_hash_undefined__",mp=Object.prototype,yp=mp.hasOwnProperty;function eo(t){var e=this.__data__;if(At){var r=e[t];return r===hp?void 0:r}return yp.call(e,t)?e[t]:void 0}a(eo,"hashGet");var vp=eo,_p=Object.prototype,Tp=_p.hasOwnProperty;function to(t){var e=this.__data__;return At?e[t]!==void 0:Tp.call(e,t)}a(to,"hashHas");var bp=to,wp="__lodash_hash_undefined__";function ro(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=At&&e===void 0?wp:e,this}a(ro,"hashSet");var Pp=ro;function Ue(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(Ue,"Hash");Ue.prototype.clear=pp;Ue.prototype.delete=gp;Ue.prototype.get=vp;Ue.prototype.has=bp;Ue.prototype.set=Pp;var ai=Ue;function no(){this.__data__=[],this.size=0}a(no,"listCacheClear");var xp=no;function so(t,e){for(var r=t.length;r--;)if(Jn(t[r][0],e))return r;return-1}a(so,"assocIndexOf");var qr=so,kp=Array.prototype,Sp=kp.splice;function io(t){var e=this.__data__,r=qr(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():Sp.call(e,r,1),--this.size,!0}a(io,"listCacheDelete");var Op=io;function ao(t){var e=this.__data__,r=qr(e,t);return r<0?void 0:e[r][1]}a(ao,"listCacheGet");var Ep=ao;function oo(t){return qr(this.__data__,t)>-1}a(oo,"listCacheHas");var Zp=oo;function lo(t,e){var r=this.__data__,n=qr(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this}a(lo,"listCacheSet");var Ip=lo;function ze(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(ze,"ListCache");ze.prototype.clear=xp;ze.prototype.delete=Op;ze.prototype.get=Ep;ze.prototype.has=Zp;ze.prototype.set=Ip;var Vr=ze,Bp=Ke(ye,"Map"),Rt=Bp;function co(){this.size=0,this.__data__={hash:new ai,map:new(Rt||Vr),string:new ai}}a(co,"mapCacheClear");var Cp=co;function uo(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}a(uo,"isKeyable");var Ap=uo;function fo(t,e){var r=t.__data__;return Ap(e)?r[typeof e=="string"?"string":"hash"]:r.map}a(fo,"getMapData");var Gr=fo;function po(t){var e=Gr(this,t).delete(t);return this.size-=e?1:0,e}a(po,"mapCacheDelete");var Rp=po;function go(t){return Gr(this,t).get(t)}a(go,"mapCacheGet");var Hp=go;function ho(t){return Gr(this,t).has(t)}a(ho,"mapCacheHas");var Dp=ho;function mo(t,e){var r=Gr(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this}a(mo,"mapCacheSet");var Np=mo;function Fe(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}a(Fe,"MapCache");Fe.prototype.clear=Cp;Fe.prototype.delete=Rp;Fe.prototype.get=Hp;Fe.prototype.has=Dp;Fe.prototype.set=Np;var Jr=Fe,Mp="Expected a function";function Xr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Mp);var r=a(function(){var n=arguments,s=e?e.apply(this,n):n[0],i=r.cache;if(i.has(s))return i.get(s);var o=t.apply(this,n);return r.cache=i.set(s,o)||i,o},"memoized");return r.cache=new(Xr.Cache||Jr),r}a(Xr,"memoize");Xr.Cache=Jr;var jp=Xr,$p=500;function yo(t){var e=jp(t,function(n){return r.size===$p&&r.clear(),n}),r=e.cache;return e}a(yo,"memoizeCapped");var Kp=yo,Up=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,zp=/\\(\\)?/g,Fp=Kp(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Up,function(r,n,s,i){e.push(s?i.replace(zp,"$1"):n||r)}),e}),Wp=Fp;function vo(t){return t==null?"":ju(t)}a(vo,"toString");var Lp=vo;function _o(t,e){return me(t)?t:Qn(t,e)?[t]:Wp(Lp(t))}a(_o,"castPath");var Yr=_o,qp=1/0;function To(t){if(typeof t=="string"||qn(t))return t;var e=t+"";return e=="0"&&1/t==-qp?"-0":e}a(To,"toKey");var jt=To;function bo(t,e){e=Yr(e,t);for(var r=0,n=e.length;t!=null&&r<n;)t=t[jt(e[r++])];return r&&r==n?t:void 0}a(bo,"baseGet");var es=bo;function wo(t,e,r){var n=t==null?void 0:es(t,e);return n===void 0?r:n}a(wo,"get");var Vp=wo;function Po(t,e){for(var r=-1,n=e.length,s=t.length;++r<n;)t[s+r]=e[r];return t}a(Po,"arrayPush");var xo=Po,Gp=Wa(Object.getPrototypeOf,Object),ko=Gp,Jp="[object Object]",Xp=Function.prototype,Yp=Object.prototype,So=Xp.toString,Qp=Yp.hasOwnProperty,eg=So.call(Object);function Oo(t){if(!He(t)||je(t)!=Jp)return!1;var e=ko(t);if(e===null)return!0;var r=Qp.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&So.call(r)==eg}a(Oo,"isPlainObject");var oi=Oo;function Eo(){this.__data__=new Vr,this.size=0}a(Eo,"stackClear");var tg=Eo;function Zo(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}a(Zo,"stackDelete");var rg=Zo;function Io(t){return this.__data__.get(t)}a(Io,"stackGet");var ng=Io;function Bo(t){return this.__data__.has(t)}a(Bo,"stackHas");var sg=Bo,ig=200;function Co(t,e){var r=this.__data__;if(r instanceof Vr){var n=r.__data__;if(!Rt||n.length<ig-1)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Jr(n)}return r.set(t,e),this.size=r.size,this}a(Co,"stackSet");var ag=Co;function We(t){var e=this.__data__=new Vr(t);this.size=e.size}a(We,"Stack");We.prototype.clear=tg;We.prototype.delete=rg;We.prototype.get=ng;We.prototype.has=sg;We.prototype.set=ag;var Qt=We;function Ao(t,e){for(var r=-1,n=t==null?0:t.length,s=0,i=[];++r<n;){var o=t[r];e(o,r,t)&&(i[s++]=o)}return i}a(Ao,"arrayFilter");var og=Ao;function Ro(){return[]}a(Ro,"stubArray");var Ho=Ro,lg=Object.prototype,cg=lg.propertyIsEnumerable,li=Object.getOwnPropertySymbols,dg=li?function(t){return t==null?[]:(t=Object(t),og(li(t),function(e){return cg.call(t,e)}))}:Ho,Do=dg,ug=Object.getOwnPropertySymbols,fg=ug?function(t){for(var e=[];t;)xo(e,Do(t)),t=ko(t);return e}:Ho,pg=fg;function No(t,e,r){var n=e(t);return me(t)?n:xo(n,r(t))}a(No,"baseGetAllKeys");var Mo=No;function jo(t){return Mo(t,Yn,Do)}a(jo,"getAllKeys");var ci=jo;function $o(t){return Mo(t,cp,pg)}a($o,"getAllKeysIn");var gg=$o,hg=Ke(ye,"DataView"),Nn=hg,mg=Ke(ye,"Promise"),Mn=mg,yg=Ke(ye,"Set"),jn=yg,di="[object Map]",vg="[object Object]",ui="[object Promise]",fi="[object Set]",pi="[object WeakMap]",gi="[object DataView]",_g=$e(Nn),Tg=$e(Rt),bg=$e(Mn),wg=$e(jn),Pg=$e(Hn),Ze=je;(Nn&&Ze(new Nn(new ArrayBuffer(1)))!=gi||Rt&&Ze(new Rt)!=di||Mn&&Ze(Mn.resolve())!=ui||jn&&Ze(new jn)!=fi||Hn&&Ze(new Hn)!=pi)&&(Ze=a(function(t){var e=je(t),r=e==vg?t.constructor:void 0,n=r?$e(r):"";if(n)switch(n){case _g:return gi;case Tg:return di;case bg:return ui;case wg:return fi;case Pg:return pi}return e},"getTag"));var hi=Ze,xg=ye.Uint8Array,mi=xg,kg="__lodash_hash_undefined__";function Ko(t){return this.__data__.set(t,kg),this}a(Ko,"setCacheAdd");var Sg=Ko;function Uo(t){return this.__data__.has(t)}a(Uo,"setCacheHas");var Og=Uo;function Ht(t){var e=-1,r=t==null?0:t.length;for(this.__data__=new Jr;++e<r;)this.add(t[e])}a(Ht,"SetCache");Ht.prototype.add=Ht.prototype.push=Sg;Ht.prototype.has=Og;var Eg=Ht;function zo(t,e){for(var r=-1,n=t==null?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}a(zo,"arraySome");var Zg=zo;function Fo(t,e){return t.has(e)}a(Fo,"cacheHas");var Ig=Fo,Bg=1,Cg=2;function Wo(t,e,r,n,s,i){var o=r&Bg,l=t.length,d=e.length;if(l!=d&&!(o&&d>l))return!1;var p=i.get(t),g=i.get(e);if(p&&g)return p==e&&g==t;var m=-1,P=!0,E=r&Cg?new Eg:void 0;for(i.set(t,e),i.set(e,t);++m<l;){var I=t[m],U=e[m];if(n)var L=o?n(U,I,m,e,t,i):n(I,U,m,t,e,i);if(L!==void 0){if(L)continue;P=!1;break}if(E){if(!Zg(e,function(ee,ae){if(!Ig(E,ae)&&(I===ee||s(I,ee,r,n,i)))return E.push(ae)})){P=!1;break}}else if(!(I===U||s(I,U,r,n,i))){P=!1;break}}return i.delete(t),i.delete(e),P}a(Wo,"equalArrays");var Lo=Wo;function qo(t){var e=-1,r=Array(t.size);return t.forEach(function(n,s){r[++e]=[s,n]}),r}a(qo,"mapToArray");var Ag=qo;function Vo(t){var e=-1,r=Array(t.size);return t.forEach(function(n){r[++e]=n}),r}a(Vo,"setToArray");var Rg=Vo,Hg=1,Dg=2,Ng="[object Boolean]",Mg="[object Date]",jg="[object Error]",$g="[object Map]",Kg="[object Number]",Ug="[object RegExp]",zg="[object Set]",Fg="[object String]",Wg="[object Symbol]",Lg="[object ArrayBuffer]",qg="[object DataView]",yi=we?we.prototype:void 0,En=yi?yi.valueOf:void 0;function Go(t,e,r,n,s,i,o){switch(r){case qg:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Lg:return!(t.byteLength!=e.byteLength||!i(new mi(t),new mi(e)));case Ng:case Mg:case Kg:return Jn(+t,+e);case jg:return t.name==e.name&&t.message==e.message;case Ug:case Fg:return t==e+"";case $g:var l=Ag;case zg:var d=n&Hg;if(l||(l=Rg),t.size!=e.size&&!d)return!1;var p=o.get(t);if(p)return p==e;n|=Dg,o.set(t,e);var g=Lo(l(t),l(e),n,s,i,o);return o.delete(t),g;case Wg:if(En)return En.call(t)==En.call(e)}return!1}a(Go,"equalByTag");var Vg=Go,Gg=1,Jg=Object.prototype,Xg=Jg.hasOwnProperty;function Jo(t,e,r,n,s,i){var o=r&Gg,l=ci(t),d=l.length,p=ci(e),g=p.length;if(d!=g&&!o)return!1;for(var m=d;m--;){var P=l[m];if(!(o?P in e:Xg.call(e,P)))return!1}var E=i.get(t),I=i.get(e);if(E&&I)return E==e&&I==t;var U=!0;i.set(t,e),i.set(e,t);for(var L=o;++m<d;){P=l[m];var ee=t[P],ae=e[P];if(n)var q=o?n(ae,ee,P,e,t,i):n(ee,ae,P,t,e,i);if(!(q===void 0?ee===ae||s(ee,ae,r,n,i):q)){U=!1;break}L||(L=P=="constructor")}if(U&&!L){var ie=t.constructor,Ge=e.constructor;ie!=Ge&&"constructor"in t&&"constructor"in e&&!(typeof ie=="function"&&ie instanceof ie&&typeof Ge=="function"&&Ge instanceof Ge)&&(U=!1)}return i.delete(t),i.delete(e),U}a(Jo,"equalObjects");var Yg=Jo,Qg=1,vi="[object Arguments]",_i="[object Array]",Xt="[object Object]",eh=Object.prototype,Ti=eh.hasOwnProperty;function Xo(t,e,r,n,s,i){var o=me(t),l=me(e),d=o?_i:hi(t),p=l?_i:hi(e);d=d==vi?Xt:d,p=p==vi?Xt:p;var g=d==Xt,m=p==Xt,P=d==p;if(P&&Dn(t)){if(!Dn(e))return!1;o=!0,g=!1}if(P&&!g)return i||(i=new Qt),o||Ka(t)?Lo(t,e,r,n,s,i):Vg(t,e,d,r,n,s,i);if(!(r&Qg)){var E=g&&Ti.call(t,"__wrapped__"),I=m&&Ti.call(e,"__wrapped__");if(E||I){var U=E?t.value():t,L=I?e.value():e;return i||(i=new Qt),s(U,L,r,n,i)}}return P?(i||(i=new Qt),Yg(t,e,r,n,s,i)):!1}a(Xo,"baseIsEqualDeep");var th=Xo;function ts(t,e,r,n,s){return t===e?!0:t==null||e==null||!He(t)&&!He(e)?t!==t&&e!==e:th(t,e,r,n,ts,s)}a(ts,"baseIsEqual");var Qr=ts,rh=1,nh=2;function Yo(t,e,r,n){var s=r.length,i=s,o=!n;if(t==null)return!i;for(t=Object(t);s--;){var l=r[s];if(o&&l[2]?l[1]!==t[l[0]]:!(l[0]in t))return!1}for(;++s<i;){l=r[s];var d=l[0],p=t[d],g=l[1];if(o&&l[2]){if(p===void 0&&!(d in t))return!1}else{var m=new Qt;if(n)var P=n(p,g,d,t,e,m);if(!(P===void 0?Qr(g,p,rh|nh,n,m):P))return!1}}return!0}a(Yo,"baseIsMatch");var sh=Yo;function Qo(t){return t===t&&!nt(t)}a(Qo,"isStrictComparable");var el=Qo;function tl(t){for(var e=Yn(t),r=e.length;r--;){var n=e[r],s=t[n];e[r]=[n,s,el(s)]}return e}a(tl,"getMatchData");var ih=tl;function rl(t,e){return function(r){return r==null?!1:r[t]===e&&(e!==void 0||t in Object(r))}}a(rl,"matchesStrictComparable");var nl=rl;function sl(t){var e=ih(t);return e.length==1&&e[0][2]?nl(e[0][0],e[0][1]):function(r){return r===t||sh(r,t,e)}}a(sl,"baseMatches");var ah=sl;function il(t,e){return t!=null&&e in Object(t)}a(il,"baseHasIn");var oh=il;function al(t,e,r){e=Yr(e,t);for(var n=-1,s=e.length,i=!1;++n<s;){var o=jt(e[n]);if(!(i=t!=null&&r(t,o)))break;t=t[o]}return i||++n!=s?i:(s=t==null?0:t.length,!!s&&Xn(s)&&Gn(o,s)&&(me(t)||Ha(t)))}a(al,"hasPath");var lh=al;function ol(t,e){return t!=null&&lh(t,e,oh)}a(ol,"hasIn");var ch=ol,dh=1,uh=2;function ll(t,e){return Qn(t)&&el(e)?nl(jt(t),e):function(r){var n=Vp(r,t);return n===void 0&&n===e?ch(r,t):Qr(e,n,dh|uh)}}a(ll,"baseMatchesProperty");var fh=ll;function cl(t){return function(e){return e?.[t]}}a(cl,"baseProperty");var ph=cl;function dl(t){return function(e){return es(e,t)}}a(dl,"basePropertyDeep");var gh=dl;function ul(t){return Qn(t)?ph(jt(t)):gh(t)}a(ul,"property");var hh=ul;function fl(t){return typeof t=="function"?t:t==null?$u:typeof t=="object"?me(t)?fh(t[0],t[1]):ah(t):hh(t)}a(fl,"baseIteratee");var rs=fl;function pl(t){return function(e,r,n){for(var s=-1,i=Object(e),o=n(e),l=o.length;l--;){var d=o[t?l:++s];if(r(i[d],d,i)===!1)break}return e}}a(pl,"createBaseFor");var mh=pl,yh=mh(),vh=yh;function gl(t,e){return t&&vh(t,e,Yn)}a(gl,"baseForOwn");var _h=gl;function hl(t,e){return Qr(t,e)}a(hl,"isEqual");var tt=hl;function ml(t,e,r){r=typeof r=="function"?r:void 0;var n=r?r(t,e):void 0;return n===void 0?Qr(t,e,void 0,r):!!n}a(ml,"isEqualWith");var Th=ml;function yl(t){return t===void 0}a(yl,"isUndefined");var bi=yl;function vl(t,e){var r={};return e=rs(e,3),_h(t,function(n,s,i){xa(r,s,e(n,s,i))}),r}a(vl,"mapValues");var bh=vl,wh="Expected a function";function _l(t){if(typeof t!="function")throw new TypeError(wh);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)}}a(_l,"negate");var Ph=_l;function Tl(t,e,r,n){if(!nt(t))return t;e=Yr(e,t);for(var s=-1,i=e.length,o=i-1,l=t;l!=null&&++s<i;){var d=jt(e[s]),p=r;if(d==="__proto__"||d==="constructor"||d==="prototype")return t;if(s!=o){var g=l[d];p=n?n(g,d,l):void 0,p===void 0&&(p=nt(g)?g:Gn(e[s+1])?[]:{})}uf(l,d,p),l=l[d]}return t}a(Tl,"baseSet");var xh=Tl;function bl(t,e,r){for(var n=-1,s=e.length,i={};++n<s;){var o=e[n],l=es(t,o);r(l,o)&&xh(i,Yr(o,t),l)}return i}a(bl,"basePickBy");var kh=bl;function wl(t,e){if(t==null)return{};var r=fa(gg(t),function(n){return[n]});return e=rs(e),kh(t,r,function(n,s){return e(n,s[0])})}a(wl,"pickBy");var Sh=wl;function Pl(t,e){return Sh(t,Ph(rs(e)))}a(Pl,"omitBy");var wi=Pl,Oh=a(t=>{let e=t.checks;return e.length===0?"":e.map(Eh).join("")},"generateStringChecks"),Eh=a(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"length":return`.length(${T(t.value)}, ${T(t.message)})`;case"email":return`.email(${T(t.message)})`;case"url":return`.url(${T(t.message)})`;case"emoji":return`.emoji(${T(t.message)})`;case"uuid":return`.uuid(${T(t.message)})`;case"cuid":return`.cuid(${T(t.message)})`;case"cuid2":return`.cuid2(${T(t.message)})`;case"ulid":return`.ulid(${T(t.message)})`;case"includes":let e=et({message:t.message,position:t.position});return`.includes(${T(t.value)}, ${e})`;case"startsWith":return`.startsWith(${T(t.value)}, ${T(t.message)})`;case"endsWith":return`.endsWith(${T(t.value)}, ${T(t.message)})`;case"regex":return`.regex(${String(t.regex)}, ${T(t.message)})`;case"trim":return".trim()";case"toLowerCase":return".toLowerCase()";case"toUpperCase":return".toUpperCase()";case"datetime":let n=t.precision===null?void 0:t.precision;return`.datetime(${et({message:t.message,precision:n,offset:t.offset})})`;case"ip":return`.ip(${et({message:t.message,version:t.version})})`;default:return""}},"_generateStringCheck"),Zh=a(t=>{let e=t.checks;return e.length===0?"":e.map(Ih).join("")},"generateNumberChecks"),Ih=a(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"int":return`.int(${T(t.message)})`;case"multipleOf":return`.multipleOf(${T(t.value)}, ${T(t.message)})`;case"finite":return`.finite(${T(t.message)})`;default:return""}},"_generateNumberCheck"),Bh=a(t=>{let e=t.checks;return e.length===0?"":e.map(Ch).join("")},"generateBigIntChecks"),Ch=a(t=>{switch(t.kind){case"min":return`.min(${T(t.value)}, ${T(t.message)})`;case"max":return`.max(${T(t.value)}, ${T(t.message)})`;case"multipleOf":return`.multipleOf(${T(t.value)}, ${T(t.message)})`;default:return""}},"_generateBigIntCheck"),Ah=a(t=>{let e=t.checks;return e.length===0?"":e.map(Rh).join("")},"generateDateChecks"),Rh=a(t=>{switch(t.kind){case"min":return`.min(${Pi(t.value)}, ${T(t.message)})`;case"max":return`.max(${Pi(t.value)}, ${T(t.message)})`;default:return""}},"_generateDateCheck"),Pi=a(t=>`new Date(${t})`,"dateTs"),Hh=a(t=>{let e=[];if(t.exactLength){let{value:r,message:n}=t.exactLength;e.push(`.length(${T(r)}, ${T(n)})`)}if(t.minLength){let{value:r,message:n}=t.minLength;e.push(`.min(${T(r)}, ${T(n)})`)}if(t.maxLength){let{value:r,message:n}=t.maxLength;e.push(`.max(${T(r)}, ${T(n)})`)}return e.join("")},"generateArrayChecks"),Dh=a(t=>{let e=[];if(t.minSize){let{value:r,message:n}=t.minSize;e.push(`.min(${T(r)}, ${T(n)})`)}if(t.maxSize){let{value:r,message:n}=t.maxSize;e.push(`.max(${T(r)}, ${T(n)})`)}return e.join("")},"generateSetChecks");function ns(t){return M(t)}a(ns,"toTypescriptSchema");function M(t){let r=t._def;switch(r.typeName){case u.ZodFirstPartyTypeKind.ZodString:return`z.string()${Oh(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNumber:return`z.number()${Zh(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNaN:return`z.nan()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodBigInt:return`z.bigint()${Bh(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodBoolean:return`z.boolean()${R(r)}${A(t._def)}`.trim();case u.ZodFirstPartyTypeKind.ZodDate:return`z.date()${Ah(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodUndefined:return`z.undefined()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNull:return`z.null()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodAny:return`z.any()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodUnknown:return`z.unknown()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNever:return`z.never()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodVoid:return`z.void()${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodArray:return`z.array(${M(r.type)})${Hh(r)}${R(r)}${A(r)}`;case u.ZodFirstPartyTypeKind.ZodObject:let n=bh(r.shape(),M),s=t.additionalProperties(),i=s?`.catchall(${M(s)})`:"";return["z.object({",...Object.entries(n).map(([lu,cu])=>` ${lu}: ${cu},`),`})${i}${R(r)}${A(r)}`].join(`
|
|
11
|
+
`).trim();case u.ZodFirstPartyTypeKind.ZodUnion:return`z.union([${r.options.map(M).join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:let l=r.options.map(M);return`z.discriminatedUnion(${T(r.discriminator)}, [${l.join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodIntersection:let p=M(r.left),g=M(r.right);return`z.intersection(${p}, ${g})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodTuple:return`z.tuple([${r.items.map(M).join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodRecord:let P=M(r.keyType),E=M(r.valueType);return`z.record(${P}, ${E})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodMap:let I=M(r.keyType),U=M(r.valueType);return`z.map(${I}, ${U})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodSet:return`z.set(${M(r.valueType)})${Dh(r)}${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodFunction:let L=r.args.items.map(M),ee=L.length?`.args(${L.join(", ")})`:"",ae=M(r.returns);return`z.function()${ee}.returns(${ae})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodLazy:return`z.lazy(() => ${M(r.getter())})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodLiteral:return`z.literal(${T(r.value)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return`z.enum([${r.values.map(T).join(", ")}])${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodEffects:throw new Ee(u.ZodFirstPartyTypeKind.ZodEffects);case u.ZodFirstPartyTypeKind.ZodNativeEnum:throw new Ee(u.ZodFirstPartyTypeKind.ZodNativeEnum);case u.ZodFirstPartyTypeKind.ZodOptional:return`z.optional(${M(r.innerType)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodNullable:return`z.nullable(${M(r.innerType)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodDefault:let Ge=et(r.defaultValue());return`z.default(${M(r.innerType)}, ${Ge})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodCatch:throw new Ee(u.ZodFirstPartyTypeKind.ZodCatch);case u.ZodFirstPartyTypeKind.ZodPromise:return`z.promise(${M(r.type)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodBranded:throw new Ee(u.ZodFirstPartyTypeKind.ZodBranded);case u.ZodFirstPartyTypeKind.ZodPipeline:throw new Ee(u.ZodFirstPartyTypeKind.ZodPipeline);case u.ZodFirstPartyTypeKind.ZodSymbol:throw new Ee(u.ZodFirstPartyTypeKind.ZodSymbol);case u.ZodFirstPartyTypeKind.ZodReadonly:return`z.readonly(${M(r.innerType)})${R(r)}${A(r)}`.trim();case u.ZodFirstPartyTypeKind.ZodRef:return`z.ref(${T(r.uri)})${R(r)}${A(r)}`.trim();default:Z.assertNever(r)}}a(M,"sUnwrapZod");var A=a(t=>t.description?`.describe(${T(t.description)})`:"","_maybeDescribe"),R=a(t=>`${Nh(t)}${Mh(t)}${jh(t)}${$h(t)}${Kh(t)}${Uh(t)}${zh(t)}`,"_addZuiExtensions"),Nh=a(t=>{var e;return(e=t[b])!=null&&e.title?`.title(${T(t[b].title)})`:""},"_maybeTitle"),Mh=a(t=>{var e;return(e=t[b])!=null&&e.displayAs?`.displayAs(${Ai({id:t[b].displayAs[0],params:t[b].displayAs[1]})})`:""},"_maybeDisplayAs"),jh=a(t=>{var e;return(e=t[b])!=null&&e.disabled?`.disabled(${t[b].disabled})`:""},"_maybeDisabled"),$h=a(t=>{var e;return(e=t[b])!=null&&e.hidden?`.hidden(${t[b].hidden})`:""},"_maybeHidden"),Kh=a(t=>{var e;return(e=t[b])!=null&&e.placeholder?`.placeholder(${T(t[b].placeholder)})`:""},"_maybePlaceholder"),Uh=a(t=>{var e;return(e=t[b])!=null&&e.secret?".secret()":""},"_maybeSecret"),zh=a(t=>{var e;let r=["title","tooltip","displayAs","disabled","hidden","placeholder","secret","coerce"],n=Object.entries((e=t[b])!=null?e:{}).filter(([s])=>!r.includes(s));return n.length>0?`.metadata(${Ai(Object.fromEntries(n))})`:""},"_maybeSetMetadata"),Fh=a(t=>{let e={type:"number",description:t.description,"x-zui":t._def["x-zui"]};t._def[b]&&(e[b]=t._def[b]);for(let r of t._def.checks)switch(r.kind){case"min":{let n=r.inclusive?"minimum":"exclusiveMinimum",s=r.inclusive?"exclusiveMinimum":"minimum";e[n]=r.value,delete e[s];break}case"max":{let n=r.inclusive?"maximum":"exclusiveMaximum",s=r.inclusive?"exclusiveMaximum":"maximum";e[n]=r.value,delete e[s];break}case"int":e.type="integer";break;case"finite":{e.format="finite";break}case"multipleOf":e.multipleOf=r.value;break;default:}return e},"zodNumberToJsonNumber"),xl="\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}",kl="(([+-]\\d{2}(:?\\d{2})?)|Z)",Wh="Z",Sl="(\\.\\d+)?",$n="\\.\\d{",Lh="}",Ol=a(t=>{let e=t.precision?$n+t.precision+Lh:t.precision===0?"":Sl,r=t.offset?kl:Wh;return new RegExp(`^${xl}${e}${r}$`)},"generateDatetimeRegex"),qh=a(t=>({precision:Vh(t),offset:t.endsWith(`${kl}$`)}),"extractPrecisionAndOffset"),Vh=a(t=>{let e=t.slice(1+xl.length);return e.startsWith(Sl)?null:e.startsWith($n)?parseInt(e.slice($n.length)):0},"_extractPrecision"),Ct={};zr(Ct,{escapeSpecialChars:()=>Gh});var Gh=a(t=>t.replaceAll(/[.*+?^${}()|[\]\\]/g,"\\$&"),"escapeSpecialChars");function ss(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage=f(c({},t.errorMessage),{[e]:r}))}a(ss,"addErrorMessage");function H(t,e,r,n,s){t[e]=r,ss(t,e,n,s)}a(H,"setResponseValueAndErrors");var $={cuid:"^[cC][^\\s-]{8,}$",cuid2:"^[a-z][a-z0-9]*$",ulid:"^[0-9A-HJKMNP-TV-Z]{26}$",email:"^(?!\\.)(?!.*\\.\\.)([a-zA-Z0-9_+-\\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\\-]*\\.)+[a-zA-Z]{2,}$",emoji:"^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",uuid:"^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$",ipv4:"^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$",ipv6:"^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$"};function is(t,e){let r=c({type:"string"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});function n(s){return e.patternStrategy==="escape"?Ct.escapeSpecialChars(s):s}if(a(n,"processPattern"),t.checks)for(let s of t.checks)switch(s.kind){case"min":H(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e);break;case"max":H(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"email":switch(e.emailStrategy){case"format:email":Oe(r,"email",s.message,e);break;case"format:idn-email":Oe(r,"idn-email",s.message,e);break;case"pattern:zod":fe(r,$.email,s.message,e);break}break;case"url":Oe(r,"uri",s.message,e);break;case"uuid":Oe(r,"uuid",s.message,e);break;case"regex":fe(r,s.regex.source,s.message,e);break;case"cuid":fe(r,$.cuid,s.message,e);break;case"cuid2":fe(r,$.cuid2,s.message,e);break;case"startsWith":fe(r,"^"+n(s.value),s.message,e);break;case"endsWith":fe(r,n(s.value)+"$",s.message,e);break;case"datetime":Oe(r,"date-time",s.message,e);break;case"length":H(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,s.value):s.value,s.message,e),H(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,s.value):s.value,s.message,e);break;case"includes":{fe(r,n(s.value),s.message,e);break}case"ip":{s.version!=="v6"&&Oe(r,"ipv4",s.message,e),s.version!=="v4"&&Oe(r,"ipv6",s.message,e);break}case"emoji":fe(r,$.emoji,s.message,e);break;case"ulid":{fe(r,$.ulid,s.message,e);break}case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}a(is,"parseStringDef");var Oe=a((t,e,r,n)=>{var s;t.format||(s=t.anyOf)!=null&&s.some(i=>i.format)?(t.anyOf||(t.anyOf=[]),t.format&&(t.anyOf.push(c({format:t.format},t.errorMessage&&n.errorMessages&&{errorMessage:{format:t.errorMessage.format}})),delete t.format,t.errorMessage&&(delete t.errorMessage.format,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.anyOf.push(c({format:e},r&&n.errorMessages&&{errorMessage:{format:r}}))):H(t,"format",e,r,n)},"addFormat"),fe=a((t,e,r,n)=>{var s;t.pattern||(s=t.allOf)!=null&&s.some(i=>i.pattern)?(t.allOf||(t.allOf=[]),t.pattern&&(t.allOf.push(c({pattern:t.pattern},t.errorMessage&&n.errorMessages&&{errorMessage:{pattern:t.errorMessage.pattern}})),delete t.pattern,t.errorMessage&&(delete t.errorMessage.pattern,Object.keys(t.errorMessage).length===0&&delete t.errorMessage)),t.allOf.push(c({pattern:e},r&&n.errorMessages&&{errorMessage:{pattern:r}}))):H(t,"pattern",e,r,n)},"addPattern"),Jh=a(t=>{let e={type:"string",description:t.description,"x-zui":t._def["x-zui"]};t._def[b]&&(e[b]=t._def[b]);for(let r of t._def.checks)switch(r.kind){case"cuid":e.format="cuid",e.pattern=$.cuid;break;case"cuid2":e.format="cuid2",e.pattern=$.cuid2;break;case"ulid":e.format="ulid",e.pattern=$.ulid;break;case"uuid":e.format="uuid",e.pattern=$.uuid;break;case"emoji":e.format="emoji",e.pattern=$.emoji;break;case"email":e.format="email",e.pattern=$.email;break;case"ip":e.format=r.version==="v6"?"ipv6":"ipv4",e.pattern=r.version==="v6"?$.ipv6:$.ipv4;break;case"datetime":e.format="date-time",e.pattern=Ol(r).source,e[b]=f(c({},e[b]),{precision:r.precision,offset:r.offset});break;case"url":e.format="uri";break;case"endsWith":e.pattern=`${Ct.escapeSpecialChars(r.value)}$`;break;case"startsWith":e.pattern=`^${Ct.escapeSpecialChars(r.value)}`;break;case"includes":let n=r.position&&r.position>=1?`^(?:.{${r.position}}).*`:"";e.pattern=`${n}${Ct.escapeSpecialChars(r.value)}`;break;case"regex":e.pattern=r.regex.source;break;case"length":e.minLength=e.maxLength=Math.max(0,r.value);break;case"min":e.minLength=Math.max(0,r.value);break;case"max":e.maxLength=Math.max(0,r.value);break;default:throw new Ui({zodType:u.ZodFirstPartyTypeKind.ZodString,checkKind:r.kind})}return e},"zodStringToJsonString"),Xh=a((t,e)=>{let r={type:"array",description:t.description,items:e(t._def.type),"x-zui":t._def["x-zui"]};return t._def[b]&&(r[b]=t._def[b]),t._def.minLength&&(r.minItems=t._def.minLength.value),t._def.maxLength&&(r.maxItems=t._def.maxLength.value),t._def.exactLength&&(r.minItems=t._def.exactLength.value,r.maxItems=t._def.exactLength.value),r},"zodArrayToJsonArray"),Yh=a((t,e)=>{let r={type:"array",description:t.description,uniqueItems:!0,items:e(t._def.valueType),"x-zui":t._def["x-zui"]};return t._def[b]&&(r[b]=t._def[b]),t._def.minSize&&(r.minItems=t._def.minSize.value),t._def.maxSize&&(r.maxItems=t._def.maxSize.value),r},"zodSetToJsonSet"),Qh=a((t,e)=>{let r={type:"array",description:t.description,items:t._def.items.map(n=>e(n))};return t._def[b]&&(r[b]=t._def[b]),t._def.rest&&(r.additionalItems=e(t._def.rest)),r},"zodTupleToJsonTuple");function V(t){let e=t,r=e._def;switch(r.typeName){case u.ZodFirstPartyTypeKind.ZodString:return Jh(e);case u.ZodFirstPartyTypeKind.ZodNumber:return Fh(e);case u.ZodFirstPartyTypeKind.ZodNaN:throw new te(u.ZodFirstPartyTypeKind.ZodNaN);case u.ZodFirstPartyTypeKind.ZodBigInt:throw new te(u.ZodFirstPartyTypeKind.ZodBigInt,{suggestedAlternative:"serialize bigint to string"});case u.ZodFirstPartyTypeKind.ZodBoolean:return{type:"boolean",description:r.description,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodDate:throw new te(u.ZodFirstPartyTypeKind.ZodDate,{suggestedAlternative:"use z.string().datetime() instead"});case u.ZodFirstPartyTypeKind.ZodUndefined:return Zn(r);case u.ZodFirstPartyTypeKind.ZodNull:return In(r);case u.ZodFirstPartyTypeKind.ZodAny:return{description:r.description,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodUnknown:return{description:r.description,"x-zui":f(c({},r["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodUnknown}})};case u.ZodFirstPartyTypeKind.ZodNever:return{not:!0,description:r.description,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodVoid:throw new te(u.ZodFirstPartyTypeKind.ZodVoid);case u.ZodFirstPartyTypeKind.ZodArray:return Xh(e,V);case u.ZodFirstPartyTypeKind.ZodObject:let n=Object.entries(r.shape()),s=n.filter(([g,m])=>!m.isOptional()),i=s.length?s.map(([g])=>g):void 0,o=n.map(([g,m])=>[g,m.mandatory()]).map(([g,m])=>[g,V(m)]),l=!1;return r.unknownKeys instanceof u.ZodType?l=V(r.unknownKeys):r.unknownKeys==="passthrough"&&(l=!0),{type:"object",description:r.description,properties:Object.fromEntries(o),required:i,additionalProperties:l,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodUnion:return{description:r.description,anyOf:r.options.map(g=>V(g)),"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return{description:r.description,anyOf:r.options.map(g=>V(g)),"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodIntersection:let d=V(r.left),p=V(r.right);return"additionalProperties"in d&&delete d.additionalProperties,"additionalProperties"in p&&delete p.additionalProperties,{description:r.description,allOf:[d,p],"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodTuple:return Qh(e,V);case u.ZodFirstPartyTypeKind.ZodRecord:return{type:"object",description:r.description,additionalProperties:V(r.valueType),"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodMap:throw new te(u.ZodFirstPartyTypeKind.ZodMap);case u.ZodFirstPartyTypeKind.ZodSet:return Yh(e,V);case u.ZodFirstPartyTypeKind.ZodFunction:throw new te(u.ZodFirstPartyTypeKind.ZodFunction);case u.ZodFirstPartyTypeKind.ZodLazy:throw new te(u.ZodFirstPartyTypeKind.ZodLazy);case u.ZodFirstPartyTypeKind.ZodLiteral:if(typeof r.value=="string")return{type:"string",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="number")return{type:"number",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(typeof r.value=="boolean")return{type:"boolean",description:r.description,const:r.value,"x-zui":r["x-zui"]};if(r.value===null)return In(r);if(r.value===void 0)return Zn(r);{u.util.assertEqual(!0);let g=typeof r.value;throw new Wr(`Unsupported literal type: "${g}"`)}case u.ZodFirstPartyTypeKind.ZodEnum:return{type:"string",description:r.description,enum:r.values,"x-zui":r["x-zui"]};case u.ZodFirstPartyTypeKind.ZodEffects:throw new te(u.ZodFirstPartyTypeKind.ZodEffects);case u.ZodFirstPartyTypeKind.ZodNativeEnum:throw new te(u.ZodFirstPartyTypeKind.ZodNativeEnum);case u.ZodFirstPartyTypeKind.ZodOptional:return{description:r.description,anyOf:[V(r.innerType),Zn()],"x-zui":f(c({},r["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodOptional}})};case u.ZodFirstPartyTypeKind.ZodNullable:return{anyOf:[V(r.innerType),In()],"x-zui":f(c({},r["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodNullable}})};case u.ZodFirstPartyTypeKind.ZodDefault:return f(c({},V(r.innerType)),{default:r.defaultValue()});case u.ZodFirstPartyTypeKind.ZodCatch:throw new te(u.ZodFirstPartyTypeKind.ZodCatch);case u.ZodFirstPartyTypeKind.ZodPromise:throw new te(u.ZodFirstPartyTypeKind.ZodPromise);case u.ZodFirstPartyTypeKind.ZodBranded:throw new te(u.ZodFirstPartyTypeKind.ZodBranded);case u.ZodFirstPartyTypeKind.ZodPipeline:throw new te(u.ZodFirstPartyTypeKind.ZodPipeline);case u.ZodFirstPartyTypeKind.ZodSymbol:throw new te(u.ZodFirstPartyTypeKind.ZodPipeline);case u.ZodFirstPartyTypeKind.ZodReadonly:return f(c({},V(r.innerType)),{readOnly:!0});case u.ZodFirstPartyTypeKind.ZodRef:return{$ref:r.uri,description:r.description,"x-zui":r["x-zui"]};default:u.util.assertNever(r)}}a(V,"toJSONSchema");var Zn=a(t=>({not:!0,description:t?.description,"x-zui":f(c({},t?.["x-zui"]),{def:{typeName:u.ZodFirstPartyTypeKind.ZodUndefined}})}),"undefinedSchema"),In=a(t=>({type:"null",description:t?.description,"x-zui":t?.["x-zui"]}),"nullSchema"),El=class{constructor(e,r,n,s){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};a(El,"ParseInputLazyPath");var oe=El,xi=a((t,e)=>{if(it(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new de(t.common.issues);return this._error=r,this._error}}},"handleResult"),Zl=class{constructor(e){this.__type__="ZuiType",this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._metadataRoot._def.description}dereference(e){return this}getReferences(){return[]}clone(){let e=this.constructor;return new e(c({},this._def))}_getType(e){return ge(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:ge(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new re,ctx:{common:e.parent.common,data:e.data,parsedType:ge(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Nt(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;let s={common:{issues:[],async:(n=r?.async)!=null?n:!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ge(e)},i=this._parseSync({data:e,path:s.path,parent:s});return xi(s,i)}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ge(e)},s=this._parse({data:e,path:n.path,parent:n}),i=await(Nt(s)?s:Promise.resolve(s));return xi(n,i)}refine(e,r){let n=a(s=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(s):r,"getIssueProperties");return this._refinement((s,i)=>{let o=e(s),l=a(()=>i.addIssue(c({code:h.custom},n(s))),"setError");return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(e,r){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof r=="function"?r(n,s):r),!1))}_refinement(e){return new xe({schema:this,typeName:"ZodEffects",effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return he.create(this,this._def)}nullable(){return De.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ot.create(this,this._def)}promise(){return Ut.create(this,this._def)}mandatory(){return this}or(e){return pn.create([this,e],this._def)}and(e){return an.create(this,e,this._def)}transform(e){return new xe(f(c({},k(this._def)),{schema:this,typeName:"ZodEffects",effect:{type:"transform",transform:e}}))}default(e){let r=typeof e=="function"?e:()=>e;return new $t(f(c({},k(this._def)),{innerType:this,defaultValue:r,typeName:"ZodDefault"}))}brand(){return new rn(c({typeName:"ZodBranded",type:this},k(this._def)))}catch(e){let r=typeof e=="function"?e:()=>e;return new nn(f(c({},k(this._def)),{innerType:this,catchValue:r,typeName:"ZodCatch"}))}describe(e){let r=this.clone();return r._metadataRoot._def.description=e,r}pipe(e){return fn.create(this,e)}readonly(){return zt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}metadata(e){var r,n,s;let i=this.clone(),o=i._metadataRoot;(s=(r=o._def)[n=b])!=null||(r[n]={});for(let[l,d]of Object.entries(e))o._def[b]=f(c({},o._def[b]),{[l]:d});return i}getMetadata(){return c({},this._metadataRoot._def[b])}setMetadata(e){this._metadataRoot._def[b]=c({},e)}get ui(){return c({},this._metadataRoot._def[b])}get _metadataRoot(){return this.naked()}displayAs(e){return this.metadata({displayAs:[e.id,e.params]})}title(e){return this.metadata({title:e})}hidden(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({hidden:r})}disabled(e){let r;return e===void 0?r=!0:typeof e=="function"?r=e.toString():r=e,this.metadata({disabled:r})}placeholder(e){return this.metadata({placeholder:e})}toJSONSchema(){return V(this)}toTypescriptType(e){return Ln(this,e)}toTypescriptSchema(){return ns(this)}naked(){return this}};a(Zl,"ZodType");var O=Zl,as=(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))(as||{}),Z;(t=>{t.assertEqual=a(s=>s,"assertEqual");function e(s){}t.assertIs=e,a(e,"assertIs");function r(s){throw new Error("assertNever called")}t.assertNever=r,a(r,"assertNever"),t.arrayToEnum=a(s=>{let i={};for(let o of s)i[o]=o;return i},"arrayToEnum"),t.getValidEnumValues=a(s=>{let i=(0,t.objectKeys)(s).filter(l=>typeof s[s[l]]!="number"),o={};for(let l of i)o[l]=s[l];return(0,t.objectValues)(o)},"getValidEnumValues"),t.objectValues=a(s=>(0,t.objectKeys)(s).map(function(i){return s[i]}),"objectValues"),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let i=[];for(let o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=a((s,i)=>{for(let o of s)if(i(o))return o},"find"),t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=n,a(n,"joinValues"),t.jsonStringifyReplacer=a((s,i)=>typeof i=="bigint"?i.toString():i,"jsonStringifyReplacer"),t.compareFunctions=a((s,i)=>s.toString()===i.toString(),"compareFunctions"),t.mock=a(()=>({}),"mock")})(Z||(Z={}));var lr;(t=>{t.mergeShapes=a((e,r)=>c(c({},e),r),"mergeShapes")})(lr||(lr={}));var _=Z.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ge=a(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 k(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:s,supportsExtensions:i,[b]:o}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);let l=o?Object.fromEntries(Object.entries(o).filter(([p])=>p!=="secret"||i?.includes("secret"))):void 0;return e?{errorMap:e,description:s,[b]:l}:{errorMap:a((p,g)=>p.code!=="invalid_type"?{message:g.defaultError}:typeof g.data>"u"?{message:n??g.defaultError}:{message:r??g.defaultError},"customMap"),description:s,[b]:l}}a(k,"processCreateParams");var os=a((t,e)=>{let r;switch(t.code){case h.invalid_type:t.received===_.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case h.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Z.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:r=`Unrecognized key(s) in object: ${Z.joinValues(t.keys,", ")}`;break;case h.invalid_union:r="Invalid input";break;case h.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Z.joinValues(t.options)}`;break;case h.invalid_enum_value:r=`Invalid enum value. Expected ${Z.joinValues(t.options)}, received '${t.received}'`;break;case h.invalid_arguments:r="Invalid function arguments";break;case h.invalid_return_type:r="Invalid function return type";break;case h.invalid_date:r="Invalid date";break;case h.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Z.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case h.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case h.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case h.custom:r="Invalid input";break;case h.invalid_intersection_types:r="Intersection results could not be merged";break;case h.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case h.not_finite:r="Number must be finite";break;case h.unresolved_reference:r="Unresolved reference";break;default:r=e.defaultError,Z.assertNever(t)}return{message:r}},"errorMap"),ki=os,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"]),Il=a(t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),"quotelessJson"),cr=class Bl extends Error{constructor(e){super(),this.issues=[],this.addIssue=a(n=>{this.issues=[...this.issues,n]},"addIssue"),this.addIssues=a((n=[])=>{this.issues=[...this.issues,...n]},"addIssues");let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){let r=e||function(i){return i.message},n={_errors:[]},s=a(i=>{for(let o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else{let l=n,d=0;for(;d<o.path.length;){let p=o.path[d];d===o.path.length-1?(l[p]=l[p]||{_errors:[]},l[p]._errors.push(r(o))):l[p]=l[p]||{_errors:[]},l=l[p],d++}}},"processError");return s(this),n}static assert(e){if(!(e instanceof Bl))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Z.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let s of this.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};a(cr,"ZodError");cr.create=a(t=>new cr(t),"create");var de=cr,Cl=os;function ls(t){Cl=t}a(ls,"setErrorMap");function st(){return Cl}a(st,"getErrorMap");var Dt=a(t=>{var e;let{data:r,path:n,errorMaps:s,issueData:i}=t,o=[...n,...i.path||[]],l=f(c({},i),{path:o}),d="",p=s.filter(g=>!!g).slice().reverse();for(let g of p)d=g(l,{data:r,defaultError:d}).message;return f(c({},i),{path:o,message:(e=i.message)!=null?e:d})},"makeIssue"),Al=[];function v(t,e){let r=Dt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,st(),os].filter(n=>!!n)});t.common.issues.push(r)}a(v,"addIssueToContext");var Rl=class Hl{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let s of r){if(s.status==="aborted")return x;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let s of r)n.push({key:await s.key,value:await s.value});return Hl.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let s of r){let{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return x;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(n[i.value]=o.value)}return{status:e.value,value:n}}};a(Rl,"ParseStatus");var re=Rl,x=Object.freeze({status:"aborted"}),Re=a(t=>({status:"dirty",value:t}),"DIRTY"),J=a(t=>({status:"valid",value:t}),"OK"),dr=a(t=>t.status==="aborted","isAborted"),ur=a(t=>t.status==="dirty","isDirty"),it=a(t=>t.status==="valid","isValid"),Nt=a(t=>typeof Promise<"u"&&t instanceof Promise,"isAsync"),w;(t=>{t.errToObj=a(e=>typeof e=="string"?{message:e}:e||{},"errToObj"),t.toString=a(e=>typeof e=="string"?e:e?.message,"toString")})(w||(w={}));var fr=class Dl extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return J(e.data)}isEqual(e){return e instanceof Dl}};a(fr,"ZodAny");fr.create=a(t=>new fr(c({typeName:"ZodAny"},k(t))),"create");var at=fr,pr=class Ie extends O{dereference(e){return new Ie(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new Ie(f(c({},this._def),{type:this._def.type.clone()}))}isEqual(e){var r,n,s,i,o,l;return e instanceof Ie?tt((r=this._def.exactLength)==null?void 0:r.value,(n=e._def.exactLength)==null?void 0:n.value)&&tt((s=this._def.maxLength)==null?void 0:s.value,(i=e._def.maxLength)==null?void 0:i.value)&&tt((o=this._def.minLength)==null?void 0:o.value,(l=e._def.minLength)==null?void 0:l.value)&&this._def.type.isEqual(e._def.type):!1}_parse(e){let{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==_.array)return v(r,{code:h.invalid_type,expected:_.array,received:r.parsedType}),x;if(s.exactLength!==null){let o=r.data.length>s.exactLength.value,l=r.data.length<s.exactLength.value;(o||l)&&(v(r,{code:o?h.too_big:h.too_small,minimum:l?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&r.data.length<s.minLength.value&&(v(r,{code:h.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&r.data.length>s.maxLength.value&&(v(r,{code:h.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,l)=>s.type._parseAsync(new oe(r,o,r.path,l)))).then(o=>re.mergeArray(n,o));let i=[...r.data].map((o,l)=>s.type._parseSync(new oe(r,o,r.path,l)));return re.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new Ie(f(c({},this._def),{minLength:{value:e,message:w.toString(r)}}))}max(e,r){return new Ie(f(c({},this._def),{maxLength:{value:e,message:w.toString(r)}}))}length(e,r){return new Ie(f(c({},this._def),{exactLength:{value:e,message:w.toString(r)}}))}nonempty(e){return this.min(1,e)}};a(pr,"ZodArray");pr.create=a((t,e)=>new pr(c({type:t,minLength:null,maxLength:null,exactLength:null,typeName:"ZodArray"},k(e))),"create");var ot=pr,em=a((t,e)=>Nl(t,e,new WeakSet),"isEqual"),Nl=a((t,e,r)=>Th(t,e,tm(r)),"_isEqualWithVisitedTracking"),tm=a(t=>(e,r)=>{if(oi(e)&&!t.has(e)&&oi(r)&&!t.has(r)){let n=wi(e,bi),s=wi(r,bi);return t.add(n).add(s).add(e).add(r),Nl(n,s,t)}},"_customizerWithVisitedTracking"),rm={compare:em},Ml=class{constructor(e=[],r={}){this._options=c(c({},rm),r),this._items=[];for(let n of e)this.add(n)}get items(){return[...this._items]}get size(){return this._items.length}has(e){return this._items.some(r=>this._options.compare(r,e))}add(e){this.has(e)||this._items.push(e)}isEqual(e){return this.size!==e.size?!1:this.isSubsetOf(e)&&e.isSubsetOf(this)}isSubsetOf(e){return this.size>e.size?!1:this._items.every(r=>e.has(r))}};a(Ml,"CustomSet");var K=Ml,gr=class er extends O{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 i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.bigint,received:i.parsedType}),x}let n,s=new re;for(let i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Z.assertNever(i);return{status:s.value,value:e.data}}isEqual(e){if(!(e instanceof er)||this._def.coerce!==e._def.coerce)return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}gte(e,r){return this.setLimit("min",e,!0,w.toString(r))}gt(e,r){return this.setLimit("min",e,!1,w.toString(r))}lte(e,r){return this.setLimit("max",e,!0,w.toString(r))}lt(e,r){return this.setLimit("max",e,!1,w.toString(r))}setLimit(e,r,n,s){return new er(f(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:w.toString(s)}]}))}_addCheck(e){return new er(f(c({},this._def),{checks:[...this._def.checks,e]}))}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};a(gr,"ZodBigInt");gr.create=a(t=>{var e;return new gr(c({checks:[],typeName:"ZodBigInt",coerce:(e=t?.coerce)!=null?e:!1},k(t)))},"create");var en=gr,hr=class jl extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.boolean,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof jl?this._def.coerce===e._def.coerce:!1}};a(hr,"ZodBoolean");hr.create=a(t=>new hr(c({typeName:"ZodBoolean",coerce:t?.coerce||!1},k(t))),"create");var tn=hr,$l=Symbol("zod_brand"),Kl=class _t extends O{dereference(e){return new _t(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new _t(f(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}isEqual(e){return e instanceof _t?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}mandatory(){return new _t(f(c({},this._def),{type:this._def.type.mandatory()}))}};a(Kl,"ZodBranded");var rn=Kl,mr=class Tt extends O{_parse(e){let{ctx:r}=this._processInputParams(e),n=f(c({},r),{common:f(c({},r.common),{issues:[]})}),s=this._def.innerType._parse({data:n.data,path:n.path,parent:c({},n)});return Nt(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new de(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new de(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}isEqual(e){return e instanceof Tt?this._def.innerType.isEqual(e._def.innerType)&&Z.compareFunctions(this._def.catchValue,e._def.catchValue):!1}dereference(e){return new Tt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Tt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}naked(){return this._def.innerType.naked()}mandatory(){return new Tt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(mr,"ZodCatch");mr.create=a((t,e)=>new mr(c({innerType:t,typeName:"ZodCatch",catchValue:typeof e.catch=="function"?e.catch:()=>e.catch},k(e))),"create");var nn=mr,cs=a((t,e={},r)=>t?at.create().superRefine((n,s)=>{var i,o;if(!t(n)){let l=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,d=(o=(i=l.fatal)!=null?i:r)!=null?o:!0,p=typeof l=="string"?{message:l}:l;s.addIssue(f(c({code:"custom"},p),{fatal:d}))}}):at.create(),"custom"),yr=class Kn extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.date,received:i.parsedType}),x}if(isNaN(e.data.getTime())){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_date}),x}let n=new re,s;for(let i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):Z.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Kn(f(c({},this._def),{checks:[...this._def.checks,e]}))}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}isEqual(e){if(!(e instanceof Kn))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)&&this._def.coerce===e._def.coerce}};a(yr,"ZodDate");yr.create=a(t=>new yr(c({checks:[],coerce:t?.coerce||!1,typeName:"ZodDate"},k(t))),"create");var sn=yr,vr=class bt extends O{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===_.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}dereference(e){return new bt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new bt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}isEqual(e){return e instanceof bt?this._def.innerType.isEqual(e._def.innerType)&&tt(this._def.defaultValue(),e._def.defaultValue()):!1}unwrap(){return this._def.innerType}naked(){return this._def.innerType.naked()}mandatory(){return new bt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(vr,"ZodDefault");vr.create=a((t,e,r)=>new vr(c({innerType:t,typeName:"ZodDefault",defaultValue:typeof e=="function"?e:()=>e},k(r))),"create");var $t=vr,ve=a(t=>Array.from(new Set(t)),"unique"),pe=a(t=>t instanceof on?pe(t.schema):t instanceof xe?pe(t.innerType()):t instanceof ln?[t.value]:t instanceof Le?t.options:t instanceof cn?Z.objectValues(t.enum):t instanceof $t?pe(t._def.innerType):t instanceof Ft?[void 0]:t instanceof dn?[null]:t instanceof he?[void 0,...pe(t.unwrap())]:t instanceof De?[null,...pe(t.unwrap())]:t instanceof rn||t instanceof zt?pe(t.unwrap()):t instanceof nn?pe(t._def.innerType):[],"getDiscriminator"),Ul=class Be extends O{dereference(e){let r=this.options.map(s=>s.dereference(e)),n=Be._getOptionsMap(this.discriminator,r);return new Be(f(c({},this._def),{options:r,optionsMap:n}))}getReferences(){return ve(this.options.flatMap(e=>e.getReferences()))}clone(){let e=this.options.map(r=>r.clone());return new Be(f(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.object)return v(r,{code:h.invalid_type,expected:_.object,received:r.parsedType}),x;let n=this.discriminator,s=r.data[n],i=this.optionsMap.get(s);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(v(r,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let s=Be._getOptionsMap(e,r);return new Be(c({typeName:"ZodDiscriminatedUnion",discriminator:e,options:r,optionsMap:s},k(n)))}static _getOptionsMap(e,r){let n=new Map;for(let s of r){let i=pe(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,s)}}return n}isEqual(e){if(!(e instanceof Be)||this._def.discriminator!==e._def.discriminator)return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K(this._def.options,{compare:r}),s=new K(e._def.options,{compare:r});return n.isEqual(s)}};a(Ul,"ZodDiscriminatedUnion");var ds=Ul;function Kt(t,e){return new Le(c({values:t,typeName:"ZodEnum"},k(e)))}a(Kt,"createZodEnum");var us=class tr extends O{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return v(r,{expected:Z.joinValues(n),received:r.parsedType,code:h.invalid_type}),x}if(this._def.values.indexOf(e.data)===-1){let r=this._getOrReturnCtx(e),n=this._def.values;return v(r,{received:r.data,code:h.invalid_enum_value,options:n}),x}return J(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return tr.create(e,c(c({},this._def),r))}exclude(e,r=this._def){return tr.create(this.options.filter(n=>!e.includes(n)),c(c({},this._def),r))}isEqual(e){if(!(e instanceof tr))return!1;let r=new K(this._def.values),n=new K(e._def.values);return r.isEqual(n)}};a(us,"ZodEnum");us.create=Kt;var Le=us,zl=class Ce extends O{constructor(){super(...arguments),this.validate=this.implement}dereference(e){let r=this._def.args.dereference(e),n=this._def.returns.dereference(e);return new Ce(f(c({},this._def),{args:r,returns:n}))}getReferences(){return ve([...this._def.args.getReferences(),...this._def.returns.getReferences()])}clone(){return new Ce(f(c({},this._def),{args:this._def.args.clone(),returns:this._def.returns.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.function)return v(r,{code:h.invalid_type,expected:_.function,received:r.parsedType}),x;function n(l,d){return Dt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,st(),ki].filter(p=>!!p),issueData:{code:h.invalid_arguments,argumentsError:d}})}a(n,"makeArgsIssue");function s(l,d){return Dt({data:l,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,st(),ki].filter(p=>!!p),issueData:{code:h.invalid_return_type,returnTypeError:d}})}a(s,"makeReturnsIssue");let i={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof Ut){let l=this;return J(async function(...d){let p=new de([]),g=await l._def.args.parseAsync(d,i).catch(E=>{throw p.addIssue(n(d,E)),p}),m=await Reflect.apply(o,this,g);return await l._def.returns._def.type.parseAsync(m,i).catch(E=>{throw p.addIssue(s(m,E)),p})})}else{let l=this;return J(function(...d){let p=l._def.args.safeParse(d,i);if(!p.success)throw new de([n(d,p.error)]);let g=Reflect.apply(o,this,p.data),m=l._def.returns.safeParse(g,i);if(!m.success)throw new de([s(g,m.error)]);return m.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ce(f(c({},this._def),{args:Me.create(e).rest(rt.create())}))}returns(e){return new Ce(f(c({},this._def),{returns:e}))}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Ce(c({args:e||Me.create([]).rest(rt.create()),returns:r||rt.create(),typeName:"ZodFunction"},k(n)))}isEqual(e){return e instanceof Ce&&this._def.args.isEqual(e._def.args)&&this._def.returns.isEqual(e._def.returns)}};a(zl,"ZodFunction");var fs=zl;function _r(t,e){let r=ge(t),n=ge(e);if(t===e)return{valid:!0,data:t};if(r===_.object&&n===_.object){let s=Z.objectKeys(e),i=Z.objectKeys(t).filter(l=>s.indexOf(l)!==-1),o=c(c({},t),e);for(let l of i){let d=_r(t[l],e[l]);if(!d.valid)return{valid:!1};o[l]=d.data}return{valid:!0,data:o}}else if(r===_.array&&n===_.array){if(t.length!==e.length)return{valid:!1};let s=[];for(let i=0;i<t.length;i++){let o=t[i],l=e[i],d=_r(o,l);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return r===_.date&&n===_.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}a(_r,"mergeValues");var Tr=class rr extends O{dereference(e){return new rr(f(c({},this._def),{left:this._def.left.dereference(e),right:this._def.right.dereference(e)}))}getReferences(){return ve([...this._def.left.getReferences(),...this._def.right.getReferences()])}clone(){return new rr(f(c({},this._def),{left:this._def.left.clone(),right:this._def.right.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=a((i,o)=>{if(dr(i)||dr(o))return x;let l=_r(i.value,o.value);return l.valid?((ur(i)||ur(o))&&r.dirty(),{status:r.value,value:l.data}):(v(n,{code:h.invalid_intersection_types}),x)},"handleParsed");return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}isEqual(e){if(!(e instanceof rr))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K([this._def.left,this._def.right],{compare:r}),s=new K([e._def.left,e._def.right],{compare:r});return n.isEqual(s)}};a(Tr,"ZodIntersection");Tr.create=a((t,e,r)=>new Tr(c({left:t,right:e,typeName:"ZodIntersection"},k(r))),"create");var an=Tr,br=class wt extends O{get schema(){return this._def.getter()}dereference(e){return new wt(f(c({},this._def),{getter:a(()=>this._def.getter().dereference(e),"getter")}))}getReferences(){return this._def.getter().getReferences()}clone(){return new wt(f(c({},this._def),{getter:a(()=>this._def.getter().clone(),"getter")}))}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}isEqual(e){return e instanceof wt?this._def.getter().isEqual(e._def.getter()):!1}naked(){return this._def.getter().naked()}mandatory(){return new wt(f(c({},this._def),{getter:a(()=>this._def.getter().mandatory(),"getter")}))}};a(br,"ZodLazy");br.create=a((t,e)=>new br(c({getter:t,typeName:"ZodLazy"},k(e))),"create");var on=br,wr=class Fl extends O{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return v(r,{received:r.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 Fl?tt(this._def.value,e._def.value):!1}};a(wr,"ZodLiteral");wr.create=a((t,e)=>new wr(c({value:t,typeName:"ZodLiteral"},k(e))),"create");var ln=wr,Pr=class nr extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new nr(f(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return ve([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new nr(f(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.map)return v(n,{code:h.invalid_type,expected:_.map,received:n.parsedType}),x;let s=this._def.keyType,i=this._def.valueType,o=[...n.data.entries()].map(([l,d],p)=>({key:s._parse(new oe(n,l,n.path,[p,"key"])),value:i._parse(new oe(n,d,n.path,[p,"value"]))}));if(n.common.async){let l=new Map;return Promise.resolve().then(async()=>{for(let d of o){let p=await d.key,g=await d.value;if(p.status==="aborted"||g.status==="aborted")return x;(p.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(p.value,g.value)}return{status:r.value,value:l}})}else{let l=new Map;for(let d of o){let p=d.key,g=d.value;if(p.status==="aborted"||g.status==="aborted")return x;(p.status==="dirty"||g.status==="dirty")&&r.dirty(),l.set(p.value,g.value)}return{status:r.value,value:l}}}isEqual(e){return!(!(e instanceof nr)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};a(Pr,"ZodMap");Pr.create=a((t,e,r)=>new Pr(c({valueType:e,keyType:t,typeName:"ZodMap"},k(r))),"create");var ps=Pr,xr=class Wl extends O{_parse(e){if(this._getType(e)!==_.nan){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.nan,received:n.parsedType}),x}return{status:"valid",value:e.data}}isEqual(e){return e instanceof Wl}};a(xr,"ZodNaN");xr.create=a(t=>new xr(c({typeName:"ZodNaN"},k(t))),"create");var gs=xr,kr=class Ll extends O{_parse(e){let r=Z.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==_.string&&n.parsedType!==_.number){let s=Z.objectValues(r);return v(n,{expected:Z.joinValues(s),received:n.parsedType,code:h.invalid_type}),x}if(r.indexOf(e.data)===-1){let s=Z.objectValues(r);return v(n,{received:n.data,code:h.invalid_enum_value,options:s}),x}return J(e.data)}get enum(){return this._def.values}isEqual(e){return e instanceof Ll?tt(this._def.values,e._def.values):!1}};a(kr,"ZodNativeEnum");kr.create=a((t,e)=>new kr(c({values:t,typeName:"ZodNativeEnum"},k(e))),"create");var cn=kr,Sr=class ql extends O{_parse(e){let r=this._getOrReturnCtx(e);return v(r,{code:h.invalid_type,expected:_.never,received:r.parsedType}),x}isEqual(e){return e instanceof ql}};a(Sr,"ZodNever");Sr.create=a(t=>new Sr(c({typeName:"ZodNever"},k(t))),"create");var dt=Sr,Or=class Vl extends O{_parse(e){if(this._getType(e)!==_.null){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.null,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof Vl}};a(Or,"ZodNull");Or.create=a(t=>new Or(c({typeName:"ZodNull"},k(t))),"create");var dn=Or,Er=class Pt extends O{dereference(e){return new Pt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new Pt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.null?J(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof Pt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new Pt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Er,"ZodNullable");Er.create=a((t,e)=>new Er(c({innerType:t,typeName:"ZodNullable"},k(e))),"create");var De=Er;function Gl(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=r>n?r:n,i=parseInt(t.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return i%o/Math.pow(10,s)}a(Gl,"floatSafeRemainder");var Zr=class sr extends O{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 i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.number,received:i.parsedType}),x}let n,s=new re;for(let i of this._def.checks)i.kind==="int"?Z.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:h.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?Gl(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),v(n,{code:h.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),v(n,{code:h.not_finite,message:i.message}),s.dirty()):Z.assertNever(i);return{status:s.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,w.toString(r))}gt(e,r){return this.setLimit("min",e,!1,w.toString(r))}lte(e,r){return this.setLimit("max",e,!0,w.toString(r))}lt(e,r){return this.setLimit("max",e,!1,w.toString(r))}setLimit(e,r,n,s){return new sr(f(c({},this._def),{checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:w.toString(s)}]}))}_addCheck(e){return new sr(f(c({},this._def),{checks:[...this._def.checks,e]}))}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Z.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}isEqual(e){if(!(e instanceof sr))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}};a(Zr,"ZodNumber");Zr.create=a(t=>new Zr(c({checks:[],typeName:"ZodNumber",coerce:t?.coerce||!1},k(t))),"create");var un=Zr;function Ae(t){if(t instanceof Ne){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=he.create(Ae(n))}return new Ne(f(c({},t._def),{shape:a(()=>e,"shape")}))}else return t instanceof ot?new ot(f(c({},t._def),{type:Ae(t.element)})):t instanceof he?he.create(Ae(t.unwrap())):t instanceof De?De.create(Ae(t.unwrap())):t instanceof Me?Me.create(t.items.map(e=>Ae(e))):t}a(Ae,"deepPartialify");var Pe=class se extends O{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Z.objectKeys(e);return this._cached={shape:e,keys:r}}dereference(e){let r=this._def.shape(),n={};for(let s in r)n[s]=r[s].dereference(e);return new se(f(c({},this._def),{shape:a(()=>n,"shape")}))}getReferences(){let e=this._def.shape(),r=[];for(let n in e)r.push(...e[n].getReferences());return ve(r)}clone(){let e={},r=this._def.shape();for(let[n,s]of Object.entries(r))e[n]=s.clone();return new se(f(c({},this._def),{shape:a(()=>e,"shape")}))}_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:n,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),l=[];if(this._def.unknownKeys!=="strip")for(let g in s.data)o.includes(g)||l.push(g);let d=[];for(let g of o){let m=i[g],P=s.data[g];d.push({key:{status:"valid",value:g},value:m._parse(new oe(s,P,s.path,g)),alwaysSet:g in s.data})}let p=this._def.unknownKeys;if(p==="passthrough")for(let g of l)d.push({key:{status:"valid",value:g},value:{status:"valid",value:s.data[g]}});else if(p==="strict")l.length>0&&(v(s,{code:h.unrecognized_keys,keys:l}),n.dirty());else if(p!=="strip")for(let g of l){let m=s.data[g];d.push({key:{status:"valid",value:g},value:p._parse(new oe(s,m,s.path,g)),alwaysSet:g in s.data})}return s.common.async?Promise.resolve().then(async()=>{let g=[];for(let m of d){let P=await m.key;g.push({key:P,value:await m.value,alwaysSet:m.alwaysSet})}return g}).then(g=>re.mergeObjectSync(n,g)):re.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new se(c(f(c({},this._def),{unknownKeys:"strict"}),e!==void 0?{errorMap:a((r,n)=>{var s,i,o,l;let d=(o=(i=(s=this._def).errorMap)==null?void 0:i.call(s,r,n).message)!=null?o:n.defaultError;return r.code==="unrecognized_keys"?{message:(l=w.errToObj(e).message)!=null?l:d}:{message:d}},"errorMap")}:{}))}strip(){return new se(f(c({},this._def),{unknownKeys:"strip"}))}passthrough(){return new se(f(c({},this._def),{unknownKeys:"passthrough"}))}additionalProperties(){if(this._def.unknownKeys instanceof O)return this._def.unknownKeys;if(this._def.unknownKeys==="passthrough")return at.create();if(this._def.unknownKeys==="strict")return dt.create()}extend(e){return new se(f(c({},this._def),{shape:a(()=>c(c({},this._def.shape()),e),"shape")}))}merge(e){return new se({unknownKeys:e._def.unknownKeys,shape:a(()=>c(c({},this._def.shape()),e._def.shape()),"shape"),typeName:"ZodObject"})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new se(f(c({},this._def),{unknownKeys:e}))}pick(e){let r={};return Z.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}omit(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}deepPartial(){return Ae(this)}partial(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{let s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s?.optional()}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}required(e){let r={};return Z.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof he;)i=i._def.innerType;r[n]=i}}),new se(f(c({},this._def),{shape:a(()=>r,"shape")}))}keyof(){return Kt(Z.objectKeys(this.shape))}isEqual(e){if(!(e instanceof se)||!this._unknownKeysEqual(e))return!1;let r=this._def.shape(),n=e._def.shape(),s=a((l,d)=>l[0]===d[0]&&l[1].isEqual(d[1]),"compare"),i=new K(Object.entries(r),{compare:s}),o=new K(Object.entries(n),{compare:s});return i.isEqual(o)}_unknownKeysEqual(e){let r=this.additionalProperties(),n=e.additionalProperties();return r===void 0||n===void 0?r===n:r.isEqual(n)}};a(Pe,"ZodObject");Pe.create=a((t,e)=>new Pe(c({shape:a(()=>t,"shape"),unknownKeys:"strip",typeName:"ZodObject"},k(e))),"create");Pe.strictCreate=a((t,e)=>new Pe(c({shape:a(()=>t,"shape"),unknownKeys:"strict",typeName:"ZodObject"},k(e))),"strictCreate");Pe.lazycreate=a((t,e)=>new Pe(c({shape:t,unknownKeys:"strip",typeName:"ZodObject"},k(e))),"lazycreate");var Ne=Pe,Ir=class ir extends O{dereference(e){return new ir(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new ir(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){return this._getType(e)===_.undefined?J(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}isEqual(e){return e instanceof ir?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return this._def.innerType.mandatory()}};a(Ir,"ZodOptional");Ir.create=a((t,e)=>new Ir(c({innerType:t,typeName:"ZodOptional"},k(e))),"create");var he=Ir,Jl=class xt extends O{dereference(e){return new xt(f(c({},this._def),{in:this._def.in.dereference(e),out:this._def.out.dereference(e)}))}getReferences(){return ve([...this._def.in.getReferences(),...this._def.out.getReferences()])}clone(){return new xt(f(c({},this._def),{in:this._def.in.clone(),out:this._def.out.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return a(async()=>{let i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?x:i.status==="dirty"?(r.dirty(),Re(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})},"handleAsync")();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?x:s.status==="dirty"?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,r){return new xt({in:e,out:r,typeName:"ZodPipeline"})}isEqual(e){return!(!(e instanceof xt)||!this._def.in.isEqual(e._def.in)||!this._def.out.isEqual(e._def.out))}};a(Jl,"ZodPipeline");var fn=Jl,Br=class ar extends O{unwrap(){return this._def.type}dereference(e){return new ar(f(c({},this._def),{type:this._def.type.dereference(e)}))}getReferences(){return this._def.type.getReferences()}clone(){return new ar(f(c({},this._def),{type:this._def.type.clone()}))}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==_.promise&&r.common.async===!1)return v(r,{code:h.invalid_type,expected:_.promise,received:r.parsedType}),x;let n=r.parsedType===_.promise?r.data:Promise.resolve(r.data);return J(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}isEqual(e){return e instanceof ar?this._def.type.isEqual(e._def.type):!1}naked(){return this._def.type.naked()}};a(Br,"ZodPromise");Br.create=a((t,e)=>new Br(c({type:t,typeName:"ZodPromise"},k(e))),"create");var Ut=Br,Cr=class kt extends O{dereference(e){return new kt(f(c({},this._def),{innerType:this._def.innerType.dereference(e)}))}getReferences(){return this._def.innerType.getReferences()}clone(){return new kt(f(c({},this._def),{innerType:this._def.innerType.clone()}))}_parse(e){let r=this._def.innerType._parse(e);return it(r)&&(r.value=Object.freeze(r.value)),r}unwrap(){return this._def.innerType}isEqual(e){return e instanceof kt?this._def.innerType.isEqual(e._def.innerType):!1}naked(){return this._def.innerType.naked()}mandatory(){return new kt(f(c({},this._def),{innerType:this._def.innerType.mandatory()}))}};a(Cr,"ZodReadonly");Cr.create=a((t,e)=>new Cr(c({innerType:t,typeName:"ZodReadonly"},k(e))),"create");var zt=Cr,Xl=class Xe extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}dereference(e){let r=this._def.keyType.dereference(e),n=this._def.valueType.dereference(e);return new Xe(f(c({},this._def),{keyType:r,valueType:n}))}getReferences(){return ve([...this._def.keyType.getReferences(),...this._def.valueType.getReferences()])}clone(){return new Xe(f(c({},this._def),{keyType:this._def.keyType.clone(),valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.object)return v(n,{code:h.invalid_type,expected:_.object,received:n.parsedType}),x;let s=[],i=this._def.keyType,o=this._def.valueType;for(let l in n.data)s.push({key:i._parse(new oe(n,l,n.path,l)),value:o._parse(new oe(n,n.data[l],n.path,l))});return n.common.async?re.mergeObjectAsync(r,s):re.mergeObjectSync(r,s)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof O?new Xe(c({keyType:e,valueType:r,typeName:"ZodRecord"},k(n))):new Xe(c({keyType:X.create(),valueType:e,typeName:"ZodRecord"},k(r)))}isEqual(e){return!(!(e instanceof Xe)||!this._def.keyType.isEqual(e._def.keyType)||!this._def.valueType.isEqual(e._def.valueType))}};a(Xl,"ZodRecord");var hs=Xl,Ar=class Yl extends O{dereference(e){let r=e[this._def.uri];return r||this}getReferences(){return[this._def.uri]}_parse(e){let r=this._getOrReturnCtx(e);return v(r,{code:h.unresolved_reference}),x}isOptional(){return!1}isNullable(){return!1}isEqual(e){return e instanceof Yl?this._def.uri===e._def.uri:!1}};a(Ar,"ZodRef");Ar.create=a(t=>new Ar({typeName:"ZodRef",uri:t}),"create");var ms=Ar,Rr=class Ye extends O{dereference(e){return new Ye(f(c({},this._def),{valueType:this._def.valueType.dereference(e)}))}getReferences(){return this._def.valueType.getReferences()}clone(){return new Ye(f(c({},this._def),{valueType:this._def.valueType.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.set)return v(n,{code:h.invalid_type,expected:_.set,received:n.parsedType}),x;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(v(n,{code:h.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),r.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(v(n,{code:h.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),r.dirty());let i=this._def.valueType;function o(d){let p=new Set;for(let g of d){if(g.status==="aborted")return x;g.status==="dirty"&&r.dirty(),p.add(g.value)}return{status:r.value,value:p}}a(o,"finalizeSet");let l=[...n.data.values()].map((d,p)=>i._parse(new oe(n,d,n.path,p)));return n.common.async?Promise.all(l).then(d=>o(d)):o(l)}min(e,r){return new Ye(f(c({},this._def),{minSize:{value:e,message:w.toString(r)}}))}max(e,r){return new Ye(f(c({},this._def),{maxSize:{value:e,message:w.toString(r)}}))}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}isEqual(e){var r,n,s,i;if(!(e instanceof Ye))return!1;let o=(r=this._def.minSize)==null?void 0:r.value,l=(n=e._def.minSize)==null?void 0:n.value;if(o!==l)return!1;let d=(s=this._def.maxSize)==null?void 0:s.value,p=(i=e._def.maxSize)==null?void 0:i.value;return d!==p?!1:this._def.valueType.isEqual(e._def.valueType)}};a(Rr,"ZodSet");Rr.create=a((t,e)=>new Rr(c({valueType:t,minSize:null,maxSize:null,typeName:"ZodSet"},k(e))),"create");var ys=Rr,vs=/^c[^\s-]{8,}$/i,_s=/^[a-z][a-z0-9]*$/,Ts=/^[0-9A-HJKMNP-TV-Z]{26}$/,bs=/^[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,ws=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ql="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ec=a(t=>t===Ql,"isEmojiRegex"),Bn,Ps=/^(((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}))$/,xs=/^(([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 tc(t,e){return!!((e==="v4"||!e)&&Ps.test(t)||(e==="v6"||!e)&&xs.test(t))}a(tc,"isValidIP");var Hr=class Qe extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){let i=this._getOrReturnCtx(e);return v(i,{code:h.invalid_type,expected:_.string,received:i.parsedType}),x}let n=new re,s;for(let i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),v(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){let o=e.data.length>i.value,l=e.data.length<i.value;(o||l)&&(s=this._getOrReturnCtx(e,s),o?v(s,{code:h.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&v(s,{code:h.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")ws.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"email",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")Bn||(Bn=new RegExp(Ql,"u")),Bn.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"emoji",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")bs.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"uuid",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")vs.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"cuid",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")_s.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"cuid2",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")Ts.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ulid",code:h.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),v(s,{validation:"url",code:h.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"regex",code:h.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Ol(i).test(e.data)||(s=this._getOrReturnCtx(e,s),v(s,{code:h.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="ip"?tc(e.data,i.version)||(s=this._getOrReturnCtx(e,s),v(s,{validation:"ip",code:h.invalid_string,message:i.message}),n.dirty()):Z.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),c({validation:r,code:h.invalid_string},w.errToObj(n)))}_addCheck(e){return new Qe(f(c({},this._def),{checks:[...this._def.checks,e]}))}email(e){return this._addCheck(c({kind:"email"},w.errToObj(e)))}url(e){return this._addCheck(c({kind:"url"},w.errToObj(e)))}emoji(e){return this._addCheck(c({kind:"emoji"},w.errToObj(e)))}uuid(e){return this._addCheck(c({kind:"uuid"},w.errToObj(e)))}cuid(e){return this._addCheck(c({kind:"cuid"},w.errToObj(e)))}cuid2(e){return this._addCheck(c({kind:"cuid2"},w.errToObj(e)))}ulid(e){return this._addCheck(c({kind:"ulid"},w.errToObj(e)))}ip(e){return this._addCheck(c({kind:"ip"},w.errToObj(e)))}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck(c({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(r=e?.offset)!=null?r:!1},w.errToObj(e?.message)))}regex(e,r){return this._addCheck(c({kind:"regex",regex:e},w.errToObj(r)))}includes(e,r){return this._addCheck(c({kind:"includes",value:e,position:r?.position},w.errToObj(r?.message)))}startsWith(e,r){return this._addCheck(c({kind:"startsWith",value:e},w.errToObj(r)))}endsWith(e,r){return this._addCheck(c({kind:"endsWith",value:e},w.errToObj(r)))}min(e,r){return this._addCheck(c({kind:"min",value:e},w.errToObj(r)))}max(e,r){return this._addCheck(c({kind:"max",value:e},w.errToObj(r)))}length(e,r){return this._addCheck(c({kind:"length",value:e},w.errToObj(r)))}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new Qe(f(c({},this._def),{checks:[...this._def.checks,{kind:"trim"}]}))}secret(){return this._def[b]=f(c({},this._def[b]),{secret:!0}),this}toLowerCase(){return new Qe(f(c({},this._def),{checks:[...this._def.checks,{kind:"toLowerCase"}]}))}toUpperCase(){return new Qe(f(c({},this._def),{checks:[...this._def.checks,{kind:"toUpperCase"}]}))}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}isEqual(e){if(!(e instanceof Qe))return!1;let r=new K(this._def.checks),n=new K(e._def.checks);return r.isEqual(n)}};a(Hr,"ZodString");Hr.create=a(t=>{var e;return new Hr(c({checks:[],typeName:"ZodString",coerce:(e=t?.coerce)!=null?e:!1},k(f(c({},t),{supportsExtensions:["secret"]}))))},"create");var X=Hr,Dr=class rc extends O{_parse(e){if(this._getType(e)!==_.symbol){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.symbol,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof rc}};a(Dr,"ZodSymbol");Dr.create=a(t=>new Dr(c({typeName:"ZodSymbol"},k(t))),"create");var ks=Dr,lt=class St extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName==="ZodEffects"?this._def.schema.sourceType():this._def.schema}dereference(e){return new St(f(c({},this._def),{schema:this._def.schema.dereference(e)}))}getReferences(){return this._def.schema.getReferences()}clone(){return new St(f(c({},this._def),{schema:this._def.schema.clone()}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:a(o=>{v(n,o),o.fatal?r.abort():r.dirty()},"addIssue"),get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){let o=s.transform(n.data,i);if(n.common.async)return Promise.resolve(o).then(async l=>{if(r.value==="aborted")return x;let d=await this._def.schema._parseAsync({data:l,path:n.path,parent:n});return d.status==="aborted"?x:d.status==="dirty"||r.value==="dirty"?Re(d.value):d});{if(r.value==="aborted")return x;let l=this._def.schema._parseSync({data:o,path:n.path,parent:n});return l.status==="aborted"?x:l.status==="dirty"||r.value==="dirty"?Re(l.value):l}}if(s.type==="refinement"){let o=a(l=>{let d=s.refinement(l,i);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l},"executeRefinement");if(n.common.async===!1){let l=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return l.status==="aborted"?x:(l.status==="dirty"&&r.dirty(),o(l.value),{status:r.value,value:l.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>l.status==="aborted"?x:(l.status==="dirty"&&r.dirty(),o(l.value).then(()=>({status:r.value,value:l.value}))))}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!it(o))return o;let l=s.transform(o.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:l}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>it(o)?Promise.resolve(s.transform(o.value,i)).then(l=>({status:r.value,value:l})):o);Z.assertNever(s)}isEqual(e){return!(e instanceof St)||!this._def.schema.isEqual(e._def.schema)?!1:this._def.effect.type==="refinement"?e._def.effect.type!=="refinement"?!1:Z.compareFunctions(this._def.effect.refinement,e._def.effect.refinement):this._def.effect.type==="transform"?e._def.effect.type!=="transform"?!1:Z.compareFunctions(this._def.effect.transform,e._def.effect.transform):this._def.effect.type==="preprocess"?e._def.effect.type!=="preprocess"?!1:Z.compareFunctions(this._def.effect.transform,e._def.effect.transform):!1}naked(){return this._def.schema.naked()}mandatory(){return new St(f(c({},this._def),{schema:this._def.schema.mandatory()}))}};a(lt,"ZodEffects");lt.create=a((t,e,r)=>new lt(c({schema:t,typeName:"ZodEffects",effect:e},k(r))),"create");lt.createWithPreprocess=a((t,e,r)=>new lt(c({schema:e,effect:{type:"preprocess",transform:t},typeName:"ZodEffects"},k(r))),"createWithPreprocess");var xe=lt,Nr=class Ot extends O{dereference(e){let r=this._def.items.map(s=>s.dereference(e)),n=this._def.rest?this._def.rest.dereference(e):null;return new Ot(f(c({},this._def),{items:r,rest:n}))}getReferences(){return ve([...this._def.items.flatMap(e=>e.getReferences()),...this._def.rest?this._def.rest.getReferences():[]])}clone(){let e=this._def.items.map(n=>n.clone()),r=this._def.rest?this._def.rest.clone():null;return new Ot(f(c({},this._def),{items:e,rest:r}))}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==_.array)return v(n,{code:h.invalid_type,expected:_.array,received:n.parsedType}),x;if(n.data.length<this._def.items.length)return v(n,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&n.data.length>this._def.items.length&&(v(n,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let i=[...n.data].map((o,l)=>{let d=this._def.items[l]||this._def.rest;return d?d._parse(new oe(n,o,n.path,l)):null}).filter(o=>!!o);return n.common.async?Promise.all(i).then(o=>re.mergeArray(r,o)):re.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new Ot(f(c({},this._def),{rest:e}))}isEqual(e){if(!(e instanceof Ot)||!this._restEquals(e))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K(this._def.items,{compare:r}),s=new K(e._def.items,{compare:r});return n.isEqual(s)}_restEquals(e){return this._def.rest===null?e._def.rest===null:e._def.rest!==null&&this._def.rest.isEqual(e._def.rest)}};a(Nr,"ZodTuple");Nr.create=a((t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Nr(c({items:t,typeName:"ZodTuple",rest:null},k(e)))},"create");var Me=Nr,Mr=class nc extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.undefined,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof nc}mandatory(){return dt.create(c({},this._def))}};a(Mr,"ZodUndefined");Mr.create=a(t=>new Mr(c({typeName:"ZodUndefined"},k(t))),"create");var Ft=Mr,jr=class Et extends O{dereference(e){let r=this._def.options.map(n=>n.dereference(e));return new Et(f(c({},this._def),{options:r}))}getReferences(){return ve(this._def.options.reduce((e,r)=>[...e,...r.getReferences()],[]))}clone(){let e=this._def.options.map(r=>r.clone());return new Et(f(c({},this._def),{options:e}))}_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function s(i){for(let l of i)if(l.result.status==="valid")return l.result;for(let l of i)if(l.result.status==="dirty")return r.common.issues.push(...l.ctx.common.issues),l.result;let o=i.map(l=>new de(l.ctx.common.issues));return v(r,{code:h.invalid_union,unionErrors:o}),x}if(a(s,"handleResults"),r.common.async)return Promise.all(n.map(async i=>{let o=f(c({},r),{common:f(c({},r.common),{issues:[]}),parent:null});return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(s);{let i,o=[];for(let d of n){let p=f(c({},r),{common:f(c({},r.common),{issues:[]}),parent:null}),g=d._parseSync({data:r.data,path:r.path,parent:p});if(g.status==="valid")return g;g.status==="dirty"&&!i&&(i={result:g,ctx:p}),p.common.issues.length&&o.push(p.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;let l=o.map(d=>new de(d));return v(r,{code:h.invalid_union,unionErrors:l}),x}}get options(){return this._def.options}isEqual(e){if(!(e instanceof Et))return!1;let r=a((i,o)=>i.isEqual(o),"compare"),n=new K([...this._def.options],{compare:r}),s=new K([...e._def.options],{compare:r});return n.isEqual(s)}mandatory(){let e=this._def.options.filter(i=>!(i instanceof Ft)).map(i=>i.mandatory()),[r,n,...s]=e;return r?n?new Et(f(c({},this._def),{options:[r,n,...s]})):r:dt.create(c({},this._def))}};a(jr,"ZodUnion");jr.create=a((t,e)=>new jr(c({options:t,typeName:"ZodUnion"},k(e))),"create");var pn=jr,$r=class sc extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return J(e.data)}isEqual(e){return e instanceof sc}};a($r,"ZodUnknown");$r.create=a(t=>new $r(c({typeName:"ZodUnknown"},k(t))),"create");var rt=$r,Kr=class ic extends O{_parse(e){if(this._getType(e)!==_.undefined){let n=this._getOrReturnCtx(e);return v(n,{code:h.invalid_type,expected:_.void,received:n.parsedType}),x}return J(e.data)}isEqual(e){return e instanceof ic}};a(Kr,"ZodVoid");Kr.create=a(t=>new Kr(c({typeName:"ZodVoid"},k(t))),"create");var Ss=Kr,nm=["gpt-3.5-turbo","gpt-3.5-turbo-16k","gpt-4","gpt-4-1106-preview","gpt-4-vision-preview","gpt-4-0125-preview","gpt-4-turbo-preview","gpt-4-turbo","gpt-4o","gpt-3.5-turbo-0125","gpt-3.5-turbo-1106"],mv=Le.create(["any","string","number","boolean","object","pattern","date","array","target","time","enum"]),ac=a(t=>X.create().displayAs({id:"variable",params:c({type:t?.type||"any"},t?.params)}),"variable"),oc=a(t=>X.create().displayAs({id:"conversation",params:c({},t?.params)}),"conversation"),lc=a(t=>X.create().displayAs({id:"user",params:c({},t?.params)}),"user"),cc=a(t=>X.create().displayAs({id:"message",params:c({},t?.params)}),"message"),dc=a(t=>X.create().displayAs({id:"agent",params:c({},t?.params)}),"agent"),uc=a(t=>X.create().displayAs({id:"event",params:c({},t?.params)}),"event"),fc=a(t=>X.create().displayAs({id:"table",params:c({},t?.params)}),"table"),pc=a(t=>X.create().displayAs({id:"tablerow",params:c({},t?.params)}),"tablerow"),gc=a(t=>X.create().displayAs({id:"intent",params:c({},t?.params)}),"intent"),hc=a(()=>Le.create(nm).displayAs({id:"dropdown",params:{}}),"aimodel"),mc=a(t=>X.create().displayAs({id:"datasource",params:c({},t)}),"datasource"),yc=a(t=>X.create().displayAs({id:"knowledgebase",params:c({},t)}),"knowledgebase"),vc={object:Ne.lazycreate},_c=a((t,e={message:`Input not instance of ${t.name}`})=>cs(r=>r instanceof t,e),"instanceOfType"),Os=X.create,Es=un.create,Tc=gs.create,bc=en.create,Zs=tn.create,wc=sn.create,Pc=ks.create,xc=Ft.create,kc=dn.create,Sc=at.create,Oc=rt.create,Ec=dt.create,Zc=Ss.create,Ic=ot.create,Bc=Ne.create,Cc=Ne.strictCreate,Ac=pn.create,Rc=ds.create,Hc=an.create,Dc=Me.create,Nc=hs.create,Mc=ms.create,jc=zt.create,$c=ps.create,Kc=ys.create,Uc=fs.create,zc=on.create,Fc=ln.create,Wc=Le.create,Lc=cn.create,qc=Ut.create,Un=xe.create,Vc=he.create,Gc=De.create,sm=$t.create,Jc=xe.createWithPreprocess,Xc=fn.create,Yc=a(()=>Os().optional(),"ostring"),Qc=a(()=>Es().optional(),"onumber"),ed=a(()=>Zs().optional(),"oboolean"),td={string:a(t=>X.create(f(c({},t),{coerce:!0})),"string"),number:a(t=>un.create(f(c({},t),{coerce:!0})),"number"),boolean:a(t=>tn.create(f(c({},t),{coerce:!0})),"boolean"),bigint:a(t=>en.create(f(c({},t),{coerce:!0})),"bigint"),date:a(t=>sn.create(f(c({},t),{coerce:!0})),"date")},rd=x,u=y,nd=a((t,e)=>t.anyOf.length?t.anyOf.length===1?W(t.anyOf[0],f(c({},e),{path:[...e.path,"anyOf",0]})):`z.union([${t.anyOf.map((r,n)=>W(r,f(c({},e),{path:[...e.path,"anyOf",n]}))).join(", ")}])`:"z.any()","parseAnyOf"),im=a(t=>{var e;return(e=t[b])!=null&&e.coerce?"z.coerce.boolean()":"z.boolean()"},"parseBoolean"),am=a(t=>"z.any()","parseDefault"),om=a((t,e)=>`z.union([${t.type.map(r=>W(f(c({},t),{type:r}),e)).join(", ")}])`,"parseMultipleType"),lm=a((t,e)=>`z.any().refine((value) => !${W(t.not,f(c({},e),{path:[...e.path,"not"]}))}.safeParse(value).success, "Invalid input: Should NOT be valid against schema")`,"parseNot"),cm=a(t=>"z.null()","parseNull"),dm=a(t=>[t.slice(0,t.length/2),t.slice(t.length/2)],"half"),um=a((t,...e)=>Object.keys(t).reduce((r,n)=>(e.includes(n)||(r[n]=t[n]),r),{}),"omit");function G(t,e,r){var n;let s=t[e],i="";if(s!==void 0){let o=r({value:s,json:JSON.stringify(s)});if(o){let l=o[0],d=o.length===3?o[1]:"",p=o.length===3?o[2]:o[1];i+=l,((n=t.errorMessage)==null?void 0:n[e])!==void 0&&(i+=d+JSON.stringify(t.errorMessage[e])),i+=p}}return i}a(G,"withMessage");var Zt=Symbol("Original index"),fm=a(t=>{let e=[];for(let r=0;r<t.length;r++){let n=t[r];if(typeof n=="boolean")e.push(n?{[Zt]:r}:{[Zt]:r,not:{}});else{if(Zt in n)return t;e.push(f(c({},n),{[Zt]:r}))}}return e},"ensureOriginalIndex");function Mt(t,e){if(t.allOf.length===0)return"z.never()";if(t.allOf.length===1){let r=t.allOf[0];return W(r,f(c({},e),{path:[...e.path,"allOf",r[Zt]]}))}else{let[r,n]=dm(fm(t.allOf));return`z.intersection(${Mt({allOf:r},e)}, ${Mt({allOf:n},e)})`}}a(Mt,"parseAllOf");var pm=a((t,e)=>{if(Array.isArray(t.items))return`z.tuple([${t.items.map((n,s)=>W(n,f(c({},e),{path:[...e.path,"items",s]})))}])`;let r=t.items?`z.array(${W(t.items,f(c({},e),{path:[...e.path,"items"]}))})`:"z.array(z.any())";return r+=G(t,"minItems",({json:n})=>[`.min(${n}`,", ",")"]),r+=G(t,"maxItems",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseArray"),gm=a(t=>`z.literal(${JSON.stringify(t.const)})`,"parseConst"),hm=a(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"),mm=a((t,e)=>{let r=W(t.if,f(c({},e),{path:[...e.path,"if"]})),n=W(t.then,f(c({},e),{path:[...e.path,"then"]})),s=W(t.else,f(c({},e),{path:[...e.path,"else"]}));return`z.union([${n}, ${s}]).superRefine((value,ctx) => {
|
|
12
12
|
const result = ${r}.safeParse(value).success
|
|
13
13
|
? ${n}.safeParse(value)
|
|
14
14
|
: ${s}.safeParse(value);
|
|
15
15
|
if (!result.success) {
|
|
16
16
|
result.error.errors.forEach((error) => ctx.addIssue(error))
|
|
17
17
|
}
|
|
18
|
-
})`},"parseIfThenElse"),
|
|
19
|
-
const schemas = [${t.oneOf.map((r,n)=>W(r,
|
|
18
|
+
})`},"parseIfThenElse"),ym=a(t=>{var e;let r="z.number()";return(e=t[b])!=null&&e.coerce&&(r="z.coerce.number()"),t.type==="integer"?r+=G(t,"type",()=>[".int(",")"]):r+=G(t,"format",({value:n})=>{if(n==="int64")return[".int(",")"]}),r+=G(t,"multipleOf",({value:n,json:s})=>n===1?r.startsWith("z.number().int(")?void 0:[".int(",")"]:[`.multipleOf(${s}`,", ",")"]),typeof t.minimum=="number"?t.exclusiveMinimum===!0?r+=G(t,"minimum",({json:n})=>[`.gt(${n}`,", ",")"]):r+=G(t,"minimum",({json:n})=>[`.gte(${n}`,", ",")"]):typeof t.exclusiveMinimum=="number"&&(r+=G(t,"exclusiveMinimum",({json:n})=>[`.gt(${n}`,", ",")"])),typeof t.maximum=="number"?t.exclusiveMaximum===!0?r+=G(t,"maximum",({json:n})=>[`.lt(${n}`,", ",")"]):r+=G(t,"maximum",({json:n})=>[`.lte(${n}`,", ",")"]):typeof t.exclusiveMaximum=="number"&&(r+=G(t,"exclusiveMaximum",({json:n})=>[`.lt(${n}`,", ",")"])),r},"parseNumber"),Is=a((t,e)=>t.oneOf.length?t.oneOf.length===1?W(t.oneOf[0],f(c({},e),{path:[...e.path,"oneOf",0]})):`z.any().superRefine((x, ctx) => {
|
|
19
|
+
const schemas = [${t.oneOf.map((r,n)=>W(r,f(c({},e),{path:[...e.path,"oneOf",n]}))).join(", ")}];
|
|
20
20
|
const errors = schemas.reduce(
|
|
21
21
|
(errors: z.ZodError[], schema) =>
|
|
22
22
|
((result) => ("error" in result ? [...errors, result.error] : errors))(
|
|
@@ -32,7 +32,7 @@ ${Q}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(T).join("
|
|
|
32
32
|
message: "Invalid input: Should pass single schema",
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
})`:"z.any()","parseOneOf");function
|
|
35
|
+
})`:"z.any()","parseOneOf");function sd(t,e){let r;t.properties&&(Object.keys(t.properties).length?(r="z.object({ ",r+=Object.keys(t.properties).map(o=>{let l=t.properties[o],d=`${JSON.stringify(o)}: ${W(l,f(c({},e),{path:[...e.path,"properties",o]}))}`,p=typeof l=="object"&&l.default!==void 0||typeof t.default=="object"&&t.default!==null&&o in t.default,g=Array.isArray(t.required)?t.required.includes(o):typeof l=="object"&&l.required===!0;return!p&&!g?`${d}.optional()`:d}).join(", "),r+=" })"):r="z.object({})");let n=t.additionalProperties!==void 0?W(t.additionalProperties,f(c({},e),{path:[...e.path,"additionalProperties"]})):void 0,s;if(t.patternProperties){let o=Object.fromEntries(Object.entries(t.patternProperties).map(([l,d])=>[l,W(d,f(c({},e),{path:[...e.path,"patternProperties",l]}))],{}));s="",r?n?s+=`.catchall(z.union([${[...Object.values(o),n].join(", ")}]))`:Object.keys(o).length>1?s+=`.catchall(z.union([${Object.values(o).join(", ")}]))`:s+=`.catchall(${Object.values(o)})`:n?s+=`z.record(z.union([${[...Object.values(o),n].join(", ")}]))`:Object.keys(o).length>1?s+=`z.record(z.union([${Object.values(o).join(", ")}]))`:s+=`z.record(${Object.values(o)})`,s+=`.superRefine((value, ctx) => {
|
|
36
36
|
`,s+=`for (const key in value) {
|
|
37
37
|
`,n&&(t.properties?s+=`let evaluated = [${Object.keys(t.properties).map(l=>JSON.stringify(l)).join(", ")}].includes(key)
|
|
38
38
|
`:s+=`let evaluated = false
|
|
@@ -64,7 +64,7 @@ ${Q}`.trim();case u.ZodFirstPartyTypeKind.ZodEnum:return l.values.map(T).join("
|
|
|
64
64
|
`,s+=`}
|
|
65
65
|
`,s+=`}
|
|
66
66
|
`),s+=`}
|
|
67
|
-
`,s+="})"}let i=r?s?r+s:n?n==="z.never()"?r+".strict()":r+`.catchall(${n})`:r:s||(n?`z.record(${n})`:"z.record(z.any())");return $.an.anyOf(t)&&(i+=`.and(${sd(p(c({},t),{anyOf:t.anyOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),$.a.oneOf(t)&&(i+=`.and(${Bs(p(c({},t),{oneOf:t.oneOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),$.an.allOf(t)&&(i+=`.and(${$t(p(c({},t),{allOf:t.allOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?p(c({},o),{type:"object"}):o)}),e)})`),i}a(id,"parseObject");var _m=a(t=>{var e;let r="z.string()";if((e=t[b])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";r="z.coerce.string()"}return r+=G(t,"format",({value:n})=>{switch(n){case"email":return[".email(",")"];case"ip":return[".ip(",")"];case"ipv4":return['.ip({ version: "v4"',", message: "," })"];case"ipv6":return['.ip({ version: "v6"',", message: "," })"];case"uri":return[".url(",")"];case"uuid":return[".uuid(",")"];case"date-time":return[".datetime(",")"]}}),r+=G(t,"pattern",({json:n})=>[`.regex(new RegExp(${n})`,", ",")"]),r+=G(t,"minLength",({json:n})=>[`.min(${n}`,", ",")"]),r+=G(t,"maxLength",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseString"),Tm=a((t,e)=>`${W(pm(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),bm=a(t=>`z.ref('${t.$ref}')`,"parseRef"),wm=a((t,e)=>{var r,n;if(t.oneOf.length<=1||!((r=t.discriminator)!=null&&r.propertyName))return Bs(t,e);let s=t.oneOf.map((i,o)=>W(i,p(c({},e),{path:[...e.path,"oneOf",o]})));return`z.discriminatedUnion("${(n=t.discriminator)==null?void 0:n.propertyName}", [${s.join(", ")}])`},"parseDiscriminator"),W=a((t,e={seen:new Map,path:[]},r)=>{if(typeof t!="object")return t?"z.any()":"z.never()";if(e.parserOverride){let i=e.parserOverride(t,e);if(typeof i=="string")return i}let n=e.seen.get(t);if(n){if(n.r!==void 0)return n.r;if(e.depth===void 0||n.n>=e.depth)return"z.any()";n.n+=1}else n={r:void 0,n:0},e.seen.set(t,n);let s=km(t,e);return r||(s=Pm(t,s),e.withoutDefaults||(s=xm(t,s))),n.r=s,s},"parseSchema"),Pm=a((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),xm=a((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),km=a((t,e)=>$.a.nullable(t)?Tm(t,e):$.an.object(t)?id(t,e):$.an.array(t)?gm(t,e):$.an.anyOf(t)?sd(t,e):$.an.allOf(t)?$t(t,e):$.a.discriminator(t)?wm(t,e):$.a.oneOf(t)?Bs(t,e):$.a.not(t)?cm(t,e):$.an.enum(t)?mm(t):$.a.const(t)?hm(t):$.a.multipleType(t)?lm(t,e):$.a.primitive(t,"string")?_m(t):$.a.primitive(t,"number")||$.a.primitive(t,"integer")?vm(t):$.a.primitive(t,"boolean")?am(t):$.a.primitive(t,"null")?dm(t):$.a.conditional(t)?ym(t,e):$.a.ref(t)?bm(t):om(t),"selectParser"),$={an:{object:a(t=>t.type==="object","object"),array:a(t=>t.type==="array","array"),anyOf:a(t=>t.anyOf!==void 0,"anyOf"),allOf:a(t=>t.allOf!==void 0,"allOf"),enum:a(t=>t.enum!==void 0,"enum")},a:{nullable:a(t=>t.nullable===!0,"nullable"),multipleType:a(t=>Array.isArray(t.type),"multipleType"),not:a(t=>t.not!==void 0,"not"),const:a(t=>t.const!==void 0,"const"),primitive:a((t,e)=>t.type===e,"primitive"),conditional:a(t=>!!("if"in t&&t.if&&"then"in t&&"else"in t&&t.then&&t.else),"conditional"),discriminator:a(t=>{var e;return t.oneOf!==void 0&&((e=t.discriminator)==null?void 0:e.propertyName)!==void 0},"discriminator"),oneOf:a(t=>t.oneOf!==void 0,"oneOf"),ref:a(t=>t.$ref!==void 0,"ref")}},Sm=a(t=>{let e;try{e=new Function("z",`return ${t}`)(u)}catch(r){return{sucess:!1,error:`Failed to evaluate schema: ${(r instanceof Error?r:new Error(String(r))).message}`}}return e instanceof u.ZodType?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),Om=a(t=>W(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),Em=a(t=>{let e=Om(t);e=e.replaceAll("errors: z.ZodError[]","errors");let r=Sm(e);if(!r.sucess)throw new Wr(r.error);return r.value},"jsonSchemaToZod"),Bt=a((t,e)=>{var r,n;if(e[b]&&t._def&&(t._def[b]=e[b]),((r=t._def)==null?void 0:r.typeName)==="ZodObject"&&e.type==="object"&&e.properties&&Object.entries(e.properties).forEach(([s,i])=>{let o=typeof t._def.shape=="function"?t._def.shape():t._def.shape;o[s]&&Bt(o[s],i)}),((n=t._def)==null?void 0:n.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&Bt(t._def.valueType,e.additionalProperties),e.type==="array"&&e.items){let s=e.items;if(typeof s=="object"&&!Array.isArray(s)){let i=t._def.type;i&&Bt(i,s)}else Array.isArray(s)&&s.forEach((i,o)=>{let l=t._def;l.typeName===y.ZodFirstPartyTypeKind.ZodTuple&&Bt(l.items[o],i)})}},"applyZuiPropsRecursively"),Zm=a(t=>{let e=Em(t);return Bt(e,t),e},"fromJSONSchemaLegacy"),Im=a(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&ad(n))&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodOptional},"isOptionalSchema"),Bm=a(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&n.type==="null")&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodNullable},"isNullableSchema"),ad=a(t=>{var e,r;return t.not===!0&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodUndefined},"isUndefinedSchema"),Cm=a(t=>{var e,r;return!t.not&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodUnknown},"isUnknownSchema"),Am=a(({type:t,minimum:e,exclusiveMinimum:r,maximum:n,exclusiveMaximum:s,multipleOf:i,format:o})=>{let l=u.number();return t==="integer"&&(l=l.int()),o==="finite"&&(l=l.finite()),r!==void 0?l=l.gt(r):e!==void 0&&(l=l.gte(e)),s!==void 0?l=l.lt(s):n!==void 0&&(l=l.lte(n)),i!==void 0&&(l=l.multipleOf(i)),l},"numberJSONSchemaToZuiNumber"),Rm=a(({format:t,pattern:e,minLength:r,maxLength:n})=>{let s=u.string();if(r&&n&&r===n?s=s.length(r):(r&&(s=s.min(r)),n&&(s=s.max(n))),t==="cuid"||e===j.cuid)s=s.cuid();else if(t==="cuid2"||e===j.cuid2)s=s.cuid2();else if(t==="emoji"||e===j.emoji)s=s.emoji();else if(t==="ulid"||e===j.ulid)s=s.ulid();else if(t==="date-time"){let{precision:i,offset:o}=e?Vh(e):{};s=s.datetime({precision:i,offset:o})}else t==="email"||e===j.email?s=s.email():t==="ipv4"||e===j.ipv4?s=s.ip():t==="ipv6"||e===j.ipv6?s=s.ip("v6"):t==="uri"?s=s.url():t==="uuid"||e===j.uuid?s=s.uuid():e&&(s=s.regex(new RegExp(e)));return s},"stringJSONSchemaToZuiString"),_t=a((t,e)=>{let r=[];e.enum!==void 0&&r.push(...e.enum),e.const!==void 0&&r.push(e.const);let n=r.filter(o=>typeof o===t),[s]=n;if(!s){if(t==="string"&&e.type==="string")return Rm(e);if(t==="number"&&(e.type==="number"||e.type==="integer"))return Am(e);if(t==="boolean")return u.boolean();if(t==="null")return u.null();throw new Wr(`Unknown primitive type: "${t}"`)}if(n.length===1)return u.literal(s);let i=n.map(o=>u.literal(o));return u.union(i)},"toZuiPrimitive"),Hm=a((t,e)=>Dm(t)?Nm(t,e):Mm(t)?$m(t,e):jm(t,e),"arrayJSONSchemaToZuiArray"),Dm=a(t=>Array.isArray(t.items),"_isTuple"),Mm=a(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),Nm=a(({items:t,additionalItems:e},r)=>{let n=t.map(r),s=u.tuple(n);return e!==void 0&&(s=s.rest(r(e))),s},"_handleTuple"),$m=a(({items:t,minItems:e,maxItems:r},n)=>{let s=u.set(n(t));return e&&(s=s.min(e)),r&&(s=s.max(r)),s},"_handleSet"),jm=a(({minItems:t,maxItems:e,items:r},n)=>{let s=u.array(n(r));return t&&t===e?s.length(t):(t&&(s=s.min(t)),e&&(s=s.max(e)),s)},"_handleArray"),Je=u.any();function od(t){return F(t)}a(od,"fromJSONSchema");function F(t){var e;if(t===void 0)return Je;if(t===!0)return u.any();if(t===!1)return u.never();if(t.default!==void 0)return F(p(c({},t),{default:void 0})).default(t.default);if(t.readOnly)return F(p(c({},t),{readOnly:void 0})).readonly();if(t.oneOf!==void 0)throw new Te({oneOf:t.oneOf});if(t.patternProperties!==void 0)throw new Te({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new Te({propertyNames:t.propertyNames});if(t.if!==void 0)throw new Te({if:t.if});if(t.then!==void 0)throw new Te({then:t.then});if(t.else!==void 0)throw new Te({else:t.else});if(t.$ref!==void 0)return u.ref(t.$ref);if(t.not!==void 0){if(ad(t))return u.undefined();if(t.not===!0)return u.never();throw new Te({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return Je;if(t.type.length===1)return F(p(c({},t),{type:t.type[0]}));let r=t,{type:n}=r,s=Bi(r,["type"]),i=t.type.map(o=>F(p(c({},s),{type:o})));return u.union(i)}if(t.type==="string")return t.enum&&t.enum.length>0?u.enum(t.enum):_t("string",t);if(t.type==="integer"){let r=_t("number",t);return r instanceof u.ZodNumber?r.int():r}if(t.type==="number")return _t("number",t);if(t.type==="boolean")return _t("boolean",t);if(t.type==="null")return _t("null",t);if(t.type==="array")return Hm(t,F);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let r=F(t.additionalProperties);return F(p(c({},t),{additionalProperties:void 0})).catchall(r)}if(t.properties!==void 0){let r={};for(let[n,s]of Object.entries(t.properties)){let i=F(s),o=(e=t.required)!=null?e:[];r[n]=o.includes(n)?i:i.optional()}return u.object(r)}if(t.additionalProperties!==void 0){let r=F(t.additionalProperties);return u.record(r)}return u.record(Je)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return Je;if(t.anyOf.length===1)return F(t.anyOf[0]);if(Im(t))return F(t.anyOf[0]).optional();if(Bm(t))return F(t.anyOf[0]).nullable();let r=t.anyOf.map(F);return u.union(r)}if(t.allOf!==void 0){if(t.allOf.length===0)return Je;if(t.allOf.length===1)return F(t.allOf[0]);let[r,...n]=t.allOf,s=F(r),i=F({allOf:n});return u.intersection(s,i)}return Cm(t)?u.unknown():Je}a(F,"_fromJSONSchema");var Km=/^\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))?$/,Fn=a((t,e,r=!0)=>{if(typeof t!="object")throw new Rn("Input must be an object");let n=a(o=>{let l=o;return e?.nullable&&(l=l.nullable()),e?.optional&&(l=l.optional()),e?.passtrough&&typeof l.passthrough=="function"&&(l=l.passthrough()),l},"applyOptions"),s=Object.entries(t).reduce((o,[l,d])=>{if(d===null)o[l]=n(y.null());else switch(typeof d){case"string":o[l]=Km.test(d)?n(y.string().datetime()):n(y.string());break;case"number":o[l]=n(y.number());break;case"boolean":o[l]=n(y.boolean());break;case"object":Array.isArray(d)?d.length===0?o[l]=n(y.array(y.unknown())):typeof d[0]=="object"?o[l]=n(y.array(Fn(d[0],e,!1))):["string","number","boolean"].includes(typeof d[0])&&(o[l]=n(y.array(y[typeof d[0]]()))):o[l]=n(Fn(d,e,!1));break;default:throw new Rn(`Unsupported type for key ${l}`)}return o},{}),i=Object.keys(s).length>0;return e?.passtrough||!r&&!i?y.object(s).passthrough():y.object(s)},"fromObject");function ld(){return{}}a(ld,"parseAnyDef");function cd(t,e){var r,n;let s={type:"array"};return((n=(r=t.type)==null?void 0:r._def)==null?void 0:n.typeName)!=="ZodAny"&&(s.items=C(t.type._def,p(c({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&H(s,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&H(s,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(H(s,"minItems",t.exactLength.value,t.exactLength.message,e),H(s,"maxItems",t.exactLength.value,t.exactLength.message,e)),s}a(cd,"parseArrayDef");function dd(t,e){let r=c({type:"integer",format:"int64"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?H(r,"minimum",n.value,n.message,e):H(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),H(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?H(r,"maximum",n.value,n.message,e):H(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),H(r,"maximum",n.value,n.message,e));break;case"multipleOf":H(r,"multipleOf",n.value,n.message,e);break}return r}a(dd,"parseBigintDef");function ud(t){return c({type:"boolean"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{})}a(ud,"parseBooleanDef");function pd(t,e){return C(t.type._def,e)}a(pd,"parseBrandedDef");var Um=a((t,e)=>C(t.innerType._def,e),"parseCatchDef");function fd(t,e){return e.dateStrategy=="integer"?zm(t,e):c({type:"string",format:"date-time"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{})}a(fd,"parseDateDef");var zm=a((t,e)=>{let r=c({type:"integer",format:"unix-time"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"&&H(r,"minimum",n.value,n.message,e);break;case"max":e.target==="jsonSchema7"&&H(r,"maximum",n.value,n.message,e);break}return r},"integerDateParser");function gd(t,e){return p(c({},C(t.innerType._def,e)),{default:t.defaultValue()})}a(gd,"parseDefaultDef");function hd(t,e){return e.effectStrategy==="input"?C(t.schema._def,e):{}}a(hd,"parseEffectsDef");function md(t){return{type:"string",enum:t.values}}a(md,"parseEnumDef");var Fm=a(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function yd(t,e){let r=[C(t.left._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),C(t.right._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(i=>!!i),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return r.forEach(i=>{if(Fm(i))s.push(...i.allOf),i.unevaluatedProperties===void 0&&(n=void 0);else{let o=i;if("additionalProperties"in i&&i.additionalProperties===!1){let l=i,{additionalProperties:d}=l;o=Bi(l,["additionalProperties"])}else n=void 0;s.push(o)}}),s.length?c({allOf:s},n):void 0}a(yd,"parseIntersectionDef");function vd(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}a(vd,"parseLiteralDef");function Cs(t,e){var r,n,s,i,o;if(e.target==="openApi3"&&((r=t.keyType)==null?void 0:r._def.typeName)==="ZodEnum")return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((d,f)=>{var g;return p(c({},d),{[f]:(g=C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"properties",f]})))!=null?g:{}})},{}),additionalProperties:!1};let l={type:"object",additionalProperties:(n=C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:{}};if(e.target==="openApi3")return l;if(((s=t.keyType)==null?void 0:s._def.typeName)==="ZodString"&&((i=t.keyType._def.checks)!=null&&i.length)){let d=Object.entries(as(t.keyType._def,e)).reduce((f,[g,m])=>g==="type"?f:p(c({},f),{[g]:m}),{});return p(c({},l),{propertyNames:d})}else if(((o=t.keyType)==null?void 0:o._def.typeName)==="ZodEnum")return p(c({},l),{propertyNames:{enum:t.keyType._def.values}});return l}a(Cs,"parseRecordDef");function _d(t,e){if(e.mapStrategy==="record")return Cs(t,e);let r=C(t.keyType._def,p(c({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},n=C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}a(_d,"parseMapDef");function Td(t){let e=t.values,n=Object.keys(t.values).filter(i=>typeof e[e[i]]!="number").map(i=>e[i]),s=Array.from(new Set(n.map(i=>typeof i)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n.filter(i=>typeof i=="string"||typeof i=="number")}}a(Td,"parseNativeEnumDef");function bd(){return{not:{}}}a(bd,"parseNeverDef");function wd(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}a(wd,"parseNullDef");var zr={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Pd(t,e){if(e.target==="openApi3")return Oi(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in zr&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,i)=>{let o=zr[i._def.typeName];return o&&!s.includes(o)?[...s,o]:s},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((s,i)=>{let o=typeof i._def.value;switch(o){case"string":case"number":case"boolean":return[...s,o];case"bigint":return[...s,"integer"];case"object":if(i._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===r.length){let s=n.filter((i,o,l)=>l.indexOf(i)===o);return{type:s.length>1?s:s[0],enum:r.reduce((i,o)=>i.includes(o._def.value)?i:[...i,o._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,s)=>[...n,...s._def.values.filter(i=>!n.includes(i))],[])};return Oi(t,e)}a(Pd,"parseUnionDef");var Oi=a((t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((s,i)=>C(s._def,p(c({},e),{currentPath:[...e.currentPath,e.unionStrategy,`${i}`]}))).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0)),n=e.discriminator&&t.typeName==="ZodDiscriminatedUnion"&&typeof t.discriminator=="string"?{discriminator:{propertyName:t.discriminator}}:{};if(r.length)return e.unionStrategy==="anyOf"?c({anyOf:r},n):c({oneOf:r},n)},"asUnionOf");function xd(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length)){let n=t.innerType;if(e.target==="openApi3"){let i={type:zr[n._def.typeName],nullable:!0};return Wn(n._def,e,i)}let s={type:[zr[n._def.typeName],"null"]};return Wn(n._def,e,s)}if(e.target==="openApi3"){let n=C(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath]}));return n&&p(c({},n),{nullable:!0})}let r=C(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return r&&{anyOf:[r,{type:"null"}]}}a(xd,"parseNullableDef");function kd(t,e){let r=c({type:"number"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",is(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?H(r,"minimum",n.value,n.message,e):H(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),H(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?H(r,"maximum",n.value,n.message,e):H(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),H(r,"maximum",n.value,n.message,e));break;case"multipleOf":H(r,"multipleOf",n.value,n.message,e);break}return r}a(kd,"parseNumberDef");var Wm=a((t,e)=>{var r;return t.unknownKeys instanceof O?(r=C(t.unknownKeys._def,p(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function Sd(t,e){let r=p(c({type:"object"},Object.entries(t.shape()).reduce((n,[s,i])=>{if(i===void 0||i._def===void 0)return n;let o=C(i._def,p(c({},e),{currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]}));return o===void 0?n:{properties:p(c({},n.properties),{[s]:o}),required:i.isOptional()?n.required:[...n.required,s]}},{properties:{},required:[]})),{additionalProperties:Wm(t,e)});return r.required.length||delete r.required,r}a(Sd,"parseObjectDef");var Lm=a((t,e)=>{var r;if(e.currentPath.toString()===((r=e.propertyPath)==null?void 0:r.toString()))return C(t.innerType._def,e);let n=C(t.innerType._def,p(c({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return n?{anyOf:[{not:{}},n]}:{}},"parseOptionalDef"),qm=a((t,e)=>{if(e.pipeStrategy==="input")return C(t.in._def,e);if(e.pipeStrategy==="output")return C(t.out._def,e);let r=C(t.in._def,p(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),n=C(t.out._def,p(c({},e),{currentPath:[...e.currentPath,"allOf",r?"1":"0"]}));return{allOf:[r,n].filter(s=>s!==void 0)}},"parsePipelineDef");function Od(t,e){return C(t.type._def,e)}a(Od,"parsePromiseDef");function Ed(t,e){let n={type:"array",uniqueItems:!0,items:C(t.valueType._def,p(c({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&H(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&H(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}a(Ed,"parseSetDef");function Zd(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>C(r._def,p(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:C(t.rest._def,p(c({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>C(r._def,p(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[])}}a(Zd,"parseTupleDef");function Id(){return{not:{}}}a(Id,"parseUndefinedDef");function Bd(){return{}}a(Bd,"parseUnknownDef");var Vm=a((t,e)=>C(t.innerType._def,e),"parseReadonlyDef");function Cd(t){return{$ref:t.uri}}a(Cd,"parseRefDef");function C(t,e,r=!1){let n=e.seen.get(t);if(n&&!r){let o=Gm(n,e);if(o!==void 0)return o}let s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);let i=Xm(t,t.typeName,e);return i&&Wn(t,e,i),s.jsonSchema=i,i}a(C,"parseDef");var Gm=a((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Jm(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},"get$ref"),Jm=a((t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")},"getRelativePath"),Xm=a((t,e,r)=>{switch(e){case"ZodString":return as(t,r);case"ZodNumber":return kd(t,r);case"ZodObject":return Sd(t,r);case"ZodBigInt":return dd(t,r);case"ZodBoolean":return ud(t);case"ZodDate":return fd(t,r);case"ZodUndefined":return Id();case"ZodNull":return wd(r);case"ZodArray":return cd(t,r);case"ZodUnion":case"ZodDiscriminatedUnion":return Pd(t,r);case"ZodIntersection":return yd(t,r);case"ZodTuple":return Zd(t,r);case"ZodRecord":return Cs(t,r);case"ZodRef":return Cd(t);case"ZodLiteral":return vd(t,r);case"ZodEnum":return md(t);case"ZodNativeEnum":return Td(t);case"ZodNullable":return xd(t,r);case"ZodOptional":return Lm(t,r);case"ZodMap":return _d(t,r);case"ZodSet":return Ed(t,r);case"ZodLazy":return C(t.getter()._def,r);case"ZodPromise":return Od(t,r);case"ZodNaN":case"ZodNever":return bd();case"ZodEffects":return hd(t,r);case"ZodAny":return ld();case"ZodUnknown":return Bd();case"ZodDefault":return gd(t,r);case"ZodBranded":return pd(t,r);case"ZodReadonly":return Vm(t,r);case"ZodCatch":return Um(t,r);case"ZodPipeline":return qm(t,r);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return(n=>{})(e)}},"selectParser"),Wn=a((t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),Object.assign(r,{[b]:c(c({},t[b]),r[b])}),r),"addMeta"),Ei={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"},Ym=a(t=>typeof t=="string"?p(c({},Ei),{name:t}):c(c({},Ei),t),"getDefaultOptions"),Qm=a(t=>{let e=Ym(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return p(c({},e),{currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))})},"getRefs"),ey=a((t,e)=>{var r;let n=Qm(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((d,[f,g])=>{var m;return p(c({},d),{[f]:(m=C(g._def,p(c({},n),{currentPath:[...n.basePath,n.definitionPath,f]}),!0))!=null?m:{}})},{}):void 0,i=typeof e=="string"?e:e?.name,o=(r=C(t._def,i===void 0?n:p(c({},n),{currentPath:[...n.basePath,n.definitionPath,i]}),!1))!=null?r:{},l=i===void 0?s?p(c({},o),{[n.definitionPath]:s}):o:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,i].join("/"),[n.definitionPath]:p(c({},s),{[i]:o})};return n.target==="jsonSchema7"?l.$schema="http://json-schema.org/draft-07/schema#":n.target==="jsonSchema2019-09"&&(l.$schema="https://json-schema.org/draft/2019-09/schema#"),l},"zodToJsonSchema"),ty=a((t,e={target:"openApi3"})=>{let r=ey(t,e);return e.$schemaUrl===!1?delete r.$schema:typeof e.$schemaUrl=="string"&&(r.$schema=e.$schemaUrl),r},"toJSONSchemaLegacy");var ut=(t,e)=>{let r=t._def,n=e._def;if(r.typeName===y.ZodFirstPartyTypeKind.ZodObject&&n.typeName===y.ZodFirstPartyTypeKind.ZodObject){let s=r.shape(),i=n.shape();return y.object({...s,...i})}if(r.typeName===y.ZodFirstPartyTypeKind.ZodRecord&&n.typeName===y.ZodFirstPartyTypeKind.ZodRecord)return y.record(y.intersection(r.valueType,n.valueType));throw new Error("Cannot merge object schemas with record schemas")},Ad=y;var re=y.string().min(1),Hd=y.object({text:re}),Dd=y.object({markdown:re}),Md=y.object({imageUrl:re}),Nd=y.object({audioUrl:re}),$d=y.object({videoUrl:re}),jd=y.object({fileUrl:re,title:re.optional()}),Kd=y.object({latitude:y.number(),longitude:y.number(),address:y.string().optional(),title:y.string().optional()}),Ud=y.object({title:re,subtitle:re.optional(),imageUrl:re.optional(),actions:y.array(y.object({action:y.enum(["postback","url","say"]),label:re,value:re}))}),Rd=y.object({text:re,options:y.array(y.object({label:re,value:re}))}),ry=y.object({items:y.array(Ud)}),ny=y.union([y.object({type:y.literal("text"),payload:Hd}),y.object({type:y.literal("markdown"),payload:Dd}),y.object({type:y.literal("image"),payload:Md}),y.object({type:y.literal("audio"),payload:Nd}),y.object({type:y.literal("video"),payload:$d}),y.object({type:y.literal("file"),payload:jd}),y.object({type:y.literal("location"),payload:Kd})]),sy=y.object({items:y.array(ny)}),iy={schema:Dd},ay={text:{schema:Hd},image:{schema:Md},audio:{schema:Nd},video:{schema:$d},file:{schema:jd},location:{schema:Kd},carousel:{schema:ry},card:{schema:Ud},dropdown:{schema:Rd},choice:{schema:Rd},bloc:{schema:sy}};var Lt="x-bot-id",Rs="x-bot-user-id",Hs="x-integration-id",Ds="x-webhook-id",Ms="x-bp-configuration-type",qt="x-bp-configuration",Vt="x-bp-operation",Ns="x-bp-type",oy={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};var zd=require("browser-or-node");var $s=console;function oe(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function Gt(t,e=8072,r=uy){if(!zd.isNode)throw new Error("This function can only be called in Node.js");let s=require("http").createServer(async(i,o)=>{try{let l=await ly(i);if(l.path==="/health"){o.writeHead(200).end("ok");return}let d=await t(l);o.writeHead(d?.status??200,d?.headers??{}).end(d?.body??"{}")}catch(l){$s.error("Error while handling request",{error:l?.message??"Internal error occured"}),o.writeHead(500).end(JSON.stringify({error:l?.message??"Internal error occured"}))}});return s.listen(e,()=>r(e)),s}async function ly(t){let e=await dy(t),r={};for(let s=0;s<t.rawHeaders.length;s+=2){let i=t.rawHeaders[s].toLowerCase(),o=t.rawHeaders[s+1];r[i]=o}let n=new URL(t.url??"",t.headers.host?`http://${t.headers.host}`:"http://botpress.cloud");return{body:e,path:n.pathname,query:cy(n.search,"?"),headers:r,method:t.method?.toUpperCase()??"GET"}}function cy(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function dy(t){return new Promise((e,r)=>{if(t.method!=="POST"&&t.method!=="PUT"&&t.method!=="PATCH")return e(void 0);let n="";t.on("data",s=>n+=s.toString()),t.on("error",s=>r(s)),t.on("end",()=>e(n))})}function uy(t){$s.info(`Listening on port ${t}`)}var Sn=require("@botpress/client");var M={};yt(M,{mapKeys:()=>gy,mapValues:()=>fy,mergeRecords:()=>my,pairs:()=>hn,stripUndefinedProps:()=>hy,values:()=>py});var hn=t=>Object.entries(t),py=t=>Object.values(t),fy=(t,e)=>Object.fromEntries(hn(t).map(([r,n])=>[r,e(n,r)])),gy=(t,e)=>Object.fromEntries(hn(t).map(([r,n])=>[e(r),n])),hy=t=>Object.fromEntries(hn(t).filter(([,e])=>e!==void 0)),my=(t,e,r)=>{let n=[...Object.keys(t),...Object.keys(e)],s=[...new Set(n)],i={};for(let o of s){let l=t[o],d=e[o];l&&d?i[o]=r(l,d):l?i[o]=l:d&&(i[o]=d)}return i};var S={};yt(S,{safePush:()=>yy,unique:()=>vy});var yy=(t,...e)=>t?[...t,...e]:[...e],vy=t=>Array.from(new Set(t));var ve={};yt(ve,{setName:()=>_y});var _y=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var Fd=t=>{let{name:e,version:r}=t,n={actions:{},events:{},channels:{}},s={name:e,version:r,entities:M.mapValues(t.entities,o=>({name:o.name})),actions:{},events:{},channels:{}},i=M.mapValues(t.entities,o=>o.schema);for(let[o,l]of Object.entries(t.definition.actions??{})){let d=l.input.schema.dereference(i),f=l.output.schema.dereference(i),g=t.actions?.[o]?.name??o;n.actions[g]={...l,...t.actions?.[o]??{},input:{schema:d},output:{schema:f}},s.actions[o]={name:g}}for(let[o,l]of Object.entries(t.definition.events??{})){let d=l.schema.dereference(i),f=t.events?.[o]?.name??o;n.events[f]={...l,...t.events?.[o]??{},schema:d},s.events[o]={name:f}}for(let[o,l]of Object.entries(t.definition.channels??{})){let d={};for(let[g,m]of Object.entries(l.messages)){let P=m.schema.dereference(i);d[g]={...m,schema:P}}let f=t.channels?.[o]?.name??o;n.channels[f]={...l,...t.channels?.[o]??{},message:{...l.message??{},tags:{...l.message?.tags??{},...t.channels?.[o]?.message?.tags??{}}},conversation:{...l.conversation??{},tags:{...l.conversation?.tags??{},...t.channels?.[o]?.conversation?.tags??{}}},messages:d},s.channels[o]={name:f}}return{resolved:n,statement:s}};var mn=Symbol("schemaName"),Wd=t=>t?M.mapValues(t,(r,n)=>({...r,[mn]:n})):{},Ld=t=>mn in t&&t[mn]!==void 0,qd=t=>t[mn];var yn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.identifier=e.identifier,this.description=e.description,this.configuration=e.configuration,this.configurations=e.configurations,this.events=e.events,this.actions=e.actions,this.channels=e.channels,this.states=e.states,this.user=e.user,this.secrets=e.secrets,this.entities=e.entities,this.interfaces=e.interfaces,this.__advanced=e.__advanced,this.attributes=e.attributes}name;version;title;description;icon;readme;configuration;configurations;events;actions;channels;states;user;secrets;identifier;entities;interfaces;__advanced;attributes;extend(e,r){let{entities:n,actions:s,events:i,channels:o}=this._callBuilder(e,r),l=this;l.interfaces??={};let d=Object.values(n).map(P=>P.name),f=d.length===0?e.name:`${e.name}<${d.join(",")}>`,{resolved:g,statement:m}=Fd({...e,entities:n,actions:M.stripUndefinedProps(s),events:M.stripUndefinedProps(i),channels:M.stripUndefinedProps(o)});return l.actions=M.mergeRecords(l.actions??{},g.actions,this._mergeActions),l.channels=M.mergeRecords(l.channels??{},g.channels,this._mergeChannels),l.events=M.mergeRecords(l.events??{},g.events,this._mergeEvents),l.interfaces[f]={id:e.id,...m},this}_callBuilder(e,r){let s={entities:Wd(this.entities)},i=r(s),o=M.pairs(i.entities).find(([d,f])=>!Ld(f));if(o)throw new Error(`Cannot extend interface "${e.name}" with entity "${o[0]}"; the provided schema is not part of the integration's entities.`);return{entities:M.mapValues(i.entities,d=>({name:qd(d),schema:d.schema})),actions:i.actions??{},events:i.events??{},channels:i.channels??{}}}_mergeActions=(e,r)=>({...e,...r,input:{schema:ut(e.input.schema,r.input.schema)},output:{schema:ut(e.output.schema,r.output.schema)}});_mergeEvents=(e,r)=>({...e,...r,schema:ut(e.schema,r.schema)});_mergeChannels=(e,r)=>{let n=M.mergeRecords(e.messages,r.messages,this._mergeMessage),s;(e.conversation||r.conversation)&&(s={tags:{...e.conversation?.tags,...r.conversation?.tags}});let i;return(e.message||r.message)&&(i={tags:{...e.message?.tags,...r.message?.tags}}),{...e,...r,messages:n,conversation:s,message:i}};_mergeMessage=(e,r)=>({schema:ut(e.schema,r.schema)})};var _e=require("@botpress/client");var Vd=Ls(require("@botpress/client")),vn={retries:3,retryCondition:t=>Vd.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(Ty(e.response?.headers??{})??t)*1e3},Ty=t=>{let e=["RateLimit-Reset","X-RateLimit-Reset","Retry-After","ratelimit-reset","x-ratelimit-reset","retry-after"];for(let r of e){let n=t[r];if(n!==void 0)return by(String(n))}},by=t=>{let e=wy(t)?Py(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},wy=t=>t.includes(" "),Py=t=>{let e=xy(t);if(!e)return;let r=new Date;return Math.max(0,Math.floor((e.getTime()-r.getTime())/1e3))},xy=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};var pt=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(r=>r));updateMessage=(e=>this._client.updateMessage(e).then(r=>r));listMessages=(e=>this._client.listMessages(e));deleteMessage=(e=>this._client.deleteMessage(e));createUser=(e=>this._client.createUser(e));getUser=(e=>this._client.getUser(e));listUsers=e=>this._client.listUsers(e);getOrCreateUser=(e=>this._client.getOrCreateUser(e));updateUser=(e=>this._client.updateUser(e));deleteUser=e=>this._client.deleteUser(e);getState=(e=>this._client.getState(e));setState=(e=>this._client.setState(e));getOrSetState=(e=>this._client.getOrSetState(e));patchState=(e=>this._client.patchState(e));configureIntegration=e=>this._client.configureIntegration(e);uploadFile=e=>this._client.uploadFile(e);upsertFile=e=>this._client.upsertFile(e);deleteFile=e=>this._client.deleteFile(e);listFiles=e=>this._client.listFiles(e);getFile=e=>this._client.getFile(e);updateFileMetadata=e=>this._client.updateFileMetadata(e);trackAnalytics=e=>this._client.trackAnalytics(e)};var _n=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};var xe="#";var Wv=y.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),Gd=t=>{let e=t[Lt],r=t[Rs],n=t[Hs],s=t[Ds],i=t[Ms],o=t[qt],l=t[Vt];if(!e)throw new Error("Missing bot headers");if(!r)throw new Error("Missing bot user headers");if(!n)throw new Error("Missing integration headers");if(!s)throw new Error("Missing webhook headers");if(!o)throw new Error("Missing configuration headers");if(!l)throw new Error("Missing operation headers");return{botId:e,botUserId:r,integrationId:n,webhookId:s,operation:l,configurationType:i??null,configuration:o?JSON.parse(Buffer.from(o,"base64").toString("utf-8")):{}}};var Jd=Ls(require("util")),ft=class{defaultOptions;constructor(e){this.defaultOptions=e}info(...e){this._log("info",e)}debug(...e){this._log("debug",e)}warn(...e){this._log("warn",e)}error(...e){this._log("error",e)}_log(e,r){this._getConsoleMethod(e)(this._serializeMessage(r))}_serializeMessage(e){let r=Jd.default.format(...e);return process.env.BP_LOG_FORMAT==="json"?this.getJsonMessage(r):r}getJsonMessage(e){return JSON.stringify({msg:e,options:this.defaultOptions})}_getConsoleMethod(e){switch(e){case"debug":return console.debug;case"warn":return console.warn;case"error":return console.error;default:return console.info}}};var gt=class t extends ft{constructor(e){super({visibleToBotOwners:!0,...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})}forBot(){return this.withVisibleToBotOwners(!0)}getJsonMessage(e){return JSON.stringify({msg:e,visible_to_bot_owner:this.defaultOptions.visibleToBotOwners,options:this.defaultOptions})}};var ky=t=>["traceparent","tracestate","sentry-trace"].reduce((e,r)=>(t[r]&&(e[r]=t[r]),e),{}),Sy=(t,e,r)=>{let[,n]=(e.headers.traceparent||"").split("-"),s=new _e.Client({botId:t.botId,integrationId:t.integrationId,retry:vn,headers:ky(e.headers)}),i=new pt(s),o=new gt({traceId:n});return{ctx:t,req:e,client:i,logger:o,instance:r}},Oy=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await Zy(t);case"register":return await Iy(t);case"unregister":return await By(t);case"message_created":return await Ry(t);case"action_triggered":return await Hy(t);case"ping":return await Ey(t);case"create_user":return await Cy(t);case"create_conversation":return await Ay(t);default:throw new _e.InvalidPayloadError(`Unknown operation ${e.operation}`)}},Xd=t=>async e=>{let r=Gd(e.headers),n=Sy(r,e,t),{logger:s}=n;try{let i;return i=await Dy(n),i?{...i,status:i.status??200}:(i=await Oy(n),i?{...i,status:i.status??200}:{status:200})}catch(i){if((0,_e.isApiError)(i)){let l=i.type==="Runtime"?i:new _e.RuntimeError(i.message,i);return s.forBot().error(l.message),{status:l.code,body:JSON.stringify(l.toJSON())}}console.error(i);let o=new _e.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 s.forBot().error(o.message),{status:o.code,body:JSON.stringify(o.toJSON())}}},Ey=async t=>{},Zy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{let{req:i}=oe(r);return s.webhook({client:t,ctx:e,req:i,logger:n})},Iy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.register)return;let{webhookUrl:i}=oe(r);await s.register({client:t,ctx:e,webhookUrl:i,logger:n})},By=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.unregister)return;let{webhookUrl:i}=oe(r);await s.unregister({ctx:e,webhookUrl:i,client:t,logger:n})},Cy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createUser)return;let{tags:i}=oe(r);return await s.createUser({ctx:e,client:t,tags:i,logger:n})},Ay=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createConversation)return;let{channel:i,tags:o}=oe(r);return await s.createConversation({ctx:e,client:t,channel:i,tags:o,logger:n})},Ry=async({ctx:t,req:e,client:r,logger:n,instance:s})=>{let{conversation:i,user:o,type:l,payload:d,message:f}=oe(e),g=s.channels[i.channel];if(!g)throw new Error(`Channel ${i.channel} not found`);let m=g.messages[l];if(!m)throw new Error(`Message of type ${l} not found in channel ${i.channel}`);await m({ctx:t,conversation:i,message:f,user:o,type:l,client:r,payload:d,ack:async({tags:E})=>{await r.updateMessage({id:f.id,tags:E})},logger:n})},Hy=async({req:t,ctx:e,client:r,logger:n,instance:s})=>{let{input:i,type:o}=oe(t);if(!o)throw new Error("Missing action type");let l=s.actions[o];if(!l)throw new Error(`Action ${o} not found`);let d=new _n,g={output:await l({ctx:e,input:i,client:r,type:o,logger:n,metadata:d}),meta:d.toJSON()};return{body:JSON.stringify(g)}},Dy=async({instance:t,client:e,ctx:r,logger:n,req:s})=>{let i=t.unknownOperationHandler;if(i)return await i({client:e,ctx:r,logger:n,req:s})};var Tn=class{constructor(e){this.props=e;this.actions=e.actions,this.channels=e.channels,this.register=e.register,this.unregister=e.unregister,this.createUser=e.createUser,this.createConversation=e.createConversation,this.webhook=e.handler,this.unknownOperationHandler=e.__advanced?.unknownOperationHandler}actions;channels;register;unregister;createUser;createConversation;webhook;unknownOperationHandler;handler=Xd(this);start=e=>Gt(this.handler,e)};var bn=class{constructor(e){this.props=e;this.integrations=e.integrations,this.plugins=e.plugins,this.user=e.user,this.conversation=e.conversation,this.message=e.message,this.states=e.states,this.configuration=e.configuration,this.events=e.events,this.recurringEvents=e.recurringEvents,this.actions=e.actions,this.tables=e.tables,this.workflows=e.workflows,this.attributes=e.attributes,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;addIntegration(e,r){let n=this;return n.integrations||(n.integrations={}),n.integrations[e.name]={...e,enabled:r?.enabled,configurationType:r?.configurationType,configuration:r?.configuration,disabledChannels:r?.disabledChannels},this}addPlugin(e,r){let n=this;n.plugins||(n.plugins={});let s=r.alias??e.name.replace("/","-");return n.plugins[s]={...e,alias:s,configuration:r.configuration,interfaces:r.interfaces},n.withPlugins.user=this._mergeUser(n.withPlugins.user,e.definition.user),n.withPlugins.conversation=this._mergeConversation(n.withPlugins.conversation,e.definition.conversation),n.withPlugins.message=this._mergeMessage(n.withPlugins.message,e.definition.message),n.withPlugins.recurringEvents=this._mergeRecurringEvents(n.withPlugins.recurringEvents,e.definition.recurringEvents),n.withPlugins.tables=this._mergeTables(n.withPlugins.tables,e.definition.tables),n.withPlugins.workflows=this._mergeWorkflows(n.withPlugins.workflows,e.definition.workflows),n.withPlugins.states=this._mergeStates(n.withPlugins.states,this._prefixKeysWithPluginAlias(e.definition.states,s)),n.withPlugins.events=this._mergeEvents(n.withPlugins.events,this._prefixKeysWithPluginAlias(e.definition.events,s)),n.withPlugins.actions=this._mergeActions(n.withPlugins.actions,this._prefixKeysWithPluginAlias(e.definition.actions,s)),this}_mergeUser=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeConversation=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeMessage=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeStates=(e,r)=>({...e,...r});_mergeEvents=(e,r)=>({...e,...r});_mergeRecurringEvents=(e,r)=>({...e,...r});_mergeActions=(e,r)=>({...e,...r});_mergeTables=(e,r)=>({...e,...r});_mergeWorkflows=(e,r)=>({...e,...r});_prefixKeysWithPluginAlias=(e,r)=>M.mapKeys(e??{},n=>`${r}${xe}${n}`);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(([r,n])=>[r,{...n,definition:{...n.definition,configuration:this._dereferenceDefinitionSchema(n.definition.configuration,e),events:this._dereferenceDefinitionSchemas(n.definition.events,e),states:this._dereferenceDefinitionSchemas(n.definition.states,e),tables:this._dereferenceDefinitionSchemas(n.definition.tables,e),actions:this._dereferenceActionDefinitionSchemas(n.definition.actions,e)}}]))}}_buildZuiReferenceMap(){let e={},r=Object.entries(this.plugins??{});for(let[n,s]of r){let i=Object.entries(s.interfaces??{});for(let[o,l]of i){let d=this.integrations?.[l.name];if(!d)throw new Error(`Interface with alias "${o}" of plugin with alias "${n}" references integration "${l.name}" which is not installed`);let f=Object.entries(l.entities??{});for(let[g,{name:m}]of f){let P=d.definition.entities?.[m]?.schema;if(!P)throw new Error(`Interface entity "${m}" does not exist in integration "${d.name}"`);e[`interface:${o}/entities/${g}`]=P}}}return e}_dereferenceZuiSchema(e,r){return e.dereference(r)}_dereferenceDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,this._dereferenceDefinitionSchema(s,r)]))}_dereferenceDefinitionSchema(e,r){return e&&{...e,schema:this._dereferenceZuiSchema(e.schema,r)}}_dereferenceActionDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,input:{schema:this._dereferenceZuiSchema(s.input.schema,r)},output:{schema:this._dereferenceZuiSchema(s.output.schema,r)}}]))}};var Ve=require("@botpress/client");var ht=class t extends ft{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 ce=class{constructor(e,r={before:{},after:{}}){this._client=e;this._hooks=r}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));getWorkflow=(e=>this._run("getWorkflow",e));updateWorkflow=(e=>this._run("updateWorkflow",e));deleteWorkflow=(e=>this._run("deleteWorkflow",e));listWorkflows=(e=>this._run("listWorkflows",e));createConversation=e=>this._client.createConversation(e);getOrCreateConversation=e=>this._client.getOrCreateConversation(e);createUser=e=>this._client.createUser(e);getOrCreateUser=e=>this._client.getOrCreateUser(e);_run=async(e,r)=>{let n=this._hooks.before[e];n&&(r=await n(r));let s=await this._client[e](r),i=this._hooks.after[e];return i&&(s=await i(s,r)),s}};var mt=t=>new Proxy({},{get:(e,r)=>({listInstances:{all:n=>ke({workflowName:r,client:t,input:n}),running:n=>ke({workflowName:r,client:t,input:n,statuses:["in_progress"]}),scheduled:n=>ke({workflowName:r,client:t,input:n,statuses:["pending","listening"]}),allFinished:n=>ke({workflowName:r,client:t,input:n,statuses:["completed","cancelled","failed","timedout"]}),cancelled:n=>ke({workflowName:r,client:t,input:n,statuses:["cancelled"]}),failed:n=>ke({workflowName:r,client:t,input:n,statuses:["failed"]}),succeeded:n=>ke({workflowName:r,client:t,input:n,statuses:["completed"]}),timedOut:n=>ke({workflowName:r,client:t,input:n,statuses:["timedout"]})},startNewInstance:async n=>{let{workflow:s}=await t.createWorkflow({name:r,status:"pending",...n});return{workflow:de({client:t,workflow:s})}}})}),ke=async t=>{let e=await t.client.listWorkflows({name:t.workflowName,statuses:t.statuses,...t.input});return{...e,workflows:e.workflows.map(r=>de({client:t.client,workflow:r}))}},de=t=>{let e=!1;return{...t.workflow,async update(r){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,...r});return await t.onWorkflowUpdate?.(n),{workflow:de({...t,workflow:n})}},async acknowledgeStartOfProcessing(){if(!t.event||t.workflow.status!=="pending"||e)return{workflow:de(t)};let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"in_progress",eventId:t.event.id});return e=!0,await t.onWorkflowUpdate?.(r),{workflow:de({...t,workflow:r})}},async setFailed({failureReason:r}){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"failed",failureReason:r});return await t.onWorkflowUpdate?.(n),{workflow:de({...t,workflow:n})}},async setCompleted({output:r}={}){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"completed",output:r});return await t.onWorkflowUpdate?.(n),{workflow:de({...t,workflow:n})}},async cancel(){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return await t.onWorkflowUpdate?.(r),{workflow:de({...t,workflow:r})}}}};var My=y.enum(["event_received","register","unregister","ping","action_triggered"]),Yd=t=>{let e=t[Lt],r=t[qt],n=t[Ns],s=My.parse(t[Vt]);if(!e)throw new Error("Missing bot headers");if(!n)throw new Error("Missing type headers");if(!r)throw new Error("Missing configuration headers");if(!s)throw new Error("Missing operation headers");return{botId:e,operation:s,type:n,configuration:r?JSON.parse(Buffer.from(r,"base64").toString("utf-8")):{}}};var Y={status:200};var Ks=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 Ny=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],Qd=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!Ny.includes(e.payload.type))throw new Error("Unexpected event type");let r={...t,logger:$y(t,e)};if(!e.payload.workflow.name)return r.logger.warn("Received workflow update event without a workflow name. Assuming this workflow was not defined by the bot.",e.payload.workflow),Y;switch(e.payload.type){case"child_workflow_deleted":case"child_workflow_finished":r.logger.info(`Received child workflow event "${e.payload.type}", but child workflows are not yet supported`);break;case"workflow_timedout":case"workflow_started":case"workflow_continued":return await jy(r,e);default:e.payload.type}return Y},$y=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),jy=async(t,e)=>{let r=Ks(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name];if(!n||n.length===0)return t.logger.warn(`No ${r} handler found for workflow "${e.payload.workflow.name}"`),Y;let{updatedWorkflow:s}=await Ky(t,e);return s.status==="pending"&&t.logger.warn(`Workflow "${e.payload.workflow.name}" is still in pending status after processing "${r}" event. This may indicate that the workflow was not properly acknowledged or terminated by the handler. `),Y},Ky=async(t,e)=>{let r=Ks(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name],s=structuredClone(e.payload.workflow);for(let i of n)await i({...t,event:e,conversation:e.payload.conversation,user:e.payload.user,workflow:de({...t,workflow:s,event:e,onWorkflowUpdate(o){s=o}}),workflows:mt(t.client)});return{updatedWorkflow:s}};var eu=t=>async e=>{let r=Yd(e.headers),n=new ht,s=new Ve.Client({botId:r.botId,retry:vn}),i=new ce(s,{before:{createMessage:async l=>{let d=t.hookHandlers.before_outgoing_message[l.type]??[];for(let f of d){let g=new ce(s);l=(await f({client:g,ctx:r,logger:n.with({conversationId:l.conversationId,userId:l.userId}),data:l,...Se({client:g})}))?.data??l}return l},callAction:async l=>{let d=t.hookHandlers.before_outgoing_call_action[l.type]??[];for(let f of d){let g=new ce(s);l=(await f({client:g,ctx:r,logger:n,data:l,...Se({client:g})}))?.data??l}return l}},after:{createMessage:async l=>{let d=t.hookHandlers.after_outgoing_message[l.message.type]??[];for(let f of d){let g=new ce(s);l=(await f({client:g,ctx:r,logger:n.with({messageId:l.message.id,conversationId:l.message.conversationId,userId:l.message.userId}),data:l,...Se({client:g})}))?.data??l}return l},callAction:async(l,d)=>{let{type:f}=d,g=t.hookHandlers.after_outgoing_call_action[f]??[];for(let m of g){let P=new ce(s);l=(await m({client:P,ctx:r,logger:n,data:{type:f,...l},...Se({client:P})}))?.data??l}return l}}}),o={req:e,ctx:r,logger:n,client:i,self:t};try{switch(r.operation){case"action_triggered":return await Ly(o);case"event_received":return await Wy(o);case"register":return await zy(o);case"unregister":return await Fy(o);case"ping":return await Uy(o);default:throw new Error(`Unknown operation ${r.operation}`)}}catch(l){let d=l instanceof Error?l:new Error(String(l));if((0,Ve.isApiError)(d)){let g=d.type==="Runtime"?d:new Ve.RuntimeError(d.message,d);return n.error(g.message),{status:g.code,body:JSON.stringify(g.toJSON())}}let f=new Ve.RuntimeError("An unexpected error occurred in the bot.",d);return n.error(f.message,d),{status:f.code,body:JSON.stringify(f.toJSON())}}},Uy=async t=>Y,zy=async t=>Y,Fy=async t=>Y,Wy=async t=>{let{ctx:e,logger:r,req:n,client:s,self:i}=t,o={client:s,ctx:e,logger:r,...Se({client:s})},l=oe(n);if(o.logger=o.logger.with({eventId:l.event.id,messageId:l.event.messageId,conversationId:l.event.conversationId,userId:l.event.userId}),e.type==="workflow_update")return await Qd(t,l.event);if(e.type==="message_created"){let E=l.event,I=E.payload.message;o.logger=o.logger.with({messageId:I.id,conversationId:I.conversationId,userId:I.userId});let U=i.hookHandlers.before_incoming_message[I.type]??[];for(let q of U){let se=await q({...o,data:I});if(I=se?.data??I,se?.stop)return Y}let L={...o,user:E.payload.user,conversation:E.payload.conversation,message:I,event:E},Q=i.messageHandlers[I.type]??[];for(let q of Q)await q(L);let ie=i.hookHandlers.after_incoming_message[I.type]??[];for(let q of ie){let se=await q({...o,data:I});if(I=se?.data??I,se?.stop)return Y}return Y}if(e.type==="state_expired"){let I=l.event.payload.state,U={...o,state:I},L=i.stateExpiredHandlers[I.name]??[];for(let Q of L)await Q(U);return Y}let d=l.event,f=i.hookHandlers.before_incoming_event[d.type]??[];for(let E of f){let I=await E({...o,data:d});if(d=I?.data??d,I?.stop)return Y}let g={...o,event:d},m=i.eventHandlers[d.type]??[];for(let E of m)await E(g);let P=i.hookHandlers.after_incoming_event[d.type]??[];for(let E of P){let I=await E({...o,data:d});if(d=I?.data??d,I?.stop)return Y}return Y},Ly=async({ctx:t,logger:e,req:r,client:n,self:s})=>{let{input:i,type:o}=oe(r);if(!o)throw new Error("Missing action type");let l=s.hookHandlers.before_incoming_call_action[o]??[];for(let P of l){let E=await P({ctx:t,logger:e,client:n,data:{type:o,input:i},...Se({client:n})});i=E?.data?.input??i,o=E?.data?.type??o}let d=s.actionHandlers[o];if(!d)throw new Error(`Action ${o} not found`);let f=await d({ctx:t,logger:e,input:i,client:n,type:o,...Se({client:n})}),g=s.hookHandlers.after_incoming_call_action[o]??[];for(let P of g){let E=await P({ctx:t,logger:e,client:n,data:{type:o,output:f},...Se({client:n})});o=E?.data?.type??o,f=E?.data?.output??f}return{status:200,body:JSON.stringify({output:f})}},Se=t=>({workflows:mt(t.client)});var wn=class{constructor(e){this.props=e;this._actionHandlers=e.actions,this._plugins=e.plugins}_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_plugins={};_registerOrder=0;get actionHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._actionHandlers[r];if(n)return n;for(let[s,i]of Object.entries(this._plugins)){let[o,l]=r.split(xe);if(!(o!==s||!l)&&(n=i.actionHandlers[l],n))return n}}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.messageHandlers[r]??[]),s=this._messageHandlers[r]??[],i=this._messageHandlers["*"]??[],o=[...s,...i].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return S.unique([...n,...o])}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.eventHandlers[r]??[]),s=this._eventHandlers[r]??[],i=this._eventHandlers["*"]??[],o=[...s,...i].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return S.unique([...n,...o])}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.stateExpiredHandlers[r]??[]),s=this._stateExpiredHandlers[r]??[],i=this._stateExpiredHandlers["*"]??[],o=[...s,...i].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return S.unique([...n,...o])}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{if(this._hookHandlers[r])return new Proxy({},{get:(s,i)=>{let o=Object.values(this._plugins).flatMap(m=>m.hookHandlers[r]?.[i]??[]),l=this._hookHandlers[r]??{},d=l[i]??[],f=l["*"]??[],g=[...d,...f].sort((m,P)=>m.order-P.order).map(({handler:m})=>m);return S.unique([...o,...g])}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,i)=>{let o=n[i]?.sort((d,f)=>d.order-f.order).map(({handler:d})=>d)??[],l=Object.values(this._plugins).flatMap(d=>d.workflowHandlers[r]?.[i]??[]);return S.unique([...o,...l])}})}})}on={message:(e,r)=>{this._messageHandlers[e]=S.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=S.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=S.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=S.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=S.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=S.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=S.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=S.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=S.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=S.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=S.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=S.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=S.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=S.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=S.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=S.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};handler=eu(this);start=e=>Gt(this.handler,e)};var Pn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.title=e.title,this.description=e.description,this.readme=e.readme,this.entities=e.entities??{},this.attributes=e.attributes,this.__advanced=e.__advanced;let r=this._getEntityReference(this.entities),n=e.events===void 0?{}:M.mapValues(e.events,o=>({...o,schema:o.schema(r)})),s=e.actions===void 0?{}:M.mapValues(e.actions,o=>({...o,input:{...o.input,schema:o.input.schema(r)},output:{...o.output,schema:o.output.schema(r)}})),i=e.channels===void 0?{}:M.mapValues(e.channels,o=>({...o,messages:M.mapValues(o.messages,l=>({...l,schema:l.schema(r)}))}));this.events=n,this.actions=s,this.channels=i}name;version;title;description;icon;readme;attributes;entities;events;actions;channels;__advanced;_getEntityReference=e=>{let r={};for(let[n,s]of Object.entries(e)){let i=s.schema._def["x-zui"]?.title,o=s.schema._def.description,l=Ad.ref(n);i&&l.title(i),o&&l.describe(o),r[n]=l}return r}};var xn=class{constructor(e){this.props=e;let r=Object.fromEntries(Object.entries(e.interfaces??{}).map(([n,s])=>[n,Object.fromEntries(Object.entries(s.definition.entities??{}).map(([i])=>[i,y.ref(`interface:${n}/entities/${i}`)]))]));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,this.configuration=e.configuration?{...e.configuration,schema:typeof e.configuration.schema=="object"?e.configuration.schema:e.configuration.schema({entities:r})}:void 0,this.states=Object.fromEntries(Object.entries(e.states??{}).map(([n,s])=>[n,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:r})}])),this.events=Object.fromEntries(Object.entries(e.events??{}).map(([n,s])=>[n,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:r})}])),this.actions=Object.fromEntries(Object.entries(e.actions??{}).map(([n,s])=>[n,{...s,input:{...s.input,schema:typeof s.input.schema=="object"?s.input.schema:s.input.schema({entities:r})},output:{...s.output,schema:typeof s.output.schema=="object"?s.output.schema:s.output.schema({entities:r})}}])),this.tables=Object.fromEntries(Object.entries(e.tables??{}).map(([n,s])=>[n,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:r})}]))}name;version;title;description;icon;readme;attributes;integrations;interfaces;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;__advanced;dereferenceEntities({intersectWithUnknownRecord:e}={intersectWithUnknownRecord:!0}){let r=this._buildZuiReferenceMap(e);return{...this,configuration:this.configuration?{...this.configuration,schema:this._dereferenceZuiSchema(this.configuration.schema,r)}:void 0,events:this._dereferenceDefinitionSchemas(this.events,r),states:this._dereferenceDefinitionSchemas(this.states,r),tables:this._dereferenceDefinitionSchemas(this.tables,r),actions:this._dereferenceActionDefinitionSchemas(this.actions,r)}}_buildZuiReferenceMap(e){return Object.fromEntries(Object.entries(this.interfaces??{}).flatMap(([r,n])=>Object.entries(n.definition.entities??{}).map(([s,i])=>[`interface:${r}/entities/${s}`,e?i.schema.and(y.record(y.string(),y.unknown())):i.schema])))}_dereferenceZuiSchema(e,r){return e.dereference(r)}_dereferenceDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,schema:this._dereferenceZuiSchema(s.schema,r)}]))}_dereferenceActionDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,input:{schema:this._dereferenceZuiSchema(s.input.schema,r)},output:{schema:this._dereferenceZuiSchema(s.output.schema,r)}}]))}};var Us=":";var tu=t=>{let[e,r]=t.split(Us);return!e||!r?null:{namespace:e,eventName:r}},ru=t=>`${t.namespace}${Us}${t.actionName}`,nu=t=>`${t.namespace}${Us}${t.eventName}`,su=(t,e)=>{let r=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},n=r.name,s=r.actions[t.actionName]?.name??t.actionName;return{namespace:n,actionName:s}},iu=(t,e)=>{let r=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},n=r.name,s=r.events[t.eventName]?.name??t.eventName;return{namespace:n,eventName:s}};var au=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>o=>qy({client:t,interfaces:e.interfaces,integrationOrInterfaceName:n,methodName:i,input:o})})}),qy=async({client:t,interfaces:e,integrationOrInterfaceName:r,methodName:n,input:s})=>{let i=su({namespace:r,actionName:n},e),o=ru(i);return(await t.callAction({type:o,input:s})).output};var zs=class t{constructor(e){this._props=e}async emit(e){let{conversationId:r,userId:n,messageId:s}=this._props;await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:r,userId:n,messageId:s})}async schedule(e,r){let{conversationId:n,userId:s,messageId:i}=this._props;await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:n,userId:s,messageId:i,schedule:r})}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})}},ou=(t,e)=>new Proxy({},{get:(r,n)=>{let s=e.alias!==void 0?`${e.alias}${xe}${n}`:n;return new zs({client:t,eventName:s})}});var Fs=class{constructor(e,r,n){this._client=e;this._stateType=r;this._stateName=n}async get(e){return await this._client.getState({type:this._stateType,name:this._stateName,id:e}).then(r=>r.state.payload)}async set(e,r){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:r})}async getOrSet(e,r){return await this._client.getOrSetState({type:this._stateType,name:this._stateName,id:e,payload:r}).then(n=>n.state.payload)}async delete(e){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:null})}async patch(e,r){await this._client.patchState({type:this._stateType,name:this._stateName,id:e,payload:r})}},lu=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>{let o=e.alias!==void 0?`${e.alias}${xe}${i}`:i;return new Fs(t,n,o)}})});var kn=class{constructor(e){this.props=e;this._actionHandlers=e.actions}_runtimeProps;_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_registerOrder=0;initialize(e){return this._runtimeProps=e,this}get _runtime(){if(!this._runtimeProps)throw new Error("Plugin not correctly initialized. This is likely because you access your plugin config outside of an handler.");return this._runtimeProps}_getTools(e){let{configuration:r,interfaces:n,alias:s}=this._runtime,i=au(e,this._runtime),o=lu(e,this._runtime),l=mt(e),d=ou(e,this._runtime);return{configuration:r,interfaces:n,actions:i,states:o,alias:s,workflows:l,events:d}}get actionHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._actionHandlers[r];if(n)return ve.setName(s=>n({...s,...this._getTools(s.client)}),n.name)}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._messageHandlers[r]??[],s=this._messageHandlers["*"]??[];return S.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>ve.setName(l=>o({...l,...this._getTools(l.client)}),o.name))}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._eventHandlers[r]??[],s=Object.entries(this._eventHandlers).filter(([l])=>this._eventResolvesTo(l,r)).flatMap(([,l])=>l??[]),i=this._eventHandlers["*"]??[];return S.unique([...n,...s,...i]).sort((l,d)=>l.order-d.order).map(({handler:l})=>ve.setName(d=>l({...d,...this._getTools(d.client)}),l.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._stateExpiredHandlers[r]??[],s=this._stateExpiredHandlers["*"]??[];return S.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>ve.setName(l=>o({...l,...this._getTools(l.client)}),o.name))}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._hookHandlers[r];if(n)return new Proxy({},{get:(s,i)=>{i=this._stripAliasPrefix(i);let o=n[i]??[],l=Object.entries(n).filter(([g])=>this._eventResolvesTo(g,i)).flatMap(([,g])=>g??[]),d=n["*"]??[];return S.unique([...o,...l,...d]).sort((g,m)=>g.order-m.order).map(({handler:g})=>ve.setName(m=>g({...m,...this._getTools(m.client)}),g.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,i)=>(n[i]?.sort((l,d)=>l.order-d.order)??[]).map(({handler:l})=>ve.setName(d=>l({...d,...this._getTools(d.client)}),l.name))})}})}on={message:(e,r)=>{this._messageHandlers[e]=S.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=S.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=S.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=S.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=S.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=S.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=S.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=S.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=S.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=S.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=S.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=S.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=S.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=S.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=S.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=S.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};_eventResolvesTo=(e,r)=>{let n=tu(e);if(!n)return!1;let s=iu(n,this._runtime.interfaces);return nu(s)===r};_stripAliasPrefix=e=>{let{alias:r}=this._runtime;if(!r)return e;let n=`${r}#`;return e.startsWith(n)?e.slice(n.length):e}};0&&(module.exports={BRAND,Bot,BotDefinition,BotLogger,BotSpecificClient,DIRTY,EMPTY_PATH,INVALID,Integration,IntegrationDefinition,IntegrationLogger,IntegrationSpecificClient,InterfaceDefinition,NEVER,OK,ParseInputLazyPath,ParseStatus,Plugin,PluginDefinition,RuntimeError,Schema,WELL_KNOWN_ATTRIBUTES,ZodAny,ZodArray,ZodBigInt,ZodBoolean,ZodBranded,ZodCatch,ZodDate,ZodDefault,ZodDiscriminatedUnion,ZodEffects,ZodEnum,ZodError,ZodFirstPartyTypeKind,ZodFunction,ZodIntersection,ZodIssueCode,ZodLazy,ZodLiteral,ZodMap,ZodNaN,ZodNativeEnum,ZodNever,ZodNull,ZodNullable,ZodNumber,ZodObject,ZodOptional,ZodParsedType,ZodPipeline,ZodPromise,ZodReadonly,ZodRecord,ZodRef,ZodSchema,ZodSet,ZodString,ZodSymbol,ZodTransformer,ZodTuple,ZodType,ZodUndefined,ZodUnion,ZodUnknown,ZodVoid,addIssueToContext,agent,aimodel,any,array,bigint,boolean,botIdHeader,botUserIdHeader,coerce,configurationHeader,configurationTypeHeader,conversation,createZodEnum,cuid2Regex,cuidRegex,custom,datasource,date,discriminatedUnion,effect,emailRegex,enum:null,errorUtil,event,function:null,getErrorMap,getParsedType,instanceof:null,integrationIdHeader,intent,intersection,ipv4Regex,ipv6Regex,isAborted,isApiError,isAsync,isDirty,isEmojiRegex,isValid,knowledgebase,late,lazy,literal,makeIssue,map,mergeObjectSchemas,message,messages,nan,nativeEnum,never,null:null,nullable,number,object,objectUtil,oboolean,onumber,operationHeader,optional,ostring,parseBody,pipeline,preprocess,processCreateParams,promise,quotelessJson,readonly,record,ref,serve,set,setErrorMap,strictObject,string,symbol,table,tablerow,transformer,transforms,tuple,typeHeader,ulidRegex,undefined,union,unknown,user,util,uuidRegex,variable,void:null,webhookIdHeader,z});
|
|
67
|
+
`,s+="})"}let i=r?s?r+s:n?n==="z.never()"?r+".strict()":r+`.catchall(${n})`:r:s||(n?`z.record(${n})`:"z.record(z.any())");return j.an.anyOf(t)&&(i+=`.and(${nd(f(c({},t),{anyOf:t.anyOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?f(c({},o),{type:"object"}):o)}),e)})`),j.a.oneOf(t)&&(i+=`.and(${Is(f(c({},t),{oneOf:t.oneOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?f(c({},o),{type:"object"}):o)}),e)})`),j.an.allOf(t)&&(i+=`.and(${Mt(f(c({},t),{allOf:t.allOf.map(o=>typeof o=="object"&&!o.type&&(o.properties||o.additionalProperties||o.patternProperties)?f(c({},o),{type:"object"}):o)}),e)})`),i}a(sd,"parseObject");var vm=a(t=>{var e;let r="z.string()";if((e=t[b])!=null&&e.coerce){if(t.format==="date-time")return"z.coerce.date()";r="z.coerce.string()"}return r+=G(t,"format",({value:n})=>{switch(n){case"email":return[".email(",")"];case"ip":return[".ip(",")"];case"ipv4":return['.ip({ version: "v4"',", message: "," })"];case"ipv6":return['.ip({ version: "v6"',", message: "," })"];case"uri":return[".url(",")"];case"uuid":return[".uuid(",")"];case"date-time":return[".datetime(",")"]}}),r+=G(t,"pattern",({json:n})=>[`.regex(new RegExp(${n})`,", ",")"]),r+=G(t,"minLength",({json:n})=>[`.min(${n}`,", ",")"]),r+=G(t,"maxLength",({json:n})=>[`.max(${n}`,", ",")"]),r},"parseString"),_m=a((t,e)=>`${W(um(t,"nullable"),e,!0)}.nullable()`,"parseNullable"),Tm=a(t=>`z.ref('${t.$ref}')`,"parseRef"),bm=a((t,e)=>{var r,n;if(t.oneOf.length<=1||!((r=t.discriminator)!=null&&r.propertyName))return Is(t,e);let s=t.oneOf.map((i,o)=>W(i,f(c({},e),{path:[...e.path,"oneOf",o]})));return`z.discriminatedUnion("${(n=t.discriminator)==null?void 0:n.propertyName}", [${s.join(", ")}])`},"parseDiscriminator"),W=a((t,e={seen:new Map,path:[]},r)=>{if(typeof t!="object")return t?"z.any()":"z.never()";if(e.parserOverride){let i=e.parserOverride(t,e);if(typeof i=="string")return i}let n=e.seen.get(t);if(n){if(n.r!==void 0)return n.r;if(e.depth===void 0||n.n>=e.depth)return"z.any()";n.n+=1}else n={r:void 0,n:0},e.seen.set(t,n);let s=xm(t,e);return r||(s=wm(t,s),e.withoutDefaults||(s=Pm(t,s))),n.r=s,s},"parseSchema"),wm=a((t,e)=>(t.description&&(e+=`.describe(${JSON.stringify(t.description)})`),e),"addMeta"),Pm=a((t,e)=>(t.default!==void 0&&(e+=`.default(${JSON.stringify(t.default)})`),e),"addDefaults"),xm=a((t,e)=>j.a.nullable(t)?_m(t,e):j.an.object(t)?sd(t,e):j.an.array(t)?pm(t,e):j.an.anyOf(t)?nd(t,e):j.an.allOf(t)?Mt(t,e):j.a.discriminator(t)?bm(t,e):j.a.oneOf(t)?Is(t,e):j.a.not(t)?lm(t,e):j.an.enum(t)?hm(t):j.a.const(t)?gm(t):j.a.multipleType(t)?om(t,e):j.a.primitive(t,"string")?vm(t):j.a.primitive(t,"number")||j.a.primitive(t,"integer")?ym(t):j.a.primitive(t,"boolean")?im(t):j.a.primitive(t,"null")?cm(t):j.a.conditional(t)?mm(t,e):j.a.ref(t)?Tm(t):am(t),"selectParser"),j={an:{object:a(t=>t.type==="object","object"),array:a(t=>t.type==="array","array"),anyOf:a(t=>t.anyOf!==void 0,"anyOf"),allOf:a(t=>t.allOf!==void 0,"allOf"),enum:a(t=>t.enum!==void 0,"enum")},a:{nullable:a(t=>t.nullable===!0,"nullable"),multipleType:a(t=>Array.isArray(t.type),"multipleType"),not:a(t=>t.not!==void 0,"not"),const:a(t=>t.const!==void 0,"const"),primitive:a((t,e)=>t.type===e,"primitive"),conditional:a(t=>!!("if"in t&&t.if&&"then"in t&&"else"in t&&t.then&&t.else),"conditional"),discriminator:a(t=>{var e;return t.oneOf!==void 0&&((e=t.discriminator)==null?void 0:e.propertyName)!==void 0},"discriminator"),oneOf:a(t=>t.oneOf!==void 0,"oneOf"),ref:a(t=>t.$ref!==void 0,"ref")}},km=a(t=>{let e;try{e=new Function("z",`return ${t}`)(u)}catch(r){return{sucess:!1,error:`Failed to evaluate schema: ${(r instanceof Error?r:new Error(String(r))).message}`}}return e instanceof u.ZodType?{sucess:!0,value:e}:{sucess:!1,error:`String "${t}" does not evaluate to a Zod schema`}},"evalZuiString"),Sm=a(t=>W(t,{seen:new Map,path:[]}),"jsonSchemaToZodStr"),Om=a(t=>{let e=Sm(t);e=e.replaceAll("errors: z.ZodError[]","errors");let r=km(e);if(!r.sucess)throw new Fr(r.error);return r.value},"jsonSchemaToZod"),It=a((t,e)=>{var r,n;if(e[b]&&t._def&&(t._def[b]=e[b]),((r=t._def)==null?void 0:r.typeName)==="ZodObject"&&e.type==="object"&&e.properties&&Object.entries(e.properties).forEach(([s,i])=>{let o=typeof t._def.shape=="function"?t._def.shape():t._def.shape;o[s]&&It(o[s],i)}),((n=t._def)==null?void 0:n.typeName)==="ZodRecord"&&e.type==="object"&&e.additionalProperties&&It(t._def.valueType,e.additionalProperties),e.type==="array"&&e.items){let s=e.items;if(typeof s=="object"&&!Array.isArray(s)){let i=t._def.type;i&&It(i,s)}else Array.isArray(s)&&s.forEach((i,o)=>{let l=t._def;l.typeName===y.ZodFirstPartyTypeKind.ZodTuple&&It(l.items[o],i)})}},"applyZuiPropsRecursively"),Em=a(t=>{let e=Om(t);return It(e,t),e},"fromJSONSchemaLegacy"),Zm=a(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&id(n))&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodOptional},"isOptionalSchema"),Im=a(t=>{var e,r;return t.anyOf!==void 0&&t.anyOf.length===2&&t.anyOf.some(n=>typeof n!="boolean"&&n.type==="null")&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodNullable},"isNullableSchema"),id=a(t=>{var e,r;return t.not===!0&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodUndefined},"isUndefinedSchema"),Bm=a(t=>{var e,r;return!t.not&&((r=(e=t["x-zui"])==null?void 0:e.def)==null?void 0:r.typeName)===u.ZodFirstPartyTypeKind.ZodUnknown},"isUnknownSchema"),Cm=a(({type:t,minimum:e,exclusiveMinimum:r,maximum:n,exclusiveMaximum:s,multipleOf:i,format:o})=>{let l=u.number();return t==="integer"&&(l=l.int()),o==="finite"&&(l=l.finite()),r!==void 0?l=l.gt(r):e!==void 0&&(l=l.gte(e)),s!==void 0?l=l.lt(s):n!==void 0&&(l=l.lte(n)),i!==void 0&&(l=l.multipleOf(i)),l},"numberJSONSchemaToZuiNumber"),Am=a(({format:t,pattern:e,minLength:r,maxLength:n})=>{let s=u.string();if(r&&n&&r===n?s=s.length(r):(r&&(s=s.min(r)),n&&(s=s.max(n))),t==="cuid"||e===$.cuid)s=s.cuid();else if(t==="cuid2"||e===$.cuid2)s=s.cuid2();else if(t==="emoji"||e===$.emoji)s=s.emoji();else if(t==="ulid"||e===$.ulid)s=s.ulid();else if(t==="date-time"){let{precision:i,offset:o}=e?qh(e):{};s=s.datetime({precision:i,offset:o})}else t==="email"||e===$.email?s=s.email():t==="ipv4"||e===$.ipv4?s=s.ip():t==="ipv6"||e===$.ipv6?s=s.ip("v6"):t==="uri"?s=s.url():t==="uuid"||e===$.uuid?s=s.uuid():e&&(s=s.regex(new RegExp(e)));return s},"stringJSONSchemaToZuiString"),vt=a((t,e)=>{let r=[];e.enum!==void 0&&r.push(...e.enum),e.const!==void 0&&r.push(e.const);let n=r.filter(o=>typeof o===t),[s]=n;if(!s){if(t==="string"&&e.type==="string")return Am(e);if(t==="number"&&(e.type==="number"||e.type==="integer"))return Cm(e);if(t==="boolean")return u.boolean();if(t==="null")return u.null();throw new Fr(`Unknown primitive type: "${t}"`)}if(n.length===1)return u.literal(s);let i=n.map(o=>u.literal(o));return u.union(i)},"toZuiPrimitive"),Rm=a((t,e)=>Hm(t)?Nm(t,e):Dm(t)?Mm(t,e):jm(t,e),"arrayJSONSchemaToZuiArray"),Hm=a(t=>Array.isArray(t.items),"_isTuple"),Dm=a(t=>t.items!==void 0&&t.uniqueItems,"_isSet"),Nm=a(({items:t,additionalItems:e},r)=>{let n=t.map(r),s=u.tuple(n);return e!==void 0&&(s=s.rest(r(e))),s},"_handleTuple"),Mm=a(({items:t,minItems:e,maxItems:r},n)=>{let s=u.set(n(t));return e&&(s=s.min(e)),r&&(s=s.max(r)),s},"_handleSet"),jm=a(({minItems:t,maxItems:e,items:r},n)=>{let s=u.array(n(r));return t&&t===e?s.length(t):(t&&(s=s.min(t)),e&&(s=s.max(e)),s)},"_handleArray"),Je=u.any();function ad(t){return F(t)}a(ad,"fromJSONSchema");function F(t){var e;if(t===void 0)return Je;if(t===!0)return u.any();if(t===!1)return u.never();if(t.default!==void 0)return F(f(c({},t),{default:void 0})).default(t.default);if(t.readOnly)return F(f(c({},t),{readOnly:void 0})).readonly();if(t.oneOf!==void 0)throw new be({oneOf:t.oneOf});if(t.patternProperties!==void 0)throw new be({patternProperties:t.patternProperties});if(t.propertyNames!==void 0)throw new be({propertyNames:t.propertyNames});if(t.if!==void 0)throw new be({if:t.if});if(t.then!==void 0)throw new be({then:t.then});if(t.else!==void 0)throw new be({else:t.else});if(t.$ref!==void 0)return u.ref(t.$ref);if(t.not!==void 0){if(id(t))return u.undefined();if(t.not===!0)return u.never();throw new be({not:t.not})}if(Array.isArray(t.type)){if(t.type.length===0)return Je;if(t.type.length===1)return F(f(c({},t),{type:t.type[0]}));let r=t,{type:n}=r,s=Ii(r,["type"]),i=t.type.map(o=>F(f(c({},s),{type:o})));return u.union(i)}if(t.type==="string")return t.enum&&t.enum.length>0?u.enum(t.enum):vt("string",t);if(t.type==="integer"){let r=vt("number",t);return r instanceof u.ZodNumber?r.int():r}if(t.type==="number")return vt("number",t);if(t.type==="boolean")return vt("boolean",t);if(t.type==="null")return vt("null",t);if(t.type==="array")return Rm(t,F);if(t.type==="object"){if(t.additionalProperties!==void 0&&t.properties!==void 0){let r=F(t.additionalProperties);return F(f(c({},t),{additionalProperties:void 0})).catchall(r)}if(t.properties!==void 0){let r={};for(let[n,s]of Object.entries(t.properties)){let i=F(s),o=(e=t.required)!=null?e:[];r[n]=o.includes(n)?i:i.optional()}return u.object(r)}if(t.additionalProperties!==void 0){let r=F(t.additionalProperties);return u.record(r)}return u.record(Je)}if(t.anyOf!==void 0){if(t.anyOf.length===0)return Je;if(t.anyOf.length===1)return F(t.anyOf[0]);if(Zm(t))return F(t.anyOf[0]).optional();if(Im(t))return F(t.anyOf[0]).nullable();let r=t.anyOf.map(F);return u.union(r)}if(t.allOf!==void 0){if(t.allOf.length===0)return Je;if(t.allOf.length===1)return F(t.allOf[0]);let[r,...n]=t.allOf,s=F(r),i=F({allOf:n});return u.intersection(s,i)}return Bm(t)?u.unknown():Je}a(F,"_fromJSONSchema");var $m=/^\d{4}-\d{2}-\d{2}(T|\s)?((\d{2}:\d{2}:\d{2}(\.\d{1,3})?)|(\d{2}:\d{2}))?(\s?([+-]\d{2}:\d{2}|Z))?$/,zn=a((t,e,r=!0)=>{if(typeof t!="object")throw new An("Input must be an object");let n=a(o=>{let l=o;return e?.nullable&&(l=l.nullable()),e?.optional&&(l=l.optional()),e?.passtrough&&typeof l.passthrough=="function"&&(l=l.passthrough()),l},"applyOptions"),s=Object.entries(t).reduce((o,[l,d])=>{if(d===null)o[l]=n(y.null());else switch(typeof d){case"string":o[l]=$m.test(d)?n(y.string().datetime()):n(y.string());break;case"number":o[l]=n(y.number());break;case"boolean":o[l]=n(y.boolean());break;case"object":Array.isArray(d)?d.length===0?o[l]=n(y.array(y.unknown())):typeof d[0]=="object"?o[l]=n(y.array(zn(d[0],e,!1))):["string","number","boolean"].includes(typeof d[0])&&(o[l]=n(y.array(y[typeof d[0]]()))):o[l]=n(zn(d,e,!1));break;default:throw new An(`Unsupported type for key ${l}`)}return o},{}),i=Object.keys(s).length>0;return e?.passtrough||!r&&!i?y.object(s).passthrough():y.object(s)},"fromObject");function od(){return{}}a(od,"parseAnyDef");function ld(t,e){var r,n;let s={type:"array"};return((n=(r=t.type)==null?void 0:r._def)==null?void 0:n.typeName)!=="ZodAny"&&(s.items=C(t.type._def,f(c({},e),{currentPath:[...e.currentPath,"items"]}))),t.minLength&&H(s,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&H(s,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(H(s,"minItems",t.exactLength.value,t.exactLength.message,e),H(s,"maxItems",t.exactLength.value,t.exactLength.message,e)),s}a(ld,"parseArrayDef");function cd(t,e){let r=c({type:"integer",format:"int64"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?H(r,"minimum",n.value,n.message,e):H(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),H(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?H(r,"maximum",n.value,n.message,e):H(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),H(r,"maximum",n.value,n.message,e));break;case"multipleOf":H(r,"multipleOf",n.value,n.message,e);break}return r}a(cd,"parseBigintDef");function dd(t){return c({type:"boolean"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{})}a(dd,"parseBooleanDef");function ud(t,e){return C(t.type._def,e)}a(ud,"parseBrandedDef");var Km=a((t,e)=>C(t.innerType._def,e),"parseCatchDef");function fd(t,e){return e.dateStrategy=="integer"?Um(t,e):c({type:"string",format:"date-time"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{})}a(fd,"parseDateDef");var Um=a((t,e)=>{let r=c({type:"integer",format:"unix-time"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"&&H(r,"minimum",n.value,n.message,e);break;case"max":e.target==="jsonSchema7"&&H(r,"maximum",n.value,n.message,e);break}return r},"integerDateParser");function pd(t,e){return f(c({},C(t.innerType._def,e)),{default:t.defaultValue()})}a(pd,"parseDefaultDef");function gd(t,e){return e.effectStrategy==="input"?C(t.schema._def,e):{}}a(gd,"parseEffectsDef");function hd(t){return{type:"string",enum:t.values}}a(hd,"parseEnumDef");var zm=a(t=>"type"in t&&t.type==="string"?!1:"allOf"in t,"isJsonSchema7AllOfType");function md(t,e){let r=[C(t.left._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),C(t.right._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","1"]}))].filter(i=>!!i),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,s=[];return r.forEach(i=>{if(zm(i))s.push(...i.allOf),i.unevaluatedProperties===void 0&&(n=void 0);else{let o=i;if("additionalProperties"in i&&i.additionalProperties===!1){let l=i,{additionalProperties:d}=l;o=Ii(l,["additionalProperties"])}else n=void 0;s.push(o)}}),s.length?c({allOf:s},n):void 0}a(md,"parseIntersectionDef");function yd(t,e){let r=typeof t.value;return r!=="bigint"&&r!=="number"&&r!=="boolean"&&r!=="string"?{type:Array.isArray(t.value)?"array":"object"}:e.target==="openApi3"?{type:r==="bigint"?"integer":r,enum:[t.value]}:{type:r==="bigint"?"integer":r,const:t.value}}a(yd,"parseLiteralDef");function Bs(t,e){var r,n,s,i,o;if(e.target==="openApi3"&&((r=t.keyType)==null?void 0:r._def.typeName)==="ZodEnum")return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((d,p)=>{var g;return f(c({},d),{[p]:(g=C(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"properties",p]})))!=null?g:{}})},{}),additionalProperties:!1};let l={type:"object",additionalProperties:(n=C(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?n:{}};if(e.target==="openApi3")return l;if(((s=t.keyType)==null?void 0:s._def.typeName)==="ZodString"&&((i=t.keyType._def.checks)!=null&&i.length)){let d=Object.entries(is(t.keyType._def,e)).reduce((p,[g,m])=>g==="type"?p:f(c({},p),{[g]:m}),{});return f(c({},l),{propertyNames:d})}else if(((o=t.keyType)==null?void 0:o._def.typeName)==="ZodEnum")return f(c({},l),{propertyNames:{enum:t.keyType._def.values}});return l}a(Bs,"parseRecordDef");function vd(t,e){if(e.mapStrategy==="record")return Bs(t,e);let r=C(t.keyType._def,f(c({},e),{currentPath:[...e.currentPath,"items","items","0"]}))||{},n=C(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"items","items","1"]}))||{};return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}a(vd,"parseMapDef");function _d(t){let e=t.values,n=Object.keys(t.values).filter(i=>typeof e[e[i]]!="number").map(i=>e[i]),s=Array.from(new Set(n.map(i=>typeof i)));return{type:s.length===1?s[0]==="string"?"string":"number":["string","number"],enum:n.filter(i=>typeof i=="string"||typeof i=="number")}}a(_d,"parseNativeEnumDef");function Td(){return{not:{}}}a(Td,"parseNeverDef");function bd(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}a(bd,"parseNullDef");var Ur={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function wd(t,e){if(e.target==="openApi3")return Si(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in Ur&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((s,i)=>{let o=Ur[i._def.typeName];return o&&!s.includes(o)?[...s,o]:s},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((s,i)=>{let o=typeof i._def.value;switch(o){case"string":case"number":case"boolean":return[...s,o];case"bigint":return[...s,"integer"];case"object":if(i._def.value===null)return[...s,"null"];case"symbol":case"undefined":case"function":default:return s}},[]);if(n.length===r.length){let s=n.filter((i,o,l)=>l.indexOf(i)===o);return{type:s.length>1?s:s[0],enum:r.reduce((i,o)=>i.includes(o._def.value)?i:[...i,o._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,s)=>[...n,...s._def.values.filter(i=>!n.includes(i))],[])};return Si(t,e)}a(wd,"parseUnionDef");var Si=a((t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((s,i)=>C(s._def,f(c({},e),{currentPath:[...e.currentPath,e.unionStrategy,`${i}`]}))).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0)),n=e.discriminator&&t.typeName==="ZodDiscriminatedUnion"&&typeof t.discriminator=="string"?{discriminator:{propertyName:t.discriminator}}:{};if(r.length)return e.unionStrategy==="anyOf"?c({anyOf:r},n):c({oneOf:r},n)},"asUnionOf");function Pd(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length)){let n=t.innerType;if(e.target==="openApi3"){let i={type:Ur[n._def.typeName],nullable:!0};return Fn(n._def,e,i)}let s={type:[Ur[n._def.typeName],"null"]};return Fn(n._def,e,s)}if(e.target==="openApi3"){let n=C(t.innerType._def,f(c({},e),{currentPath:[...e.currentPath]}));return n&&f(c({},n),{nullable:!0})}let r=C(t.innerType._def,f(c({},e),{currentPath:[...e.currentPath,"anyOf","0"]}));return r&&{anyOf:[r,{type:"null"}]}}a(Pd,"parseNullableDef");function xd(t,e){let r=c({type:"number"},t.coerce?{[b]:{coerce:t.coerce||void 0}}:{});if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",ss(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?H(r,"minimum",n.value,n.message,e):H(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),H(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?H(r,"maximum",n.value,n.message,e):H(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),H(r,"maximum",n.value,n.message,e));break;case"multipleOf":H(r,"multipleOf",n.value,n.message,e);break}return r}a(xd,"parseNumberDef");var Fm=a((t,e)=>{var r;return t.unknownKeys instanceof O?(r=C(t.unknownKeys._def,f(c({},e),{currentPath:[...e.currentPath,"additionalProperties"]})))!=null?r:!0:t.unknownKeys==="passthrough"},"getAdditionalProperties");function kd(t,e){let r=f(c({type:"object"},Object.entries(t.shape()).reduce((n,[s,i])=>{if(i===void 0||i._def===void 0)return n;let o=C(i._def,f(c({},e),{currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]}));return o===void 0?n:{properties:f(c({},n.properties),{[s]:o}),required:i.isOptional()?n.required:[...n.required,s]}},{properties:{},required:[]})),{additionalProperties:Fm(t,e)});return r.required.length||delete r.required,r}a(kd,"parseObjectDef");var Wm=a((t,e)=>{var r;if(e.currentPath.toString()===((r=e.propertyPath)==null?void 0:r.toString()))return C(t.innerType._def,e);let n=C(t.innerType._def,f(c({},e),{currentPath:[...e.currentPath,"anyOf","1"]}));return n?{anyOf:[{not:{}},n]}:{}},"parseOptionalDef"),Lm=a((t,e)=>{if(e.pipeStrategy==="input")return C(t.in._def,e);if(e.pipeStrategy==="output")return C(t.out._def,e);let r=C(t.in._def,f(c({},e),{currentPath:[...e.currentPath,"allOf","0"]})),n=C(t.out._def,f(c({},e),{currentPath:[...e.currentPath,"allOf",r?"1":"0"]}));return{allOf:[r,n].filter(s=>s!==void 0)}},"parsePipelineDef");function Sd(t,e){return C(t.type._def,e)}a(Sd,"parsePromiseDef");function Od(t,e){let n={type:"array",uniqueItems:!0,items:C(t.valueType._def,f(c({},e),{currentPath:[...e.currentPath,"items"]}))};return t.minSize&&H(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&H(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}a(Od,"parseSetDef");function Ed(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>C(r._def,f(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:C(t.rest._def,f(c({},e),{currentPath:[...e.currentPath,"additionalItems"]}))}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>C(r._def,f(c({},e),{currentPath:[...e.currentPath,"items",`${n}`]}))).reduce((r,n)=>n===void 0?r:[...r,n],[])}}a(Ed,"parseTupleDef");function Zd(){return{not:{}}}a(Zd,"parseUndefinedDef");function Id(){return{}}a(Id,"parseUnknownDef");var qm=a((t,e)=>C(t.innerType._def,e),"parseReadonlyDef");function Bd(t){return{$ref:t.uri}}a(Bd,"parseRefDef");function C(t,e,r=!1){let n=e.seen.get(t);if(n&&!r){let o=Vm(n,e);if(o!==void 0)return o}let s={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,s);let i=Jm(t,t.typeName,e);return i&&Fn(t,e,i),s.jsonSchema=i,i}a(C,"parseDef");var Vm=a((t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Gm(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((r,n)=>e.currentPath[n]===r)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},"get$ref"),Gm=a((t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")},"getRelativePath"),Jm=a((t,e,r)=>{switch(e){case"ZodString":return is(t,r);case"ZodNumber":return xd(t,r);case"ZodObject":return kd(t,r);case"ZodBigInt":return cd(t,r);case"ZodBoolean":return dd(t);case"ZodDate":return fd(t,r);case"ZodUndefined":return Zd();case"ZodNull":return bd(r);case"ZodArray":return ld(t,r);case"ZodUnion":case"ZodDiscriminatedUnion":return wd(t,r);case"ZodIntersection":return md(t,r);case"ZodTuple":return Ed(t,r);case"ZodRecord":return Bs(t,r);case"ZodRef":return Bd(t);case"ZodLiteral":return yd(t,r);case"ZodEnum":return hd(t);case"ZodNativeEnum":return _d(t);case"ZodNullable":return Pd(t,r);case"ZodOptional":return Wm(t,r);case"ZodMap":return vd(t,r);case"ZodSet":return Od(t,r);case"ZodLazy":return C(t.getter()._def,r);case"ZodPromise":return Sd(t,r);case"ZodNaN":case"ZodNever":return Td();case"ZodEffects":return gd(t,r);case"ZodAny":return od();case"ZodUnknown":return Id();case"ZodDefault":return pd(t,r);case"ZodBranded":return ud(t,r);case"ZodReadonly":return qm(t,r);case"ZodCatch":return Km(t,r);case"ZodPipeline":return Lm(t,r);case"ZodFunction":case"ZodVoid":case"ZodSymbol":return;default:return(n=>{})(e)}},"selectParser"),Fn=a((t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),Object.assign(r,{[b]:c(c({},t[b]),r[b])}),r),"addMeta"),Oi={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"},Xm=a(t=>typeof t=="string"?f(c({},Oi),{name:t}):c(c({},Oi),t),"getDefaultOptions"),Ym=a(t=>{let e=Xm(t),r=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return f(c({},e),{currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([n,s])=>[s._def,{def:s._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))})},"getRefs"),Qm=a((t,e)=>{var r;let n=Ym(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((d,[p,g])=>{var m;return f(c({},d),{[p]:(m=C(g._def,f(c({},n),{currentPath:[...n.basePath,n.definitionPath,p]}),!0))!=null?m:{}})},{}):void 0,i=typeof e=="string"?e:e?.name,o=(r=C(t._def,i===void 0?n:f(c({},n),{currentPath:[...n.basePath,n.definitionPath,i]}),!1))!=null?r:{},l=i===void 0?s?f(c({},o),{[n.definitionPath]:s}):o:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,i].join("/"),[n.definitionPath]:f(c({},s),{[i]:o})};return n.target==="jsonSchema7"?l.$schema="http://json-schema.org/draft-07/schema#":n.target==="jsonSchema2019-09"&&(l.$schema="https://json-schema.org/draft/2019-09/schema#"),l},"zodToJsonSchema"),ey=a((t,e={target:"openApi3"})=>{let r=Qm(t,e);return e.$schemaUrl===!1?delete r.$schema:typeof e.$schemaUrl=="string"&&(r.$schema=e.$schemaUrl),r},"toJSONSchemaLegacy");var ut=(t,e)=>{let r=t._def,n=e._def;if(r.typeName===y.ZodFirstPartyTypeKind.ZodObject&&n.typeName===y.ZodFirstPartyTypeKind.ZodObject){let s=r.shape(),i=n.shape();return y.object({...s,...i})}if(r.typeName===y.ZodFirstPartyTypeKind.ZodRecord&&n.typeName===y.ZodFirstPartyTypeKind.ZodRecord)return y.record(y.intersection(r.valueType,n.valueType));throw new Error("Cannot merge object schemas with record schemas")},Cd=y;var ne=y.string().min(1),Rd=y.object({text:ne}),Hd=y.object({markdown:ne}),Dd=y.object({imageUrl:ne}),Nd=y.object({audioUrl:ne}),Md=y.object({videoUrl:ne}),jd=y.object({fileUrl:ne,title:ne.optional()}),$d=y.object({latitude:y.number(),longitude:y.number(),address:y.string().optional(),title:y.string().optional()}),Kd=y.object({title:ne,subtitle:ne.optional(),imageUrl:ne.optional(),actions:y.array(y.object({action:y.enum(["postback","url","say"]),label:ne,value:ne}))}),Ad=y.object({text:ne,options:y.array(y.object({label:ne,value:ne}))}),ty=y.object({items:y.array(Kd)}),ry=y.union([y.object({type:y.literal("text"),payload:Rd}),y.object({type:y.literal("markdown"),payload:Hd}),y.object({type:y.literal("image"),payload:Dd}),y.object({type:y.literal("audio"),payload:Nd}),y.object({type:y.literal("video"),payload:Md}),y.object({type:y.literal("file"),payload:jd}),y.object({type:y.literal("location"),payload:$d})]),ny=y.object({items:y.array(ry)}),sy={schema:Hd},iy={text:{schema:Rd},image:{schema:Dd},audio:{schema:Nd},video:{schema:Md},file:{schema:jd},location:{schema:$d},carousel:{schema:ty},card:{schema:Kd},dropdown:{schema:Ad},choice:{schema:Ad},bloc:{schema:ny}};var Wt="x-bot-id",As="x-bot-user-id",Rs="x-integration-id",Hs="x-webhook-id",Ds="x-bp-configuration-type",Lt="x-bp-configuration",qt="x-bp-operation",Ns="x-bp-type",ay={HIDDEN_IN_STUDIO:{bpActionHiddenInStudio:"true"},AWAIT_RETURN:{bpActionAwaitReturn:"true"}};var Ud=require("browser-or-node");var Ms=console;function le(t){if(!t.body)throw new Error("Missing body");return JSON.parse(t.body)}async function Vt(t,e=8072,r=dy){if(!Ud.isNode)throw new Error("This function can only be called in Node.js");let s=require("http").createServer(async(i,o)=>{try{let l=await oy(i);if(l.path==="/health"){o.writeHead(200).end("ok");return}let d=await t(l);o.writeHead(d?.status??200,d?.headers??{}).end(d?.body??"{}")}catch(l){Ms.error("Error while handling request",{error:l?.message??"Internal error occured"}),o.writeHead(500).end(JSON.stringify({error:l?.message??"Internal error occured"}))}});return s.listen(e,()=>r(e)),s}async function oy(t){let e=await cy(t),r={};for(let s=0;s<t.rawHeaders.length;s+=2){let i=t.rawHeaders[s].toLowerCase(),o=t.rawHeaders[s+1];r[i]=o}let n=new URL(t.url??"",t.headers.host?`http://${t.headers.host}`:"http://botpress.cloud");return{body:e,path:n.pathname,query:ly(n.search,"?"),headers:r,method:t.method?.toUpperCase()??"GET"}}function ly(t,e){return t.indexOf(e)===0?t.slice(e.length):t}async function cy(t){return new Promise((e,r)=>{if(t.method!=="POST"&&t.method!=="PUT"&&t.method!=="PATCH")return e(void 0);let n="";t.on("data",s=>n+=s.toString()),t.on("error",s=>r(s)),t.on("end",()=>e(n))})}function dy(t){Ms.info(`Listening on port ${t}`)}var kn=require("@botpress/client");var N={};mt(N,{mapKeys:()=>py,mapValues:()=>fy,mergeRecords:()=>hy,pairs:()=>gn,stripUndefinedProps:()=>gy,values:()=>uy});var gn=t=>Object.entries(t),uy=t=>Object.values(t),fy=(t,e)=>Object.fromEntries(gn(t).map(([r,n])=>[r,e(n,r)])),py=(t,e)=>Object.fromEntries(gn(t).map(([r,n])=>[e(r),n])),gy=t=>Object.fromEntries(gn(t).filter(([,e])=>e!==void 0)),hy=(t,e,r)=>{let n=[...Object.keys(t),...Object.keys(e)],s=[...new Set(n)],i={};for(let o of s){let l=t[o],d=e[o];l&&d?i[o]=r(l,d):l?i[o]=l:d&&(i[o]=d)}return i};var S={};mt(S,{safePush:()=>my,unique:()=>yy});var my=(t,...e)=>t?[...t,...e]:[...e],yy=t=>Array.from(new Set(t));var Y={};mt(Y,{setName:()=>vy});var vy=(t,e)=>(Object.defineProperty(t,"name",{value:e}),t);var zd=t=>{let{name:e,version:r}=t,n={actions:{},events:{},channels:{}},s={name:e,version:r,entities:N.mapValues(t.entities,o=>({name:o.name})),actions:{},events:{},channels:{}},i=N.mapValues(t.entities,o=>o.schema);for(let[o,l]of Object.entries(t.definition.actions??{})){let d=l.input.schema.dereference(i),p=l.output.schema.dereference(i),g=t.actions?.[o]?.name??o;n.actions[g]={...l,...t.actions?.[o]??{},input:{schema:d},output:{schema:p}},s.actions[o]={name:g}}for(let[o,l]of Object.entries(t.definition.events??{})){let d=l.schema.dereference(i),p=t.events?.[o]?.name??o;n.events[p]={...l,...t.events?.[o]??{},schema:d},s.events[o]={name:p}}for(let[o,l]of Object.entries(t.definition.channels??{})){let d={};for(let[g,m]of Object.entries(l.messages)){let P=m.schema.dereference(i);d[g]={...m,schema:P}}let p=t.channels?.[o]?.name??o;n.channels[p]={...l,...t.channels?.[o]??{},message:{...l.message??{},tags:{...l.message?.tags??{},...t.channels?.[o]?.message?.tags??{}}},conversation:{...l.conversation??{},tags:{...l.conversation?.tags??{},...t.channels?.[o]?.conversation?.tags??{}}},messages:d},s.channels[o]={name:p}}return{resolved:n,statement:s}};var hn=Symbol("schemaName"),Fd=t=>t?N.mapValues(t,(r,n)=>({...r,[hn]:n})):{},Wd=t=>hn in t&&t[hn]!==void 0,Ld=t=>t[hn];var mn=class{constructor(e){this.props=e;this.name=e.name,this.version=e.version,this.icon=e.icon,this.readme=e.readme,this.title=e.title,this.identifier=e.identifier,this.description=e.description,this.configuration=e.configuration,this.configurations=e.configurations,this.events=e.events,this.actions=e.actions,this.channels=e.channels,this.states=e.states,this.user=e.user,this.secrets=e.secrets,this.entities=e.entities,this.interfaces=e.interfaces,this.__advanced=e.__advanced,this.attributes=e.attributes}name;version;title;description;icon;readme;configuration;configurations;events;actions;channels;states;user;secrets;identifier;entities;interfaces;__advanced;attributes;extend(e,r){let{entities:n,actions:s,events:i,channels:o}=this._callBuilder(e,r),l=this;l.interfaces??={};let d=Object.values(n).map(P=>P.name),p=d.length===0?e.name:`${e.name}<${d.join(",")}>`,{resolved:g,statement:m}=zd({...e,entities:n,actions:N.stripUndefinedProps(s),events:N.stripUndefinedProps(i),channels:N.stripUndefinedProps(o)});return l.actions=N.mergeRecords(l.actions??{},g.actions,this._mergeActions),l.channels=N.mergeRecords(l.channels??{},g.channels,this._mergeChannels),l.events=N.mergeRecords(l.events??{},g.events,this._mergeEvents),l.interfaces[p]={id:e.id,...m},this}_callBuilder(e,r){let s={entities:Fd(this.entities)},i=r(s),o=N.pairs(i.entities).find(([d,p])=>!Wd(p));if(o)throw new Error(`Cannot extend interface "${e.name}" with entity "${o[0]}"; the provided schema is not part of the integration's entities.`);return{entities:N.mapValues(i.entities,d=>({name:Ld(d),schema:d.schema})),actions:i.actions??{},events:i.events??{},channels:i.channels??{}}}_mergeActions=(e,r)=>({...e,...r,input:{schema:ut(e.input.schema,r.input.schema)},output:{schema:ut(e.output.schema,r.output.schema)}});_mergeEvents=(e,r)=>({...e,...r,schema:ut(e.schema,r.schema)});_mergeChannels=(e,r)=>{let n=N.mergeRecords(e.messages,r.messages,this._mergeMessage),s;(e.conversation||r.conversation)&&(s={tags:{...e.conversation?.tags,...r.conversation?.tags}});let i;return(e.message||r.message)&&(i={tags:{...e.message?.tags,...r.message?.tags}}),{...e,...r,messages:n,conversation:s,message:i}};_mergeMessage=(e,r)=>({schema:ut(e.schema,r.schema)})};var _e=require("@botpress/client");var qd=Ws(require("@botpress/client")),yn={retries:3,retryCondition:t=>qd.axiosRetry.isNetworkOrIdempotentRequestError(t)||[429,502].includes(t.response?.status??0),retryDelay:(t,e)=>(_y(e.response?.headers??{})??t)*1e3},_y=t=>{let e=["RateLimit-Reset","X-RateLimit-Reset","Retry-After","ratelimit-reset","x-ratelimit-reset","retry-after"];for(let r of e){let n=t[r];if(n!==void 0)return Ty(String(n))}},Ty=t=>{let e=by(t)?wy(t):t.length>0?parseInt(t,10):void 0;return e===void 0||isNaN(e)?void 0:e},by=t=>t.includes(" "),wy=t=>{let e=Py(t);if(!e)return;let r=new Date;return Math.max(0,Math.floor((e.getTime()-r.getTime())/1e3))},Py=t=>{let e=new Date(t);return isNaN(e.getTime())?void 0:e};var ft=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(r=>r));updateMessage=(e=>this._client.updateMessage(e).then(r=>r));listMessages=(e=>this._client.listMessages(e));deleteMessage=(e=>this._client.deleteMessage(e));createUser=(e=>this._client.createUser(e));getUser=(e=>this._client.getUser(e));listUsers=e=>this._client.listUsers(e);getOrCreateUser=(e=>this._client.getOrCreateUser(e));updateUser=(e=>this._client.updateUser(e));deleteUser=e=>this._client.deleteUser(e);getState=(e=>this._client.getState(e));setState=(e=>this._client.setState(e));getOrSetState=(e=>this._client.getOrSetState(e));patchState=(e=>this._client.patchState(e));configureIntegration=e=>this._client.configureIntegration(e);uploadFile=e=>this._client.uploadFile(e);upsertFile=e=>this._client.upsertFile(e);deleteFile=e=>this._client.deleteFile(e);listFiles=e=>this._client.listFiles(e);getFile=e=>this._client.getFile(e);updateFileMetadata=e=>this._client.updateFileMetadata(e);trackAnalytics=e=>this._client.trackAnalytics(e)};var vn=class{_cost=0;get cost(){return this._cost}setCost(e){this._cost=e}toJSON(){return{cost:this.cost}}};var ke="#";var Fv=y.enum(["webhook_received","message_created","action_triggered","register","unregister","ping","create_user","create_conversation"]),Vd=t=>{let e=t[Wt],r=t[As],n=t[Rs],s=t[Hs],i=t[Ds],o=t[Lt],l=t[qt];if(!e)throw new Error("Missing bot headers");if(!r)throw new Error("Missing bot user headers");if(!n)throw new Error("Missing integration headers");if(!s)throw new Error("Missing webhook headers");if(!o)throw new Error("Missing configuration headers");if(!l)throw new Error("Missing operation headers");return{botId:e,botUserId:r,integrationId:n,webhookId:s,operation:l,configurationType:i??null,configuration:o?JSON.parse(Buffer.from(o,"base64").toString("utf-8")):{}}};var Gd=Ws(require("util")),pt=class{defaultOptions;constructor(e){this.defaultOptions=e}info(...e){this._log("info",e)}debug(...e){this._log("debug",e)}warn(...e){this._log("warn",e)}error(...e){this._log("error",e)}_log(e,r){this._getConsoleMethod(e)(this._serializeMessage(r))}_serializeMessage(e){let r=Gd.default.format(...e);return process.env.BP_LOG_FORMAT==="json"?this.getJsonMessage(r):r}getJsonMessage(e){return JSON.stringify({msg:e,options:this.defaultOptions})}_getConsoleMethod(e){switch(e){case"debug":return console.debug;case"warn":return console.warn;case"error":return console.error;default:return console.info}}};var gt=class t extends pt{constructor(e){super({visibleToBotOwners:!0,...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})}forBot(){return this.withVisibleToBotOwners(!0)}getJsonMessage(e){return JSON.stringify({msg:e,visible_to_bot_owner:this.defaultOptions.visibleToBotOwners,options:this.defaultOptions})}};var xy=t=>["traceparent","tracestate","sentry-trace"].reduce((e,r)=>(t[r]&&(e[r]=t[r]),e),{}),ky=(t,e,r)=>{let[,n]=(e.headers.traceparent||"").split("-"),s=new _e.Client({botId:t.botId,integrationId:t.integrationId,retry:yn,headers:xy(e.headers)}),i=new ft(s),o=new gt({traceId:n});return{ctx:t,req:e,client:i,logger:o,instance:r}},Sy=async t=>{let{ctx:e}=t;switch(e.operation){case"webhook_received":return await Ey(t);case"register":return await Zy(t);case"unregister":return await Iy(t);case"message_created":return await Ay(t);case"action_triggered":return await Ry(t);case"ping":return await Oy(t);case"create_user":return await By(t);case"create_conversation":return await Cy(t);default:throw new _e.InvalidPayloadError(`Unknown operation ${e.operation}`)}},Jd=t=>async e=>{let r=Vd(e.headers),n=ky(r,e,t),{logger:s}=n;try{let i;return i=await Hy(n),i?{...i,status:i.status??200}:(i=await Sy(n),i?{...i,status:i.status??200}:{status:200})}catch(i){if((0,_e.isApiError)(i)){let l=i.type==="Runtime"?i:new _e.RuntimeError(i.message,i);return s.forBot().error(l.message),{status:l.code,body:JSON.stringify(l.toJSON())}}console.error(i);let o=new _e.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 s.forBot().error(o.message),{status:o.code,body:JSON.stringify(o.toJSON())}}},Oy=async t=>{},Ey=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{let{req:i}=le(r);return s.webhook({client:t,ctx:e,req:i,logger:n})},Zy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.register)return;let{webhookUrl:i}=le(r);await s.register({client:t,ctx:e,webhookUrl:i,logger:n})},Iy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.unregister)return;let{webhookUrl:i}=le(r);await s.unregister({ctx:e,webhookUrl:i,client:t,logger:n})},By=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createUser)return;let{tags:i}=le(r);return await s.createUser({ctx:e,client:t,tags:i,logger:n})},Cy=async({client:t,ctx:e,req:r,logger:n,instance:s})=>{if(!s.createConversation)return;let{channel:i,tags:o}=le(r);return await s.createConversation({ctx:e,client:t,channel:i,tags:o,logger:n})},Ay=async({ctx:t,req:e,client:r,logger:n,instance:s})=>{let{conversation:i,user:o,type:l,payload:d,message:p}=le(e),g=s.channels[i.channel];if(!g)throw new Error(`Channel ${i.channel} not found`);let m=g.messages[l];if(!m)throw new Error(`Message of type ${l} not found in channel ${i.channel}`);await m({ctx:t,conversation:i,message:p,user:o,type:l,client:r,payload:d,ack:async({tags:E})=>{await r.updateMessage({id:p.id,tags:E})},logger:n})},Ry=async({req:t,ctx:e,client:r,logger:n,instance:s})=>{let{input:i,type:o}=le(t);if(!o)throw new Error("Missing action type");let l=s.actions[o];if(!l)throw new Error(`Action ${o} not found`);let d=new vn,g={output:await l({ctx:e,input:i,client:r,type:o,logger:n,metadata:d}),meta:d.toJSON()};return{body:JSON.stringify(g)}},Hy=async({instance:t,client:e,ctx:r,logger:n,req:s})=>{let i=t.unknownOperationHandler;if(i)return await i({client:e,ctx:r,logger:n,req:s})};var _n=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=Jd(this);start=e=>Vt(this.handler,e)};var Tn=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;addIntegration(e,r){let n=this;return n.integrations||(n.integrations={}),n.integrations[e.name]={...e,enabled:r?.enabled,configurationType:r?.configurationType,configuration:r?.configuration,disabledChannels:r?.disabledChannels},this}addPlugin(e,r){let n=this;n.plugins||(n.plugins={});let s=r.alias??e.name.replace("/","-");return n.plugins[s]={...e,alias:s,configuration:r.configuration,interfaces:r.interfaces},n.withPlugins.user=this._mergeUser(n.withPlugins.user,e.definition.user),n.withPlugins.conversation=this._mergeConversation(n.withPlugins.conversation,e.definition.conversation),n.withPlugins.message=this._mergeMessage(n.withPlugins.message,e.definition.message),n.withPlugins.recurringEvents=this._mergeRecurringEvents(n.withPlugins.recurringEvents,e.definition.recurringEvents),n.withPlugins.tables=this._mergeTables(n.withPlugins.tables,e.definition.tables),n.withPlugins.workflows=this._mergeWorkflows(n.withPlugins.workflows,e.definition.workflows),n.withPlugins.states=this._mergeStates(n.withPlugins.states,this._prefixKeysWithPluginAlias(e.definition.states,s)),n.withPlugins.events=this._mergeEvents(n.withPlugins.events,this._prefixKeysWithPluginAlias(e.definition.events,s)),n.withPlugins.actions=this._mergeActions(n.withPlugins.actions,this._prefixKeysWithPluginAlias(e.definition.actions,s)),this}_mergeUser=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeConversation=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeMessage=(e,r)=>({tags:{...e?.tags,...r?.tags}});_mergeStates=(e,r)=>({...e,...r});_mergeEvents=(e,r)=>({...e,...r});_mergeRecurringEvents=(e,r)=>({...e,...r});_mergeActions=(e,r)=>({...e,...r});_mergeTables=(e,r)=>({...e,...r});_mergeWorkflows=(e,r)=>({...e,...r});_prefixKeysWithPluginAlias=(e,r)=>N.mapKeys(e??{},n=>`${r}${ke}${n}`);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(([r,n])=>[r,{...n,definition:{...n.definition,configuration:this._dereferenceDefinitionSchema(n.definition.configuration,e),events:this._dereferenceDefinitionSchemas(n.definition.events,e),states:this._dereferenceDefinitionSchemas(n.definition.states,e),tables:this._dereferenceDefinitionSchemas(n.definition.tables,e),actions:this._dereferenceActionDefinitionSchemas(n.definition.actions,e)}}]))}}_buildZuiReferenceMap(){let e={},r=Object.entries(this.plugins??{});for(let[n,s]of r){let i=Object.entries(s.interfaces??{});for(let[o,l]of i){let d=this.integrations?.[l.name];if(!d)throw new Error(`Interface with alias "${o}" of plugin with alias "${n}" references integration "${l.name}" which is not installed`);let p=Object.entries(l.entities??{});for(let[g,{name:m}]of p){let P=d.definition.entities?.[m]?.schema;if(!P)throw new Error(`Interface entity "${m}" does not exist in integration "${d.name}"`);e[`interface:${o}/entities/${g}`]=P}}}return e}_dereferenceZuiSchema(e,r){return e.dereference(r)}_dereferenceDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,this._dereferenceDefinitionSchema(s,r)]))}_dereferenceDefinitionSchema(e,r){return e&&{...e,schema:this._dereferenceZuiSchema(e.schema,r)}}_dereferenceActionDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,input:{schema:this._dereferenceZuiSchema(s.input.schema,r)},output:{schema:this._dereferenceZuiSchema(s.output.schema,r)}}]))}};var Ve=require("@botpress/client");var ht=class t extends pt{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 ue=class{constructor(e,r={before:{},after:{}}){this._client=e;this._hooks=r}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));getWorkflow=(e=>this._run("getWorkflow",e));updateWorkflow=(e=>this._run("updateWorkflow",e));deleteWorkflow=(e=>this._run("deleteWorkflow",e));listWorkflows=(e=>this._run("listWorkflows",e));createConversation=e=>this._client.createConversation(e);getOrCreateConversation=e=>this._client.getOrCreateConversation(e);createUser=e=>this._client.createUser(e);getOrCreateUser=e=>this._client.getOrCreateUser(e);_run=async(e,r)=>{let n=this._hooks.before[e];n&&(r=await n(r));let s=await this._client[e](r),i=this._hooks.after[e];return i&&(s=await i(s,r)),s}};var Dy=y.enum(["event_received","register","unregister","ping","action_triggered"]),Xd=t=>{let e=t[Wt],r=t[Lt],n=t[Ns],s=Dy.parse(t[qt]);if(!e)throw new Error("Missing bot headers");if(!n)throw new Error("Missing type headers");if(!r)throw new Error("Missing configuration headers");if(!s)throw new Error("Missing operation headers");return{botId:e,operation:s,type:n,configuration:r?JSON.parse(Buffer.from(r,"base64").toString("utf-8")):{}}};var Q={status:200};var $s=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 Ny=["child_workflow_deleted","child_workflow_finished","workflow_timedout","workflow_started","workflow_continued"],Yd=async(t,e)=>{if(t.ctx.type!=="workflow_update"||!Ny.includes(e.payload.type))throw new Error("Unexpected event type");let r={...t,logger:My(t,e)};if(!e.payload.workflow.name)return r.logger.warn("Received workflow update event without a workflow name. Assuming this workflow was not defined by the bot.",e.payload.workflow),Q;switch(e.payload.type){case"child_workflow_deleted":case"child_workflow_finished":r.logger.info(`Received child workflow event "${e.payload.type}", but child workflows are not yet supported`);break;case"workflow_timedout":case"workflow_started":case"workflow_continued":return await jy(r,e);default:e.payload.type}return Q},My=(t,e)=>t.logger.with({eventId:e.id,workflowId:e.payload.workflow.id,conversationId:e.payload.conversation?.id,userId:e.payload.user?.id}),jy=async(t,e)=>{let r=$s(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name];if(!n||n.length===0)return t.logger.warn(`No ${r} handler found for workflow "${e.payload.workflow.name}"`),Q;let{updatedWorkflow:s}=await $y(t,e);return s.status==="pending"&&t.logger.warn(`Workflow "${e.payload.workflow.name}" is still in pending status after processing "${r}" event. This may indicate that the workflow was not properly acknowledged or terminated by the handler. `),Q},$y=async(t,e)=>{let r=$s(e.payload.type),n=t.self.workflowHandlers[r]?.[e.payload.workflow.name],s=structuredClone(e.payload.workflow);for(let i of n??[])s=await i({...t,event:e,conversation:e.payload.conversation,user:e.payload.user,workflow:s});return{updatedWorkflow:s}};var Qd=t=>async e=>{let r=Xd(e.headers),n=new ht,s=new Ve.Client({botId:r.botId,retry:yn}),i=new ue(s,{before:{createMessage:async l=>{let d=t.hookHandlers.before_outgoing_message[l.type]??[];for(let p of d){let g=new ue(s);l=(await p({client:g,ctx:r,logger:n.with({conversationId:l.conversationId,userId:l.userId}),data:l}))?.data??l}return l},callAction:async l=>{let d=t.hookHandlers.before_outgoing_call_action[l.type]??[];for(let p of d){let g=new ue(s);l=(await p({client:g,ctx:r,logger:n,data:l}))?.data??l}return l}},after:{createMessage:async l=>{let d=t.hookHandlers.after_outgoing_message[l.message.type]??[];for(let p of d){let g=new ue(s);l=(await p({client:g,ctx:r,logger:n.with({messageId:l.message.id,conversationId:l.message.conversationId,userId:l.message.userId}),data:l}))?.data??l}return l},callAction:async(l,d)=>{let{type:p}=d,g=t.hookHandlers.after_outgoing_call_action[p]??[];for(let m of g){let P=new ue(s);l=(await m({client:P,ctx:r,logger:n,data:{type:p,...l}}))?.data??l}return l}}}),o={req:e,ctx:r,logger:n,client:i,self:t};try{switch(r.operation){case"action_triggered":return await Wy(o);case"event_received":return await Fy(o);case"register":return await Uy(o);case"unregister":return await zy(o);case"ping":return await Ky(o);default:throw new Error(`Unknown operation ${r.operation}`)}}catch(l){let d=l instanceof Error?l:new Error(String(l));if((0,Ve.isApiError)(d)){let g=d.type==="Runtime"?d:new Ve.RuntimeError(d.message,d);return n.error(g.message),{status:g.code,body:JSON.stringify(g.toJSON())}}let p=new Ve.RuntimeError("An unexpected error occurred in the bot.",d);return n.error(p.message,d),{status:p.code,body:JSON.stringify(p.toJSON())}}},Ky=async t=>Q,Uy=async t=>Q,zy=async t=>Q,Fy=async t=>{let{ctx:e,logger:r,req:n,client:s,self:i}=t,o={client:s,ctx:e,logger:r},l=le(n);if(o.logger=o.logger.with({eventId:l.event.id,messageId:l.event.messageId,conversationId:l.event.conversationId,userId:l.event.userId}),e.type==="workflow_update")return await Yd(t,l.event);if(e.type==="message_created"){let E=l.event,I=E.payload.message;o.logger=o.logger.with({messageId:I.id,conversationId:I.conversationId,userId:I.userId});let U=i.hookHandlers.before_incoming_message[I.type]??[];for(let q of U){let ie=await q({...o,data:I});if(I=ie?.data??I,ie?.stop)return Q}let L={...o,user:E.payload.user,conversation:E.payload.conversation,message:I,event:E},ee=i.messageHandlers[I.type]??[];for(let q of ee)await q(L);let ae=i.hookHandlers.after_incoming_message[I.type]??[];for(let q of ae){let ie=await q({...o,data:I});if(I=ie?.data??I,ie?.stop)return Q}return Q}if(e.type==="state_expired"){let I=l.event.payload.state,U={...o,state:I},L=i.stateExpiredHandlers[I.name]??[];for(let ee of L)await ee(U);return Q}let d=l.event,p=i.hookHandlers.before_incoming_event[d.type]??[];for(let E of p){let I=await E({...o,data:d});if(d=I?.data??d,I?.stop)return Q}let g={...o,event:d},m=i.eventHandlers[d.type]??[];for(let E of m)await E(g);let P=i.hookHandlers.after_incoming_event[d.type]??[];for(let E of P){let I=await E({...o,data:d});if(d=I?.data??d,I?.stop)return Q}return Q},Wy=async({ctx:t,logger:e,req:r,client:n,self:s})=>{let{input:i,type:o}=le(r);if(!o)throw new Error("Missing action type");let l=s.hookHandlers.before_incoming_call_action[o]??[];for(let P of l){let E=await P({ctx:t,logger:e,client:n,data:{type:o,input:i}});i=E?.data?.input??i,o=E?.data?.type??o}let d=s.actionHandlers[o];if(!d)throw new Error(`Action ${o} not found`);let p=await d({ctx:t,logger:e,input:i,client:n,type:o}),g=s.hookHandlers.after_incoming_call_action[o]??[];for(let P of g){let E=await P({ctx:t,logger:e,client:n,data:{type:o,output:p}});o=E?.data?.type??o,p=E?.data?.output??p}return{status:200,body:JSON.stringify({output:p})}};var Te=t=>new Proxy({},{get:(e,r)=>({listInstances:{all:n=>Se({workflowName:r,client:t,input:n}),running:n=>Se({workflowName:r,client:t,input:n,statuses:["in_progress"]}),scheduled:n=>Se({workflowName:r,client:t,input:n,statuses:["pending","listening"]}),allFinished:n=>Se({workflowName:r,client:t,input:n,statuses:["completed","cancelled","failed","timedout"]}),cancelled:n=>Se({workflowName:r,client:t,input:n,statuses:["cancelled"]}),failed:n=>Se({workflowName:r,client:t,input:n,statuses:["failed"]}),succeeded:n=>Se({workflowName:r,client:t,input:n,statuses:["completed"]}),timedOut:n=>Se({workflowName:r,client:t,input:n,statuses:["timedout"]})},startNewInstance:async n=>{let{workflow:s}=await t.createWorkflow({name:r,status:"pending",...n});return{workflow:ce({client:t,workflow:s})}}})}),Se=async t=>{let e=await t.client.listWorkflows({name:t.workflowName,statuses:t.statuses,...t.input});return{...e,workflows:e.workflows.map(r=>ce({client:t.client,workflow:r}))}},ce=t=>{let e=!1;return{...t.workflow,async update(r){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,...r});return await t.onWorkflowUpdate?.(n),{workflow:ce({...t,workflow:n})}},async acknowledgeStartOfProcessing(){if(!t.event||t.workflow.status!=="pending"||e)return{workflow:ce(t)};let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"in_progress",eventId:t.event.id});return e=!0,await t.onWorkflowUpdate?.(r),{workflow:ce({...t,workflow:r})}},async setFailed({failureReason:r}){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"failed",failureReason:r});return await t.onWorkflowUpdate?.(n),{workflow:ce({...t,workflow:n})}},async setCompleted({output:r}={}){let{workflow:n}=await t.client.updateWorkflow({id:t.workflow.id,status:"completed",output:r});return await t.onWorkflowUpdate?.(n),{workflow:ce({...t,workflow:n})}},async cancel(){let{workflow:r}=await t.client.updateWorkflow({id:t.workflow.id,status:"cancelled"});return await t.onWorkflowUpdate?.(r),{workflow:ce({...t,workflow:r})}}}};var bn=class{constructor(e){this.props=e;this._actionHandlers=e.actions,this._plugins=e.plugins}_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_plugins={};_registerOrder=0;get actionHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._actionHandlers[r];if(n)return n;for(let[s,i]of Object.entries(this._plugins)){let[o,l]=r.split(ke);if(!(o!==s||!l)&&(n=i.actionHandlers[l],n))return Y.setName(d=>n({...d,workflows:Te(d.client)}),n.name)}}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.messageHandlers[r]??[]),s=this._messageHandlers[r]??[],i=this._messageHandlers["*"]??[],o=[...s,...i].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return S.unique([...n,...o]).map(l=>Y.setName(d=>l({...d,workflows:Te(d.client)}),l.name))}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.eventHandlers[r]??[]),s=this._eventHandlers[r]??[],i=this._eventHandlers["*"]??[],o=[...s,...i].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return S.unique([...n,...o]).map(l=>Y.setName(d=>l({...d,workflows:Te(d.client)}),l.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{let n=Object.values(this._plugins).flatMap(l=>l.stateExpiredHandlers[r]??[]),s=this._stateExpiredHandlers[r]??[],i=this._stateExpiredHandlers["*"]??[],o=[...s,...i].sort((l,d)=>l.order-d.order).map(({handler:l})=>l);return S.unique([...n,...o]).map(l=>Y.setName(d=>l({...d,workflows:Te(d.client)}),l.name))}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{if(this._hookHandlers[r])return new Proxy({},{get:(s,i)=>{let o=Object.values(this._plugins).flatMap(m=>m.hookHandlers[r]?.[i]??[]),l=this._hookHandlers[r]??{},d=l[i]??[],p=l["*"]??[],g=[...d,...p].sort((m,P)=>m.order-P.order).map(({handler:m})=>m);return S.unique([...o,...g]).map(m=>Y.setName(P=>m({...P,workflows:Te(P.client)}),m.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,i)=>{let o=n[i]?.sort((d,p)=>d.order-p.order).map(({handler:d})=>d)??[],l=Object.values(this._plugins).flatMap(d=>d.workflowHandlers[r]?.[i]??[]);return S.unique([...o,...l]).map(d=>Y.setName(async p=>{let g=p.workflow;return await d({...p,workflow:ce({...p,onWorkflowUpdate(m){g=m}}),workflows:Te(p.client)}),g},d.name))}})}})}on={message:(e,r)=>{this._messageHandlers[e]=S.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=S.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=S.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=S.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=S.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=S.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=S.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=S.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=S.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=S.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=S.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=S.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=S.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=S.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=S.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=S.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};handler=Qd(this);start=e=>Vt(this.handler,e)};var wn=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 r=this._getEntityReference(this.entities),n=e.events===void 0?{}:N.mapValues(e.events,o=>({...o,schema:o.schema(r)})),s=e.actions===void 0?{}:N.mapValues(e.actions,o=>({...o,input:{...o.input,schema:o.input.schema(r)},output:{...o.output,schema:o.output.schema(r)}})),i=e.channels===void 0?{}:N.mapValues(e.channels,o=>({...o,messages:N.mapValues(o.messages,l=>({...l,schema:l.schema(r)}))}));this.events=n,this.actions=s,this.channels=i}name;version;title;description;icon;readme;attributes;entities;events;actions;channels;__advanced;_getEntityReference=e=>{let r={};for(let[n,s]of Object.entries(e)){let i=s.schema._def["x-zui"]?.title,o=s.schema._def.description,l=Cd.ref(n);i&&l.title(i),o&&l.describe(o),r[n]=l}return r}};var Pn=class{constructor(e){this.props=e;let r=Object.fromEntries(Object.entries(e.interfaces??{}).map(([n,s])=>[n,Object.fromEntries(Object.entries(s.definition.entities??{}).map(([i])=>[i,y.ref(`interface:${n}/entities/${i}`)]))]));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,this.configuration=e.configuration?{...e.configuration,schema:typeof e.configuration.schema=="object"?e.configuration.schema:e.configuration.schema({entities:r})}:void 0,this.states=Object.fromEntries(Object.entries(e.states??{}).map(([n,s])=>[n,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:r})}])),this.events=Object.fromEntries(Object.entries(e.events??{}).map(([n,s])=>[n,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:r})}])),this.actions=Object.fromEntries(Object.entries(e.actions??{}).map(([n,s])=>[n,{...s,input:{...s.input,schema:typeof s.input.schema=="object"?s.input.schema:s.input.schema({entities:r})},output:{...s.output,schema:typeof s.output.schema=="object"?s.output.schema:s.output.schema({entities:r})}}])),this.tables=Object.fromEntries(Object.entries(e.tables??{}).map(([n,s])=>[n,{...s,schema:typeof s.schema=="object"?s.schema:s.schema({entities:r})}]))}name;version;title;description;icon;readme;attributes;integrations;interfaces;user;conversation;message;states;configuration;events;recurringEvents;actions;tables;workflows;__advanced;dereferenceEntities({intersectWithUnknownRecord:e}={intersectWithUnknownRecord:!0}){let r=this._buildZuiReferenceMap(e);return{...this,configuration:this.configuration?{...this.configuration,schema:this._dereferenceZuiSchema(this.configuration.schema,r)}:void 0,events:this._dereferenceDefinitionSchemas(this.events,r),states:this._dereferenceDefinitionSchemas(this.states,r),tables:this._dereferenceDefinitionSchemas(this.tables,r),actions:this._dereferenceActionDefinitionSchemas(this.actions,r)}}_buildZuiReferenceMap(e){return Object.fromEntries(Object.entries(this.interfaces??{}).flatMap(([r,n])=>Object.entries(n.definition.entities??{}).map(([s,i])=>[`interface:${r}/entities/${s}`,e?i.schema.and(y.record(y.string(),y.unknown())):i.schema])))}_dereferenceZuiSchema(e,r){return e.dereference(r)}_dereferenceDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,schema:this._dereferenceZuiSchema(s.schema,r)}]))}_dereferenceActionDefinitionSchemas(e,r){return Object.fromEntries(Object.entries(e??{}).map(([n,s])=>[n,{...s,input:{schema:this._dereferenceZuiSchema(s.input.schema,r)},output:{schema:this._dereferenceZuiSchema(s.output.schema,r)}}]))}};var Ks=":";var eu=t=>{let[e,r]=t.split(Ks);return!e||!r?null:{namespace:e,eventName:r}},tu=t=>`${t.namespace}${Ks}${t.actionName}`,ru=t=>`${t.namespace}${Ks}${t.eventName}`,nu=(t,e)=>{let r=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},n=r.name,s=r.actions[t.actionName]?.name??t.actionName;return{namespace:n,actionName:s}},su=(t,e)=>{let r=e[t.namespace]??{name:t.namespace,version:"0.0.0",entities:{},actions:{},events:{},channels:{}},n=r.name,s=r.events[t.eventName]?.name??t.eventName;return{namespace:n,eventName:s}};var iu=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>o=>Ly({client:t,interfaces:e.interfaces,integrationOrInterfaceName:n,methodName:i,input:o})})}),Ly=async({client:t,interfaces:e,integrationOrInterfaceName:r,methodName:n,input:s})=>{let i=nu({namespace:r,actionName:n},e),o=tu(i);return(await t.callAction({type:o,input:s})).output};var Us=class t{constructor(e){this._props=e}async emit(e){let{conversationId:r,userId:n,messageId:s}=this._props;await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:r,userId:n,messageId:s})}async schedule(e,r){let{conversationId:n,userId:s,messageId:i}=this._props;await this._props.client.createEvent({type:this._props.eventName,payload:e,conversationId:n,userId:s,messageId:i,schedule:r})}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})}},au=(t,e)=>new Proxy({},{get:(r,n)=>{let s=e.alias!==void 0?`${e.alias}${ke}${n}`:n;return new Us({client:t,eventName:s})}});var zs=class{constructor(e,r,n){this._client=e;this._stateType=r;this._stateName=n}async get(e){return await this._client.getState({type:this._stateType,name:this._stateName,id:e}).then(r=>r.state.payload)}async set(e,r){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:r})}async getOrSet(e,r){return await this._client.getOrSetState({type:this._stateType,name:this._stateName,id:e,payload:r}).then(n=>n.state.payload)}async delete(e){await this._client.setState({type:this._stateType,name:this._stateName,id:e,payload:null})}async patch(e,r){await this._client.patchState({type:this._stateType,name:this._stateName,id:e,payload:r})}},ou=(t,e)=>new Proxy({},{get:(r,n)=>new Proxy({},{get:(s,i)=>{let o=e.alias!==void 0?`${e.alias}${ke}${i}`:i;return new zs(t,n,o)}})});var xn=class{constructor(e){this.props=e;this._actionHandlers=e.actions}_runtimeProps;_actionHandlers;_messageHandlers={};_eventHandlers={};_stateExpiredHandlers={};_hookHandlers={before_incoming_event:{},before_incoming_message:{},before_outgoing_message:{},before_outgoing_call_action:{},before_incoming_call_action:{},after_incoming_event:{},after_incoming_message:{},after_outgoing_message:{},after_outgoing_call_action:{},after_incoming_call_action:{}};_workflowHandlers={started:{},continued:{},timed_out:{}};_registerOrder=0;initialize(e){return this._runtimeProps=e,this}get _runtime(){if(!this._runtimeProps)throw new Error("Plugin not correctly initialized. This is likely because you access your plugin config outside of an handler.");return this._runtimeProps}_getTools(e){let{configuration:r,interfaces:n,alias:s}=this._runtime,i=iu(e,this._runtime),o=ou(e,this._runtime),l=Te(e),d=au(e,this._runtime);return{configuration:r,interfaces:n,actions:i,states:o,alias:s,workflows:l,events:d}}get actionHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._actionHandlers[r];if(n)return Y.setName(s=>n({...s,...this._getTools(s.client)}),n.name)}})}get messageHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._messageHandlers[r]??[],s=this._messageHandlers["*"]??[];return S.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>Y.setName(l=>o({...l,message:l.message,...this._getTools(l.client)}),o.name))}})}get eventHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._eventHandlers[r]??[],s=Object.entries(this._eventHandlers).filter(([l])=>this._eventResolvesTo(l,r)).flatMap(([,l])=>l??[]),i=this._eventHandlers["*"]??[];return S.unique([...n,...s,...i]).sort((l,d)=>l.order-d.order).map(({handler:l})=>Y.setName(d=>l({...d,event:d.event,...this._getTools(d.client)}),l.name))}})}get stateExpiredHandlers(){return new Proxy({},{get:(e,r)=>{r=this._stripAliasPrefix(r);let n=this._stateExpiredHandlers[r]??[],s=this._stateExpiredHandlers["*"]??[];return S.unique([...n,...s]).sort((o,l)=>o.order-l.order).map(({handler:o})=>Y.setName(l=>o({...l,state:l.state,...this._getTools(l.client)}),o.name))}})}get hookHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._hookHandlers[r];if(n)return new Proxy({},{get:(s,i)=>{i=this._stripAliasPrefix(i);let o=n[i]??[],l=Object.entries(n).filter(([g])=>this._eventResolvesTo(g,i)).flatMap(([,g])=>g??[]),d=n["*"]??[];return S.unique([...o,...l,...d]).sort((g,m)=>g.order-m.order).map(({handler:g})=>Y.setName(m=>g({...m,data:m.data,...this._getTools(m.client)}),g.name))}})}})}get workflowHandlers(){return new Proxy({},{get:(e,r)=>{let n=this._workflowHandlers[r];if(n)return new Proxy({},{get:(s,i)=>(n[i]?.sort((l,d)=>l.order-d.order)??[]).map(({handler:l})=>Y.setName(async d=>{let p=d.workflow;return await l({...d,workflow:ce({...d,onWorkflowUpdate(g){p=g}}),...this._getTools(d.client)}),p},l.name))})}})}on={message:(e,r)=>{this._messageHandlers[e]=S.safePush(this._messageHandlers[e],{handler:r,order:this._registerOrder++})},event:(e,r)=>{this._eventHandlers[e]=S.safePush(this._eventHandlers[e],{handler:r,order:this._registerOrder++})},stateExpired:(e,r)=>{this._stateExpiredHandlers[e]=S.safePush(this._stateExpiredHandlers[e],{handler:r,order:this._registerOrder++})},beforeIncomingEvent:(e,r)=>{this._hookHandlers.before_incoming_event[e]=S.safePush(this._hookHandlers.before_incoming_event[e],{handler:r,order:this._registerOrder++})},beforeIncomingMessage:(e,r)=>{this._hookHandlers.before_incoming_message[e]=S.safePush(this._hookHandlers.before_incoming_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingMessage:(e,r)=>{this._hookHandlers.before_outgoing_message[e]=S.safePush(this._hookHandlers.before_outgoing_message[e],{handler:r,order:this._registerOrder++})},beforeOutgoingCallAction:(e,r)=>{this._hookHandlers.before_outgoing_call_action[e]=S.safePush(this._hookHandlers.before_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},beforeIncomingCallAction:(e,r)=>{this._hookHandlers.before_incoming_call_action[e]=S.safePush(this._hookHandlers.before_incoming_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingEvent:(e,r)=>{this._hookHandlers.after_incoming_event[e]=S.safePush(this._hookHandlers.after_incoming_event[e],{handler:r,order:this._registerOrder++})},afterIncomingMessage:(e,r)=>{this._hookHandlers.after_incoming_message[e]=S.safePush(this._hookHandlers.after_incoming_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingMessage:(e,r)=>{this._hookHandlers.after_outgoing_message[e]=S.safePush(this._hookHandlers.after_outgoing_message[e],{handler:r,order:this._registerOrder++})},afterOutgoingCallAction:(e,r)=>{this._hookHandlers.after_outgoing_call_action[e]=S.safePush(this._hookHandlers.after_outgoing_call_action[e],{handler:r,order:this._registerOrder++})},afterIncomingCallAction:(e,r)=>{this._hookHandlers.after_incoming_call_action[e]=S.safePush(this._hookHandlers.after_incoming_call_action[e],{handler:r,order:this._registerOrder++})},workflowStart:(e,r)=>{this._workflowHandlers.started[e]=S.safePush(this._workflowHandlers.started[e],{handler:r,order:this._registerOrder++})},workflowContinue:(e,r)=>{this._workflowHandlers.continued[e]=S.safePush(this._workflowHandlers.continued[e],{handler:r,order:this._registerOrder++})},workflowTimeout:(e,r)=>{this._workflowHandlers.timed_out[e]=S.safePush(this._workflowHandlers.timed_out[e],{handler:r,order:this._registerOrder++})}};_eventResolvesTo=(e,r)=>{let n=eu(e);if(!n)return!1;let s=su(n,this._runtime.interfaces);return ru(s)===r};_stripAliasPrefix=e=>{let{alias:r}=this._runtime;if(!r)return e;let n=`${r}#`;return e.startsWith(n)?e.slice(n.length):e}};0&&(module.exports={BRAND,Bot,BotDefinition,BotLogger,BotSpecificClient,DIRTY,EMPTY_PATH,INVALID,Integration,IntegrationDefinition,IntegrationLogger,IntegrationSpecificClient,InterfaceDefinition,NEVER,OK,ParseInputLazyPath,ParseStatus,Plugin,PluginDefinition,RuntimeError,Schema,WELL_KNOWN_ATTRIBUTES,ZodAny,ZodArray,ZodBigInt,ZodBoolean,ZodBranded,ZodCatch,ZodDate,ZodDefault,ZodDiscriminatedUnion,ZodEffects,ZodEnum,ZodError,ZodFirstPartyTypeKind,ZodFunction,ZodIntersection,ZodIssueCode,ZodLazy,ZodLiteral,ZodMap,ZodNaN,ZodNativeEnum,ZodNever,ZodNull,ZodNullable,ZodNumber,ZodObject,ZodOptional,ZodParsedType,ZodPipeline,ZodPromise,ZodReadonly,ZodRecord,ZodRef,ZodSchema,ZodSet,ZodString,ZodSymbol,ZodTransformer,ZodTuple,ZodType,ZodUndefined,ZodUnion,ZodUnknown,ZodVoid,addIssueToContext,agent,aimodel,any,array,bigint,boolean,botIdHeader,botUserIdHeader,coerce,configurationHeader,configurationTypeHeader,conversation,createZodEnum,cuid2Regex,cuidRegex,custom,datasource,date,discriminatedUnion,effect,emailRegex,enum:null,errorUtil,event,function:null,getErrorMap,getParsedType,instanceof:null,integrationIdHeader,intent,intersection,ipv4Regex,ipv6Regex,isAborted,isApiError,isAsync,isDirty,isEmojiRegex,isValid,knowledgebase,late,lazy,literal,makeIssue,map,mergeObjectSchemas,message,messages,nan,nativeEnum,never,null:null,nullable,number,object,objectUtil,oboolean,onumber,operationHeader,optional,ostring,parseBody,pipeline,preprocess,processCreateParams,promise,quotelessJson,readonly,record,ref,serve,set,setErrorMap,strictObject,string,symbol,table,tablerow,transformer,transforms,tuple,typeHeader,ulidRegex,undefined,union,unknown,user,util,uuidRegex,variable,void:null,webhookIdHeader,z});
|
|
68
68
|
/*! Bundled license information:
|
|
69
69
|
|
|
70
70
|
@bpinternal/zui/dist/index.js:
|