@novu/framework 0.24.3-alpha.12 → 0.24.3-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/next.js CHANGED
@@ -15,15 +15,15 @@ var Ne__default = /*#__PURE__*/_interopDefault(Ne);
15
15
  var sn__default = /*#__PURE__*/_interopDefault(sn);
16
16
  var nn__default = /*#__PURE__*/_interopDefault(nn);
17
17
 
18
- var en=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var _=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Rt=_(B=>{Object.defineProperty(B,"__esModule",{value:!0});B.getDefaultOptions=B.defaultOptions=B.ignoreOverride=void 0;B.ignoreOverride=Symbol("Let zodToJsonSchema decide on which parser to use");B.defaultOptions={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"};var an=r=>typeof r=="string"?{...B.defaultOptions,name:r}:{...B.defaultOptions,...r};B.getDefaultOptions=an;});var Tr=_(Et=>{Object.defineProperty(Et,"__esModule",{value:!0});Et.getRefs=void 0;var on=Rt(),dn=r=>{let e=(0, on.getDefaultOptions)(r),t=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return {...e,currentPath:t,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([s,n])=>[n._def,{def:n._def,path:[...e.basePath,e.definitionPath,s],jsonSchema:void 0}]))}};Et.getRefs=dn;});var se=_(Ce=>{Object.defineProperty(Ce,"__esModule",{value:!0});Ce.setResponseValueAndErrors=Ce.addErrorMessage=void 0;function cs(r,e,t,s){s?.errorMessages&&t&&(r.errorMessage={...r.errorMessage,[e]:t});}Ce.addErrorMessage=cs;function un(r,e,t,s,n){r[e]=t,cs(r,e,s,n);}Ce.setResponseValueAndErrors=un;});var Ke=_(E=>{Object.defineProperty(E,"__esModule",{value:!0});E.getParsedType=E.ZodParsedType=E.objectUtil=E.util=void 0;var ls;(function(r){r.assertEqual=n=>n;function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{let a={};for(let i of n)a[i]=i;return a},r.getValidEnumValues=n=>{let a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(let o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let a=[];for(let i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(let i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a;})(ls=E.util||(E.util={}));(function(r){r.mergeShapes=(e,t)=>({...e,...t});})(E.objectUtil||(E.objectUtil={}));E.ZodParsedType=ls.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);var ln=r=>{switch(typeof r){case"undefined":return E.ZodParsedType.undefined;case"string":return E.ZodParsedType.string;case"number":return isNaN(r)?E.ZodParsedType.nan:E.ZodParsedType.number;case"boolean":return E.ZodParsedType.boolean;case"function":return E.ZodParsedType.function;case"bigint":return E.ZodParsedType.bigint;case"symbol":return E.ZodParsedType.symbol;case"object":return Array.isArray(r)?E.ZodParsedType.array:r===null?E.ZodParsedType.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?E.ZodParsedType.promise:typeof Map<"u"&&r instanceof Map?E.ZodParsedType.map:typeof Set<"u"&&r instanceof Set?E.ZodParsedType.set:typeof Date<"u"&&r instanceof Date?E.ZodParsedType.date:E.ZodParsedType.object;default:return E.ZodParsedType.unknown}};E.getParsedType=ln;});var wt=_(ne=>{Object.defineProperty(ne,"__esModule",{value:!0});ne.ZodError=ne.quotelessJson=ne.ZodIssueCode=void 0;var ps=Ke();ne.ZodIssueCode=ps.util.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"]);var pn=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");ne.quotelessJson=pn;var ze=class r extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s];},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s];};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e;}get errors(){return this.issues}format(e){let t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else {let o=s,c=0;for(;c<i.path.length;){let l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++;}}};return n(this),s}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ps.util.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},s=[];for(let n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):s.push(e(n));return {formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};ne.ZodError=ze;ze.create=r=>new ze(r);});var Ir=_(Or=>{Object.defineProperty(Or,"__esModule",{value:!0});var le=Ke(),k=wt(),fn=(r,e)=>{let t;switch(r.code){case k.ZodIssueCode.invalid_type:r.received===le.ZodParsedType.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case k.ZodIssueCode.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,le.util.jsonStringifyReplacer)}`;break;case k.ZodIssueCode.unrecognized_keys:t=`Unrecognized key(s) in object: ${le.util.joinValues(r.keys,", ")}`;break;case k.ZodIssueCode.invalid_union:t="Invalid input";break;case k.ZodIssueCode.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${le.util.joinValues(r.options)}`;break;case k.ZodIssueCode.invalid_enum_value:t=`Invalid enum value. Expected ${le.util.joinValues(r.options)}, received '${r.received}'`;break;case k.ZodIssueCode.invalid_arguments:t="Invalid function arguments";break;case k.ZodIssueCode.invalid_return_type:t="Invalid function return type";break;case k.ZodIssueCode.invalid_date:t="Invalid date";break;case k.ZodIssueCode.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:le.util.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case k.ZodIssueCode.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case k.ZodIssueCode.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case k.ZodIssueCode.custom:t="Invalid input";break;case k.ZodIssueCode.invalid_intersection_types:t="Intersection results could not be merged";break;case k.ZodIssueCode.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case k.ZodIssueCode.not_finite:t="Number must be finite";break;default:t=e.defaultError,le.util.assertNever(r);}return {message:t}};Or.default=fn;});var bt=_(G=>{var hn=G&&G.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(G,"__esModule",{value:!0});G.getErrorMap=G.setErrorMap=G.defaultErrorMap=void 0;var fs=hn(Ir());G.defaultErrorMap=fs.default;var hs=fs.default;function mn(r){hs=r;}G.setErrorMap=mn;function yn(){return hs}G.getErrorMap=yn;});var Rr=_(R=>{var _n=R&&R.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(R,"__esModule",{value:!0});R.isAsync=R.isValid=R.isDirty=R.isAborted=R.OK=R.DIRTY=R.INVALID=R.ParseStatus=R.addIssueToContext=R.EMPTY_PATH=R.makeIssue=void 0;var gn=bt(),ms=_n(Ir()),vn=r=>{let{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};if(n.message!==void 0)return {...n,path:a,message:n.message};let o="",c=s.filter(l=>!!l).slice().reverse();for(let l of c)o=l(i,{data:e,defaultError:o}).message;return {...n,path:a,message:o}};R.makeIssue=vn;R.EMPTY_PATH=[];function Tn(r,e){let t=(0, gn.getErrorMap)(),s=(0, R.makeIssue)({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===ms.default?void 0:ms.default].filter(n=>!!n)});r.common.issues.push(s);}R.addIssueToContext=Tn;var xr=class r{constructor(){this.value="valid";}dirty(){this.value==="valid"&&(this.value="dirty");}abort(){this.value!=="aborted"&&(this.value="aborted");}static mergeArray(e,t){let s=[];for(let n of t){if(n.status==="aborted")return R.INVALID;n.status==="dirty"&&e.dirty(),s.push(n.value);}return {status:e.value,value:s}}static async mergeObjectAsync(e,t){let s=[];for(let n of t){let a=await n.key,i=await n.value;s.push({key:a,value:i});}return r.mergeObjectSync(e,s)}static mergeObjectSync(e,t){let s={};for(let n of t){let{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return R.INVALID;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value);}return {status:e.value,value:s}}};R.ParseStatus=xr;R.INVALID=Object.freeze({status:"aborted"});var On=r=>({status:"dirty",value:r});R.DIRTY=On;var In=r=>({status:"valid",value:r});R.OK=In;var xn=r=>r.status==="aborted";R.isAborted=xn;var Rn=r=>r.status==="dirty";R.isDirty=Rn;var En=r=>r.status==="valid";R.isValid=En;var wn=r=>typeof Promise<"u"&&r instanceof Promise;R.isAsync=wn;});var _s=_(ys=>{Object.defineProperty(ys,"__esModule",{value:!0});});var gs=_(Be=>{Object.defineProperty(Be,"__esModule",{value:!0});Be.errorUtil=void 0;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message;})(Be.errorUtil||(Be.errorUtil={}));});var Ns=_(d=>{var At=d&&d.__classPrivateFieldGet||function(r,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(r):s?s.value:e.get(r)},Ts=d&&d.__classPrivateFieldSet||function(r,e,t,s,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t},Ge,Ye;Object.defineProperty(d,"__esModule",{value:!0});d.boolean=d.bigint=d.array=d.any=d.coerce=d.ZodFirstPartyTypeKind=d.late=d.ZodSchema=d.Schema=d.custom=d.ZodReadonly=d.ZodPipeline=d.ZodBranded=d.BRAND=d.ZodNaN=d.ZodCatch=d.ZodDefault=d.ZodNullable=d.ZodOptional=d.ZodTransformer=d.ZodEffects=d.ZodPromise=d.ZodNativeEnum=d.ZodEnum=d.ZodLiteral=d.ZodLazy=d.ZodFunction=d.ZodSet=d.ZodMap=d.ZodRecord=d.ZodTuple=d.ZodIntersection=d.ZodDiscriminatedUnion=d.ZodUnion=d.ZodObject=d.ZodArray=d.ZodVoid=d.ZodNever=d.ZodUnknown=d.ZodAny=d.ZodNull=d.ZodUndefined=d.ZodSymbol=d.ZodDate=d.ZodBoolean=d.ZodBigInt=d.ZodNumber=d.ZodString=d.datetimeRegex=d.ZodType=void 0;d.NEVER=d.void=d.unknown=d.union=d.undefined=d.tuple=d.transformer=d.symbol=d.string=d.strictObject=d.set=d.record=d.promise=d.preprocess=d.pipeline=d.ostring=d.optional=d.onumber=d.oboolean=d.object=d.number=d.nullable=d.null=d.never=d.nativeEnum=d.nan=d.map=d.literal=d.lazy=d.intersection=d.instanceof=d.function=d.enum=d.effect=d.discriminatedUnion=d.date=void 0;var Pt=bt(),m=gs(),u=Rr(),h=Ke(),f=wt(),L=class{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n;}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}},vs=(r,e)=>{if((0, u.isValid)(e))return {success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return {success:!1,get error(){if(this._error)return this._error;let t=new f.ZodError(r.common.issues);return this._error=t,this._error}}};function g(r){if(!r)return {};let{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,o)=>{var c,l;let{message:p}=r;return i.code==="invalid_enum_value"?{message:p??o.defaultError}:typeof o.data>"u"?{message:(c=p??s)!==null&&c!==void 0?c:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(l=p??t)!==null&&l!==void 0?l:o.defaultError}},description:n}}var v=class{constructor(e){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._def.description}_getType(e){return (0, h.getParsedType)(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:(0, h.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return {status:new u.ParseStatus,ctx:{common:e.parent.common,data:e.data,parsedType:(0, h.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if((0, u.isAsync)(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;let n={common:{issues:[],async:(s=t?.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0, h.getParsedType)(e)},a=this._parseSync({data:e,path:n.path,parent:n});return vs(n,a)}async parseAsync(e,t){let s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){let s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0, h.getParsedType)(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await((0, u.isAsync)(n)?n:Promise.resolve(n));return vs(s,a)}refine(e,t){let s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{let i=e(n),o=()=>a.addIssue({code:f.ZodIssueCode.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new j({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return V.create(this,this._def)}nullable(){return J.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ee.create(this,this._def)}promise(){return oe.create(this,this._def)}or(e){return ge.create([this,e],this._def)}and(e){return ve.create(this,e,this._def)}transform(e){return new j({...g(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new Re({...g(this._def),innerType:this,defaultValue:t,typeName:y.ZodDefault})}brand(){return new Je({typeName:y.ZodBranded,type:this,...g(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new Ee({...g(this._def),innerType:this,catchValue:t,typeName:y.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Xe.create(this,e)}readonly(){return we.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};d.ZodType=v;d.Schema=v;d.ZodSchema=v;var Pn=/^c[^\s-]{8,}$/i,An=/^[0-9a-z]+$/,Nn=/^[0-9A-HJKMNP-TV-Z]{26}$/,kn=/^[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,Cn=/^[a-z0-9_-]{21}$/i,Dn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Sn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Zn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Er,jn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Un=/^(([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})))$/,Mn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Os="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Vn=new RegExp(`^${Os}$`);function Is(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Ln(r){return new RegExp(`^${Is(r)}$`)}function xs(r){let e=`${Os}T${Is(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}d.datetimeRegex=xs;function $n(r,e){return !!((e==="v4"||!e)&&jn.test(r)||(e==="v6"||!e)&&Un.test(r))}var ae=class r extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.ZodParsedType.string){let a=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(a,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.string,received:a.parsedType}),u.INVALID}let s=new u.ParseStatus,n;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(n=this._getOrReturnCtx(e,n),i?(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty());}else if(a.kind==="email")Sn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"email",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")Er||(Er=new RegExp(Zn,"u")),Er.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"emoji",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")kn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"uuid",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")Cn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"nanoid",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")Pn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"cuid",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")An.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"cuid2",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")Nn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"ulid",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data);}catch{n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"url",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty();}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"regex",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?xs(a).test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?Vn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?Ln(a).test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?Dn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"duration",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?$n(e.data,a.version)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"ip",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?Mn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"base64",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty()):h.util.assertNever(a);return {status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:f.ZodIssueCode.invalid_string,...m.errorUtil.errToObj(s)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errorUtil.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errorUtil.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errorUtil.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errorUtil.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errorUtil.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errorUtil.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errorUtil.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errorUtil.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errorUtil.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errorUtil.errToObj(e)})}datetime(e){var t,s;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(t=e?.offset)!==null&&t!==void 0?t:!1,local:(s=e?.local)!==null&&s!==void 0?s:!1,...m.errorUtil.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...m.errorUtil.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...m.errorUtil.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...m.errorUtil.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...m.errorUtil.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...m.errorUtil.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...m.errorUtil.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...m.errorUtil.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...m.errorUtil.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...m.errorUtil.errToObj(t)})}nonempty(e){return this.min(1,m.errorUtil.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return !!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return !!this._def.checks.find(e=>e.kind==="date")}get isTime(){return !!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return !!this._def.checks.find(e=>e.kind==="duration")}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 isNANOID(){return !!this._def.checks.find(e=>e.kind==="nanoid")}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 isBase64(){return !!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};d.ZodString=ae;ae.create=r=>{var e;return new ae({checks:[],typeName:y.ZodString,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...g(r)})};function qn(r,e){let t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=parseInt(r.toFixed(n).replace(".","")),i=parseInt(e.toFixed(n).replace(".",""));return a%i/Math.pow(10,n)}var pe=class r extends v{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)!==h.ZodParsedType.number){let a=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(a,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.number,received:a.parsedType}),u.INVALID}let s,n=new u.ParseStatus;for(let a of this._def.checks)a.kind==="int"?h.util.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),(0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),(0, u.addIssueToContext)(s,{code:f.ZodIssueCode.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),(0, u.addIssueToContext)(s,{code:f.ZodIssueCode.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?qn(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),(0, u.addIssueToContext)(s,{code:f.ZodIssueCode.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),(0, u.addIssueToContext)(s,{code:f.ZodIssueCode.not_finite,message:a.message}),n.dirty()):h.util.assertNever(a);return {status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.errorUtil.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.errorUtil.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.errorUtil.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.errorUtil.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.errorUtil.toString(n)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.errorUtil.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.errorUtil.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.errorUtil.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.errorUtil.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.errorUtil.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.errorUtil.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return !!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&h.util.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return !0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);}return Number.isFinite(t)&&Number.isFinite(e)}};d.ZodNumber=pe;pe.create=r=>new pe({checks:[],typeName:y.ZodNumber,coerce:r?.coerce||!1,...g(r)});var fe=class r extends v{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)!==h.ZodParsedType.bigint){let a=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(a,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.bigint,received:a.parsedType}),u.INVALID}let s,n=new u.ParseStatus;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),(0, u.addIssueToContext)(s,{code:f.ZodIssueCode.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),(0, u.addIssueToContext)(s,{code:f.ZodIssueCode.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),(0, u.addIssueToContext)(s,{code:f.ZodIssueCode.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):h.util.assertNever(a);return {status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.errorUtil.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.errorUtil.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.errorUtil.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.errorUtil.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.errorUtil.toString(n)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.errorUtil.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.errorUtil.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};d.ZodBigInt=fe;fe.create=r=>{var e;return new fe({checks:[],typeName:y.ZodBigInt,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...g(r)})};var he=class extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.ZodParsedType.boolean){let s=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.boolean,received:s.parsedType}),u.INVALID}return (0, u.OK)(e.data)}};d.ZodBoolean=he;he.create=r=>new he({typeName:y.ZodBoolean,coerce:r?.coerce||!1,...g(r)});var me=class r extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.ZodParsedType.date){let a=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(a,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.date,received:a.parsedType}),u.INVALID}if(isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(a,{code:f.ZodIssueCode.invalid_date}),u.INVALID}let s=new u.ParseStatus,n;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):h.util.assertNever(a);return {status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:m.errorUtil.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.errorUtil.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};d.ZodDate=me;me.create=r=>new me({checks:[],coerce:r?.coerce||!1,typeName:y.ZodDate,...g(r)});var Se=class extends v{_parse(e){if(this._getType(e)!==h.ZodParsedType.symbol){let s=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.symbol,received:s.parsedType}),u.INVALID}return (0, u.OK)(e.data)}};d.ZodSymbol=Se;Se.create=r=>new Se({typeName:y.ZodSymbol,...g(r)});var ye=class extends v{_parse(e){if(this._getType(e)!==h.ZodParsedType.undefined){let s=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.undefined,received:s.parsedType}),u.INVALID}return (0, u.OK)(e.data)}};d.ZodUndefined=ye;ye.create=r=>new ye({typeName:y.ZodUndefined,...g(r)});var _e=class extends v{_parse(e){if(this._getType(e)!==h.ZodParsedType.null){let s=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.null,received:s.parsedType}),u.INVALID}return (0, u.OK)(e.data)}};d.ZodNull=_e;_e.create=r=>new _e({typeName:y.ZodNull,...g(r)});var ie=class extends v{constructor(){super(...arguments),this._any=!0;}_parse(e){return (0, u.OK)(e.data)}};d.ZodAny=ie;ie.create=r=>new ie({typeName:y.ZodAny,...g(r)});var H=class extends v{constructor(){super(...arguments),this._unknown=!0;}_parse(e){return (0, u.OK)(e.data)}};d.ZodUnknown=H;H.create=r=>new H({typeName:y.ZodUnknown,...g(r)});var W=class extends v{_parse(e){let t=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(t,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.never,received:t.parsedType}),u.INVALID}};d.ZodNever=W;W.create=r=>new W({typeName:y.ZodNever,...g(r)});var Ze=class extends v{_parse(e){if(this._getType(e)!==h.ZodParsedType.undefined){let s=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.void,received:s.parsedType}),u.INVALID}return (0, u.OK)(e.data)}};d.ZodVoid=Ze;Ze.create=r=>new Ze({typeName:y.ZodVoid,...g(r)});var ee=class r extends v{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==h.ZodParsedType.array)return (0, u.addIssueToContext)(t,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.array,received:t.parsedType}),u.INVALID;if(n.exactLength!==null){let i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&((0, u.addIssueToContext)(t,{code:i?f.ZodIssueCode.too_big:f.ZodIssueCode.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty());}if(n.minLength!==null&&t.data.length<n.minLength.value&&((0, u.addIssueToContext)(t,{code:f.ZodIssueCode.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&((0, u.addIssueToContext)(t,{code:f.ZodIssueCode.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new L(t,i,t.path,o)))).then(i=>u.ParseStatus.mergeArray(s,i));let a=[...t.data].map((i,o)=>n.type._parseSync(new L(t,i,t.path,o)));return u.ParseStatus.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:m.errorUtil.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:m.errorUtil.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:m.errorUtil.toString(t)}})}nonempty(e){return this.min(1,e)}};d.ZodArray=ee;ee.create=(r,e)=>new ee({type:r,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...g(e)});function De(r){if(r instanceof D){let e={};for(let t in r.shape){let s=r.shape[t];e[t]=V.create(De(s));}return new D({...r._def,shape:()=>e})}else return r instanceof ee?new ee({...r._def,type:De(r.element)}):r instanceof V?V.create(De(r.unwrap())):r instanceof J?J.create(De(r.unwrap())):r instanceof Y?Y.create(r.items.map(e=>De(e))):r}var D=class r extends v{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(),t=h.util.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==h.ZodParsedType.object){let l=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(l,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.object,received:l.parsedType}),u.INVALID}let{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof W&&this._def.unknownKeys==="strip"))for(let l in n.data)i.includes(l)||o.push(l);let c=[];for(let l of i){let p=a[l],O=n.data[l];c.push({key:{status:"valid",value:l},value:p._parse(new L(n,O,n.path,l)),alwaysSet:l in n.data});}if(this._def.catchall instanceof W){let l=this._def.unknownKeys;if(l==="passthrough")for(let p of o)c.push({key:{status:"valid",value:p},value:{status:"valid",value:n.data[p]}});else if(l==="strict")o.length>0&&((0, u.addIssueToContext)(n,{code:f.ZodIssueCode.unrecognized_keys,keys:o}),s.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else {let l=this._def.catchall;for(let p of o){let O=n.data[p];c.push({key:{status:"valid",value:p},value:l._parse(new L(n,O,n.path,p)),alwaysSet:p in n.data});}}return n.common.async?Promise.resolve().then(async()=>{let l=[];for(let p of c){let O=await p.key,A=await p.value;l.push({key:O,value:A,alwaysSet:p.alwaysSet});}return l}).then(l=>u.ParseStatus.mergeObjectSync(s,l)):u.ParseStatus.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return m.errorUtil.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var n,a,i,o;let c=(i=(a=(n=this._def).errorMap)===null||a===void 0?void 0:a.call(n,t,s).message)!==null&&i!==void 0?i:s.defaultError;return t.code==="unrecognized_keys"?{message:(o=m.errorUtil.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};return h.util.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s]);}),new r({...this._def,shape:()=>t})}omit(e){let t={};return h.util.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s]);}),new r({...this._def,shape:()=>t})}deepPartial(){return De(this)}partial(e){let t={};return h.util.objectKeys(this.shape).forEach(s=>{let n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional();}),new r({...this._def,shape:()=>t})}required(e){let t={};return h.util.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else {let a=this.shape[s];for(;a instanceof V;)a=a._def.innerType;t[s]=a;}}),new r({...this._def,shape:()=>t})}keyof(){return Rs(h.util.objectKeys(this.shape))}};d.ZodObject=D;D.create=(r,e)=>new D({shape:()=>r,unknownKeys:"strip",catchall:W.create(),typeName:y.ZodObject,...g(e)});D.strictCreate=(r,e)=>new D({shape:()=>r,unknownKeys:"strict",catchall:W.create(),typeName:y.ZodObject,...g(e)});D.lazycreate=(r,e)=>new D({shape:r,unknownKeys:"strip",catchall:W.create(),typeName:y.ZodObject,...g(e)});var ge=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(let o of a)if(o.result.status==="valid")return o.result;for(let o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(o=>new f.ZodError(o.ctx.common.issues));return (0, u.addIssueToContext)(t,{code:f.ZodIssueCode.invalid_union,unionErrors:i}),u.INVALID}if(t.common.async)return Promise.all(s.map(async a=>{let i={...t,common:{...t.common,issues:[]},parent:null};return {result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a,i=[];for(let c of s){let l={...t,common:{...t.common,issues:[]},parent:null},p=c._parseSync({data:t.data,path:t.path,parent:l});if(p.status==="valid")return p;p.status==="dirty"&&!a&&(a={result:p,ctx:l}),l.common.issues.length&&i.push(l.common.issues);}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(c=>new f.ZodError(c));return (0, u.addIssueToContext)(t,{code:f.ZodIssueCode.invalid_union,unionErrors:o}),u.INVALID}}get options(){return this._def.options}};d.ZodUnion=ge;ge.create=(r,e)=>new ge({options:r,typeName:y.ZodUnion,...g(e)});var Q=r=>r instanceof Te?Q(r.schema):r instanceof j?Q(r.innerType()):r instanceof Oe?[r.value]:r instanceof Ie?r.options:r instanceof xe?h.util.objectValues(r.enum):r instanceof Re?Q(r._def.innerType):r instanceof ye?[void 0]:r instanceof _e?[null]:r instanceof V?[void 0,...Q(r.unwrap())]:r instanceof J?[null,...Q(r.unwrap())]:r instanceof Je||r instanceof we?Q(r.unwrap()):r instanceof Ee?Q(r._def.innerType):[],Nt=class r extends v{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.ZodParsedType.object)return (0, u.addIssueToContext)(t,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.object,received:t.parsedType}),u.INVALID;let s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):((0, u.addIssueToContext)(t,{code:f.ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),u.INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){let n=new Map;for(let a of t){let i=Q(a.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,a);}}return new r({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...g(s)})}};d.ZodDiscriminatedUnion=Nt;function wr(r,e){let t=(0, h.getParsedType)(r),s=(0, h.getParsedType)(e);if(r===e)return {valid:!0,data:r};if(t===h.ZodParsedType.object&&s===h.ZodParsedType.object){let n=h.util.objectKeys(e),a=h.util.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(let o of a){let c=wr(r[o],e[o]);if(!c.valid)return {valid:!1};i[o]=c.data;}return {valid:!0,data:i}}else if(t===h.ZodParsedType.array&&s===h.ZodParsedType.array){if(r.length!==e.length)return {valid:!1};let n=[];for(let a=0;a<r.length;a++){let i=r[a],o=e[a],c=wr(i,o);if(!c.valid)return {valid:!1};n.push(c.data);}return {valid:!0,data:n}}else return t===h.ZodParsedType.date&&s===h.ZodParsedType.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var ve=class extends v{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if((0, u.isAborted)(a)||(0, u.isAborted)(i))return u.INVALID;let o=wr(a.value,i.value);return o.valid?(((0, u.isDirty)(a)||(0, u.isDirty)(i))&&t.dirty(),{status:t.value,value:o.data}):((0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_intersection_types}),u.INVALID)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};d.ZodIntersection=ve;ve.create=(r,e,t)=>new ve({left:r,right:e,typeName:y.ZodIntersection,...g(t)});var Y=class r extends v{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.ZodParsedType.array)return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.array,received:s.parsedType}),u.INVALID;if(s.data.length<this._def.items.length)return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),u.INVALID;!this._def.rest&&s.data.length>this._def.items.length&&((0, u.addIssueToContext)(s,{code:f.ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...s.data].map((i,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new L(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>u.ParseStatus.mergeArray(t,i)):u.ParseStatus.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};d.ZodTuple=Y;Y.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Y({items:r,typeName:y.ZodTuple,rest:null,...g(e)})};var kt=class r extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.ZodParsedType.object)return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.object,received:s.parsedType}),u.INVALID;let n=[],a=this._def.keyType,i=this._def.valueType;for(let o in s.data)n.push({key:a._parse(new L(s,o,s.path,o)),value:i._parse(new L(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?u.ParseStatus.mergeObjectAsync(t,n):u.ParseStatus.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof v?new r({keyType:e,valueType:t,typeName:y.ZodRecord,...g(s)}):new r({keyType:ae.create(),valueType:e,typeName:y.ZodRecord,...g(t)})}};d.ZodRecord=kt;var je=class extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.ZodParsedType.map)return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.map,received:s.parsedType}),u.INVALID;let n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],l)=>({key:n._parse(new L(s,o,s.path,[l,"key"])),value:a._parse(new L(s,c,s.path,[l,"value"]))}));if(s.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of i){let l=await c.key,p=await c.value;if(l.status==="aborted"||p.status==="aborted")return u.INVALID;(l.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(l.value,p.value);}return {status:t.value,value:o}})}else {let o=new Map;for(let c of i){let l=c.key,p=c.value;if(l.status==="aborted"||p.status==="aborted")return u.INVALID;(l.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(l.value,p.value);}return {status:t.value,value:o}}}};d.ZodMap=je;je.create=(r,e,t)=>new je({valueType:e,keyType:r,typeName:y.ZodMap,...g(t)});var Ue=class r extends v{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.ZodParsedType.set)return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.set,received:s.parsedType}),u.INVALID;let n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&((0, u.addIssueToContext)(s,{code:f.ZodIssueCode.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&((0, u.addIssueToContext)(s,{code:f.ZodIssueCode.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let a=this._def.valueType;function i(c){let l=new Set;for(let p of c){if(p.status==="aborted")return u.INVALID;p.status==="dirty"&&t.dirty(),l.add(p.value);}return {status:t.value,value:l}}let o=[...s.data.values()].map((c,l)=>a._parse(new L(s,c,s.path,l)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new r({...this._def,minSize:{value:e,message:m.errorUtil.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:m.errorUtil.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};d.ZodSet=Ue;Ue.create=(r,e)=>new Ue({valueType:r,minSize:null,maxSize:null,typeName:y.ZodSet,...g(e)});var Ct=class r extends v{constructor(){super(...arguments),this.validate=this.implement;}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.ZodParsedType.function)return (0, u.addIssueToContext)(t,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.function,received:t.parsedType}),u.INVALID;function s(o,c){return (0, u.makeIssue)({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,(0, Pt.getErrorMap)(),Pt.defaultErrorMap].filter(l=>!!l),issueData:{code:f.ZodIssueCode.invalid_arguments,argumentsError:c}})}function n(o,c){return (0, u.makeIssue)({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,(0, Pt.getErrorMap)(),Pt.defaultErrorMap].filter(l=>!!l),issueData:{code:f.ZodIssueCode.invalid_return_type,returnTypeError:c}})}let a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof oe){let o=this;return (0, u.OK)(async function(...c){let l=new f.ZodError([]),p=await o._def.args.parseAsync(c,a).catch(q=>{throw l.addIssue(s(c,q)),l}),O=await Reflect.apply(i,this,p);return await o._def.returns._def.type.parseAsync(O,a).catch(q=>{throw l.addIssue(n(O,q)),l})})}else {let o=this;return (0, u.OK)(function(...c){let l=o._def.args.safeParse(c,a);if(!l.success)throw new f.ZodError([s(c,l.error)]);let p=Reflect.apply(i,this,l.data),O=o._def.returns.safeParse(p,a);if(!O.success)throw new f.ZodError([n(p,O.error)]);return O.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:Y.create(e).rest(H.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new r({args:e||Y.create([]).rest(H.create()),returns:t||H.create(),typeName:y.ZodFunction,...g(s)})}};d.ZodFunction=Ct;var Te=class extends v{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};d.ZodLazy=Te;Te.create=(r,e)=>new Te({getter:r,typeName:y.ZodLazy,...g(e)});var Oe=class extends v{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(t,{received:t.data,code:f.ZodIssueCode.invalid_literal,expected:this._def.value}),u.INVALID}return {status:"valid",value:e.data}}get value(){return this._def.value}};d.ZodLiteral=Oe;Oe.create=(r,e)=>new Oe({value:r,typeName:y.ZodLiteral,...g(e)});function Rs(r,e){return new Ie({values:r,typeName:y.ZodEnum,...g(e)})}var Ie=class r extends v{constructor(){super(...arguments),Ge.set(this,void 0);}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),s=this._def.values;return (0, u.addIssueToContext)(t,{expected:h.util.joinValues(s),received:t.parsedType,code:f.ZodIssueCode.invalid_type}),u.INVALID}if(At(this,Ge,"f")||Ts(this,Ge,new Set(this._def.values),"f"),!At(this,Ge,"f").has(e.data)){let t=this._getOrReturnCtx(e),s=this._def.values;return (0, u.addIssueToContext)(t,{received:t.data,code:f.ZodIssueCode.invalid_enum_value,options:s}),u.INVALID}return (0, u.OK)(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}};d.ZodEnum=Ie;Ge=new WeakMap;Ie.create=Rs;var xe=class extends v{constructor(){super(...arguments),Ye.set(this,void 0);}_parse(e){let t=h.util.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==h.ZodParsedType.string&&s.parsedType!==h.ZodParsedType.number){let n=h.util.objectValues(t);return (0, u.addIssueToContext)(s,{expected:h.util.joinValues(n),received:s.parsedType,code:f.ZodIssueCode.invalid_type}),u.INVALID}if(At(this,Ye,"f")||Ts(this,Ye,new Set(h.util.getValidEnumValues(this._def.values)),"f"),!At(this,Ye,"f").has(e.data)){let n=h.util.objectValues(t);return (0, u.addIssueToContext)(s,{received:s.data,code:f.ZodIssueCode.invalid_enum_value,options:n}),u.INVALID}return (0, u.OK)(e.data)}get enum(){return this._def.values}};d.ZodNativeEnum=xe;Ye=new WeakMap;xe.create=(r,e)=>new xe({values:r,typeName:y.ZodNativeEnum,...g(e)});var oe=class extends v{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.ZodParsedType.promise&&t.common.async===!1)return (0, u.addIssueToContext)(t,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.promise,received:t.parsedType}),u.INVALID;let s=t.parsedType===h.ZodParsedType.promise?t.data:Promise.resolve(t.data);return (0, u.OK)(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};d.ZodPromise=oe;oe.create=(r,e)=>new oe({type:r,typeName:y.ZodPromise,...g(e)});var j=class extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{(0, u.addIssueToContext)(s,i),i.fatal?t.abort():t.dirty();},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){let i=n.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return u.INVALID;let c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?u.INVALID:c.status==="dirty"||t.value==="dirty"?(0, u.DIRTY)(c.value):c});{if(t.value==="aborted")return u.INVALID;let o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?u.INVALID:o.status==="dirty"||t.value==="dirty"?(0, u.DIRTY)(o.value):o}}if(n.type==="refinement"){let i=o=>{let c=n.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){let o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?u.INVALID:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?u.INVALID:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){let i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!(0, u.isValid)(i))return i;let o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return {status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>(0, u.isValid)(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);h.util.assertNever(n);}};d.ZodEffects=j;d.ZodTransformer=j;j.create=(r,e,t)=>new j({schema:r,typeName:y.ZodEffects,effect:e,...g(t)});j.createWithPreprocess=(r,e,t)=>new j({schema:e,effect:{type:"preprocess",transform:r},typeName:y.ZodEffects,...g(t)});var V=class extends v{_parse(e){return this._getType(e)===h.ZodParsedType.undefined?(0, u.OK)(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};d.ZodOptional=V;V.create=(r,e)=>new V({innerType:r,typeName:y.ZodOptional,...g(e)});var J=class extends v{_parse(e){return this._getType(e)===h.ZodParsedType.null?(0, u.OK)(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};d.ZodNullable=J;J.create=(r,e)=>new J({innerType:r,typeName:y.ZodNullable,...g(e)});var Re=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return t.parsedType===h.ZodParsedType.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};d.ZodDefault=Re;Re.create=(r,e)=>new Re({innerType:r,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...g(e)});var Ee=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return (0, u.isAsync)(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new f.ZodError(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new f.ZodError(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};d.ZodCatch=Ee;Ee.create=(r,e)=>new Ee({innerType:r,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...g(e)});var Me=class extends v{_parse(e){if(this._getType(e)!==h.ZodParsedType.nan){let s=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.nan,received:s.parsedType}),u.INVALID}return {status:"valid",value:e.data}}};d.ZodNaN=Me;Me.create=r=>new Me({typeName:y.ZodNaN,...g(r)});d.BRAND=Symbol("zod_brand");var Je=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}};d.ZodBranded=Je;var Xe=class r extends v{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return (async()=>{let a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?u.INVALID:a.status==="dirty"?(t.dirty(),(0, u.DIRTY)(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{let n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?u.INVALID:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new r({in:e,out:t,typeName:y.ZodPipeline})}};d.ZodPipeline=Xe;var we=class extends v{_parse(e){let t=this._def.innerType._parse(e),s=n=>((0, u.isValid)(n)&&(n.value=Object.freeze(n.value)),n);return (0, u.isAsync)(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}};d.ZodReadonly=we;we.create=(r,e)=>new we({innerType:r,typeName:y.ZodReadonly,...g(e)});function Es(r,e={},t){return r?ie.create().superRefine((s,n)=>{var a,i;if(!r(s)){let o=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;n.addIssue({code:"custom",...l,fatal:c});}}):ie.create()}d.custom=Es;d.late={object:D.lazycreate};var y;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly";})(y=d.ZodFirstPartyTypeKind||(d.ZodFirstPartyTypeKind={}));var Fn=(r,e={message:`Input not instance of ${r.name}`})=>Es(t=>t instanceof r,e);d.instanceof=Fn;var ws=ae.create;d.string=ws;var bs=pe.create;d.number=bs;var Wn=Me.create;d.nan=Wn;var Kn=fe.create;d.bigint=Kn;var Ps=he.create;d.boolean=Ps;var zn=me.create;d.date=zn;var Bn=Se.create;d.symbol=Bn;var Gn=ye.create;d.undefined=Gn;var Yn=_e.create;d.null=Yn;var Jn=ie.create;d.any=Jn;var Xn=H.create;d.unknown=Xn;var Qn=W.create;d.never=Qn;var Hn=Ze.create;d.void=Hn;var ea=ee.create;d.array=ea;var ta=D.create;d.object=ta;var ra=D.strictCreate;d.strictObject=ra;var sa=ge.create;d.union=sa;var na=Nt.create;d.discriminatedUnion=na;var aa=ve.create;d.intersection=aa;var ia=Y.create;d.tuple=ia;var oa=kt.create;d.record=oa;var da=je.create;d.map=da;var ua=Ue.create;d.set=ua;var ca=Ct.create;d.function=ca;var la=Te.create;d.lazy=la;var pa=Oe.create;d.literal=pa;var fa=Ie.create;d.enum=fa;var ha=xe.create;d.nativeEnum=ha;var ma=oe.create;d.promise=ma;var As=j.create;d.effect=As;d.transformer=As;var ya=V.create;d.optional=ya;var _a=J.create;d.nullable=_a;var ga=j.createWithPreprocess;d.preprocess=ga;var va=Xe.create;d.pipeline=va;var Ta=()=>ws().optional();d.ostring=Ta;var Oa=()=>bs().optional();d.onumber=Oa;var Ia=()=>Ps().optional();d.oboolean=Ia;d.coerce={string:r=>ae.create({...r,coerce:!0}),number:r=>pe.create({...r,coerce:!0}),boolean:r=>he.create({...r,coerce:!0}),bigint:r=>fe.create({...r,coerce:!0}),date:r=>me.create({...r,coerce:!0})};d.NEVER=u.INVALID;});var br=_($=>{var xa=$&&$.__createBinding||(Object.create?function(r,e,t,s){s===void 0&&(s=t),Object.defineProperty(r,s,{enumerable:!0,get:function(){return e[t]}});}:function(r,e,t,s){s===void 0&&(s=t),r[s]=e[t];}),Ve=$&&$.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&xa(e,r,t);};Object.defineProperty($,"__esModule",{value:!0});Ve(bt(),$);Ve(Rr(),$);Ve(_s(),$);Ve(Ke(),$);Ve(Ns(),$);Ve(wt(),$);});var Dt=_(S=>{var ks=S&&S.__createBinding||(Object.create?function(r,e,t,s){s===void 0&&(s=t),Object.defineProperty(r,s,{enumerable:!0,get:function(){return e[t]}});}:function(r,e,t,s){s===void 0&&(s=t),r[s]=e[t];}),Ra=S&&S.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e});}:function(r,e){r.default=e;}),Ea=S&&S.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)t!=="default"&&Object.prototype.hasOwnProperty.call(r,t)&&ks(e,r,t);return Ra(e,r),e},wa=S&&S.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&ks(e,r,t);};Object.defineProperty(S,"__esModule",{value:!0});S.z=void 0;var Cs=Ea(br());S.z=Cs;wa(br(),S);S.default=Cs;});var Pr=_(St=>{Object.defineProperty(St,"__esModule",{value:!0});St.parseAnyDef=void 0;function ba(){return {}}St.parseAnyDef=ba;});var Ar=_(jt=>{Object.defineProperty(jt,"__esModule",{value:!0});jt.parseArrayDef=void 0;var Pa=Dt(),Zt=se(),Aa=P();function Na(r,e){let t={type:"array"};return r.type?._def?.typeName!==Pa.ZodFirstPartyTypeKind.ZodAny&&(t.items=(0, Aa.parseDef)(r.type._def,{...e,currentPath:[...e.currentPath,"items"]})),r.minLength&&(0, Zt.setResponseValueAndErrors)(t,"minItems",r.minLength.value,r.minLength.message,e),r.maxLength&&(0, Zt.setResponseValueAndErrors)(t,"maxItems",r.maxLength.value,r.maxLength.message,e),r.exactLength&&((0, Zt.setResponseValueAndErrors)(t,"minItems",r.exactLength.value,r.exactLength.message,e),(0, Zt.setResponseValueAndErrors)(t,"maxItems",r.exactLength.value,r.exactLength.message,e)),t}jt.parseArrayDef=Na;});var Nr=_(Ut=>{Object.defineProperty(Ut,"__esModule",{value:!0});Ut.parseBigintDef=void 0;var be=se();function ka(r,e){let t={type:"integer",format:"int64"};if(!r.checks)return t;for(let s of r.checks)switch(s.kind){case"min":e.target==="jsonSchema7"?s.inclusive?(0, be.setResponseValueAndErrors)(t,"minimum",s.value,s.message,e):(0, be.setResponseValueAndErrors)(t,"exclusiveMinimum",s.value,s.message,e):(s.inclusive||(t.exclusiveMinimum=!0),(0, be.setResponseValueAndErrors)(t,"minimum",s.value,s.message,e));break;case"max":e.target==="jsonSchema7"?s.inclusive?(0, be.setResponseValueAndErrors)(t,"maximum",s.value,s.message,e):(0, be.setResponseValueAndErrors)(t,"exclusiveMaximum",s.value,s.message,e):(s.inclusive||(t.exclusiveMaximum=!0),(0, be.setResponseValueAndErrors)(t,"maximum",s.value,s.message,e));break;case"multipleOf":(0, be.setResponseValueAndErrors)(t,"multipleOf",s.value,s.message,e);break}return t}Ut.parseBigintDef=ka;});var kr=_(Mt=>{Object.defineProperty(Mt,"__esModule",{value:!0});Mt.parseBooleanDef=void 0;function Ca(){return {type:"boolean"}}Mt.parseBooleanDef=Ca;});var Cr=_(Vt=>{Object.defineProperty(Vt,"__esModule",{value:!0});Vt.parseBrandedDef=void 0;var Da=P();function Sa(r,e){return (0, Da.parseDef)(r.type._def,e)}Vt.parseBrandedDef=Sa;});var Dr=_(Lt=>{Object.defineProperty(Lt,"__esModule",{value:!0});Lt.parseCatchDef=void 0;var Za=P(),ja=(r,e)=>(0, Za.parseDef)(r.innerType._def,e);Lt.parseCatchDef=ja;});var Sr=_($t=>{Object.defineProperty($t,"__esModule",{value:!0});$t.parseDateDef=void 0;var Ds=se();function Ss(r,e,t){let s=t??e.dateStrategy;if(Array.isArray(s))return {anyOf:s.map((n,a)=>Ss(r,e,n))};switch(s){case"string":case"format:date-time":return {type:"string",format:"date-time"};case"format:date":return {type:"string",format:"date"};case"integer":return Ua(r,e)}}$t.parseDateDef=Ss;var Ua=(r,e)=>{let t={type:"integer",format:"unix-time"};if(e.target==="openApi3")return t;for(let s of r.checks)switch(s.kind){case"min":(0, Ds.setResponseValueAndErrors)(t,"minimum",s.value,s.message,e);break;case"max":(0, Ds.setResponseValueAndErrors)(t,"maximum",s.value,s.message,e);break}return t};});var Zr=_(qt=>{Object.defineProperty(qt,"__esModule",{value:!0});qt.parseDefaultDef=void 0;var Ma=P();function Va(r,e){return {...(0, Ma.parseDef)(r.innerType._def,e),default:r.defaultValue()}}qt.parseDefaultDef=Va;});var jr=_(Ft=>{Object.defineProperty(Ft,"__esModule",{value:!0});Ft.parseEffectsDef=void 0;var La=P();function $a(r,e){return e.effectStrategy==="input"?(0, La.parseDef)(r.schema._def,e):{}}Ft.parseEffectsDef=$a;});var Ur=_(Wt=>{Object.defineProperty(Wt,"__esModule",{value:!0});Wt.parseEnumDef=void 0;function qa(r){return {type:"string",enum:r.values}}Wt.parseEnumDef=qa;});var Mr=_(Kt=>{Object.defineProperty(Kt,"__esModule",{value:!0});Kt.parseIntersectionDef=void 0;var Zs=P(),Fa=r=>"type"in r&&r.type==="string"?!1:"allOf"in r;function Wa(r,e){let t=[(0, Zs.parseDef)(r.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),(0, Zs.parseDef)(r.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(a=>!!a),s=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,n=[];return t.forEach(a=>{if(Fa(a))n.push(...a.allOf),a.unevaluatedProperties===void 0&&(s=void 0);else {let i=a;if("additionalProperties"in a&&a.additionalProperties===!1){let{additionalProperties:o,...c}=a;i=c;}else s=void 0;n.push(i);}}),n.length?{allOf:n,...s}:void 0}Kt.parseIntersectionDef=Wa;});var Vr=_(zt=>{Object.defineProperty(zt,"__esModule",{value:!0});zt.parseLiteralDef=void 0;function Ka(r,e){let t=typeof r.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(r.value)?"array":"object"}:e.target==="openApi3"?{type:t==="bigint"?"integer":t,enum:[r.value]}:{type:t==="bigint"?"integer":t,const:r.value}}zt.parseLiteralDef=Ka;});var Bt=_(U=>{Object.defineProperty(U,"__esModule",{value:!0});U.parseStringDef=U.zodPatterns=void 0;var Pe=se();U.zodPatterns={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,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:RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u"),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][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,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})))$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/};function za(r,e){let t={type:"string"};function s(n){return e.patternStrategy==="escape"?Ba(n):n}if(r.checks)for(let n of r.checks)switch(n.kind){case"min":(0, Pe.setResponseValueAndErrors)(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,n.value):n.value,n.message,e);break;case"max":(0, Pe.setResponseValueAndErrors)(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":K(t,"email",n.message,e);break;case"format:idn-email":K(t,"idn-email",n.message,e);break;case"pattern:zod":z(t,U.zodPatterns.email,n.message,e);break}break;case"url":K(t,"uri",n.message,e);break;case"uuid":K(t,"uuid",n.message,e);break;case"regex":z(t,n.regex,n.message,e);break;case"cuid":z(t,U.zodPatterns.cuid,n.message,e);break;case"cuid2":z(t,U.zodPatterns.cuid2,n.message,e);break;case"startsWith":z(t,RegExp(`^${s(n.value)}`),n.message,e);break;case"endsWith":z(t,RegExp(`${s(n.value)}$`),n.message,e);break;case"datetime":K(t,"date-time",n.message,e);break;case"date":K(t,"date",n.message,e);break;case"time":K(t,"time",n.message,e);break;case"duration":K(t,"duration",n.message,e);break;case"length":(0, Pe.setResponseValueAndErrors)(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,n.value):n.value,n.message,e),(0, Pe.setResponseValueAndErrors)(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,n.value):n.value,n.message,e);break;case"includes":{z(t,RegExp(s(n.value)),n.message,e);break}case"ip":{n.version!=="v6"&&K(t,"ipv4",n.message,e),n.version!=="v4"&&K(t,"ipv6",n.message,e);break}case"emoji":z(t,U.zodPatterns.emoji,n.message,e);break;case"ulid":{z(t,U.zodPatterns.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{K(t,"binary",n.message,e);break}case"contentEncoding:base64":{(0, Pe.setResponseValueAndErrors)(t,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{z(t,U.zodPatterns.base64,n.message,e);break}}break}case"nanoid":z(t,U.zodPatterns.nanoid,n.message,e);}return t}U.parseStringDef=za;var Ba=r=>Array.from(r).map(e=>/[a-zA-Z0-9]/.test(e)?e:`\\${e}`).join(""),K=(r,e,t,s)=>{r.format||r.anyOf?.some(n=>n.format)?(r.anyOf||(r.anyOf=[]),r.format&&(r.anyOf.push({format:r.format,...r.errorMessage&&s.errorMessages&&{errorMessage:{format:r.errorMessage.format}}}),delete r.format,r.errorMessage&&(delete r.errorMessage.format,Object.keys(r.errorMessage).length===0&&delete r.errorMessage)),r.anyOf.push({format:e,...t&&s.errorMessages&&{errorMessage:{format:t}}})):(0, Pe.setResponseValueAndErrors)(r,"format",e,t,s);},z=(r,e,t,s)=>{r.pattern||r.allOf?.some(n=>n.pattern)?(r.allOf||(r.allOf=[]),r.pattern&&(r.allOf.push({pattern:r.pattern,...r.errorMessage&&s.errorMessages&&{errorMessage:{pattern:r.errorMessage.pattern}}}),delete r.pattern,r.errorMessage&&(delete r.errorMessage.pattern,Object.keys(r.errorMessage).length===0&&delete r.errorMessage)),r.allOf.push({pattern:js(e,s),...t&&s.errorMessages&&{errorMessage:{pattern:t}}})):(0, Pe.setResponseValueAndErrors)(r,"pattern",js(e,s),t,s);},js=(r,e)=>{if(!e.applyRegexFlags||!r.flags)return r.source;let t={i:r.flags.includes("i"),m:r.flags.includes("m"),s:r.flags.includes("s")},s=t.i?r.source.toLowerCase():r.source,n="",a=!1,i=!1,o=!1;for(let c=0;c<s.length;c++){if(a){n+=s[c],a=!1;continue}if(t.i){if(i){if(s[c].match(/[a-z]/)){o?(n+=s[c],n+=`${s[c-2]}-${s[c]}`.toUpperCase(),o=!1):s[c+1]==="-"&&s[c+2]?.match(/[a-z]/)?(n+=s[c],o=!0):n+=`${s[c]}${s[c].toUpperCase()}`;continue}}else if(s[c].match(/[a-z]/)){n+=`[${s[c]}${s[c].toUpperCase()}]`;continue}}if(t.m){if(s[c]==="^"){n+=`(^|(?<=[\r
18
+ var en=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var _=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Rt=_(B=>{Object.defineProperty(B,"__esModule",{value:!0});B.getDefaultOptions=B.defaultOptions=B.ignoreOverride=void 0;B.ignoreOverride=Symbol("Let zodToJsonSchema decide on which parser to use");B.defaultOptions={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"};var an=r=>typeof r=="string"?{...B.defaultOptions,name:r}:{...B.defaultOptions,...r};B.getDefaultOptions=an;});var Tr=_(Et=>{Object.defineProperty(Et,"__esModule",{value:!0});Et.getRefs=void 0;var on=Rt(),dn=r=>{let e=(0, on.getDefaultOptions)(r),t=e.name!==void 0?[...e.basePath,e.definitionPath,e.name]:e.basePath;return {...e,currentPath:t,propertyPath:void 0,seen:new Map(Object.entries(e.definitions).map(([s,n])=>[n._def,{def:n._def,path:[...e.basePath,e.definitionPath,s],jsonSchema:void 0}]))}};Et.getRefs=dn;});var se=_(ke=>{Object.defineProperty(ke,"__esModule",{value:!0});ke.setResponseValueAndErrors=ke.addErrorMessage=void 0;function cs(r,e,t,s){s?.errorMessages&&t&&(r.errorMessage={...r.errorMessage,[e]:t});}ke.addErrorMessage=cs;function un(r,e,t,s,n){r[e]=t,cs(r,e,s,n);}ke.setResponseValueAndErrors=un;});var Ke=_(E=>{Object.defineProperty(E,"__esModule",{value:!0});E.getParsedType=E.ZodParsedType=E.objectUtil=E.util=void 0;var ls;(function(r){r.assertEqual=n=>n;function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{let a={};for(let i of n)a[i]=i;return a},r.getValidEnumValues=n=>{let a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(let o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let a=[];for(let i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(let i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a;})(ls=E.util||(E.util={}));(function(r){r.mergeShapes=(e,t)=>({...e,...t});})(E.objectUtil||(E.objectUtil={}));E.ZodParsedType=ls.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);var ln=r=>{switch(typeof r){case"undefined":return E.ZodParsedType.undefined;case"string":return E.ZodParsedType.string;case"number":return isNaN(r)?E.ZodParsedType.nan:E.ZodParsedType.number;case"boolean":return E.ZodParsedType.boolean;case"function":return E.ZodParsedType.function;case"bigint":return E.ZodParsedType.bigint;case"symbol":return E.ZodParsedType.symbol;case"object":return Array.isArray(r)?E.ZodParsedType.array:r===null?E.ZodParsedType.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?E.ZodParsedType.promise:typeof Map<"u"&&r instanceof Map?E.ZodParsedType.map:typeof Set<"u"&&r instanceof Set?E.ZodParsedType.set:typeof Date<"u"&&r instanceof Date?E.ZodParsedType.date:E.ZodParsedType.object;default:return E.ZodParsedType.unknown}};E.getParsedType=ln;});var wt=_(ne=>{Object.defineProperty(ne,"__esModule",{value:!0});ne.ZodError=ne.quotelessJson=ne.ZodIssueCode=void 0;var ps=Ke();ne.ZodIssueCode=ps.util.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"]);var pn=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");ne.quotelessJson=pn;var ze=class r extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s];},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s];};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e;}get errors(){return this.issues}format(e){let t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else {let o=s,c=0;for(;c<i.path.length;){let l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++;}}};return n(this),s}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ps.util.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},s=[];for(let n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):s.push(e(n));return {formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};ne.ZodError=ze;ze.create=r=>new ze(r);});var Ir=_(Or=>{Object.defineProperty(Or,"__esModule",{value:!0});var le=Ke(),C=wt(),fn=(r,e)=>{let t;switch(r.code){case C.ZodIssueCode.invalid_type:r.received===le.ZodParsedType.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case C.ZodIssueCode.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,le.util.jsonStringifyReplacer)}`;break;case C.ZodIssueCode.unrecognized_keys:t=`Unrecognized key(s) in object: ${le.util.joinValues(r.keys,", ")}`;break;case C.ZodIssueCode.invalid_union:t="Invalid input";break;case C.ZodIssueCode.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${le.util.joinValues(r.options)}`;break;case C.ZodIssueCode.invalid_enum_value:t=`Invalid enum value. Expected ${le.util.joinValues(r.options)}, received '${r.received}'`;break;case C.ZodIssueCode.invalid_arguments:t="Invalid function arguments";break;case C.ZodIssueCode.invalid_return_type:t="Invalid function return type";break;case C.ZodIssueCode.invalid_date:t="Invalid date";break;case C.ZodIssueCode.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:le.util.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case C.ZodIssueCode.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case C.ZodIssueCode.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case C.ZodIssueCode.custom:t="Invalid input";break;case C.ZodIssueCode.invalid_intersection_types:t="Intersection results could not be merged";break;case C.ZodIssueCode.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case C.ZodIssueCode.not_finite:t="Number must be finite";break;default:t=e.defaultError,le.util.assertNever(r);}return {message:t}};Or.default=fn;});var bt=_(G=>{var hn=G&&G.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(G,"__esModule",{value:!0});G.getErrorMap=G.setErrorMap=G.defaultErrorMap=void 0;var fs=hn(Ir());G.defaultErrorMap=fs.default;var hs=fs.default;function mn(r){hs=r;}G.setErrorMap=mn;function yn(){return hs}G.getErrorMap=yn;});var Rr=_(R=>{var _n=R&&R.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(R,"__esModule",{value:!0});R.isAsync=R.isValid=R.isDirty=R.isAborted=R.OK=R.DIRTY=R.INVALID=R.ParseStatus=R.addIssueToContext=R.EMPTY_PATH=R.makeIssue=void 0;var gn=bt(),ms=_n(Ir()),vn=r=>{let{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};if(n.message!==void 0)return {...n,path:a,message:n.message};let o="",c=s.filter(l=>!!l).slice().reverse();for(let l of c)o=l(i,{data:e,defaultError:o}).message;return {...n,path:a,message:o}};R.makeIssue=vn;R.EMPTY_PATH=[];function Tn(r,e){let t=(0, gn.getErrorMap)(),s=(0, R.makeIssue)({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===ms.default?void 0:ms.default].filter(n=>!!n)});r.common.issues.push(s);}R.addIssueToContext=Tn;var xr=class r{constructor(){this.value="valid";}dirty(){this.value==="valid"&&(this.value="dirty");}abort(){this.value!=="aborted"&&(this.value="aborted");}static mergeArray(e,t){let s=[];for(let n of t){if(n.status==="aborted")return R.INVALID;n.status==="dirty"&&e.dirty(),s.push(n.value);}return {status:e.value,value:s}}static async mergeObjectAsync(e,t){let s=[];for(let n of t){let a=await n.key,i=await n.value;s.push({key:a,value:i});}return r.mergeObjectSync(e,s)}static mergeObjectSync(e,t){let s={};for(let n of t){let{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return R.INVALID;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value);}return {status:e.value,value:s}}};R.ParseStatus=xr;R.INVALID=Object.freeze({status:"aborted"});var On=r=>({status:"dirty",value:r});R.DIRTY=On;var In=r=>({status:"valid",value:r});R.OK=In;var xn=r=>r.status==="aborted";R.isAborted=xn;var Rn=r=>r.status==="dirty";R.isDirty=Rn;var En=r=>r.status==="valid";R.isValid=En;var wn=r=>typeof Promise<"u"&&r instanceof Promise;R.isAsync=wn;});var _s=_(ys=>{Object.defineProperty(ys,"__esModule",{value:!0});});var gs=_(Be=>{Object.defineProperty(Be,"__esModule",{value:!0});Be.errorUtil=void 0;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message;})(Be.errorUtil||(Be.errorUtil={}));});var Ns=_(d=>{var At=d&&d.__classPrivateFieldGet||function(r,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(r):s?s.value:e.get(r)},Ts=d&&d.__classPrivateFieldSet||function(r,e,t,s,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t},Ge,Ye;Object.defineProperty(d,"__esModule",{value:!0});d.boolean=d.bigint=d.array=d.any=d.coerce=d.ZodFirstPartyTypeKind=d.late=d.ZodSchema=d.Schema=d.custom=d.ZodReadonly=d.ZodPipeline=d.ZodBranded=d.BRAND=d.ZodNaN=d.ZodCatch=d.ZodDefault=d.ZodNullable=d.ZodOptional=d.ZodTransformer=d.ZodEffects=d.ZodPromise=d.ZodNativeEnum=d.ZodEnum=d.ZodLiteral=d.ZodLazy=d.ZodFunction=d.ZodSet=d.ZodMap=d.ZodRecord=d.ZodTuple=d.ZodIntersection=d.ZodDiscriminatedUnion=d.ZodUnion=d.ZodObject=d.ZodArray=d.ZodVoid=d.ZodNever=d.ZodUnknown=d.ZodAny=d.ZodNull=d.ZodUndefined=d.ZodSymbol=d.ZodDate=d.ZodBoolean=d.ZodBigInt=d.ZodNumber=d.ZodString=d.datetimeRegex=d.ZodType=void 0;d.NEVER=d.void=d.unknown=d.union=d.undefined=d.tuple=d.transformer=d.symbol=d.string=d.strictObject=d.set=d.record=d.promise=d.preprocess=d.pipeline=d.ostring=d.optional=d.onumber=d.oboolean=d.object=d.number=d.nullable=d.null=d.never=d.nativeEnum=d.nan=d.map=d.literal=d.lazy=d.intersection=d.instanceof=d.function=d.enum=d.effect=d.discriminatedUnion=d.date=void 0;var Pt=bt(),m=gs(),u=Rr(),h=Ke(),f=wt(),L=class{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n;}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}},vs=(r,e)=>{if((0, u.isValid)(e))return {success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return {success:!1,get error(){if(this._error)return this._error;let t=new f.ZodError(r.common.issues);return this._error=t,this._error}}};function g(r){if(!r)return {};let{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,o)=>{var c,l;let{message:p}=r;return i.code==="invalid_enum_value"?{message:p??o.defaultError}:typeof o.data>"u"?{message:(c=p??s)!==null&&c!==void 0?c:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(l=p??t)!==null&&l!==void 0?l:o.defaultError}},description:n}}var v=class{constructor(e){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._def.description}_getType(e){return (0, h.getParsedType)(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:(0, h.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return {status:new u.ParseStatus,ctx:{common:e.parent.common,data:e.data,parsedType:(0, h.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if((0, u.isAsync)(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;let n={common:{issues:[],async:(s=t?.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0, h.getParsedType)(e)},a=this._parseSync({data:e,path:n.path,parent:n});return vs(n,a)}async parseAsync(e,t){let s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){let s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0, h.getParsedType)(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await((0, u.isAsync)(n)?n:Promise.resolve(n));return vs(s,a)}refine(e,t){let s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{let i=e(n),o=()=>a.addIssue({code:f.ZodIssueCode.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new j({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return V.create(this,this._def)}nullable(){return J.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ee.create(this,this._def)}promise(){return oe.create(this,this._def)}or(e){return ge.create([this,e],this._def)}and(e){return ve.create(this,e,this._def)}transform(e){return new j({...g(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new Re({...g(this._def),innerType:this,defaultValue:t,typeName:y.ZodDefault})}brand(){return new Je({typeName:y.ZodBranded,type:this,...g(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new Ee({...g(this._def),innerType:this,catchValue:t,typeName:y.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Xe.create(this,e)}readonly(){return we.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};d.ZodType=v;d.Schema=v;d.ZodSchema=v;var Pn=/^c[^\s-]{8,}$/i,An=/^[0-9a-z]+$/,Nn=/^[0-9A-HJKMNP-TV-Z]{26}$/,Cn=/^[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,kn=/^[a-z0-9_-]{21}$/i,Dn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Sn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Zn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Er,jn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Un=/^(([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})))$/,Mn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Os="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Vn=new RegExp(`^${Os}$`);function Is(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Ln(r){return new RegExp(`^${Is(r)}$`)}function xs(r){let e=`${Os}T${Is(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}d.datetimeRegex=xs;function $n(r,e){return !!((e==="v4"||!e)&&jn.test(r)||(e==="v6"||!e)&&Un.test(r))}var ae=class r extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.ZodParsedType.string){let a=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(a,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.string,received:a.parsedType}),u.INVALID}let s=new u.ParseStatus,n;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(n=this._getOrReturnCtx(e,n),i?(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty());}else if(a.kind==="email")Sn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"email",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")Er||(Er=new RegExp(Zn,"u")),Er.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"emoji",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")Cn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"uuid",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")kn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"nanoid",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")Pn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"cuid",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")An.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"cuid2",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")Nn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"ulid",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data);}catch{n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"url",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty();}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"regex",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?xs(a).test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?Vn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?Ln(a).test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?Dn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"duration",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?$n(e.data,a.version)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"ip",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?Mn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"base64",code:f.ZodIssueCode.invalid_string,message:a.message}),s.dirty()):h.util.assertNever(a);return {status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:f.ZodIssueCode.invalid_string,...m.errorUtil.errToObj(s)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errorUtil.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errorUtil.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errorUtil.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errorUtil.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errorUtil.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errorUtil.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errorUtil.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errorUtil.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errorUtil.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errorUtil.errToObj(e)})}datetime(e){var t,s;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(t=e?.offset)!==null&&t!==void 0?t:!1,local:(s=e?.local)!==null&&s!==void 0?s:!1,...m.errorUtil.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...m.errorUtil.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...m.errorUtil.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...m.errorUtil.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...m.errorUtil.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...m.errorUtil.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...m.errorUtil.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...m.errorUtil.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...m.errorUtil.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...m.errorUtil.errToObj(t)})}nonempty(e){return this.min(1,m.errorUtil.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return !!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return !!this._def.checks.find(e=>e.kind==="date")}get isTime(){return !!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return !!this._def.checks.find(e=>e.kind==="duration")}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 isNANOID(){return !!this._def.checks.find(e=>e.kind==="nanoid")}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 isBase64(){return !!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};d.ZodString=ae;ae.create=r=>{var e;return new ae({checks:[],typeName:y.ZodString,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...g(r)})};function qn(r,e){let t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=parseInt(r.toFixed(n).replace(".","")),i=parseInt(e.toFixed(n).replace(".",""));return a%i/Math.pow(10,n)}var pe=class r extends v{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)!==h.ZodParsedType.number){let a=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(a,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.number,received:a.parsedType}),u.INVALID}let s,n=new u.ParseStatus;for(let a of this._def.checks)a.kind==="int"?h.util.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),(0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),(0, u.addIssueToContext)(s,{code:f.ZodIssueCode.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),(0, u.addIssueToContext)(s,{code:f.ZodIssueCode.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?qn(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),(0, u.addIssueToContext)(s,{code:f.ZodIssueCode.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),(0, u.addIssueToContext)(s,{code:f.ZodIssueCode.not_finite,message:a.message}),n.dirty()):h.util.assertNever(a);return {status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.errorUtil.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.errorUtil.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.errorUtil.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.errorUtil.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.errorUtil.toString(n)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.errorUtil.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.errorUtil.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.errorUtil.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.errorUtil.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.errorUtil.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.errorUtil.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return !!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&h.util.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return !0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);}return Number.isFinite(t)&&Number.isFinite(e)}};d.ZodNumber=pe;pe.create=r=>new pe({checks:[],typeName:y.ZodNumber,coerce:r?.coerce||!1,...g(r)});var fe=class r extends v{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)!==h.ZodParsedType.bigint){let a=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(a,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.bigint,received:a.parsedType}),u.INVALID}let s,n=new u.ParseStatus;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),(0, u.addIssueToContext)(s,{code:f.ZodIssueCode.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),(0, u.addIssueToContext)(s,{code:f.ZodIssueCode.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),(0, u.addIssueToContext)(s,{code:f.ZodIssueCode.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):h.util.assertNever(a);return {status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.errorUtil.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.errorUtil.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.errorUtil.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.errorUtil.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.errorUtil.toString(n)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.errorUtil.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.errorUtil.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};d.ZodBigInt=fe;fe.create=r=>{var e;return new fe({checks:[],typeName:y.ZodBigInt,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...g(r)})};var he=class extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.ZodParsedType.boolean){let s=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.boolean,received:s.parsedType}),u.INVALID}return (0, u.OK)(e.data)}};d.ZodBoolean=he;he.create=r=>new he({typeName:y.ZodBoolean,coerce:r?.coerce||!1,...g(r)});var me=class r extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.ZodParsedType.date){let a=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(a,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.date,received:a.parsedType}),u.INVALID}if(isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(a,{code:f.ZodIssueCode.invalid_date}),u.INVALID}let s=new u.ParseStatus,n;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:f.ZodIssueCode.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):h.util.assertNever(a);return {status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:m.errorUtil.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.errorUtil.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};d.ZodDate=me;me.create=r=>new me({checks:[],coerce:r?.coerce||!1,typeName:y.ZodDate,...g(r)});var Se=class extends v{_parse(e){if(this._getType(e)!==h.ZodParsedType.symbol){let s=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.symbol,received:s.parsedType}),u.INVALID}return (0, u.OK)(e.data)}};d.ZodSymbol=Se;Se.create=r=>new Se({typeName:y.ZodSymbol,...g(r)});var ye=class extends v{_parse(e){if(this._getType(e)!==h.ZodParsedType.undefined){let s=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.undefined,received:s.parsedType}),u.INVALID}return (0, u.OK)(e.data)}};d.ZodUndefined=ye;ye.create=r=>new ye({typeName:y.ZodUndefined,...g(r)});var _e=class extends v{_parse(e){if(this._getType(e)!==h.ZodParsedType.null){let s=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.null,received:s.parsedType}),u.INVALID}return (0, u.OK)(e.data)}};d.ZodNull=_e;_e.create=r=>new _e({typeName:y.ZodNull,...g(r)});var ie=class extends v{constructor(){super(...arguments),this._any=!0;}_parse(e){return (0, u.OK)(e.data)}};d.ZodAny=ie;ie.create=r=>new ie({typeName:y.ZodAny,...g(r)});var H=class extends v{constructor(){super(...arguments),this._unknown=!0;}_parse(e){return (0, u.OK)(e.data)}};d.ZodUnknown=H;H.create=r=>new H({typeName:y.ZodUnknown,...g(r)});var W=class extends v{_parse(e){let t=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(t,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.never,received:t.parsedType}),u.INVALID}};d.ZodNever=W;W.create=r=>new W({typeName:y.ZodNever,...g(r)});var Ze=class extends v{_parse(e){if(this._getType(e)!==h.ZodParsedType.undefined){let s=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.void,received:s.parsedType}),u.INVALID}return (0, u.OK)(e.data)}};d.ZodVoid=Ze;Ze.create=r=>new Ze({typeName:y.ZodVoid,...g(r)});var ee=class r extends v{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==h.ZodParsedType.array)return (0, u.addIssueToContext)(t,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.array,received:t.parsedType}),u.INVALID;if(n.exactLength!==null){let i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&((0, u.addIssueToContext)(t,{code:i?f.ZodIssueCode.too_big:f.ZodIssueCode.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty());}if(n.minLength!==null&&t.data.length<n.minLength.value&&((0, u.addIssueToContext)(t,{code:f.ZodIssueCode.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&((0, u.addIssueToContext)(t,{code:f.ZodIssueCode.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new L(t,i,t.path,o)))).then(i=>u.ParseStatus.mergeArray(s,i));let a=[...t.data].map((i,o)=>n.type._parseSync(new L(t,i,t.path,o)));return u.ParseStatus.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:m.errorUtil.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:m.errorUtil.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:m.errorUtil.toString(t)}})}nonempty(e){return this.min(1,e)}};d.ZodArray=ee;ee.create=(r,e)=>new ee({type:r,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...g(e)});function De(r){if(r instanceof D){let e={};for(let t in r.shape){let s=r.shape[t];e[t]=V.create(De(s));}return new D({...r._def,shape:()=>e})}else return r instanceof ee?new ee({...r._def,type:De(r.element)}):r instanceof V?V.create(De(r.unwrap())):r instanceof J?J.create(De(r.unwrap())):r instanceof Y?Y.create(r.items.map(e=>De(e))):r}var D=class r extends v{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(),t=h.util.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==h.ZodParsedType.object){let l=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(l,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.object,received:l.parsedType}),u.INVALID}let{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof W&&this._def.unknownKeys==="strip"))for(let l in n.data)i.includes(l)||o.push(l);let c=[];for(let l of i){let p=a[l],O=n.data[l];c.push({key:{status:"valid",value:l},value:p._parse(new L(n,O,n.path,l)),alwaysSet:l in n.data});}if(this._def.catchall instanceof W){let l=this._def.unknownKeys;if(l==="passthrough")for(let p of o)c.push({key:{status:"valid",value:p},value:{status:"valid",value:n.data[p]}});else if(l==="strict")o.length>0&&((0, u.addIssueToContext)(n,{code:f.ZodIssueCode.unrecognized_keys,keys:o}),s.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else {let l=this._def.catchall;for(let p of o){let O=n.data[p];c.push({key:{status:"valid",value:p},value:l._parse(new L(n,O,n.path,p)),alwaysSet:p in n.data});}}return n.common.async?Promise.resolve().then(async()=>{let l=[];for(let p of c){let O=await p.key,A=await p.value;l.push({key:O,value:A,alwaysSet:p.alwaysSet});}return l}).then(l=>u.ParseStatus.mergeObjectSync(s,l)):u.ParseStatus.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return m.errorUtil.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var n,a,i,o;let c=(i=(a=(n=this._def).errorMap)===null||a===void 0?void 0:a.call(n,t,s).message)!==null&&i!==void 0?i:s.defaultError;return t.code==="unrecognized_keys"?{message:(o=m.errorUtil.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};return h.util.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s]);}),new r({...this._def,shape:()=>t})}omit(e){let t={};return h.util.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s]);}),new r({...this._def,shape:()=>t})}deepPartial(){return De(this)}partial(e){let t={};return h.util.objectKeys(this.shape).forEach(s=>{let n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional();}),new r({...this._def,shape:()=>t})}required(e){let t={};return h.util.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else {let a=this.shape[s];for(;a instanceof V;)a=a._def.innerType;t[s]=a;}}),new r({...this._def,shape:()=>t})}keyof(){return Rs(h.util.objectKeys(this.shape))}};d.ZodObject=D;D.create=(r,e)=>new D({shape:()=>r,unknownKeys:"strip",catchall:W.create(),typeName:y.ZodObject,...g(e)});D.strictCreate=(r,e)=>new D({shape:()=>r,unknownKeys:"strict",catchall:W.create(),typeName:y.ZodObject,...g(e)});D.lazycreate=(r,e)=>new D({shape:r,unknownKeys:"strip",catchall:W.create(),typeName:y.ZodObject,...g(e)});var ge=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(let o of a)if(o.result.status==="valid")return o.result;for(let o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(o=>new f.ZodError(o.ctx.common.issues));return (0, u.addIssueToContext)(t,{code:f.ZodIssueCode.invalid_union,unionErrors:i}),u.INVALID}if(t.common.async)return Promise.all(s.map(async a=>{let i={...t,common:{...t.common,issues:[]},parent:null};return {result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a,i=[];for(let c of s){let l={...t,common:{...t.common,issues:[]},parent:null},p=c._parseSync({data:t.data,path:t.path,parent:l});if(p.status==="valid")return p;p.status==="dirty"&&!a&&(a={result:p,ctx:l}),l.common.issues.length&&i.push(l.common.issues);}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(c=>new f.ZodError(c));return (0, u.addIssueToContext)(t,{code:f.ZodIssueCode.invalid_union,unionErrors:o}),u.INVALID}}get options(){return this._def.options}};d.ZodUnion=ge;ge.create=(r,e)=>new ge({options:r,typeName:y.ZodUnion,...g(e)});var Q=r=>r instanceof Te?Q(r.schema):r instanceof j?Q(r.innerType()):r instanceof Oe?[r.value]:r instanceof Ie?r.options:r instanceof xe?h.util.objectValues(r.enum):r instanceof Re?Q(r._def.innerType):r instanceof ye?[void 0]:r instanceof _e?[null]:r instanceof V?[void 0,...Q(r.unwrap())]:r instanceof J?[null,...Q(r.unwrap())]:r instanceof Je||r instanceof we?Q(r.unwrap()):r instanceof Ee?Q(r._def.innerType):[],Nt=class r extends v{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.ZodParsedType.object)return (0, u.addIssueToContext)(t,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.object,received:t.parsedType}),u.INVALID;let s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):((0, u.addIssueToContext)(t,{code:f.ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),u.INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){let n=new Map;for(let a of t){let i=Q(a.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,a);}}return new r({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...g(s)})}};d.ZodDiscriminatedUnion=Nt;function wr(r,e){let t=(0, h.getParsedType)(r),s=(0, h.getParsedType)(e);if(r===e)return {valid:!0,data:r};if(t===h.ZodParsedType.object&&s===h.ZodParsedType.object){let n=h.util.objectKeys(e),a=h.util.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(let o of a){let c=wr(r[o],e[o]);if(!c.valid)return {valid:!1};i[o]=c.data;}return {valid:!0,data:i}}else if(t===h.ZodParsedType.array&&s===h.ZodParsedType.array){if(r.length!==e.length)return {valid:!1};let n=[];for(let a=0;a<r.length;a++){let i=r[a],o=e[a],c=wr(i,o);if(!c.valid)return {valid:!1};n.push(c.data);}return {valid:!0,data:n}}else return t===h.ZodParsedType.date&&s===h.ZodParsedType.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var ve=class extends v{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if((0, u.isAborted)(a)||(0, u.isAborted)(i))return u.INVALID;let o=wr(a.value,i.value);return o.valid?(((0, u.isDirty)(a)||(0, u.isDirty)(i))&&t.dirty(),{status:t.value,value:o.data}):((0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_intersection_types}),u.INVALID)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};d.ZodIntersection=ve;ve.create=(r,e,t)=>new ve({left:r,right:e,typeName:y.ZodIntersection,...g(t)});var Y=class r extends v{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.ZodParsedType.array)return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.array,received:s.parsedType}),u.INVALID;if(s.data.length<this._def.items.length)return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),u.INVALID;!this._def.rest&&s.data.length>this._def.items.length&&((0, u.addIssueToContext)(s,{code:f.ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...s.data].map((i,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new L(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>u.ParseStatus.mergeArray(t,i)):u.ParseStatus.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};d.ZodTuple=Y;Y.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Y({items:r,typeName:y.ZodTuple,rest:null,...g(e)})};var Ct=class r extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.ZodParsedType.object)return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.object,received:s.parsedType}),u.INVALID;let n=[],a=this._def.keyType,i=this._def.valueType;for(let o in s.data)n.push({key:a._parse(new L(s,o,s.path,o)),value:i._parse(new L(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?u.ParseStatus.mergeObjectAsync(t,n):u.ParseStatus.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof v?new r({keyType:e,valueType:t,typeName:y.ZodRecord,...g(s)}):new r({keyType:ae.create(),valueType:e,typeName:y.ZodRecord,...g(t)})}};d.ZodRecord=Ct;var je=class extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.ZodParsedType.map)return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.map,received:s.parsedType}),u.INVALID;let n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],l)=>({key:n._parse(new L(s,o,s.path,[l,"key"])),value:a._parse(new L(s,c,s.path,[l,"value"]))}));if(s.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of i){let l=await c.key,p=await c.value;if(l.status==="aborted"||p.status==="aborted")return u.INVALID;(l.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(l.value,p.value);}return {status:t.value,value:o}})}else {let o=new Map;for(let c of i){let l=c.key,p=c.value;if(l.status==="aborted"||p.status==="aborted")return u.INVALID;(l.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(l.value,p.value);}return {status:t.value,value:o}}}};d.ZodMap=je;je.create=(r,e,t)=>new je({valueType:e,keyType:r,typeName:y.ZodMap,...g(t)});var Ue=class r extends v{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.ZodParsedType.set)return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.set,received:s.parsedType}),u.INVALID;let n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&((0, u.addIssueToContext)(s,{code:f.ZodIssueCode.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&((0, u.addIssueToContext)(s,{code:f.ZodIssueCode.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let a=this._def.valueType;function i(c){let l=new Set;for(let p of c){if(p.status==="aborted")return u.INVALID;p.status==="dirty"&&t.dirty(),l.add(p.value);}return {status:t.value,value:l}}let o=[...s.data.values()].map((c,l)=>a._parse(new L(s,c,s.path,l)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new r({...this._def,minSize:{value:e,message:m.errorUtil.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:m.errorUtil.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};d.ZodSet=Ue;Ue.create=(r,e)=>new Ue({valueType:r,minSize:null,maxSize:null,typeName:y.ZodSet,...g(e)});var kt=class r extends v{constructor(){super(...arguments),this.validate=this.implement;}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.ZodParsedType.function)return (0, u.addIssueToContext)(t,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.function,received:t.parsedType}),u.INVALID;function s(o,c){return (0, u.makeIssue)({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,(0, Pt.getErrorMap)(),Pt.defaultErrorMap].filter(l=>!!l),issueData:{code:f.ZodIssueCode.invalid_arguments,argumentsError:c}})}function n(o,c){return (0, u.makeIssue)({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,(0, Pt.getErrorMap)(),Pt.defaultErrorMap].filter(l=>!!l),issueData:{code:f.ZodIssueCode.invalid_return_type,returnTypeError:c}})}let a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof oe){let o=this;return (0, u.OK)(async function(...c){let l=new f.ZodError([]),p=await o._def.args.parseAsync(c,a).catch(q=>{throw l.addIssue(s(c,q)),l}),O=await Reflect.apply(i,this,p);return await o._def.returns._def.type.parseAsync(O,a).catch(q=>{throw l.addIssue(n(O,q)),l})})}else {let o=this;return (0, u.OK)(function(...c){let l=o._def.args.safeParse(c,a);if(!l.success)throw new f.ZodError([s(c,l.error)]);let p=Reflect.apply(i,this,l.data),O=o._def.returns.safeParse(p,a);if(!O.success)throw new f.ZodError([n(p,O.error)]);return O.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:Y.create(e).rest(H.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new r({args:e||Y.create([]).rest(H.create()),returns:t||H.create(),typeName:y.ZodFunction,...g(s)})}};d.ZodFunction=kt;var Te=class extends v{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};d.ZodLazy=Te;Te.create=(r,e)=>new Te({getter:r,typeName:y.ZodLazy,...g(e)});var Oe=class extends v{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(t,{received:t.data,code:f.ZodIssueCode.invalid_literal,expected:this._def.value}),u.INVALID}return {status:"valid",value:e.data}}get value(){return this._def.value}};d.ZodLiteral=Oe;Oe.create=(r,e)=>new Oe({value:r,typeName:y.ZodLiteral,...g(e)});function Rs(r,e){return new Ie({values:r,typeName:y.ZodEnum,...g(e)})}var Ie=class r extends v{constructor(){super(...arguments),Ge.set(this,void 0);}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),s=this._def.values;return (0, u.addIssueToContext)(t,{expected:h.util.joinValues(s),received:t.parsedType,code:f.ZodIssueCode.invalid_type}),u.INVALID}if(At(this,Ge,"f")||Ts(this,Ge,new Set(this._def.values),"f"),!At(this,Ge,"f").has(e.data)){let t=this._getOrReturnCtx(e),s=this._def.values;return (0, u.addIssueToContext)(t,{received:t.data,code:f.ZodIssueCode.invalid_enum_value,options:s}),u.INVALID}return (0, u.OK)(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}};d.ZodEnum=Ie;Ge=new WeakMap;Ie.create=Rs;var xe=class extends v{constructor(){super(...arguments),Ye.set(this,void 0);}_parse(e){let t=h.util.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==h.ZodParsedType.string&&s.parsedType!==h.ZodParsedType.number){let n=h.util.objectValues(t);return (0, u.addIssueToContext)(s,{expected:h.util.joinValues(n),received:s.parsedType,code:f.ZodIssueCode.invalid_type}),u.INVALID}if(At(this,Ye,"f")||Ts(this,Ye,new Set(h.util.getValidEnumValues(this._def.values)),"f"),!At(this,Ye,"f").has(e.data)){let n=h.util.objectValues(t);return (0, u.addIssueToContext)(s,{received:s.data,code:f.ZodIssueCode.invalid_enum_value,options:n}),u.INVALID}return (0, u.OK)(e.data)}get enum(){return this._def.values}};d.ZodNativeEnum=xe;Ye=new WeakMap;xe.create=(r,e)=>new xe({values:r,typeName:y.ZodNativeEnum,...g(e)});var oe=class extends v{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.ZodParsedType.promise&&t.common.async===!1)return (0, u.addIssueToContext)(t,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.promise,received:t.parsedType}),u.INVALID;let s=t.parsedType===h.ZodParsedType.promise?t.data:Promise.resolve(t.data);return (0, u.OK)(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};d.ZodPromise=oe;oe.create=(r,e)=>new oe({type:r,typeName:y.ZodPromise,...g(e)});var j=class extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{(0, u.addIssueToContext)(s,i),i.fatal?t.abort():t.dirty();},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){let i=n.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return u.INVALID;let c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?u.INVALID:c.status==="dirty"||t.value==="dirty"?(0, u.DIRTY)(c.value):c});{if(t.value==="aborted")return u.INVALID;let o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?u.INVALID:o.status==="dirty"||t.value==="dirty"?(0, u.DIRTY)(o.value):o}}if(n.type==="refinement"){let i=o=>{let c=n.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){let o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?u.INVALID:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?u.INVALID:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){let i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!(0, u.isValid)(i))return i;let o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return {status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>(0, u.isValid)(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);h.util.assertNever(n);}};d.ZodEffects=j;d.ZodTransformer=j;j.create=(r,e,t)=>new j({schema:r,typeName:y.ZodEffects,effect:e,...g(t)});j.createWithPreprocess=(r,e,t)=>new j({schema:e,effect:{type:"preprocess",transform:r},typeName:y.ZodEffects,...g(t)});var V=class extends v{_parse(e){return this._getType(e)===h.ZodParsedType.undefined?(0, u.OK)(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};d.ZodOptional=V;V.create=(r,e)=>new V({innerType:r,typeName:y.ZodOptional,...g(e)});var J=class extends v{_parse(e){return this._getType(e)===h.ZodParsedType.null?(0, u.OK)(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};d.ZodNullable=J;J.create=(r,e)=>new J({innerType:r,typeName:y.ZodNullable,...g(e)});var Re=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return t.parsedType===h.ZodParsedType.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};d.ZodDefault=Re;Re.create=(r,e)=>new Re({innerType:r,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...g(e)});var Ee=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return (0, u.isAsync)(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new f.ZodError(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new f.ZodError(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};d.ZodCatch=Ee;Ee.create=(r,e)=>new Ee({innerType:r,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...g(e)});var Me=class extends v{_parse(e){if(this._getType(e)!==h.ZodParsedType.nan){let s=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(s,{code:f.ZodIssueCode.invalid_type,expected:h.ZodParsedType.nan,received:s.parsedType}),u.INVALID}return {status:"valid",value:e.data}}};d.ZodNaN=Me;Me.create=r=>new Me({typeName:y.ZodNaN,...g(r)});d.BRAND=Symbol("zod_brand");var Je=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}};d.ZodBranded=Je;var Xe=class r extends v{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return (async()=>{let a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?u.INVALID:a.status==="dirty"?(t.dirty(),(0, u.DIRTY)(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{let n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?u.INVALID:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new r({in:e,out:t,typeName:y.ZodPipeline})}};d.ZodPipeline=Xe;var we=class extends v{_parse(e){let t=this._def.innerType._parse(e),s=n=>((0, u.isValid)(n)&&(n.value=Object.freeze(n.value)),n);return (0, u.isAsync)(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}};d.ZodReadonly=we;we.create=(r,e)=>new we({innerType:r,typeName:y.ZodReadonly,...g(e)});function Es(r,e={},t){return r?ie.create().superRefine((s,n)=>{var a,i;if(!r(s)){let o=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;n.addIssue({code:"custom",...l,fatal:c});}}):ie.create()}d.custom=Es;d.late={object:D.lazycreate};var y;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly";})(y=d.ZodFirstPartyTypeKind||(d.ZodFirstPartyTypeKind={}));var Fn=(r,e={message:`Input not instance of ${r.name}`})=>Es(t=>t instanceof r,e);d.instanceof=Fn;var ws=ae.create;d.string=ws;var bs=pe.create;d.number=bs;var Wn=Me.create;d.nan=Wn;var Kn=fe.create;d.bigint=Kn;var Ps=he.create;d.boolean=Ps;var zn=me.create;d.date=zn;var Bn=Se.create;d.symbol=Bn;var Gn=ye.create;d.undefined=Gn;var Yn=_e.create;d.null=Yn;var Jn=ie.create;d.any=Jn;var Xn=H.create;d.unknown=Xn;var Qn=W.create;d.never=Qn;var Hn=Ze.create;d.void=Hn;var ea=ee.create;d.array=ea;var ta=D.create;d.object=ta;var ra=D.strictCreate;d.strictObject=ra;var sa=ge.create;d.union=sa;var na=Nt.create;d.discriminatedUnion=na;var aa=ve.create;d.intersection=aa;var ia=Y.create;d.tuple=ia;var oa=Ct.create;d.record=oa;var da=je.create;d.map=da;var ua=Ue.create;d.set=ua;var ca=kt.create;d.function=ca;var la=Te.create;d.lazy=la;var pa=Oe.create;d.literal=pa;var fa=Ie.create;d.enum=fa;var ha=xe.create;d.nativeEnum=ha;var ma=oe.create;d.promise=ma;var As=j.create;d.effect=As;d.transformer=As;var ya=V.create;d.optional=ya;var _a=J.create;d.nullable=_a;var ga=j.createWithPreprocess;d.preprocess=ga;var va=Xe.create;d.pipeline=va;var Ta=()=>ws().optional();d.ostring=Ta;var Oa=()=>bs().optional();d.onumber=Oa;var Ia=()=>Ps().optional();d.oboolean=Ia;d.coerce={string:r=>ae.create({...r,coerce:!0}),number:r=>pe.create({...r,coerce:!0}),boolean:r=>he.create({...r,coerce:!0}),bigint:r=>fe.create({...r,coerce:!0}),date:r=>me.create({...r,coerce:!0})};d.NEVER=u.INVALID;});var br=_($=>{var xa=$&&$.__createBinding||(Object.create?function(r,e,t,s){s===void 0&&(s=t),Object.defineProperty(r,s,{enumerable:!0,get:function(){return e[t]}});}:function(r,e,t,s){s===void 0&&(s=t),r[s]=e[t];}),Ve=$&&$.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&xa(e,r,t);};Object.defineProperty($,"__esModule",{value:!0});Ve(bt(),$);Ve(Rr(),$);Ve(_s(),$);Ve(Ke(),$);Ve(Ns(),$);Ve(wt(),$);});var Dt=_(S=>{var Cs=S&&S.__createBinding||(Object.create?function(r,e,t,s){s===void 0&&(s=t),Object.defineProperty(r,s,{enumerable:!0,get:function(){return e[t]}});}:function(r,e,t,s){s===void 0&&(s=t),r[s]=e[t];}),Ra=S&&S.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e});}:function(r,e){r.default=e;}),Ea=S&&S.__importStar||function(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)t!=="default"&&Object.prototype.hasOwnProperty.call(r,t)&&Cs(e,r,t);return Ra(e,r),e},wa=S&&S.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Cs(e,r,t);};Object.defineProperty(S,"__esModule",{value:!0});S.z=void 0;var ks=Ea(br());S.z=ks;wa(br(),S);S.default=ks;});var Pr=_(St=>{Object.defineProperty(St,"__esModule",{value:!0});St.parseAnyDef=void 0;function ba(){return {}}St.parseAnyDef=ba;});var Ar=_(jt=>{Object.defineProperty(jt,"__esModule",{value:!0});jt.parseArrayDef=void 0;var Pa=Dt(),Zt=se(),Aa=P();function Na(r,e){let t={type:"array"};return r.type?._def?.typeName!==Pa.ZodFirstPartyTypeKind.ZodAny&&(t.items=(0, Aa.parseDef)(r.type._def,{...e,currentPath:[...e.currentPath,"items"]})),r.minLength&&(0, Zt.setResponseValueAndErrors)(t,"minItems",r.minLength.value,r.minLength.message,e),r.maxLength&&(0, Zt.setResponseValueAndErrors)(t,"maxItems",r.maxLength.value,r.maxLength.message,e),r.exactLength&&((0, Zt.setResponseValueAndErrors)(t,"minItems",r.exactLength.value,r.exactLength.message,e),(0, Zt.setResponseValueAndErrors)(t,"maxItems",r.exactLength.value,r.exactLength.message,e)),t}jt.parseArrayDef=Na;});var Nr=_(Ut=>{Object.defineProperty(Ut,"__esModule",{value:!0});Ut.parseBigintDef=void 0;var be=se();function Ca(r,e){let t={type:"integer",format:"int64"};if(!r.checks)return t;for(let s of r.checks)switch(s.kind){case"min":e.target==="jsonSchema7"?s.inclusive?(0, be.setResponseValueAndErrors)(t,"minimum",s.value,s.message,e):(0, be.setResponseValueAndErrors)(t,"exclusiveMinimum",s.value,s.message,e):(s.inclusive||(t.exclusiveMinimum=!0),(0, be.setResponseValueAndErrors)(t,"minimum",s.value,s.message,e));break;case"max":e.target==="jsonSchema7"?s.inclusive?(0, be.setResponseValueAndErrors)(t,"maximum",s.value,s.message,e):(0, be.setResponseValueAndErrors)(t,"exclusiveMaximum",s.value,s.message,e):(s.inclusive||(t.exclusiveMaximum=!0),(0, be.setResponseValueAndErrors)(t,"maximum",s.value,s.message,e));break;case"multipleOf":(0, be.setResponseValueAndErrors)(t,"multipleOf",s.value,s.message,e);break}return t}Ut.parseBigintDef=Ca;});var Cr=_(Mt=>{Object.defineProperty(Mt,"__esModule",{value:!0});Mt.parseBooleanDef=void 0;function ka(){return {type:"boolean"}}Mt.parseBooleanDef=ka;});var kr=_(Vt=>{Object.defineProperty(Vt,"__esModule",{value:!0});Vt.parseBrandedDef=void 0;var Da=P();function Sa(r,e){return (0, Da.parseDef)(r.type._def,e)}Vt.parseBrandedDef=Sa;});var Dr=_(Lt=>{Object.defineProperty(Lt,"__esModule",{value:!0});Lt.parseCatchDef=void 0;var Za=P(),ja=(r,e)=>(0, Za.parseDef)(r.innerType._def,e);Lt.parseCatchDef=ja;});var Sr=_($t=>{Object.defineProperty($t,"__esModule",{value:!0});$t.parseDateDef=void 0;var Ds=se();function Ss(r,e,t){let s=t??e.dateStrategy;if(Array.isArray(s))return {anyOf:s.map((n,a)=>Ss(r,e,n))};switch(s){case"string":case"format:date-time":return {type:"string",format:"date-time"};case"format:date":return {type:"string",format:"date"};case"integer":return Ua(r,e)}}$t.parseDateDef=Ss;var Ua=(r,e)=>{let t={type:"integer",format:"unix-time"};if(e.target==="openApi3")return t;for(let s of r.checks)switch(s.kind){case"min":(0, Ds.setResponseValueAndErrors)(t,"minimum",s.value,s.message,e);break;case"max":(0, Ds.setResponseValueAndErrors)(t,"maximum",s.value,s.message,e);break}return t};});var Zr=_(qt=>{Object.defineProperty(qt,"__esModule",{value:!0});qt.parseDefaultDef=void 0;var Ma=P();function Va(r,e){return {...(0, Ma.parseDef)(r.innerType._def,e),default:r.defaultValue()}}qt.parseDefaultDef=Va;});var jr=_(Ft=>{Object.defineProperty(Ft,"__esModule",{value:!0});Ft.parseEffectsDef=void 0;var La=P();function $a(r,e){return e.effectStrategy==="input"?(0, La.parseDef)(r.schema._def,e):{}}Ft.parseEffectsDef=$a;});var Ur=_(Wt=>{Object.defineProperty(Wt,"__esModule",{value:!0});Wt.parseEnumDef=void 0;function qa(r){return {type:"string",enum:r.values}}Wt.parseEnumDef=qa;});var Mr=_(Kt=>{Object.defineProperty(Kt,"__esModule",{value:!0});Kt.parseIntersectionDef=void 0;var Zs=P(),Fa=r=>"type"in r&&r.type==="string"?!1:"allOf"in r;function Wa(r,e){let t=[(0, Zs.parseDef)(r.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),(0, Zs.parseDef)(r.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(a=>!!a),s=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,n=[];return t.forEach(a=>{if(Fa(a))n.push(...a.allOf),a.unevaluatedProperties===void 0&&(s=void 0);else {let i=a;if("additionalProperties"in a&&a.additionalProperties===!1){let{additionalProperties:o,...c}=a;i=c;}else s=void 0;n.push(i);}}),n.length?{allOf:n,...s}:void 0}Kt.parseIntersectionDef=Wa;});var Vr=_(zt=>{Object.defineProperty(zt,"__esModule",{value:!0});zt.parseLiteralDef=void 0;function Ka(r,e){let t=typeof r.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(r.value)?"array":"object"}:e.target==="openApi3"?{type:t==="bigint"?"integer":t,enum:[r.value]}:{type:t==="bigint"?"integer":t,const:r.value}}zt.parseLiteralDef=Ka;});var Bt=_(U=>{Object.defineProperty(U,"__esModule",{value:!0});U.parseStringDef=U.zodPatterns=void 0;var Pe=se();U.zodPatterns={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,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:RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u"),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][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,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})))$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/};function za(r,e){let t={type:"string"};function s(n){return e.patternStrategy==="escape"?Ba(n):n}if(r.checks)for(let n of r.checks)switch(n.kind){case"min":(0, Pe.setResponseValueAndErrors)(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,n.value):n.value,n.message,e);break;case"max":(0, Pe.setResponseValueAndErrors)(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,n.value):n.value,n.message,e);break;case"email":switch(e.emailStrategy){case"format:email":K(t,"email",n.message,e);break;case"format:idn-email":K(t,"idn-email",n.message,e);break;case"pattern:zod":z(t,U.zodPatterns.email,n.message,e);break}break;case"url":K(t,"uri",n.message,e);break;case"uuid":K(t,"uuid",n.message,e);break;case"regex":z(t,n.regex,n.message,e);break;case"cuid":z(t,U.zodPatterns.cuid,n.message,e);break;case"cuid2":z(t,U.zodPatterns.cuid2,n.message,e);break;case"startsWith":z(t,RegExp(`^${s(n.value)}`),n.message,e);break;case"endsWith":z(t,RegExp(`${s(n.value)}$`),n.message,e);break;case"datetime":K(t,"date-time",n.message,e);break;case"date":K(t,"date",n.message,e);break;case"time":K(t,"time",n.message,e);break;case"duration":K(t,"duration",n.message,e);break;case"length":(0, Pe.setResponseValueAndErrors)(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,n.value):n.value,n.message,e),(0, Pe.setResponseValueAndErrors)(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,n.value):n.value,n.message,e);break;case"includes":{z(t,RegExp(s(n.value)),n.message,e);break}case"ip":{n.version!=="v6"&&K(t,"ipv4",n.message,e),n.version!=="v4"&&K(t,"ipv6",n.message,e);break}case"emoji":z(t,U.zodPatterns.emoji,n.message,e);break;case"ulid":{z(t,U.zodPatterns.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{K(t,"binary",n.message,e);break}case"contentEncoding:base64":{(0, Pe.setResponseValueAndErrors)(t,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{z(t,U.zodPatterns.base64,n.message,e);break}}break}case"nanoid":z(t,U.zodPatterns.nanoid,n.message,e);}return t}U.parseStringDef=za;var Ba=r=>Array.from(r).map(e=>/[a-zA-Z0-9]/.test(e)?e:`\\${e}`).join(""),K=(r,e,t,s)=>{r.format||r.anyOf?.some(n=>n.format)?(r.anyOf||(r.anyOf=[]),r.format&&(r.anyOf.push({format:r.format,...r.errorMessage&&s.errorMessages&&{errorMessage:{format:r.errorMessage.format}}}),delete r.format,r.errorMessage&&(delete r.errorMessage.format,Object.keys(r.errorMessage).length===0&&delete r.errorMessage)),r.anyOf.push({format:e,...t&&s.errorMessages&&{errorMessage:{format:t}}})):(0, Pe.setResponseValueAndErrors)(r,"format",e,t,s);},z=(r,e,t,s)=>{r.pattern||r.allOf?.some(n=>n.pattern)?(r.allOf||(r.allOf=[]),r.pattern&&(r.allOf.push({pattern:r.pattern,...r.errorMessage&&s.errorMessages&&{errorMessage:{pattern:r.errorMessage.pattern}}}),delete r.pattern,r.errorMessage&&(delete r.errorMessage.pattern,Object.keys(r.errorMessage).length===0&&delete r.errorMessage)),r.allOf.push({pattern:js(e,s),...t&&s.errorMessages&&{errorMessage:{pattern:t}}})):(0, Pe.setResponseValueAndErrors)(r,"pattern",js(e,s),t,s);},js=(r,e)=>{if(!e.applyRegexFlags||!r.flags)return r.source;let t={i:r.flags.includes("i"),m:r.flags.includes("m"),s:r.flags.includes("s")},s=t.i?r.source.toLowerCase():r.source,n="",a=!1,i=!1,o=!1;for(let c=0;c<s.length;c++){if(a){n+=s[c],a=!1;continue}if(t.i){if(i){if(s[c].match(/[a-z]/)){o?(n+=s[c],n+=`${s[c-2]}-${s[c]}`.toUpperCase(),o=!1):s[c+1]==="-"&&s[c+2]?.match(/[a-z]/)?(n+=s[c],o=!0):n+=`${s[c]}${s[c].toUpperCase()}`;continue}}else if(s[c].match(/[a-z]/)){n+=`[${s[c]}${s[c].toUpperCase()}]`;continue}}if(t.m){if(s[c]==="^"){n+=`(^|(?<=[\r
19
19
  ]))`;continue}else if(s[c]==="$"){n+=`($|(?=[\r
20
20
  ]))`;continue}}if(t.s&&s[c]==="."){n+=i?`${s[c]}\r
21
21
  `:`[${s[c]}\r
22
- ]`;continue}n+=s[c],s[c]==="\\"?a=!0:i&&s[c]==="]"?i=!1:!i&&s[c]==="["&&(i=!0);}try{let c=new RegExp(n);}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),r.source}return n};});var Yt=_(Gt=>{Object.defineProperty(Gt,"__esModule",{value:!0});Gt.parseRecordDef=void 0;var Lr=Dt(),Us=P(),Ga=Bt();function Ya(r,e){if(e.target==="openApi3"&&r.keyType?._def.typeName===Lr.ZodFirstPartyTypeKind.ZodEnum)return {type:"object",required:r.keyType._def.values,properties:r.keyType._def.values.reduce((s,n)=>({...s,[n]:(0, Us.parseDef)(r.valueType._def,{...e,currentPath:[...e.currentPath,"properties",n]})??{}}),{}),additionalProperties:!1};let t={type:"object",additionalProperties:(0, Us.parseDef)(r.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??{}};if(e.target==="openApi3")return t;if(r.keyType?._def.typeName===Lr.ZodFirstPartyTypeKind.ZodString&&r.keyType._def.checks?.length){let s=Object.entries((0, Ga.parseStringDef)(r.keyType._def,e)).reduce((n,[a,i])=>a==="type"?n:{...n,[a]:i},{});return {...t,propertyNames:s}}else if(r.keyType?._def.typeName===Lr.ZodFirstPartyTypeKind.ZodEnum)return {...t,propertyNames:{enum:r.keyType._def.values}};return t}Gt.parseRecordDef=Ya;});var $r=_(Jt=>{Object.defineProperty(Jt,"__esModule",{value:!0});Jt.parseMapDef=void 0;var Ms=P(),Ja=Yt();function Xa(r,e){if(e.mapStrategy==="record")return (0, Ja.parseRecordDef)(r,e);let t=(0, Ms.parseDef)(r.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||{},s=(0, Ms.parseDef)(r.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||{};return {type:"array",maxItems:125,items:{type:"array",items:[t,s],minItems:2,maxItems:2}}}Jt.parseMapDef=Xa;});var qr=_(Xt=>{Object.defineProperty(Xt,"__esModule",{value:!0});Xt.parseNativeEnumDef=void 0;function Qa(r){let e=r.values,s=Object.keys(r.values).filter(a=>typeof e[e[a]]!="number").map(a=>e[a]),n=Array.from(new Set(s.map(a=>typeof a)));return {type:n.length===1?n[0]==="string"?"string":"number":["string","number"],enum:s}}Xt.parseNativeEnumDef=Qa;});var Fr=_(Qt=>{Object.defineProperty(Qt,"__esModule",{value:!0});Qt.parseNeverDef=void 0;function Ha(){return {not:{}}}Qt.parseNeverDef=Ha;});var Wr=_(Ht=>{Object.defineProperty(Ht,"__esModule",{value:!0});Ht.parseNullDef=void 0;function ei(r){return r.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}Ht.parseNullDef=ei;});var er=_(de=>{Object.defineProperty(de,"__esModule",{value:!0});de.parseUnionDef=de.primitiveMappings=void 0;var ti=P();de.primitiveMappings={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function ri(r,e){if(e.target==="openApi3")return Vs(r,e);let t=r.options instanceof Map?Array.from(r.options.values()):r.options;if(t.every(s=>s._def.typeName in de.primitiveMappings&&(!s._def.checks||!s._def.checks.length))){let s=t.reduce((n,a)=>{let i=de.primitiveMappings[a._def.typeName];return i&&!n.includes(i)?[...n,i]:n},[]);return {type:s.length>1?s:s[0]}}else if(t.every(s=>s._def.typeName==="ZodLiteral"&&!s.description)){let s=t.reduce((n,a)=>{let i=typeof a._def.value;switch(i){case"string":case"number":case"boolean":return [...n,i];case"bigint":return [...n,"integer"];case"object":if(a._def.value===null)return [...n,"null"];case"symbol":case"undefined":case"function":default:return n}},[]);if(s.length===t.length){let n=s.filter((a,i,o)=>o.indexOf(a)===i);return {type:n.length>1?n:n[0],enum:t.reduce((a,i)=>a.includes(i._def.value)?a:[...a,i._def.value],[])}}}else if(t.every(s=>s._def.typeName==="ZodEnum"))return {type:"string",enum:t.reduce((s,n)=>[...s,...n._def.values.filter(a=>!s.includes(a))],[])};return Vs(r,e)}de.parseUnionDef=ri;var Vs=(r,e)=>{let t=(r.options instanceof Map?Array.from(r.options.values()):r.options).map((s,n)=>(0, ti.parseDef)(s._def,{...e,currentPath:[...e.currentPath,"anyOf",`${n}`]})).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0));return t.length?{anyOf:t}:void 0};});var Kr=_(tr=>{Object.defineProperty(tr,"__esModule",{value:!0});tr.parseNullableDef=void 0;var Ls=P(),$s=er();function si(r,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(r.innerType._def.typeName)&&(!r.innerType._def.checks||!r.innerType._def.checks.length))return e.target==="openApi3"?{type:$s.primitiveMappings[r.innerType._def.typeName],nullable:!0}:{type:[$s.primitiveMappings[r.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let s=(0, Ls.parseDef)(r.innerType._def,{...e,currentPath:[...e.currentPath]});return s&&"$ref"in s?{allOf:[s],nullable:!0}:s&&{...s,nullable:!0}}let t=(0, Ls.parseDef)(r.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return t&&{anyOf:[t,{type:"null"}]}}tr.parseNullableDef=si;});var zr=_(rr=>{Object.defineProperty(rr,"__esModule",{value:!0});rr.parseNumberDef=void 0;var ue=se();function ni(r,e){let t={type:"number"};if(!r.checks)return t;for(let s of r.checks)switch(s.kind){case"int":t.type="integer",(0, ue.addErrorMessage)(t,"type",s.message,e);break;case"min":e.target==="jsonSchema7"?s.inclusive?(0, ue.setResponseValueAndErrors)(t,"minimum",s.value,s.message,e):(0, ue.setResponseValueAndErrors)(t,"exclusiveMinimum",s.value,s.message,e):(s.inclusive||(t.exclusiveMinimum=!0),(0, ue.setResponseValueAndErrors)(t,"minimum",s.value,s.message,e));break;case"max":e.target==="jsonSchema7"?s.inclusive?(0, ue.setResponseValueAndErrors)(t,"maximum",s.value,s.message,e):(0, ue.setResponseValueAndErrors)(t,"exclusiveMaximum",s.value,s.message,e):(s.inclusive||(t.exclusiveMaximum=!0),(0, ue.setResponseValueAndErrors)(t,"maximum",s.value,s.message,e));break;case"multipleOf":(0, ue.setResponseValueAndErrors)(t,"multipleOf",s.value,s.message,e);break}return t}rr.parseNumberDef=ni;});var Gr=_(Le=>{Object.defineProperty(Le,"__esModule",{value:!0});Le.parseObjectDef=Le.parseObjectDefX=void 0;var Qe=P();function Br(r,e){return e.removeAdditionalStrategy==="strict"?r.catchall._def.typeName==="ZodNever"?r.unknownKeys!=="strict":(0, Qe.parseDef)(r.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??!0:r.catchall._def.typeName==="ZodNever"?r.unknownKeys==="passthrough":(0, Qe.parseDef)(r.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??!0}function ai(r,e){Object.keys(r.shape()).reduce((s,n)=>{let a=r.shape()[n],i=a.isOptional();i||(a={...a._def.innerSchema});let o=(0, Qe.parseDef)(a._def,{...e,currentPath:[...e.currentPath,"properties",n],propertyPath:[...e.currentPath,"properties",n]});return o!==void 0&&(s.properties[n]=o,i||(s.required||(s.required=[]),s.required.push(n))),s},{type:"object",properties:{},additionalProperties:Br(r,e)});let t={type:"object",...Object.entries(r.shape()).reduce((s,[n,a])=>{if(a===void 0||a._def===void 0)return s;let i=(0, Qe.parseDef)(a._def,{...e,currentPath:[...e.currentPath,"properties",n],propertyPath:[...e.currentPath,"properties",n]});return i===void 0?s:{properties:{...s.properties,[n]:i},required:a.isOptional()?s.required:[...s.required,n]}},{properties:{},required:[]}),additionalProperties:Br(r,e)};return t.required.length||delete t.required,t}Le.parseObjectDefX=ai;function ii(r,e){let t={type:"object",...Object.entries(r.shape()).reduce((s,[n,a])=>{if(a===void 0||a._def===void 0)return s;let i=(0, Qe.parseDef)(a._def,{...e,currentPath:[...e.currentPath,"properties",n],propertyPath:[...e.currentPath,"properties",n]});return i===void 0?s:{properties:{...s.properties,[n]:i},required:a.isOptional()?s.required:[...s.required,n]}},{properties:{},required:[]}),additionalProperties:Br(r,e)};return t.required.length||delete t.required,t}Le.parseObjectDef=ii;});var Yr=_(sr=>{Object.defineProperty(sr,"__esModule",{value:!0});sr.parseOptionalDef=void 0;var qs=P(),oi=(r,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return (0, qs.parseDef)(r.innerType._def,e);let t=(0, qs.parseDef)(r.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return t?{anyOf:[{not:{}},t]}:{}};sr.parseOptionalDef=oi;});var Jr=_(ar=>{Object.defineProperty(ar,"__esModule",{value:!0});ar.parsePipelineDef=void 0;var nr=P(),di=(r,e)=>{if(e.pipeStrategy==="input")return (0, nr.parseDef)(r.in._def,e);if(e.pipeStrategy==="output")return (0, nr.parseDef)(r.out._def,e);let t=(0, nr.parseDef)(r.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),s=(0, nr.parseDef)(r.out._def,{...e,currentPath:[...e.currentPath,"allOf",t?"1":"0"]});return {allOf:[t,s].filter(n=>n!==void 0)}};ar.parsePipelineDef=di;});var Xr=_(ir=>{Object.defineProperty(ir,"__esModule",{value:!0});ir.parsePromiseDef=void 0;var ui=P();function ci(r,e){return (0, ui.parseDef)(r.type._def,e)}ir.parsePromiseDef=ci;});var Qr=_(or=>{Object.defineProperty(or,"__esModule",{value:!0});or.parseSetDef=void 0;var Fs=se(),li=P();function pi(r,e){let s={type:"array",uniqueItems:!0,items:(0, li.parseDef)(r.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return r.minSize&&(0, Fs.setResponseValueAndErrors)(s,"minItems",r.minSize.value,r.minSize.message,e),r.maxSize&&(0, Fs.setResponseValueAndErrors)(s,"maxItems",r.maxSize.value,r.maxSize.message,e),s}or.parseSetDef=pi;});var es=_(dr=>{Object.defineProperty(dr,"__esModule",{value:!0});dr.parseTupleDef=void 0;var Hr=P();function fi(r,e){return r.rest?{type:"array",minItems:r.items.length,items:r.items.map((t,s)=>(0, Hr.parseDef)(t._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((t,s)=>s===void 0?t:[...t,s],[]),additionalItems:(0, Hr.parseDef)(r.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:r.items.length,maxItems:r.items.length,items:r.items.map((t,s)=>(0, Hr.parseDef)(t._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((t,s)=>s===void 0?t:[...t,s],[])}}dr.parseTupleDef=fi;});var ts=_(ur=>{Object.defineProperty(ur,"__esModule",{value:!0});ur.parseUndefinedDef=void 0;function hi(){return {not:{}}}ur.parseUndefinedDef=hi;});var rs=_(cr=>{Object.defineProperty(cr,"__esModule",{value:!0});cr.parseUnknownDef=void 0;function mi(){return {}}cr.parseUnknownDef=mi;});var ss=_(lr=>{Object.defineProperty(lr,"__esModule",{value:!0});lr.parseReadonlyDef=void 0;var yi=P(),_i=(r,e)=>(0, yi.parseDef)(r.innerType._def,e);lr.parseReadonlyDef=_i;});var P=_(pr=>{Object.defineProperty(pr,"__esModule",{value:!0});pr.parseDef=void 0;var I=Dt(),gi=Pr(),vi=Ar(),Ti=Nr(),Oi=kr(),Ii=Cr(),xi=Dr(),Ri=Sr(),Ei=Zr(),wi=jr(),bi=Ur(),Pi=Mr(),Ai=Vr(),Ni=$r(),ki=qr(),Ci=Fr(),Di=Wr(),Si=Kr(),Zi=zr(),ji=Gr(),Ui=Yr(),Mi=Jr(),Vi=Xr(),Li=Yt(),$i=Qr(),qi=Bt(),Fi=es(),Wi=ts(),Ki=er(),zi=rs(),Bi=ss(),Gi=Rt();function Ws(r,e,t=!1){let s=e.seen.get(r);if(e.override){let i=e.override?.(r,e,s,t);if(i!==Gi.ignoreOverride)return i}if(s&&!t){let i=Yi(s,e);if(i!==void 0)return i}let n={def:r,path:e.currentPath,jsonSchema:void 0};e.seen.set(r,n);let a=Xi(r,r.typeName,e);return a&&Qi(r,e,a),n.jsonSchema=a,a}pr.parseDef=Ws;var Yi=(r,e)=>{switch(e.$refStrategy){case"root":return {$ref:r.path.join("/")};case"relative":return {$ref:Ji(e.currentPath,r.path)};case"none":case"seen":return r.path.length<e.currentPath.length&&r.path.every((t,s)=>e.currentPath[s]===t)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},Ji=(r,e)=>{let t=0;for(;t<r.length&&t<e.length&&r[t]===e[t];t++);return [(r.length-t).toString(),...e.slice(t)].join("/")},Xi=(r,e,t)=>{switch(e){case I.ZodFirstPartyTypeKind.ZodString:return (0, qi.parseStringDef)(r,t);case I.ZodFirstPartyTypeKind.ZodNumber:return (0, Zi.parseNumberDef)(r,t);case I.ZodFirstPartyTypeKind.ZodObject:return (0, ji.parseObjectDef)(r,t);case I.ZodFirstPartyTypeKind.ZodBigInt:return (0, Ti.parseBigintDef)(r,t);case I.ZodFirstPartyTypeKind.ZodBoolean:return (0, Oi.parseBooleanDef)();case I.ZodFirstPartyTypeKind.ZodDate:return (0, Ri.parseDateDef)(r,t);case I.ZodFirstPartyTypeKind.ZodUndefined:return (0, Wi.parseUndefinedDef)();case I.ZodFirstPartyTypeKind.ZodNull:return (0, Di.parseNullDef)(t);case I.ZodFirstPartyTypeKind.ZodArray:return (0, vi.parseArrayDef)(r,t);case I.ZodFirstPartyTypeKind.ZodUnion:case I.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return (0, Ki.parseUnionDef)(r,t);case I.ZodFirstPartyTypeKind.ZodIntersection:return (0, Pi.parseIntersectionDef)(r,t);case I.ZodFirstPartyTypeKind.ZodTuple:return (0, Fi.parseTupleDef)(r,t);case I.ZodFirstPartyTypeKind.ZodRecord:return (0, Li.parseRecordDef)(r,t);case I.ZodFirstPartyTypeKind.ZodLiteral:return (0, Ai.parseLiteralDef)(r,t);case I.ZodFirstPartyTypeKind.ZodEnum:return (0, bi.parseEnumDef)(r);case I.ZodFirstPartyTypeKind.ZodNativeEnum:return (0, ki.parseNativeEnumDef)(r);case I.ZodFirstPartyTypeKind.ZodNullable:return (0, Si.parseNullableDef)(r,t);case I.ZodFirstPartyTypeKind.ZodOptional:return (0, Ui.parseOptionalDef)(r,t);case I.ZodFirstPartyTypeKind.ZodMap:return (0, Ni.parseMapDef)(r,t);case I.ZodFirstPartyTypeKind.ZodSet:return (0, $i.parseSetDef)(r,t);case I.ZodFirstPartyTypeKind.ZodLazy:return Ws(r.getter()._def,t);case I.ZodFirstPartyTypeKind.ZodPromise:return (0, Vi.parsePromiseDef)(r,t);case I.ZodFirstPartyTypeKind.ZodNaN:case I.ZodFirstPartyTypeKind.ZodNever:return (0, Ci.parseNeverDef)();case I.ZodFirstPartyTypeKind.ZodEffects:return (0, wi.parseEffectsDef)(r,t);case I.ZodFirstPartyTypeKind.ZodAny:return (0, gi.parseAnyDef)();case I.ZodFirstPartyTypeKind.ZodUnknown:return (0, zi.parseUnknownDef)();case I.ZodFirstPartyTypeKind.ZodDefault:return (0, Ei.parseDefaultDef)(r,t);case I.ZodFirstPartyTypeKind.ZodBranded:return (0, Ii.parseBrandedDef)(r,t);case I.ZodFirstPartyTypeKind.ZodReadonly:return (0, Bi.parseReadonlyDef)(r,t);case I.ZodFirstPartyTypeKind.ZodCatch:return (0, xi.parseCatchDef)(r,t);case I.ZodFirstPartyTypeKind.ZodPipeline:return (0, Mi.parsePipelineDef)(r,t);case I.ZodFirstPartyTypeKind.ZodFunction:case I.ZodFirstPartyTypeKind.ZodVoid:case I.ZodFirstPartyTypeKind.ZodSymbol:return;default:return (s=>{})()}},Qi=(r,e,t)=>(r.description&&(t.description=r.description,e.markdownDescription&&(t.markdownDescription=r.description)),t);});var ns=_(fr=>{Object.defineProperty(fr,"__esModule",{value:!0});fr.zodToJsonSchema=void 0;var Ks=P(),Hi=Tr(),eo=(r,e)=>{let t=(0, Hi.getRefs)(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[l,p])=>({...c,[l]:(0, Ks.parseDef)(p._def,{...t,currentPath:[...t.basePath,t.definitionPath,l]},!0)??{}}),{}):void 0,n=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,a=(0, Ks.parseDef)(r._def,n===void 0?t:{...t,currentPath:[...t.basePath,t.definitionPath,n]},!1)??{},i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(a.title=i);let o=n===void 0?s?{...a,[t.definitionPath]:s}:a:{$ref:[...t.$refStrategy==="relative"?[]:t.basePath,t.definitionPath,n].join("/"),[t.definitionPath]:{...s,[n]:a}};return t.target==="jsonSchema7"?o.$schema="http://json-schema.org/draft-07/schema#":t.target==="jsonSchema2019-09"&&(o.$schema="https://json-schema.org/draft/2019-09/schema#"),o};fr.zodToJsonSchema=eo;});var zs=_(T=>{var to=T&&T.__createBinding||(Object.create?function(r,e,t,s){s===void 0&&(s=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,s,n);}:function(r,e,t,s){s===void 0&&(s=t),r[s]=e[t];}),x=T&&T.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&to(e,r,t);};Object.defineProperty(T,"__esModule",{value:!0});x(Rt(),T);x(Tr(),T);x(se(),T);x(P(),T);x(Pr(),T);x(Ar(),T);x(Nr(),T);x(kr(),T);x(Cr(),T);x(Dr(),T);x(Sr(),T);x(Zr(),T);x(jr(),T);x(Ur(),T);x(Mr(),T);x(Vr(),T);x($r(),T);x(qr(),T);x(Fr(),T);x(Wr(),T);x(Kr(),T);x(zr(),T);x(Gr(),T);x(Yr(),T);x(Jr(),T);x(Xr(),T);x(ss(),T);x(Yt(),T);x(Qr(),T);x(Bt(),T);x(es(),T);x(ts(),T);x(er(),T);x(rs(),T);x(ns(),T);var ro=ns();T.default=ro.zodToJsonSchema;});var et=(s=>(s.TRIGGER="trigger",s.EXECUTE="execute",s.PREVIEW="preview",s))(et||{}),tt=(s=>(s.DISCOVER="discover",s.HEALTH_CHECK="health-check",s.CODE="code",s))(tt||{});var F=(w=>(w.WORKFLOW_NOT_FOUND_ERROR="WorkflowNotFoundError",w.WORKFLOW_ALREADY_EXISTS_ERROR="WorkflowAlreadyExistsError",w.WORKFLOW_EXECUTION_FAILED_ERROR="WorkflowExecutionFailedError",w.EXECUTION_STATE_OUTPUT_INVALID_ERROR="ExecutionStateOutputInvalidError",w.EXECUTION_STATE_RESULT_INVALID_ERROR="ExecutionStateResultInvalidError",w.EXECUTION_PROVIDER_OUTPUT_INVALID_ERROR="ExecutionProviderOutputInvalidError",w.PROVIDER_NOT_FOUND_ERROR="ProviderNotFoundError",w.PROVIDER_EXECUTION_FAILED_ERROR="ProviderExecutionFailedError",w.STEP_NOT_FOUND_ERROR="StepNotFoundError",w.STEP_ALREADY_EXISTS_ERROR="StepAlreadyExistsError",w.STEP_EXECUTION_FAILED_ERROR="StepExecutionFailedError",w.EXECUTION_STATE_CORRUPT_ERROR="ExecutionStateCorruptError",w.EXECUTION_EVENT_PAYLOAD_INVALID_ERROR="ExecutionEventPayloadInvalidError",w.EXECUTION_EVENT_CONTROL_INVALID_ERROR="ExecutionEventControlInvalidError",w.EXECUTION_STATE_CONTROL_INVALID_ERROR="ExecutionStateControlInvalidError",w.METHOD_NOT_ALLOWED_ERROR="MethodNotAllowedError",w.INVALID_ACTION_ERROR="InvalidActionError",w.MISSING_SECRET_KEY_ERROR="MissingSecretKeyError",w.SIGNATURE_MISMATCH_ERROR="SignatureMismatchError",w.SIGNATURE_NOT_FOUND_ERROR="SignatureNotFoundError",w.SIGNATURE_INVALID_ERROR="SignatureInvalidError",w.SIGNATURE_EXPIRED_ERROR="SignatureExpiredError",w.SIGNING_KEY_NOT_FOUND_ERROR="SigningKeyNotFoundError",w.PLATFORM_ERROR="PlatformError",w.SIGNATURE_VERSION_INVALID_ERROR="SignatureVersionInvalidError",w))(F||{});var rt=(s=>(s.POST="POST",s.GET="GET",s.OPTIONS="OPTIONS",s))(rt||{});var X=class extends Error{data},st=class extends X{statusCode=404},M=class extends X{statusCode=400},te=class extends X{statusCode=401},Ae=class extends X{statusCode=500},nt=class extends X{statusCode=409};var at=class extends M{code="ExecutionStateCorruptError";constructor(e,t){super(`Workflow with id: \`${e}\` has a corrupt state. Step with id: \`${t}\` does not exist. Please provide the missing state.`),this.data={workflowId:e,stepId:t};}},$e=class extends M{code="ExecutionEventPayloadInvalidError";constructor(e,t){super(`Workflow with id: \`${e}\` has invalid \`payload\`. Please provide the correct event payload.`),this.data=t;}},it=class extends M{code="ExecutionEventControlInvalidError";constructor(e,t){super(`Workflow with id: \`${e}\` has invalid \`controls\`. Please provide the correct event controls.`),this.data=t;}},ot=class extends M{code="ExecutionStateControlInvalidError";constructor(e,t,s){super(`Workflow with id: \`${e}\` has an invalid state. Step with id: \`${t}\` has invalid \`controls\`. Please provide the correct step controls.`),this.data=s;}},dt=class extends M{code="ExecutionStateOutputInvalidError";constructor(e,t,s){super(`Workflow with id: \`${e}\` has an invalid state. Step with id: \`${t}\` has invalid output. Please provide the correct step output.`),this.data=s;}},ut=class extends M{code="ExecutionStateResultInvalidError";constructor(e,t,s){super(`Workflow with id: \`${e}\` has an invalid state. Step with id: \`${t}\` has invalid result. Please provide the correct step result.`),this.data=s;}},ct=class extends M{code="ExecutionProviderOutputInvalidError";constructor(e,t,s,n){super(`Workflow with id: \`${e}\` has an invalid state. Step with id: \`${t}\` and provider with id: \`${s}\` has invalid output. Please provide the correct provider output.`),this.data=n;}};var os=()=>typeof Response<"u"?Response:en("cross-fetch").Response;var b={info:r=>Ne__default.default.blue(r),warning:r=>Ne__default.default.yellow(r),error:r=>Ne__default.default.red(r),success:r=>Ne__default.default.green(r),underline:r=>Ne__default.default.underline(r),bold:r=>Ne__default.default.bold(r)},N={SUCCESS:b.success("\u2714"),ERROR:b.error("\u2717"),WARNING:b.warning("\u26A0"),INFO:b.info("\u2139"),ARROW:b.bold("\u2192"),MOCK:b.info("\u25CB"),HYDRATED:b.bold(b.info("\u2192")),STEP:b.info("\u03C3"),ACTION:b.info("\u03B1"),DURATION:b.info("\u0394"),PROVIDER:b.info("\u2699"),OUTPUT:b.info("\u21E2"),INPUT:b.info("\u21E0"),WORKFLOW:b.info("\u03C9"),STATE:b.info("\u03C3"),EXECUTE:b.info("\u03B5"),PREVIEW:b.info("\u03C1")};var vr=r=>Object.values(r).map(e=>`\`${e}\``).join(", "),lt=r=>r.replaceAll(/(\w)(\w*)/g,(e,t,s)=>t.toUpperCase()+s.toLowerCase()).replaceAll(/[\s-]+/g,"");var ds=(r,e="https://api.novu.co")=>{let t=process.env.NOVU_API_URL||e;return {post:async(s,n)=>(await fetch(t+"/v1"+s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${r}`},body:JSON.stringify(n)})).json()}};var pt=class extends X{code="MethodNotAllowedError";statusCode=405;message=`Method not allowed. Please use one of ${vr(rt)}`},qe=class extends M{code="InvalidActionError";constructor(e,t){super(`Invalid query string: \`action\`=\`${e}\`. Please use one of ${vr(t)}`);}};var ft=class extends Ae{code="PlatformError";message="Something went wrong. Please try again later."};var Fe=class extends nt{constructor(e,t){super(`${lt(e)} with id: \`${t}\` already exists. Please use a different id.`);}},re=class extends st{constructor(e,t){super(`${lt(e)} with id: \`${t}\` does not exist. Please provide a valid id.`);}},ke=class extends Ae{constructor(e,t){super(`Failed to execute ${lt(e)} with id: \`${t}\`. Please try again later.`);}};var ht=class extends re{code="ProviderNotFoundError";constructor(e){super("provider",e);}},mt=class extends ke{code="ProviderExecutionFailedError";constructor(e){super("workflow",e);}};var yt=class extends te{code="SignatureMismatchError";constructor(){super("Signature does not match the expected signature. Please ensure the signature provided in the `novu-signature` header is correct and try again.");}},_t=class extends te{code="SignatureNotFoundError";constructor(){super("Signature not found. Please provide a signature in the `novu-signature` header");}},gt=class extends te{code="SignatureInvalidError";constructor(){super("Signature is invalid. Please provide a valid signature in the `novu-signature` header");}},vt=class extends te{code="SignatureExpiredError";constructor(){super(`Signature expired. Please provide a signature with a timestamp no older than ${5} minutes in the \`novu-signature\` header`);}},Tt=class extends te{code="SigningKeyNotFoundError";constructor(){super("Signature key not found. Please provide a valid key in the Client constructor `config.secretKey`");}};var Ot=class extends re{code="StepNotFoundError";constructor(e){super("step",e);}};var We=class extends re{code="WorkflowNotFoundError";constructor(e){super("workflow",e);}},It=class extends Fe{code="WorkflowAlreadyExistsError";constructor(e){super("workflow",e);}};var xt=class{ajv;compiledSchemas;constructor(){this.ajv=new sn__default.default({useDefaults:!0,removeAdditional:"all"}),nn__default.default(this.ajv),this.compiledSchemas=new Map;}isSchema(e){return typeof e=="boolean"?!1:e.type==="object"||!!e.anyOf||!!e.oneOf}async validate(e,t){let s=this.compiledSchemas.get(t);return s||(s=this.ajv.compile(t),this.compiledSchemas.set(t,s)),s(e)?{success:!0,data:e}:{success:!1,errors:s.errors.map(a=>({path:a.instancePath,message:a.message}))}}transformToJsonSchema(e){return e}};var hr=class{isSchema(e){return e.safeParseAsync!==void 0}async validate(e,t){let s=t.safeParse(e);return s.success?{success:!0,data:s.data}:{success:!1,errors:s.error.errors.map(n=>({path:`/${n.path.join("/")}`,message:n.message}))}}transformToJsonSchema(e){try{return zs().zodToJsonSchema(e)}catch(t){throw t?.message?.includes("Cannot find module")&&console.error("Tried to use a zod schema in @novu/framework without `zod-to-json-schema` installed. Please install it by running `npm install zod-to-json-schema`."),t}}};var Bs=[new hr,new xt],Gs=async(r,e)=>{for(let t of Bs)if(t.isSchema(r))return t.validate(e,r);throw new Error("Invalid schema")},Ys=r=>{for(let e of Bs)if(e.isSchema(r))return e.transformToJsonSchema(r);throw new Error("Invalid schema")};var Js={name:"@novu/framework",version:"0.24.3-alpha.11",description:"The Code-First Notifications Workflow SDK.",main:"./dist/index.js",types:"./dist/index.d.ts",publishConfig:{registry:"https://registry.npmjs.org",access:"public"},private:!1,repository:{type:"git",url:"git+https://github.com/novuhq/novu.git"},files:["dist","README.md"],scripts:{preinstall:"npx only-allow pnpm",test:"vitest","test:watch":"vitest --watch",lint:"eslint src --ext .ts","lint:fix":"eslint src --ext .ts --fix",format:"prettier --check --ignore-path .gitignore .","format:fix":"prettier --write --ignore-path .gitignore .",build:"tsup","build:watch":"tsup --watch","$comment:bump:prerelease":"This is a workaround to support `npm version prerelease` with lerna","bump:prerelease":"npm version prerelease --preid=alpha & PID=$!; (sleep 1 && kill -9 $PID) & wait $PID","release:alpha":"pnpm bump:prerelease || pnpm build && npm publish"},keywords:["novu","code-first","workflows","durable","sdk","notifications","email","sms","push","webhooks","next","nuxt","h3","express"],author:"Novu",license:"MIT",exports:{".":{require:"./dist/index.js",import:"./dist/index.js",types:"./dist/index.d.ts"},"./express":{require:"./dist/express.js",import:"./dist/express.js",types:"./dist/express.d.ts"},"./next":{require:"./dist/next.js",import:"./dist/next.js",types:"./dist/next.d.ts"},"./nuxt":{require:"./dist/nuxt.js",import:"./dist/nuxt.js",types:"./dist/nuxt.d.ts"},"./h3":{require:"./dist/h3.js",import:"./dist/h3.js",types:"./dist/h3.d.ts"},"./sveltekit":{require:"./dist/sveltekit.js",import:"./dist/sveltekit.js",types:"./dist/sveltekit.d.ts"},"./remix":{require:"./dist/remix.js",import:"./dist/remix.js",types:"./dist/remix.d.ts"}},devDependencies:{"@sveltejs/kit":"^2.5.10","@types/express":"^4.17.13","@types/json-schema":"^7.0.15","@types/node":"^20.11.20","@vercel/node":"^2.15.9",express:"^4.18.2",h3:"^1.11.1",next:"^13.5.4",prettier:"^3.2.5","ts-node":"^10.9.2",tsup:"^8.0.2",typescript:"^5.3.3",vitest:"^1.2.1",zod:"^3.23.0","zod-to-json-schema":"^3.23.0"},dependencies:{"@novu/shared":"^0.24.2",ajv:"^8.12.0","ajv-formats":"^2.1.1","better-ajv-errors":"^1.2.0",chalk:"^4.1.2","cross-fetch":"^4.0.0","json-schema-faker":"^0.5.6","json-schema-to-ts":"^3.0.0",liquidjs:"^10.13.1",ora:"^5.4.1"}};var He=Js.version,mr="2024-06-26";jsonSchemaFaker.JSONSchemaFaker.random.shuffle=function(){return ["[placeholder]"]};jsonSchemaFaker.JSONSchemaFaker.option({useDefaultValue:!0,alwaysFakeOptionals:!0});function Xs(){return process.env.NODE_ENV==="development"}var _r=class{discoveredWorkflows=[];templateEngine=new liquidjs.Liquid;secretKey;version=He;strictAuthentication;constructor(e){let t=this.buildOptions(e);this.secretKey=t.secretKey,this.strictAuthentication=t.strictAuthentication;}buildOptions(e){let t={secretKey:void 0,strictAuthentication:!0};if(t.secretKey=e?.secretKey||process.env.NOVU_SECRET_KEY||process.env.NOVU_API_KEY,!Xs()&&!t.secretKey)throw new Error("Missing secret key. Set the NOVU_SECRET_KEY environment variable or pass secretKey to the client options.");return e?.strictAuthentication!==void 0?t.strictAuthentication=e.strictAuthentication:Xs()&&(t.strictAuthentication=!1),t}addWorkflows(e){for(let t of e){if(this.discoveredWorkflows.some(s=>s.workflowId===t.workflowId))throw new It(t.workflowId);this.discoveredWorkflows.push(t);}}healthCheck(){let e=this.discoveredWorkflows.length,t=this.discoveredWorkflows.reduce((s,n)=>s+n.steps.length,0);return {status:"ok",sdkVersion:He,frameworkVersion:mr,discovered:{workflows:e,steps:t}}}getWorkflow(e){let t=this.discoveredWorkflows.find(s=>s.workflowId===e);if(t)return t;throw new We(e)}getStep(e,t){let n=this.getWorkflow(e).steps.find(a=>a.stepId===t);if(n)return n;throw new Ot(t)}getRegisteredWorkflows(){return this.discoveredWorkflows}discover(){return {workflows:this.getRegisteredWorkflows()}}mock(e){return jsonSchemaFaker.JSONSchemaFaker.generate(Ys(e))}async validate(e,t,s,n,a,i,o){let c=await Gs(t,e);if(c.success)return c.data;switch(s){case"event":this.throwInvalidEvent(n,a,c.errors);case"step":this.throwInvalidStep(i,n,a,c.errors);case"provider":this.throwInvalidProvider(i,o,n,a,c.errors);default:throw new Error(`Invalid component: '${s}'`)}}throwInvalidProvider(e,t,s,n,a){if(!e)throw new Error("stepId is required");if(!t)throw new Error("providerId is required");switch(s){case"output":throw new ct(n,e,t,a);default:throw new Error(`Invalid payload type: '${s}'`)}}throwInvalidStep(e,t,s,n){if(!e)throw new Error("stepId is required");switch(t){case"output":throw new dt(s,e,n);case"result":throw new ut(s,e,n);case"controls":throw new ot(s,e,n);default:throw new Error(`Invalid payload type: '${t}'`)}}throwInvalidEvent(e,t,s){switch(e){case"controls":throw new it(t,s);case"payload":throw new $e(t,s);default:throw new Error(`Invalid payload type: '${e}'`)}}executeStepFactory(e,t){return async(s,n,a)=>{let i=this.getStep(e.workflowId,s),o=ao(e),c=await this.createStepControls(i,o),l=e.action==="preview";if(!l&&await this.shouldSkip(a?.skip,c))return t({options:{skip:!0}}),{};let p=this.previewStep.bind(this),O=this.executeStep.bind(this),q=await(l?p:O)(e,{...i,providers:i.providers.map(C=>{let Z=a?.providers?.[C.type];if(!Z)throw new ht(C.type);return {...C,resolve:Z}}),resolve:n});return s===e.stepId&&t(q),q.outputs}}async shouldSkip(e,t){return e?e(t):!1}async executeWorkflow(e){let n=`${{execute:"Executing",preview:"Previewing"}[e.action]} workflowId:`;console.log(`
23
- ${b.bold(b.underline(n))} '${e.workflowId}'`);let a=this.getWorkflow(e.workflowId),i=process.hrtime(),o={outputs:{},providers:{},options:{}},c,l=new Promise(ce=>{c=ce;}),p=ce=>{c(),o=ce;},O;try{if(e.action==="execute"&&!e.payload&&!e.data)throw new $e(e.workflowId,{message:"Event `payload` is required"});let ce=await this.createExecutionPayload(e,a);await Promise.race([l,a.execute({payload:ce,environment:{},inputs:{},controls:{},subscriber:e.subscriber,step:{email:this.executeStepFactory(e,p),sms:this.executeStepFactory(e,p),inApp:this.executeStepFactory(e,p),digest:this.executeStepFactory(e,p),delay:this.executeStepFactory(e,p),push:this.executeStepFactory(e,p),chat:this.executeStepFactory(e,p),custom:this.executeStepFactory(e,p)}})]);}catch(ce){O=ce;}let A=process.hrtime(i),q=A[0],C=A[1],Z=q*1e3+C/1e6,Qs=O?N.ERROR:N.SUCCESS,Hs=e.action==="execute"?"Executed":e.action==="preview"?"Previewed":"Invalid action";if(console.log(`${Qs} ${Hs} workflowId: \`${e.workflowId}\``),this.prettyPrintExecute(e,Z,O),O)throw O;return {outputs:o.outputs,providers:o.providers,options:o.options,metadata:{status:"success",error:!1,duration:Z}}}async createExecutionPayload(e,t){let s=e.payload||e.data;if(e.action==="preview"){let a=this.mock(t.payload.schema);s=Object.assign(a,s);}return await this.validate(s,t.payload.unknownSchema,"event","payload",e.workflowId)}prettyPrintExecute(e,t,s){let n=s?N.ERROR:N.SUCCESS,a=e.action==="execute"?"Executed":e.action==="preview"?"Previewed":"Invalid action",i=s?"Failed to execute":a,o=s?b.error:b.success,c=`${n} ${i} workflowId: '${e.workflowId}`;console.log(`
22
+ ]`;continue}n+=s[c],s[c]==="\\"?a=!0:i&&s[c]==="]"?i=!1:!i&&s[c]==="["&&(i=!0);}try{let c=new RegExp(n);}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),r.source}return n};});var Yt=_(Gt=>{Object.defineProperty(Gt,"__esModule",{value:!0});Gt.parseRecordDef=void 0;var Lr=Dt(),Us=P(),Ga=Bt();function Ya(r,e){if(e.target==="openApi3"&&r.keyType?._def.typeName===Lr.ZodFirstPartyTypeKind.ZodEnum)return {type:"object",required:r.keyType._def.values,properties:r.keyType._def.values.reduce((s,n)=>({...s,[n]:(0, Us.parseDef)(r.valueType._def,{...e,currentPath:[...e.currentPath,"properties",n]})??{}}),{}),additionalProperties:!1};let t={type:"object",additionalProperties:(0, Us.parseDef)(r.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??{}};if(e.target==="openApi3")return t;if(r.keyType?._def.typeName===Lr.ZodFirstPartyTypeKind.ZodString&&r.keyType._def.checks?.length){let s=Object.entries((0, Ga.parseStringDef)(r.keyType._def,e)).reduce((n,[a,i])=>a==="type"?n:{...n,[a]:i},{});return {...t,propertyNames:s}}else if(r.keyType?._def.typeName===Lr.ZodFirstPartyTypeKind.ZodEnum)return {...t,propertyNames:{enum:r.keyType._def.values}};return t}Gt.parseRecordDef=Ya;});var $r=_(Jt=>{Object.defineProperty(Jt,"__esModule",{value:!0});Jt.parseMapDef=void 0;var Ms=P(),Ja=Yt();function Xa(r,e){if(e.mapStrategy==="record")return (0, Ja.parseRecordDef)(r,e);let t=(0, Ms.parseDef)(r.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||{},s=(0, Ms.parseDef)(r.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||{};return {type:"array",maxItems:125,items:{type:"array",items:[t,s],minItems:2,maxItems:2}}}Jt.parseMapDef=Xa;});var qr=_(Xt=>{Object.defineProperty(Xt,"__esModule",{value:!0});Xt.parseNativeEnumDef=void 0;function Qa(r){let e=r.values,s=Object.keys(r.values).filter(a=>typeof e[e[a]]!="number").map(a=>e[a]),n=Array.from(new Set(s.map(a=>typeof a)));return {type:n.length===1?n[0]==="string"?"string":"number":["string","number"],enum:s}}Xt.parseNativeEnumDef=Qa;});var Fr=_(Qt=>{Object.defineProperty(Qt,"__esModule",{value:!0});Qt.parseNeverDef=void 0;function Ha(){return {not:{}}}Qt.parseNeverDef=Ha;});var Wr=_(Ht=>{Object.defineProperty(Ht,"__esModule",{value:!0});Ht.parseNullDef=void 0;function ei(r){return r.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}Ht.parseNullDef=ei;});var er=_(de=>{Object.defineProperty(de,"__esModule",{value:!0});de.parseUnionDef=de.primitiveMappings=void 0;var ti=P();de.primitiveMappings={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function ri(r,e){if(e.target==="openApi3")return Vs(r,e);let t=r.options instanceof Map?Array.from(r.options.values()):r.options;if(t.every(s=>s._def.typeName in de.primitiveMappings&&(!s._def.checks||!s._def.checks.length))){let s=t.reduce((n,a)=>{let i=de.primitiveMappings[a._def.typeName];return i&&!n.includes(i)?[...n,i]:n},[]);return {type:s.length>1?s:s[0]}}else if(t.every(s=>s._def.typeName==="ZodLiteral"&&!s.description)){let s=t.reduce((n,a)=>{let i=typeof a._def.value;switch(i){case"string":case"number":case"boolean":return [...n,i];case"bigint":return [...n,"integer"];case"object":if(a._def.value===null)return [...n,"null"];case"symbol":case"undefined":case"function":default:return n}},[]);if(s.length===t.length){let n=s.filter((a,i,o)=>o.indexOf(a)===i);return {type:n.length>1?n:n[0],enum:t.reduce((a,i)=>a.includes(i._def.value)?a:[...a,i._def.value],[])}}}else if(t.every(s=>s._def.typeName==="ZodEnum"))return {type:"string",enum:t.reduce((s,n)=>[...s,...n._def.values.filter(a=>!s.includes(a))],[])};return Vs(r,e)}de.parseUnionDef=ri;var Vs=(r,e)=>{let t=(r.options instanceof Map?Array.from(r.options.values()):r.options).map((s,n)=>(0, ti.parseDef)(s._def,{...e,currentPath:[...e.currentPath,"anyOf",`${n}`]})).filter(s=>!!s&&(!e.strictUnions||typeof s=="object"&&Object.keys(s).length>0));return t.length?{anyOf:t}:void 0};});var Kr=_(tr=>{Object.defineProperty(tr,"__esModule",{value:!0});tr.parseNullableDef=void 0;var Ls=P(),$s=er();function si(r,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(r.innerType._def.typeName)&&(!r.innerType._def.checks||!r.innerType._def.checks.length))return e.target==="openApi3"?{type:$s.primitiveMappings[r.innerType._def.typeName],nullable:!0}:{type:[$s.primitiveMappings[r.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let s=(0, Ls.parseDef)(r.innerType._def,{...e,currentPath:[...e.currentPath]});return s&&"$ref"in s?{allOf:[s],nullable:!0}:s&&{...s,nullable:!0}}let t=(0, Ls.parseDef)(r.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return t&&{anyOf:[t,{type:"null"}]}}tr.parseNullableDef=si;});var zr=_(rr=>{Object.defineProperty(rr,"__esModule",{value:!0});rr.parseNumberDef=void 0;var ue=se();function ni(r,e){let t={type:"number"};if(!r.checks)return t;for(let s of r.checks)switch(s.kind){case"int":t.type="integer",(0, ue.addErrorMessage)(t,"type",s.message,e);break;case"min":e.target==="jsonSchema7"?s.inclusive?(0, ue.setResponseValueAndErrors)(t,"minimum",s.value,s.message,e):(0, ue.setResponseValueAndErrors)(t,"exclusiveMinimum",s.value,s.message,e):(s.inclusive||(t.exclusiveMinimum=!0),(0, ue.setResponseValueAndErrors)(t,"minimum",s.value,s.message,e));break;case"max":e.target==="jsonSchema7"?s.inclusive?(0, ue.setResponseValueAndErrors)(t,"maximum",s.value,s.message,e):(0, ue.setResponseValueAndErrors)(t,"exclusiveMaximum",s.value,s.message,e):(s.inclusive||(t.exclusiveMaximum=!0),(0, ue.setResponseValueAndErrors)(t,"maximum",s.value,s.message,e));break;case"multipleOf":(0, ue.setResponseValueAndErrors)(t,"multipleOf",s.value,s.message,e);break}return t}rr.parseNumberDef=ni;});var Gr=_(Le=>{Object.defineProperty(Le,"__esModule",{value:!0});Le.parseObjectDef=Le.parseObjectDefX=void 0;var Qe=P();function Br(r,e){return e.removeAdditionalStrategy==="strict"?r.catchall._def.typeName==="ZodNever"?r.unknownKeys!=="strict":(0, Qe.parseDef)(r.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??!0:r.catchall._def.typeName==="ZodNever"?r.unknownKeys==="passthrough":(0, Qe.parseDef)(r.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??!0}function ai(r,e){Object.keys(r.shape()).reduce((s,n)=>{let a=r.shape()[n],i=a.isOptional();i||(a={...a._def.innerSchema});let o=(0, Qe.parseDef)(a._def,{...e,currentPath:[...e.currentPath,"properties",n],propertyPath:[...e.currentPath,"properties",n]});return o!==void 0&&(s.properties[n]=o,i||(s.required||(s.required=[]),s.required.push(n))),s},{type:"object",properties:{},additionalProperties:Br(r,e)});let t={type:"object",...Object.entries(r.shape()).reduce((s,[n,a])=>{if(a===void 0||a._def===void 0)return s;let i=(0, Qe.parseDef)(a._def,{...e,currentPath:[...e.currentPath,"properties",n],propertyPath:[...e.currentPath,"properties",n]});return i===void 0?s:{properties:{...s.properties,[n]:i},required:a.isOptional()?s.required:[...s.required,n]}},{properties:{},required:[]}),additionalProperties:Br(r,e)};return t.required.length||delete t.required,t}Le.parseObjectDefX=ai;function ii(r,e){let t={type:"object",...Object.entries(r.shape()).reduce((s,[n,a])=>{if(a===void 0||a._def===void 0)return s;let i=(0, Qe.parseDef)(a._def,{...e,currentPath:[...e.currentPath,"properties",n],propertyPath:[...e.currentPath,"properties",n]});return i===void 0?s:{properties:{...s.properties,[n]:i},required:a.isOptional()?s.required:[...s.required,n]}},{properties:{},required:[]}),additionalProperties:Br(r,e)};return t.required.length||delete t.required,t}Le.parseObjectDef=ii;});var Yr=_(sr=>{Object.defineProperty(sr,"__esModule",{value:!0});sr.parseOptionalDef=void 0;var qs=P(),oi=(r,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return (0, qs.parseDef)(r.innerType._def,e);let t=(0, qs.parseDef)(r.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return t?{anyOf:[{not:{}},t]}:{}};sr.parseOptionalDef=oi;});var Jr=_(ar=>{Object.defineProperty(ar,"__esModule",{value:!0});ar.parsePipelineDef=void 0;var nr=P(),di=(r,e)=>{if(e.pipeStrategy==="input")return (0, nr.parseDef)(r.in._def,e);if(e.pipeStrategy==="output")return (0, nr.parseDef)(r.out._def,e);let t=(0, nr.parseDef)(r.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),s=(0, nr.parseDef)(r.out._def,{...e,currentPath:[...e.currentPath,"allOf",t?"1":"0"]});return {allOf:[t,s].filter(n=>n!==void 0)}};ar.parsePipelineDef=di;});var Xr=_(ir=>{Object.defineProperty(ir,"__esModule",{value:!0});ir.parsePromiseDef=void 0;var ui=P();function ci(r,e){return (0, ui.parseDef)(r.type._def,e)}ir.parsePromiseDef=ci;});var Qr=_(or=>{Object.defineProperty(or,"__esModule",{value:!0});or.parseSetDef=void 0;var Fs=se(),li=P();function pi(r,e){let s={type:"array",uniqueItems:!0,items:(0, li.parseDef)(r.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return r.minSize&&(0, Fs.setResponseValueAndErrors)(s,"minItems",r.minSize.value,r.minSize.message,e),r.maxSize&&(0, Fs.setResponseValueAndErrors)(s,"maxItems",r.maxSize.value,r.maxSize.message,e),s}or.parseSetDef=pi;});var es=_(dr=>{Object.defineProperty(dr,"__esModule",{value:!0});dr.parseTupleDef=void 0;var Hr=P();function fi(r,e){return r.rest?{type:"array",minItems:r.items.length,items:r.items.map((t,s)=>(0, Hr.parseDef)(t._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((t,s)=>s===void 0?t:[...t,s],[]),additionalItems:(0, Hr.parseDef)(r.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:r.items.length,maxItems:r.items.length,items:r.items.map((t,s)=>(0, Hr.parseDef)(t._def,{...e,currentPath:[...e.currentPath,"items",`${s}`]})).reduce((t,s)=>s===void 0?t:[...t,s],[])}}dr.parseTupleDef=fi;});var ts=_(ur=>{Object.defineProperty(ur,"__esModule",{value:!0});ur.parseUndefinedDef=void 0;function hi(){return {not:{}}}ur.parseUndefinedDef=hi;});var rs=_(cr=>{Object.defineProperty(cr,"__esModule",{value:!0});cr.parseUnknownDef=void 0;function mi(){return {}}cr.parseUnknownDef=mi;});var ss=_(lr=>{Object.defineProperty(lr,"__esModule",{value:!0});lr.parseReadonlyDef=void 0;var yi=P(),_i=(r,e)=>(0, yi.parseDef)(r.innerType._def,e);lr.parseReadonlyDef=_i;});var P=_(pr=>{Object.defineProperty(pr,"__esModule",{value:!0});pr.parseDef=void 0;var I=Dt(),gi=Pr(),vi=Ar(),Ti=Nr(),Oi=Cr(),Ii=kr(),xi=Dr(),Ri=Sr(),Ei=Zr(),wi=jr(),bi=Ur(),Pi=Mr(),Ai=Vr(),Ni=$r(),Ci=qr(),ki=Fr(),Di=Wr(),Si=Kr(),Zi=zr(),ji=Gr(),Ui=Yr(),Mi=Jr(),Vi=Xr(),Li=Yt(),$i=Qr(),qi=Bt(),Fi=es(),Wi=ts(),Ki=er(),zi=rs(),Bi=ss(),Gi=Rt();function Ws(r,e,t=!1){let s=e.seen.get(r);if(e.override){let i=e.override?.(r,e,s,t);if(i!==Gi.ignoreOverride)return i}if(s&&!t){let i=Yi(s,e);if(i!==void 0)return i}let n={def:r,path:e.currentPath,jsonSchema:void 0};e.seen.set(r,n);let a=Xi(r,r.typeName,e);return a&&Qi(r,e,a),n.jsonSchema=a,a}pr.parseDef=Ws;var Yi=(r,e)=>{switch(e.$refStrategy){case"root":return {$ref:r.path.join("/")};case"relative":return {$ref:Ji(e.currentPath,r.path)};case"none":case"seen":return r.path.length<e.currentPath.length&&r.path.every((t,s)=>e.currentPath[s]===t)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},Ji=(r,e)=>{let t=0;for(;t<r.length&&t<e.length&&r[t]===e[t];t++);return [(r.length-t).toString(),...e.slice(t)].join("/")},Xi=(r,e,t)=>{switch(e){case I.ZodFirstPartyTypeKind.ZodString:return (0, qi.parseStringDef)(r,t);case I.ZodFirstPartyTypeKind.ZodNumber:return (0, Zi.parseNumberDef)(r,t);case I.ZodFirstPartyTypeKind.ZodObject:return (0, ji.parseObjectDef)(r,t);case I.ZodFirstPartyTypeKind.ZodBigInt:return (0, Ti.parseBigintDef)(r,t);case I.ZodFirstPartyTypeKind.ZodBoolean:return (0, Oi.parseBooleanDef)();case I.ZodFirstPartyTypeKind.ZodDate:return (0, Ri.parseDateDef)(r,t);case I.ZodFirstPartyTypeKind.ZodUndefined:return (0, Wi.parseUndefinedDef)();case I.ZodFirstPartyTypeKind.ZodNull:return (0, Di.parseNullDef)(t);case I.ZodFirstPartyTypeKind.ZodArray:return (0, vi.parseArrayDef)(r,t);case I.ZodFirstPartyTypeKind.ZodUnion:case I.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return (0, Ki.parseUnionDef)(r,t);case I.ZodFirstPartyTypeKind.ZodIntersection:return (0, Pi.parseIntersectionDef)(r,t);case I.ZodFirstPartyTypeKind.ZodTuple:return (0, Fi.parseTupleDef)(r,t);case I.ZodFirstPartyTypeKind.ZodRecord:return (0, Li.parseRecordDef)(r,t);case I.ZodFirstPartyTypeKind.ZodLiteral:return (0, Ai.parseLiteralDef)(r,t);case I.ZodFirstPartyTypeKind.ZodEnum:return (0, bi.parseEnumDef)(r);case I.ZodFirstPartyTypeKind.ZodNativeEnum:return (0, Ci.parseNativeEnumDef)(r);case I.ZodFirstPartyTypeKind.ZodNullable:return (0, Si.parseNullableDef)(r,t);case I.ZodFirstPartyTypeKind.ZodOptional:return (0, Ui.parseOptionalDef)(r,t);case I.ZodFirstPartyTypeKind.ZodMap:return (0, Ni.parseMapDef)(r,t);case I.ZodFirstPartyTypeKind.ZodSet:return (0, $i.parseSetDef)(r,t);case I.ZodFirstPartyTypeKind.ZodLazy:return Ws(r.getter()._def,t);case I.ZodFirstPartyTypeKind.ZodPromise:return (0, Vi.parsePromiseDef)(r,t);case I.ZodFirstPartyTypeKind.ZodNaN:case I.ZodFirstPartyTypeKind.ZodNever:return (0, ki.parseNeverDef)();case I.ZodFirstPartyTypeKind.ZodEffects:return (0, wi.parseEffectsDef)(r,t);case I.ZodFirstPartyTypeKind.ZodAny:return (0, gi.parseAnyDef)();case I.ZodFirstPartyTypeKind.ZodUnknown:return (0, zi.parseUnknownDef)();case I.ZodFirstPartyTypeKind.ZodDefault:return (0, Ei.parseDefaultDef)(r,t);case I.ZodFirstPartyTypeKind.ZodBranded:return (0, Ii.parseBrandedDef)(r,t);case I.ZodFirstPartyTypeKind.ZodReadonly:return (0, Bi.parseReadonlyDef)(r,t);case I.ZodFirstPartyTypeKind.ZodCatch:return (0, xi.parseCatchDef)(r,t);case I.ZodFirstPartyTypeKind.ZodPipeline:return (0, Mi.parsePipelineDef)(r,t);case I.ZodFirstPartyTypeKind.ZodFunction:case I.ZodFirstPartyTypeKind.ZodVoid:case I.ZodFirstPartyTypeKind.ZodSymbol:return;default:return (s=>{})()}},Qi=(r,e,t)=>(r.description&&(t.description=r.description,e.markdownDescription&&(t.markdownDescription=r.description)),t);});var ns=_(fr=>{Object.defineProperty(fr,"__esModule",{value:!0});fr.zodToJsonSchema=void 0;var Ks=P(),Hi=Tr(),eo=(r,e)=>{let t=(0, Hi.getRefs)(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[l,p])=>({...c,[l]:(0, Ks.parseDef)(p._def,{...t,currentPath:[...t.basePath,t.definitionPath,l]},!0)??{}}),{}):void 0,n=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,a=(0, Ks.parseDef)(r._def,n===void 0?t:{...t,currentPath:[...t.basePath,t.definitionPath,n]},!1)??{},i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(a.title=i);let o=n===void 0?s?{...a,[t.definitionPath]:s}:a:{$ref:[...t.$refStrategy==="relative"?[]:t.basePath,t.definitionPath,n].join("/"),[t.definitionPath]:{...s,[n]:a}};return t.target==="jsonSchema7"?o.$schema="http://json-schema.org/draft-07/schema#":t.target==="jsonSchema2019-09"&&(o.$schema="https://json-schema.org/draft/2019-09/schema#"),o};fr.zodToJsonSchema=eo;});var zs=_(T=>{var to=T&&T.__createBinding||(Object.create?function(r,e,t,s){s===void 0&&(s=t);var n=Object.getOwnPropertyDescriptor(e,t);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[t]}}),Object.defineProperty(r,s,n);}:function(r,e,t,s){s===void 0&&(s=t),r[s]=e[t];}),x=T&&T.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&to(e,r,t);};Object.defineProperty(T,"__esModule",{value:!0});x(Rt(),T);x(Tr(),T);x(se(),T);x(P(),T);x(Pr(),T);x(Ar(),T);x(Nr(),T);x(Cr(),T);x(kr(),T);x(Dr(),T);x(Sr(),T);x(Zr(),T);x(jr(),T);x(Ur(),T);x(Mr(),T);x(Vr(),T);x($r(),T);x(qr(),T);x(Fr(),T);x(Wr(),T);x(Kr(),T);x(zr(),T);x(Gr(),T);x(Yr(),T);x(Jr(),T);x(Xr(),T);x(ss(),T);x(Yt(),T);x(Qr(),T);x(Bt(),T);x(es(),T);x(ts(),T);x(er(),T);x(rs(),T);x(ns(),T);var ro=ns();T.default=ro.zodToJsonSchema;});var et=(s=>(s.TRIGGER="trigger",s.EXECUTE="execute",s.PREVIEW="preview",s))(et||{}),tt=(s=>(s.DISCOVER="discover",s.HEALTH_CHECK="health-check",s.CODE="code",s))(tt||{});var F=(w=>(w.WORKFLOW_NOT_FOUND_ERROR="WorkflowNotFoundError",w.WORKFLOW_ALREADY_EXISTS_ERROR="WorkflowAlreadyExistsError",w.WORKFLOW_EXECUTION_FAILED_ERROR="WorkflowExecutionFailedError",w.EXECUTION_STATE_OUTPUT_INVALID_ERROR="ExecutionStateOutputInvalidError",w.EXECUTION_STATE_RESULT_INVALID_ERROR="ExecutionStateResultInvalidError",w.EXECUTION_PROVIDER_OUTPUT_INVALID_ERROR="ExecutionProviderOutputInvalidError",w.PROVIDER_NOT_FOUND_ERROR="ProviderNotFoundError",w.PROVIDER_EXECUTION_FAILED_ERROR="ProviderExecutionFailedError",w.STEP_NOT_FOUND_ERROR="StepNotFoundError",w.STEP_ALREADY_EXISTS_ERROR="StepAlreadyExistsError",w.STEP_EXECUTION_FAILED_ERROR="StepExecutionFailedError",w.EXECUTION_STATE_CORRUPT_ERROR="ExecutionStateCorruptError",w.EXECUTION_EVENT_PAYLOAD_INVALID_ERROR="ExecutionEventPayloadInvalidError",w.EXECUTION_EVENT_CONTROL_INVALID_ERROR="ExecutionEventControlInvalidError",w.EXECUTION_STATE_CONTROL_INVALID_ERROR="ExecutionStateControlInvalidError",w.METHOD_NOT_ALLOWED_ERROR="MethodNotAllowedError",w.INVALID_ACTION_ERROR="InvalidActionError",w.MISSING_SECRET_KEY_ERROR="MissingSecretKeyError",w.SIGNATURE_MISMATCH_ERROR="SignatureMismatchError",w.SIGNATURE_NOT_FOUND_ERROR="SignatureNotFoundError",w.SIGNATURE_INVALID_ERROR="SignatureInvalidError",w.SIGNATURE_EXPIRED_ERROR="SignatureExpiredError",w.SIGNING_KEY_NOT_FOUND_ERROR="SigningKeyNotFoundError",w.PLATFORM_ERROR="PlatformError",w.SIGNATURE_VERSION_INVALID_ERROR="SignatureVersionInvalidError",w))(F||{});var rt=(s=>(s.POST="POST",s.GET="GET",s.OPTIONS="OPTIONS",s))(rt||{});var X=class extends Error{data},st=class extends X{statusCode=404},M=class extends X{statusCode=400},te=class extends X{statusCode=401},Ae=class extends X{statusCode=500},nt=class extends X{statusCode=409};var at=class extends M{code="ExecutionStateCorruptError";constructor(e,t){super(`Workflow with id: \`${e}\` has a corrupt state. Step with id: \`${t}\` does not exist. Please provide the missing state.`),this.data={workflowId:e,stepId:t};}},$e=class extends M{code="ExecutionEventPayloadInvalidError";constructor(e,t){super(`Workflow with id: \`${e}\` has invalid \`payload\`. Please provide the correct event payload.`),this.data=t;}},it=class extends M{code="ExecutionEventControlInvalidError";constructor(e,t){super(`Workflow with id: \`${e}\` has invalid \`controls\`. Please provide the correct event controls.`),this.data=t;}},ot=class extends M{code="ExecutionStateControlInvalidError";constructor(e,t,s){super(`Workflow with id: \`${e}\` has an invalid state. Step with id: \`${t}\` has invalid \`controls\`. Please provide the correct step controls.`),this.data=s;}},dt=class extends M{code="ExecutionStateOutputInvalidError";constructor(e,t,s){super(`Workflow with id: \`${e}\` has an invalid state. Step with id: \`${t}\` has invalid output. Please provide the correct step output.`),this.data=s;}},ut=class extends M{code="ExecutionStateResultInvalidError";constructor(e,t,s){super(`Workflow with id: \`${e}\` has an invalid state. Step with id: \`${t}\` has invalid result. Please provide the correct step result.`),this.data=s;}},ct=class extends M{code="ExecutionProviderOutputInvalidError";constructor(e,t,s,n){super(`Workflow with id: \`${e}\` has an invalid state. Step with id: \`${t}\` and provider with id: \`${s}\` has invalid output. Please provide the correct provider output.`),this.data=n;}};var os=()=>typeof Response<"u"?Response:en("cross-fetch").Response;var b={info:r=>Ne__default.default.blue(r),warning:r=>Ne__default.default.yellow(r),error:r=>Ne__default.default.red(r),success:r=>Ne__default.default.green(r),underline:r=>Ne__default.default.underline(r),bold:r=>Ne__default.default.bold(r)},N={SUCCESS:b.success("\u2714"),ERROR:b.error("\u2717"),WARNING:b.warning("\u26A0"),INFO:b.info("\u2139"),ARROW:b.bold("\u2192"),MOCK:b.info("\u25CB"),HYDRATED:b.bold(b.info("\u2192")),STEP:b.info("\u03C3"),ACTION:b.info("\u03B1"),DURATION:b.info("\u0394"),PROVIDER:b.info("\u2699"),OUTPUT:b.info("\u21E2"),INPUT:b.info("\u21E0"),WORKFLOW:b.info("\u03C9"),STATE:b.info("\u03C3"),EXECUTE:b.info("\u03B5"),PREVIEW:b.info("\u03C1")};var vr=r=>Object.values(r).map(e=>`\`${e}\``).join(", "),lt=r=>r.replaceAll(/(\w)(\w*)/g,(e,t,s)=>t.toUpperCase()+s.toLowerCase()).replaceAll(/[\s-]+/g,"");var ds=(r,e="https://api.novu.co")=>{let t=process.env.NOVU_API_URL||e;return {post:async(s,n)=>(await fetch(t+"/v1"+s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${r}`},body:JSON.stringify(n)})).json()}};var pt=class extends X{code="MethodNotAllowedError";statusCode=405;message=`Method not allowed. Please use one of ${vr(rt)}`},qe=class extends M{code="InvalidActionError";constructor(e,t){super(`Invalid query string: \`action\`=\`${e}\`. Please use one of ${vr(t)}`);}};var ft=class extends Ae{code="PlatformError";message="Something went wrong. Please try again later."};var Fe=class extends nt{constructor(e,t){super(`${lt(e)} with id: \`${t}\` already exists. Please use a different id.`);}},re=class extends st{constructor(e,t){super(`${lt(e)} with id: \`${t}\` does not exist. Please provide a valid id.`);}},Ce=class extends Ae{constructor(e,t){super(`Failed to execute ${lt(e)} with id: \`${t}\`. Please try again later.`);}};var ht=class extends re{code="ProviderNotFoundError";constructor(e){super("provider",e);}},mt=class extends Ce{code="ProviderExecutionFailedError";constructor(e){super("workflow",e);}};var yt=class extends te{code="SignatureMismatchError";constructor(){super("Signature does not match the expected signature. Please ensure the signature provided in the `novu-signature` header is correct and try again.");}},_t=class extends te{code="SignatureNotFoundError";constructor(){super("Signature not found. Please provide a signature in the `novu-signature` header");}},gt=class extends te{code="SignatureInvalidError";constructor(){super("Signature is invalid. Please provide a valid signature in the `novu-signature` header");}},vt=class extends te{code="SignatureExpiredError";constructor(){super(`Signature expired. Please provide a signature with a timestamp no older than ${5} minutes in the \`novu-signature\` header`);}},Tt=class extends te{code="SigningKeyNotFoundError";constructor(){super("Signature key not found. Please provide a valid key in the Client constructor `config.secretKey`");}};var Ot=class extends re{code="StepNotFoundError";constructor(e){super("step",e);}};var We=class extends re{code="WorkflowNotFoundError";constructor(e){super("workflow",e);}},It=class extends Fe{code="WorkflowAlreadyExistsError";constructor(e){super("workflow",e);}};var xt=class{ajv;compiledSchemas;constructor(){this.ajv=new sn__default.default({useDefaults:!0,removeAdditional:"all"}),nn__default.default(this.ajv),this.compiledSchemas=new Map;}isSchema(e){return typeof e=="boolean"?!1:e.type==="object"||!!e.anyOf||!!e.oneOf}async validate(e,t){let s=this.compiledSchemas.get(t);return s||(s=this.ajv.compile(t),this.compiledSchemas.set(t,s)),s(e)?{success:!0,data:e}:{success:!1,errors:s.errors.map(a=>({path:a.instancePath,message:a.message}))}}transformToJsonSchema(e){return e}};var hr=class{isSchema(e){return e.safeParseAsync!==void 0}async validate(e,t){let s=t.safeParse(e);return s.success?{success:!0,data:s.data}:{success:!1,errors:s.error.errors.map(n=>({path:`/${n.path.join("/")}`,message:n.message}))}}transformToJsonSchema(e){try{return zs().zodToJsonSchema(e)}catch(t){throw t?.message?.includes("Cannot find module")&&console.error("Tried to use a zod schema in @novu/framework without `zod-to-json-schema` installed. Please install it by running `npm install zod-to-json-schema`."),t}}};var Bs=[new hr,new xt],Gs=async(r,e)=>{for(let t of Bs)if(t.isSchema(r))return t.validate(e,r);throw new Error("Invalid schema")},Ys=r=>{for(let e of Bs)if(e.isSchema(r))return e.transformToJsonSchema(r);throw new Error("Invalid schema")};var Js={name:"@novu/framework",version:"0.24.3-alpha.12",description:"The Code-First Notifications Workflow SDK.",main:"./dist/index.js",types:"./dist/index.d.ts",publishConfig:{registry:"https://registry.npmjs.org",access:"public"},private:!1,repository:{type:"git",url:"git+https://github.com/novuhq/novu.git"},files:["dist","README.md"],scripts:{preinstall:"npx only-allow pnpm",test:"vitest","test:watch":"vitest --watch",lint:"eslint src --ext .ts","lint:fix":"eslint src --ext .ts --fix",format:"prettier --check --ignore-path .gitignore .","format:fix":"prettier --write --ignore-path .gitignore .",build:"tsup","build:watch":"tsup --watch","$comment:bump:prerelease":"This is a workaround to support `npm version prerelease` with lerna","bump:prerelease":"npm version prerelease --preid=alpha & PID=$!; (sleep 1 && kill -9 $PID) & wait $PID","release:alpha":"pnpm bump:prerelease || pnpm build && npm publish"},keywords:["novu","code-first","workflows","durable","sdk","notifications","email","sms","push","webhooks","next","nuxt","h3","express"],author:"Novu Team <engineering@novu.co>",license:"ISC",exports:{".":{require:"./dist/index.js",import:"./dist/index.js",types:"./dist/index.d.ts"},"./express":{require:"./dist/express.js",import:"./dist/express.js",types:"./dist/express.d.ts"},"./next":{require:"./dist/next.js",import:"./dist/next.js",types:"./dist/next.d.ts"},"./nuxt":{require:"./dist/nuxt.js",import:"./dist/nuxt.js",types:"./dist/nuxt.d.ts"},"./h3":{require:"./dist/h3.js",import:"./dist/h3.js",types:"./dist/h3.d.ts"},"./sveltekit":{require:"./dist/sveltekit.js",import:"./dist/sveltekit.js",types:"./dist/sveltekit.d.ts"},"./remix":{require:"./dist/remix.js",import:"./dist/remix.js",types:"./dist/remix.d.ts"}},devDependencies:{"@sveltejs/kit":"^2.5.10","@types/express":"^4.17.13","@types/json-schema":"^7.0.15","@types/node":"^20.11.20","@vercel/node":"^2.15.9",express:"^4.18.2",h3:"^1.11.1",next:"^13.5.4",prettier:"^3.2.5","ts-node":"^10.9.2",tsup:"^8.0.2",typescript:"^5.3.3",vitest:"^1.2.1",zod:"^3.23.0","zod-to-json-schema":"^3.23.0"},dependencies:{"@novu/shared":"^0.24.2",ajv:"^8.12.0","ajv-formats":"^2.1.1","better-ajv-errors":"^1.2.0",chalk:"^4.1.2","cross-fetch":"^4.0.0","json-schema-faker":"^0.5.6","json-schema-to-ts":"^3.0.0",liquidjs:"^10.13.1",ora:"^5.4.1"}};var He=Js.version,mr="2024-06-26";jsonSchemaFaker.JSONSchemaFaker.random.shuffle=function(){return ["[placeholder]"]};jsonSchemaFaker.JSONSchemaFaker.option({useDefaultValue:!0,alwaysFakeOptionals:!0});function Xs(){return process.env.NODE_ENV==="development"}var _r=class{discoveredWorkflows=[];templateEngine=new liquidjs.Liquid;secretKey;version=He;strictAuthentication;constructor(e){let t=this.buildOptions(e);this.secretKey=t.secretKey,this.strictAuthentication=t.strictAuthentication;}buildOptions(e){let t={secretKey:void 0,strictAuthentication:!Xs()};if(t.secretKey=e?.secretKey||process.env.NOVU_SECRET_KEY||process.env.NOVU_API_KEY,!Xs()&&!t.secretKey)throw new Error("Missing secret key. Set the NOVU_SECRET_KEY environment variable or pass `secretKey` to the client options.");return e?.strictAuthentication!==void 0?t.strictAuthentication=e.strictAuthentication:process.env.NOVU_STRICT_AUTHENTICATION_ENABLED!==void 0&&(t.strictAuthentication=process.env.NOVU_STRICT_AUTHENTICATION_ENABLED==="true"),t}addWorkflows(e){for(let t of e){if(this.discoveredWorkflows.some(s=>s.workflowId===t.workflowId))throw new It(t.workflowId);this.discoveredWorkflows.push(t);}}healthCheck(){let e=this.discoveredWorkflows.length,t=this.discoveredWorkflows.reduce((s,n)=>s+n.steps.length,0);return {status:"ok",sdkVersion:He,frameworkVersion:mr,discovered:{workflows:e,steps:t}}}getWorkflow(e){let t=this.discoveredWorkflows.find(s=>s.workflowId===e);if(t)return t;throw new We(e)}getStep(e,t){let n=this.getWorkflow(e).steps.find(a=>a.stepId===t);if(n)return n;throw new Ot(t)}getRegisteredWorkflows(){return this.discoveredWorkflows}discover(){return {workflows:this.getRegisteredWorkflows()}}mock(e){return jsonSchemaFaker.JSONSchemaFaker.generate(Ys(e))}async validate(e,t,s,n,a,i,o){let c=await Gs(t,e);if(c.success)return c.data;switch(s){case"event":this.throwInvalidEvent(n,a,c.errors);case"step":this.throwInvalidStep(i,n,a,c.errors);case"provider":this.throwInvalidProvider(i,o,n,a,c.errors);default:throw new Error(`Invalid component: '${s}'`)}}throwInvalidProvider(e,t,s,n,a){if(!e)throw new Error("stepId is required");if(!t)throw new Error("providerId is required");switch(s){case"output":throw new ct(n,e,t,a);default:throw new Error(`Invalid payload type: '${s}'`)}}throwInvalidStep(e,t,s,n){if(!e)throw new Error("stepId is required");switch(t){case"output":throw new dt(s,e,n);case"result":throw new ut(s,e,n);case"controls":throw new ot(s,e,n);default:throw new Error(`Invalid payload type: '${t}'`)}}throwInvalidEvent(e,t,s){switch(e){case"controls":throw new it(t,s);case"payload":throw new $e(t,s);default:throw new Error(`Invalid payload type: '${e}'`)}}executeStepFactory(e,t){return async(s,n,a)=>{let i=this.getStep(e.workflowId,s),o=ao(e),c=await this.createStepControls(i,o),l=e.action==="preview";if(!l&&await this.shouldSkip(a?.skip,c))return t({options:{skip:!0}}),{};let p=this.previewStep.bind(this),O=this.executeStep.bind(this),q=await(l?p:O)(e,{...i,providers:i.providers.map(k=>{let Z=a?.providers?.[k.type];if(!Z)throw new ht(k.type);return {...k,resolve:Z}}),resolve:n});return s===e.stepId&&t(q),q.outputs}}async shouldSkip(e,t){return e?e(t):!1}async executeWorkflow(e){let n=`${{execute:"Executing",preview:"Previewing"}[e.action]} workflowId:`;console.log(`
23
+ ${b.bold(b.underline(n))} '${e.workflowId}'`);let a=this.getWorkflow(e.workflowId),i=process.hrtime(),o={outputs:{},providers:{},options:{}},c,l=new Promise(ce=>{c=ce;}),p=ce=>{c(),o=ce;},O;try{if(e.action==="execute"&&!e.payload&&!e.data)throw new $e(e.workflowId,{message:"Event `payload` is required"});let ce=await this.createExecutionPayload(e,a);await Promise.race([l,a.execute({payload:ce,environment:{},inputs:{},controls:{},subscriber:e.subscriber,step:{email:this.executeStepFactory(e,p),sms:this.executeStepFactory(e,p),inApp:this.executeStepFactory(e,p),digest:this.executeStepFactory(e,p),delay:this.executeStepFactory(e,p),push:this.executeStepFactory(e,p),chat:this.executeStepFactory(e,p),custom:this.executeStepFactory(e,p)}})]);}catch(ce){O=ce;}let A=process.hrtime(i),q=A[0],k=A[1],Z=q*1e3+k/1e6,Qs=O?N.ERROR:N.SUCCESS,Hs=e.action==="execute"?"Executed":e.action==="preview"?"Previewed":"Invalid action";if(console.log(`${Qs} ${Hs} workflowId: \`${e.workflowId}\``),this.prettyPrintExecute(e,Z,O),O)throw O;return {outputs:o.outputs,providers:o.providers,options:o.options,metadata:{status:"success",error:!1,duration:Z}}}async createExecutionPayload(e,t){let s=e.payload||e.data;if(e.action==="preview"){let a=this.mock(t.payload.schema);s=Object.assign(a,s);}return await this.validate(s,t.payload.unknownSchema,"event","payload",e.workflowId)}prettyPrintExecute(e,t,s){let n=s?N.ERROR:N.SUCCESS,a=e.action==="execute"?"Executed":e.action==="preview"?"Previewed":"Invalid action",i=s?"Failed to execute":a,o=s?b.error:b.success,c=`${n} ${i} workflowId: '${e.workflowId}`;console.log(`
24
24
  ${b.bold(o(c))}'`),console.log(` \u251C ${N.STEP} stepId: '${e.stepId}'`),console.log(` \u251C ${N.ACTION} action: '${e.action}'`),console.log(` \u2514 ${N.DURATION} duration: '${t.toFixed(2)}ms'
25
25
  `);}async executeProviders(e,t,s){return t.providers.reduce(async(n,a)=>{let i=await n,o=this.previewProvider.bind(this),c=this.executeProvider.bind(this),p=await(e.action==="preview"?o:c)(e,t,a,s);return {...i,[a.type]:p}},Promise.resolve({}))}previewProvider(e,t,s,n){return console.log(` ${N.MOCK} Mocked provider: \`${s.type}\``),this.mock(s.outputs.schema)}async executeProvider(e,t,s,n){let a=yr__default.default({indent:2}).start(`Executing provider: \`${s.type}\``);try{if(e.stepId===t.stepId){let i=await this.createStepControls(t,e),o=await s.resolve({controls:i,outputs:n}),c=await this.validate(o,s.outputs.unknownSchema,"step","output",e.workflowId,t.stepId,s.type);return a.succeed(`Executed provider: \`${s.type}\``),c}else a.stopAndPersist({symbol:N.HYDRATED,text:`Hydrated provider: \`${s.type}\``});}catch(i){throw a.stopAndPersist({symbol:N.ERROR,text:`Failed to execute provider: \`${s.type}\``}),new mt(`Failed to execute provider: '${s.type}'.
26
- ${i.message}`)}}async executeStep(e,t){if(e.stepId===t.stepId){let s=yr__default.default({indent:1}).start(`Executing stepId: \`${t.stepId}\``);try{let n=await this.createStepControls(t,e),a=await this.compileControls(n,e),i=await t.resolve(a),o=await this.validate(i,t.outputs.unknownSchema,"step","output",e.workflowId,t.stepId),c=await this.executeProviders(e,t,o);return s.succeed(`Executed stepId: \`${t.stepId}\``),{outputs:o,providers:c}}catch(n){throw s.stopAndPersist({prefixText:"",symbol:N.ERROR,text:`Failed to execute stepId: \`${t.stepId}\``}),n}}else {let s=yr__default.default({indent:1}).start(`Hydrating stepId: \`${t.stepId}\``);try{let n=e.state.find(a=>a.stepId===t.stepId);if(n){let a=await this.validate(n.outputs,t.results.unknownSchema,"step","result",e.workflowId,t.stepId);return s.stopAndPersist({symbol:N.HYDRATED,text:`Hydrated stepId: \`${t.stepId}\``}),{outputs:a,providers:await this.executeProviders(e,t,a)}}else throw new at(e.workflowId,t.stepId)}catch(n){throw s.stopAndPersist({symbol:N.ERROR,text:`Failed to hydrate stepId: \`${t.stepId}\``}),n}}}async compileControls(e,t){let s=this.templateEngine.parse(JSON.stringify(e)),n=await this.templateEngine.render(s,{...t.payload||t.data,subscriber:t.subscriber});return JSON.parse(n)}async createStepControls(e,t){let s=t.controls||t.inputs;return await this.validate(s,e.controls.unknownSchema,"step","controls",t.workflowId,e.stepId)}async previewStep(e,t){let s=yr__default.default({indent:1}).start(`Previewing stepId: \`${t.stepId}\``);try{if(e.stepId===t.stepId){let n=await this.createStepControls(t,e),a=await this.compileControls(n,e),i=await t.resolve(a),o=await this.validate(i,t.outputs.unknownSchema,"step","output",e.workflowId,t.stepId);return s.stopAndPersist({symbol:N.MOCK,text:`Mocked stepId: \`${t.stepId}\``}),{outputs:o,providers:await this.executeProviders(e,t,o)}}else {let n=this.mock(t.results.schema);return s.stopAndPersist({symbol:N.MOCK,text:`Mocked stepId: \`${t.stepId}\``}),{outputs:n,providers:await this.executeProviders(e,t,n)}}}catch(n){throw s.stopAndPersist({symbol:N.ERROR,text:`Failed to preview stepId: \`${t.stepId}\``}),n}}getStepCode(e,t){return {code:this.getStep(e,t).resolve.toString()}}getWorkflowCode(e){return {code:this.getWorkflow(e).execute.toString()}}getCode(e,t){let s;if(e)t?s=this.getStepCode(e,t):s=this.getWorkflowCode(e);else throw new We(e);return s}};function ao(r){return JSON.parse(JSON.stringify(r))}var gr=class{frameworkName;handler;client;hmacEnabled;http;constructor(e){this.handler=e.handler,this.client=e.client?e.client:new _r,this.client.addWorkflows(e.workflows),this.http=ds(this.client.secretKey),this.frameworkName=e.frameworkName,this.hmacEnabled=this.client.strictAuthentication;}createHandler(){return async(...e)=>{let t=await this.handler(...e),s=await this.handleAction({actions:t});return t.transformResponse(s)}}getStaticHeaders(){let e=`novu-framework:v${this.client.version}`;return {"content-type":"application/json","access-control-allow-origin":"*","access-control-allow-methods":"GET, POST","access-control-allow-headers":"*","access-control-max-age":"604800","novu-framework-version":mr,"novu-framework-sdk":He,"novu-framework-api":this.frameworkName,"user-agent":e}}createResponse(e,t){return {status:e,body:JSON.stringify(t),headers:{...this.getStaticHeaders()}}}createError(e){return {status:e.statusCode,body:JSON.stringify({message:e.message,data:e.data,code:e.code}),headers:this.getStaticHeaders()}}async handleAction({actions:e}){let t=await e.url(),s=await e.method(),n=t.searchParams.get("action")||"",a=t.searchParams.get("workflowId")||"",i=t.searchParams.get("stepId")||"",o=await e.headers("novu-signature")||await e.headers("x-novu-signature")||"",c=await e.headers("novu-anonymous")||await e.headers("x-novu-anonymous")||"",l=t.searchParams.get("source")||"",p={};try{s==="POST"&&(p=await e.body());}catch{}try{n!=="health-check"&&this.validateHmac(p,o);let O=this.getPostActionMap(p,a,i,n,c,l),A=this.getGetActionMap(a,i);if(s==="POST")return await this.handlePostAction(n,O);if(s==="GET")return await this.handleGetAction(n,A);if(s==="OPTIONS")return this.createResponse(200,{})}catch(O){return this.handleError(O)}return this.createError(new pt(s))}getPostActionMap(e,t,s,n,a,i){return {trigger:this.triggerAction({workflowId:t,...e}),execute:async()=>{let o=await this.client.executeWorkflow({...e,workflowId:t,stepId:s,action:n});return this.createResponse(200,o)},preview:async()=>{let o=await this.client.executeWorkflow({...e,workflowId:t,stepId:s,action:n});return this.createResponse(200,o)}}}triggerAction(e){return async()=>{let t={name:e.workflowId,to:e.to,payload:e?.payload||{},transactionId:e.transactionId,overrides:e.overrides||{},...e.actor&&{actor:e.actor},...e.tenant&&{tenant:e.tenant},...e.bridgeUrl&&{bridgeUrl:e.bridgeUrl}},s=await this.http.post("/events/trigger",t);return this.createResponse(200,s)}}getGetActionMap(e,t){return {discover:async()=>{let s=await this.client.discover();return this.createResponse(200,s)},"health-check":async()=>{let s=await this.client.healthCheck();return this.createResponse(200,s)},code:async()=>{let s=await this.client.getCode(e,t);return this.createResponse(200,s)}}}async handlePostAction(e,t){if(Object.values(et).includes(e)){let s=t[e];return s()}else throw new qe(e,et)}async handleGetAction(e,t){if(Object.values(tt).includes(e)){let s=t[e];return s()}else throw new qe(e,tt)}isClientError(e){return Object.values(F).includes(e.code)}handleError(e){return this.isClientError(e)?(e.statusCode===500&&console.error(e),this.createError(e)):e.response.status===400?this.createError(e.response):(console.error(e),this.createError(new ft))}validateHmac(e,t){if(!this.hmacEnabled)return;if(!t)throw new _t;if(!this.client.secretKey)throw new Tt;let[s,n]=t.split(",");if(!s||!n)throw new gt;let[a,i]=s.split("="),[o,c]=n.split("=");if(Number(a)<Date.now()-1500)throw new vt;if(!(this.hashHmac(this.client.secretKey,`${i}.${JSON.stringify(e)}`)===c))throw new yt}hashHmac(e,t){return crypto.createHmac("sha256",e).update(t).digest("hex")}};var uo="next",Qu=r=>{let t=new gr({frameworkName:uo,...r,handler:(a,i,o)=>{let c=i,l=p=>{let O=typeof c.headers.get=="function"?c.headers.get(p):c.headers[p];return Array.isArray(O)?O[0]:O};return {body:()=>typeof c.json=="function"?c.json():c.body,headers:l,method:()=>a||c.method||"",queryString:(p,O)=>{let A=c.query?.[p]||O.searchParams.get(p);return Array.isArray(A)?A[0]:A},url:()=>{let p;try{p=new URL(c.url);}catch{}if(p){let C=l("host");if(C){let Z=new URL(C.includes("://")?C:`${p.protocol}//${C}`);p.protocol=Z.protocol,p.host=Z.host,p.port=Z.port,p.username=Z.username,p.password=Z.password;}return p}let O="https",A=l("host")||"";try{process.env.NODE_ENV==="development"&&(O="http");}catch{}return new URL(c.url,`${O}://${A}`)},transformResponse:({body:p,headers:O,status:A})=>{if(typeof o?.setHeader=="function"&&Object.entries(O).forEach(([C,Z])=>{o.setHeader(C,Z);}),typeof o?.status=="function"&&typeof o?.send=="function"){o.status(A).send(p);return}let q=os();return new q(p,{status:A,headers:O})}}}}).createHandler(),s=t.bind(null,void 0);return Object.defineProperties(s,{GET:{value:t.bind(null,"GET")},POST:{value:t.bind(null,"POST")},PUT:{value:t.bind(null,"PUT")},OPTIONS:{value:t.bind(null,"OPTIONS")}})};
26
+ ${i.message}`)}}async executeStep(e,t){if(e.stepId===t.stepId){let s=yr__default.default({indent:1}).start(`Executing stepId: \`${t.stepId}\``);try{let n=await this.createStepControls(t,e),a=await this.compileControls(n,e),i=await t.resolve(a),o=await this.validate(i,t.outputs.unknownSchema,"step","output",e.workflowId,t.stepId),c=await this.executeProviders(e,t,o);return s.succeed(`Executed stepId: \`${t.stepId}\``),{outputs:o,providers:c}}catch(n){throw s.stopAndPersist({prefixText:"",symbol:N.ERROR,text:`Failed to execute stepId: \`${t.stepId}\``}),n}}else {let s=yr__default.default({indent:1}).start(`Hydrating stepId: \`${t.stepId}\``);try{let n=e.state.find(a=>a.stepId===t.stepId);if(n){let a=await this.validate(n.outputs,t.results.unknownSchema,"step","result",e.workflowId,t.stepId);return s.stopAndPersist({symbol:N.HYDRATED,text:`Hydrated stepId: \`${t.stepId}\``}),{outputs:a,providers:await this.executeProviders(e,t,a)}}else throw new at(e.workflowId,t.stepId)}catch(n){throw s.stopAndPersist({symbol:N.ERROR,text:`Failed to hydrate stepId: \`${t.stepId}\``}),n}}}async compileControls(e,t){let s=this.templateEngine.parse(JSON.stringify(e)),n=await this.templateEngine.render(s,{...t.payload||t.data,subscriber:t.subscriber});return JSON.parse(n)}async createStepControls(e,t){let s=t.controls||t.inputs;return await this.validate(s,e.controls.unknownSchema,"step","controls",t.workflowId,e.stepId)}async previewStep(e,t){let s=yr__default.default({indent:1}).start(`Previewing stepId: \`${t.stepId}\``);try{if(e.stepId===t.stepId){let n=await this.createStepControls(t,e),a=await this.compileControls(n,e),i=await t.resolve(a),o=await this.validate(i,t.outputs.unknownSchema,"step","output",e.workflowId,t.stepId);return s.stopAndPersist({symbol:N.MOCK,text:`Mocked stepId: \`${t.stepId}\``}),{outputs:o,providers:await this.executeProviders(e,t,o)}}else {let n=this.mock(t.results.schema);return s.stopAndPersist({symbol:N.MOCK,text:`Mocked stepId: \`${t.stepId}\``}),{outputs:n,providers:await this.executeProviders(e,t,n)}}}catch(n){throw s.stopAndPersist({symbol:N.ERROR,text:`Failed to preview stepId: \`${t.stepId}\``}),n}}getStepCode(e,t){return {code:this.getStep(e,t).resolve.toString()}}getWorkflowCode(e){return {code:this.getWorkflow(e).execute.toString()}}getCode(e,t){let s;if(e)t?s=this.getStepCode(e,t):s=this.getWorkflowCode(e);else throw new We(e);return s}};function ao(r){return JSON.parse(JSON.stringify(r))}var gr=class{frameworkName;handler;client;hmacEnabled;http;constructor(e){this.handler=e.handler,this.client=e.client?e.client:new _r,this.client.addWorkflows(e.workflows),this.http=ds(this.client.secretKey),this.frameworkName=e.frameworkName,this.hmacEnabled=this.client.strictAuthentication;}createHandler(){return async(...e)=>{let t=await this.handler(...e),s=await this.handleAction({actions:t});return t.transformResponse(s)}}getStaticHeaders(){let e=`novu-framework:v${this.client.version}`;return {"content-type":"application/json","access-control-allow-origin":"*","access-control-allow-methods":"GET, POST","access-control-allow-headers":"*","access-control-max-age":"604800","novu-framework-version":mr,"novu-framework-sdk":He,"novu-framework-api":this.frameworkName,"user-agent":e}}createResponse(e,t){return {status:e,body:JSON.stringify(t),headers:{...this.getStaticHeaders()}}}createError(e){return {status:e.statusCode,body:JSON.stringify({message:e.message,data:e.data,code:e.code}),headers:this.getStaticHeaders()}}async handleAction({actions:e}){let t=await e.url(),s=await e.method(),n=t.searchParams.get("action")||"",a=t.searchParams.get("workflowId")||"",i=t.searchParams.get("stepId")||"",o=await e.headers("novu-signature")||await e.headers("x-novu-signature")||"",c=await e.headers("novu-anonymous")||await e.headers("x-novu-anonymous")||"",l=t.searchParams.get("source")||"",p={};try{s==="POST"&&(p=await e.body());}catch{}try{n!=="health-check"&&this.validateHmac(p,o);let O=this.getPostActionMap(p,a,i,n,c,l),A=this.getGetActionMap(a,i);if(s==="POST")return await this.handlePostAction(n,O);if(s==="GET")return await this.handleGetAction(n,A);if(s==="OPTIONS")return this.createResponse(200,{})}catch(O){return this.handleError(O)}return this.createError(new pt(s))}getPostActionMap(e,t,s,n,a,i){return {trigger:this.triggerAction({workflowId:t,...e}),execute:async()=>{let o=await this.client.executeWorkflow({...e,workflowId:t,stepId:s,action:n});return this.createResponse(200,o)},preview:async()=>{let o=await this.client.executeWorkflow({...e,workflowId:t,stepId:s,action:n});return this.createResponse(200,o)}}}triggerAction(e){return async()=>{let t={name:e.workflowId,to:e.to,payload:e?.payload||{},transactionId:e.transactionId,overrides:e.overrides||{},...e.actor&&{actor:e.actor},...e.tenant&&{tenant:e.tenant},...e.bridgeUrl&&{bridgeUrl:e.bridgeUrl}},s=await this.http.post("/events/trigger",t);return this.createResponse(200,s)}}getGetActionMap(e,t){return {discover:async()=>{let s=await this.client.discover();return this.createResponse(200,s)},"health-check":async()=>{let s=await this.client.healthCheck();return this.createResponse(200,s)},code:async()=>{let s=await this.client.getCode(e,t);return this.createResponse(200,s)}}}async handlePostAction(e,t){if(Object.values(et).includes(e)){let s=t[e];return s()}else throw new qe(e,et)}async handleGetAction(e,t){if(Object.values(tt).includes(e)){let s=t[e];return s()}else throw new qe(e,tt)}isClientError(e){return Object.values(F).includes(e.code)}handleError(e){return this.isClientError(e)?(e.statusCode===500&&console.error(e),this.createError(e)):e.response.status===400?this.createError(e.response):(console.error(e),this.createError(new ft))}validateHmac(e,t){if(!this.hmacEnabled)return;if(!t)throw new _t;if(!this.client.secretKey)throw new Tt;let[s,n]=t.split(",");if(!s||!n)throw new gt;let[a,i]=s.split("="),[o,c]=n.split("=");if(Number(a)<Date.now()-1500)throw new vt;if(!(this.hashHmac(this.client.secretKey,`${i}.${JSON.stringify(e)}`)===c))throw new yt}hashHmac(e,t){return crypto.createHmac("sha256",e).update(t).digest("hex")}};var uo="next",Qu=r=>{let t=new gr({frameworkName:uo,...r,handler:(a,i,o)=>{let c=i,l=p=>{let O=typeof c.headers.get=="function"?c.headers.get(p):c.headers[p];return Array.isArray(O)?O[0]:O};return {body:()=>typeof c.json=="function"?c.json():c.body,headers:l,method:()=>a||c.method||"",queryString:(p,O)=>{let A=c.query?.[p]||O.searchParams.get(p);return Array.isArray(A)?A[0]:A},url:()=>{let p;try{p=new URL(c.url);}catch{}if(p){let k=l("host");if(k){let Z=new URL(k.includes("://")?k:`${p.protocol}//${k}`);p.protocol=Z.protocol,p.host=Z.host,p.port=Z.port,p.username=Z.username,p.password=Z.password;}return p}let O="https",A=l("host")||"";try{process.env.NODE_ENV==="development"&&(O="http");}catch{}return new URL(c.url,`${O}://${A}`)},transformResponse:({body:p,headers:O,status:A})=>{if(typeof o?.setHeader=="function"&&Object.entries(O).forEach(([k,Z])=>{o.setHeader(k,Z);}),typeof o?.status=="function"&&typeof o?.send=="function"){o.status(A).send(p);return}let q=os();return new q(p,{status:A,headers:O})}}}}).createHandler(),s=t.bind(null,void 0);return Object.defineProperties(s,{GET:{value:t.bind(null,"GET")},POST:{value:t.bind(null,"POST")},PUT:{value:t.bind(null,"PUT")},OPTIONS:{value:t.bind(null,"OPTIONS")}})};
27
27
 
28
28
  exports.frameworkName = uo;
29
29
  exports.serve = Qu;