@novu/framework 0.24.3-alpha.10

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/README.md ADDED
@@ -0,0 +1,62 @@
1
+ <div align="center">
2
+ <a href="https://novu.co?utm_source=github" target="_blank">
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/2233092/213641039-220ac15f-f367-4d13-9eaf-56e79433b8c1.png">
5
+ <img alt="Novu Logo" src="https://user-images.githubusercontent.com/2233092/213641043-3bbb3f21-3c53-4e67-afe5-755aeb222159.png" width="280"/>
6
+ </picture>
7
+ </a>
8
+ </div>
9
+
10
+ # Code-First Notifications Workflow SDK
11
+
12
+ [![Version](https://img.shields.io/npm/v/@novu/framework.svg)](https://www.npmjs.org/package/@novu/framework)
13
+ [![Downloads](https://img.shields.io/npm/dm/@novu/framework.svg)](https://www.npmjs.com/package/@novu/framework)
14
+
15
+ Novu Framework allows you to write notification workflows in your codebase. Workflows are functions that execute business logic and use your preferred libraries for email, SMS, and chat generation. You can use Novu Framework with [React.Email](https://react.email/), [MJML](https://mjml.io/), or any other template generator.
16
+
17
+ Learn more about the Code-First Notifications Workflow SDK in our [docs](https://docs.novu.co/framework/quickstart).
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ npm install @novu/framework
23
+ ```
24
+
25
+ ## Quickstart
26
+
27
+ ```typescript
28
+ import { workflow, CronExpression, } from "@novu/framework";
29
+ import { serve } from "@novu/framework/next";
30
+ import { z } from 'zod';
31
+
32
+ // Define your notification workflow
33
+ const weeklyComments = workflow(
34
+ 'comment-on-post',
35
+ async ({ payload, step }) => {
36
+ const inAppResponse = await step.inApp('new-comment', async () => ({
37
+ body: `You have a new comment on your post ${payload.comment}`,
38
+ }));
39
+
40
+ const weeklyDigest = await step.digest('weekly-digest', () => ({
41
+ cron: CronExpression.EVERY_WEEK,
42
+ }));
43
+
44
+ await step.email('weekly-comments', async (controls) => ({
45
+ subject: `${controls.prefix} - Weekly post comments (${weeklyDigest.events.length})`,
46
+ body: `Weekly digest: ${weeklyDigest.events.map(({ payload }) => payload.comment).join(', ')}`,
47
+ }), {
48
+ // Skip the notification if the user has already seen it
49
+ skip: () => inAppResponse.seen,
50
+ // Non-technical stakeholders can modify strongly-validated copy in Novu Cloud
51
+ inputSchema: z.object({ prefix: z.string().describe('The prefix of the subject.').default('Hi!') }),
52
+ });
53
+ },
54
+ { payloadSchema: z.object({ comment: z.string().describe('The comment on the post.') }) }
55
+ );
56
+
57
+ // Use your favorite framework to serve your workflows
58
+ const { GET, POST, OPTIONS } = serve({ workflows: [weeklyComments] });
59
+
60
+ // Trigger your notification workflow
61
+ weeklyComments.trigger({ postId: '123', to: 'user:123' });
62
+ ```
@@ -0,0 +1,9 @@
1
+ import { l as SupportedFrameworkName, a as ServeHandlerOptions } from './handler-y6PZIhGI.js';
2
+ import 'json-schema-to-ts';
3
+ import 'zod';
4
+ import '@novu/shared';
5
+
6
+ declare const frameworkName: SupportedFrameworkName;
7
+ declare const serve: (options: ServeHandlerOptions) => any;
8
+
9
+ export { frameworkName, serve };
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ var crypto = require('crypto');
4
+ var jsonSchemaFaker = require('json-schema-faker');
5
+ var liquidjs = require('liquidjs');
6
+ var yr = require('ora');
7
+ var Ae = require('chalk');
8
+ var en = require('ajv');
9
+ var tn = require('ajv-formats');
10
+
11
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
+
13
+ var yr__default = /*#__PURE__*/_interopDefault(yr);
14
+ var Ae__default = /*#__PURE__*/_interopDefault(Ae);
15
+ var en__default = /*#__PURE__*/_interopDefault(en);
16
+ var tn__default = /*#__PURE__*/_interopDefault(tn);
17
+
18
+ var _=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var Rt=_(F=>{Object.defineProperty(F,"__esModule",{value:!0});F.getDefaultOptions=F.defaultOptions=F.ignoreOverride=void 0;F.ignoreOverride=Symbol("Let zodToJsonSchema decide on which parser to use");F.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 rn=r=>typeof r=="string"?{...F.defaultOptions,name:r}:{...F.defaultOptions,...r};F.getDefaultOptions=rn;});var Tr=_(Et=>{Object.defineProperty(Et,"__esModule",{value:!0});Et.getRefs=void 0;var sn=Rt(),nn=r=>{let e=(0, sn.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=nn;});var te=_(Ce=>{Object.defineProperty(Ce,"__esModule",{value:!0});Ce.setResponseValueAndErrors=Ce.addErrorMessage=void 0;function us(r,e,t,s){s?.errorMessages&&t&&(r.errorMessage={...r.errorMessage,[e]:t});}Ce.addErrorMessage=us;function an(r,e,t,s,n){r[e]=t,us(r,e,s,n);}Ce.setResponseValueAndErrors=an;});var Ke=_(R=>{Object.defineProperty(R,"__esModule",{value:!0});R.getParsedType=R.ZodParsedType=R.objectUtil=R.util=void 0;var cs;(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(d=>typeof n[n[d]]!="number"),i={};for(let d of a)i[d]=n[d];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;})(cs=R.util||(R.util={}));(function(r){r.mergeShapes=(e,t)=>({...e,...t});})(R.objectUtil||(R.objectUtil={}));R.ZodParsedType=cs.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);var dn=r=>{switch(typeof r){case"undefined":return R.ZodParsedType.undefined;case"string":return R.ZodParsedType.string;case"number":return isNaN(r)?R.ZodParsedType.nan:R.ZodParsedType.number;case"boolean":return R.ZodParsedType.boolean;case"function":return R.ZodParsedType.function;case"bigint":return R.ZodParsedType.bigint;case"symbol":return R.ZodParsedType.symbol;case"object":return Array.isArray(r)?R.ZodParsedType.array:r===null?R.ZodParsedType.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?R.ZodParsedType.promise:typeof Map<"u"&&r instanceof Map?R.ZodParsedType.map:typeof Set<"u"&&r instanceof Set?R.ZodParsedType.set:typeof Date<"u"&&r instanceof Date?R.ZodParsedType.date:R.ZodParsedType.object;default:return R.ZodParsedType.unknown}};R.getParsedType=dn;});var wt=_(re=>{Object.defineProperty(re,"__esModule",{value:!0});re.ZodError=re.quotelessJson=re.ZodIssueCode=void 0;var ls=Ke();re.ZodIssueCode=ls.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 un=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");re.quotelessJson=un;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 d=s,c=0;for(;c<i.path.length;){let l=i.path[c];c===i.path.length-1?(d[l]=d[l]||{_errors:[]},d[l]._errors.push(t(i))):d[l]=d[l]||{_errors:[]},d=d[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,ls.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()}};re.ZodError=ze;ze.create=r=>new ze(r);});var Or=_(Ir=>{Object.defineProperty(Ir,"__esModule",{value:!0});var ue=Ke(),k=wt(),cn=(r,e)=>{let t;switch(r.code){case k.ZodIssueCode.invalid_type:r.received===ue.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,ue.util.jsonStringifyReplacer)}`;break;case k.ZodIssueCode.unrecognized_keys:t=`Unrecognized key(s) in object: ${ue.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 ${ue.util.joinValues(r.options)}`;break;case k.ZodIssueCode.invalid_enum_value:t=`Invalid enum value. Expected ${ue.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}"`:ue.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,ue.util.assertNever(r);}return {message:t}};Ir.default=cn;});var bt=_(W=>{var ln=W&&W.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(W,"__esModule",{value:!0});W.getErrorMap=W.setErrorMap=W.defaultErrorMap=void 0;var ps=ln(Or());W.defaultErrorMap=ps.default;var fs=ps.default;function pn(r){fs=r;}W.setErrorMap=pn;function fn(){return fs}W.getErrorMap=fn;});var Rr=_(x=>{var hn=x&&x.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(x,"__esModule",{value:!0});x.isAsync=x.isValid=x.isDirty=x.isAborted=x.OK=x.DIRTY=x.INVALID=x.ParseStatus=x.addIssueToContext=x.EMPTY_PATH=x.makeIssue=void 0;var mn=bt(),hs=hn(Or()),yn=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 d="",c=s.filter(l=>!!l).slice().reverse();for(let l of c)d=l(i,{data:e,defaultError:d}).message;return {...n,path:a,message:d}};x.makeIssue=yn;x.EMPTY_PATH=[];function _n(r,e){let t=(0, mn.getErrorMap)(),s=(0, x.makeIssue)({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===hs.default?void 0:hs.default].filter(n=>!!n)});r.common.issues.push(s);}x.addIssueToContext=_n;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 x.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 x.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}}};x.ParseStatus=xr;x.INVALID=Object.freeze({status:"aborted"});var gn=r=>({status:"dirty",value:r});x.DIRTY=gn;var vn=r=>({status:"valid",value:r});x.OK=vn;var Tn=r=>r.status==="aborted";x.isAborted=Tn;var In=r=>r.status==="dirty";x.isDirty=In;var On=r=>r.status==="valid";x.isValid=On;var xn=r=>typeof Promise<"u"&&r instanceof Promise;x.isAsync=xn;});var ys=_(ms=>{Object.defineProperty(ms,"__esModule",{value:!0});});var _s=_(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 As=_(o=>{var At=o&&o.__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)},vs=o&&o.__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(o,"__esModule",{value:!0});o.boolean=o.bigint=o.array=o.any=o.coerce=o.ZodFirstPartyTypeKind=o.late=o.ZodSchema=o.Schema=o.custom=o.ZodReadonly=o.ZodPipeline=o.ZodBranded=o.BRAND=o.ZodNaN=o.ZodCatch=o.ZodDefault=o.ZodNullable=o.ZodOptional=o.ZodTransformer=o.ZodEffects=o.ZodPromise=o.ZodNativeEnum=o.ZodEnum=o.ZodLiteral=o.ZodLazy=o.ZodFunction=o.ZodSet=o.ZodMap=o.ZodRecord=o.ZodTuple=o.ZodIntersection=o.ZodDiscriminatedUnion=o.ZodUnion=o.ZodObject=o.ZodArray=o.ZodVoid=o.ZodNever=o.ZodUnknown=o.ZodAny=o.ZodNull=o.ZodUndefined=o.ZodSymbol=o.ZodDate=o.ZodBoolean=o.ZodBigInt=o.ZodNumber=o.ZodString=o.datetimeRegex=o.ZodType=void 0;o.NEVER=o.void=o.unknown=o.union=o.undefined=o.tuple=o.transformer=o.symbol=o.string=o.strictObject=o.set=o.record=o.promise=o.preprocess=o.pipeline=o.ostring=o.optional=o.onumber=o.oboolean=o.object=o.number=o.nullable=o.null=o.never=o.nativeEnum=o.nan=o.map=o.literal=o.lazy=o.intersection=o.instanceof=o.function=o.enum=o.effect=o.discriminatedUnion=o.date=void 0;var Pt=bt(),m=_s(),u=Rr(),f=Ke(),p=wt(),M=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}},gs=(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 p.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,d)=>{var c,l;let{message:h}=r;return i.code==="invalid_enum_value"?{message:h??d.defaultError}:typeof d.data>"u"?{message:(c=h??s)!==null&&c!==void 0?c:d.defaultError}:i.code!=="invalid_type"?{message:d.defaultError}:{message:(l=h??t)!==null&&l!==void 0?l:d.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, f.getParsedType)(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:(0, f.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, f.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, f.getParsedType)(e)},a=this._parseSync({data:e,path:n.path,parent:n});return gs(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, f.getParsedType)(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await((0, u.isAsync)(n)?n:Promise.resolve(n));return gs(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),d=()=>a.addIssue({code:p.ZodIssueCode.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(d(),!1)):i?!0:(d(),!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 D({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return j.create(this,this._def)}nullable(){return z.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return J.create(this,this._def)}promise(){return ae.create(this,this._def)}or(e){return ye.create([this,e],this._def)}and(e){return _e.create(this,e,this._def)}transform(e){return new D({...g(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new Oe({...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 xe({...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 Re.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};o.ZodType=v;o.Schema=v;o.ZodSchema=v;var En=/^c[^\s-]{8,}$/i,wn=/^[0-9a-z]+$/,bn=/^[0-9A-HJKMNP-TV-Z]{26}$/,Pn=/^[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,An=/^[a-z0-9_-]{21}$/i,kn=/^[-+]?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)?)??$/,Cn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Nn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Er,Dn=/^(?:(?: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])$/,Sn=/^(([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})))$/,Zn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ts="((\\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])))",jn=new RegExp(`^${Ts}$`);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 Mn(r){return new RegExp(`^${Is(r)}$`)}function Os(r){let e=`${Ts}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}$`)}o.datetimeRegex=Os;function Un(r,e){return !!((e==="v4"||!e)&&Dn.test(r)||(e==="v6"||!e)&&Sn.test(r))}var se=class r extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.ZodParsedType.string){let a=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(a,{code:p.ZodIssueCode.invalid_type,expected:f.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:p.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:p.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,d=e.data.length<a.value;(i||d)&&(n=this._getOrReturnCtx(e,n),i?(0, u.addIssueToContext)(n,{code:p.ZodIssueCode.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):d&&(0, u.addIssueToContext)(n,{code:p.ZodIssueCode.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty());}else if(a.kind==="email")Cn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"email",code:p.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")Er||(Er=new RegExp(Nn,"u")),Er.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"emoji",code:p.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")Pn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"uuid",code:p.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")An.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"nanoid",code:p.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")En.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"cuid",code:p.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")wn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"cuid2",code:p.ZodIssueCode.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")bn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"ulid",code:p.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:p.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:p.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:p.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:p.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:p.ZodIssueCode.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?Os(a).test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:p.ZodIssueCode.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?jn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:p.ZodIssueCode.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?Mn(a).test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{code:p.ZodIssueCode.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?kn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"duration",code:p.ZodIssueCode.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?Un(e.data,a.version)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"ip",code:p.ZodIssueCode.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?Zn.test(e.data)||(n=this._getOrReturnCtx(e,n),(0, u.addIssueToContext)(n,{validation:"base64",code:p.ZodIssueCode.invalid_string,message:a.message}),s.dirty()):f.util.assertNever(a);return {status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:p.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}};o.ZodString=se;se.create=r=>{var e;return new se({checks:[],typeName:y.ZodString,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...g(r)})};function Vn(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 ce=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)!==f.ZodParsedType.number){let a=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(a,{code:p.ZodIssueCode.invalid_type,expected:f.ZodParsedType.number,received:a.parsedType}),u.INVALID}let s,n=new u.ParseStatus;for(let a of this._def.checks)a.kind==="int"?f.util.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),(0, u.addIssueToContext)(s,{code:p.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:p.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:p.ZodIssueCode.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?Vn(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),(0, u.addIssueToContext)(s,{code:p.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:p.ZodIssueCode.not_finite,message:a.message}),n.dirty()):f.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"&&f.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)}};o.ZodNumber=ce;ce.create=r=>new ce({checks:[],typeName:y.ZodNumber,coerce:r?.coerce||!1,...g(r)});var le=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)!==f.ZodParsedType.bigint){let a=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(a,{code:p.ZodIssueCode.invalid_type,expected:f.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:p.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:p.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:p.ZodIssueCode.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):f.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}};o.ZodBigInt=le;le.create=r=>{var e;return new le({checks:[],typeName:y.ZodBigInt,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...g(r)})};var pe=class extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.ZodParsedType.boolean){let s=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(s,{code:p.ZodIssueCode.invalid_type,expected:f.ZodParsedType.boolean,received:s.parsedType}),u.INVALID}return (0, u.OK)(e.data)}};o.ZodBoolean=pe;pe.create=r=>new pe({typeName:y.ZodBoolean,coerce:r?.coerce||!1,...g(r)});var fe=class r extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.ZodParsedType.date){let a=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(a,{code:p.ZodIssueCode.invalid_type,expected:f.ZodParsedType.date,received:a.parsedType}),u.INVALID}if(isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(a,{code:p.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:p.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:p.ZodIssueCode.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):f.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}};o.ZodDate=fe;fe.create=r=>new fe({checks:[],coerce:r?.coerce||!1,typeName:y.ZodDate,...g(r)});var De=class extends v{_parse(e){if(this._getType(e)!==f.ZodParsedType.symbol){let s=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(s,{code:p.ZodIssueCode.invalid_type,expected:f.ZodParsedType.symbol,received:s.parsedType}),u.INVALID}return (0, u.OK)(e.data)}};o.ZodSymbol=De;De.create=r=>new De({typeName:y.ZodSymbol,...g(r)});var he=class extends v{_parse(e){if(this._getType(e)!==f.ZodParsedType.undefined){let s=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(s,{code:p.ZodIssueCode.invalid_type,expected:f.ZodParsedType.undefined,received:s.parsedType}),u.INVALID}return (0, u.OK)(e.data)}};o.ZodUndefined=he;he.create=r=>new he({typeName:y.ZodUndefined,...g(r)});var me=class extends v{_parse(e){if(this._getType(e)!==f.ZodParsedType.null){let s=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(s,{code:p.ZodIssueCode.invalid_type,expected:f.ZodParsedType.null,received:s.parsedType}),u.INVALID}return (0, u.OK)(e.data)}};o.ZodNull=me;me.create=r=>new me({typeName:y.ZodNull,...g(r)});var ne=class extends v{constructor(){super(...arguments),this._any=!0;}_parse(e){return (0, u.OK)(e.data)}};o.ZodAny=ne;ne.create=r=>new ne({typeName:y.ZodAny,...g(r)});var Y=class extends v{constructor(){super(...arguments),this._unknown=!0;}_parse(e){return (0, u.OK)(e.data)}};o.ZodUnknown=Y;Y.create=r=>new Y({typeName:y.ZodUnknown,...g(r)});var L=class extends v{_parse(e){let t=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(t,{code:p.ZodIssueCode.invalid_type,expected:f.ZodParsedType.never,received:t.parsedType}),u.INVALID}};o.ZodNever=L;L.create=r=>new L({typeName:y.ZodNever,...g(r)});var Se=class extends v{_parse(e){if(this._getType(e)!==f.ZodParsedType.undefined){let s=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(s,{code:p.ZodIssueCode.invalid_type,expected:f.ZodParsedType.void,received:s.parsedType}),u.INVALID}return (0, u.OK)(e.data)}};o.ZodVoid=Se;Se.create=r=>new Se({typeName:y.ZodVoid,...g(r)});var J=class r extends v{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==f.ZodParsedType.array)return (0, u.addIssueToContext)(t,{code:p.ZodIssueCode.invalid_type,expected:f.ZodParsedType.array,received:t.parsedType}),u.INVALID;if(n.exactLength!==null){let i=t.data.length>n.exactLength.value,d=t.data.length<n.exactLength.value;(i||d)&&((0, u.addIssueToContext)(t,{code:i?p.ZodIssueCode.too_big:p.ZodIssueCode.too_small,minimum:d?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:p.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:p.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,d)=>n.type._parseAsync(new M(t,i,t.path,d)))).then(i=>u.ParseStatus.mergeArray(s,i));let a=[...t.data].map((i,d)=>n.type._parseSync(new M(t,i,t.path,d)));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)}};o.ZodArray=J;J.create=(r,e)=>new J({type:r,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...g(e)});function Ne(r){if(r instanceof C){let e={};for(let t in r.shape){let s=r.shape[t];e[t]=j.create(Ne(s));}return new C({...r._def,shape:()=>e})}else return r instanceof J?new J({...r._def,type:Ne(r.element)}):r instanceof j?j.create(Ne(r.unwrap())):r instanceof z?z.create(Ne(r.unwrap())):r instanceof K?K.create(r.items.map(e=>Ne(e))):r}var C=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=f.util.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==f.ZodParsedType.object){let l=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(l,{code:p.ZodIssueCode.invalid_type,expected:f.ZodParsedType.object,received:l.parsedType}),u.INVALID}let{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),d=[];if(!(this._def.catchall instanceof L&&this._def.unknownKeys==="strip"))for(let l in n.data)i.includes(l)||d.push(l);let c=[];for(let l of i){let h=a[l],E=n.data[l];c.push({key:{status:"valid",value:l},value:h._parse(new M(n,E,n.path,l)),alwaysSet:l in n.data});}if(this._def.catchall instanceof L){let l=this._def.unknownKeys;if(l==="passthrough")for(let h of d)c.push({key:{status:"valid",value:h},value:{status:"valid",value:n.data[h]}});else if(l==="strict")d.length>0&&((0, u.addIssueToContext)(n,{code:p.ZodIssueCode.unrecognized_keys,keys:d}),s.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else {let l=this._def.catchall;for(let h of d){let E=n.data[h];c.push({key:{status:"valid",value:h},value:l._parse(new M(n,E,n.path,h)),alwaysSet:h in n.data});}}return n.common.async?Promise.resolve().then(async()=>{let l=[];for(let h of c){let E=await h.key,X=await h.value;l.push({key:E,value:X,alwaysSet:h.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,d;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:(d=m.errorUtil.errToObj(e).message)!==null&&d!==void 0?d: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 f.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 f.util.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s]);}),new r({...this._def,shape:()=>t})}deepPartial(){return Ne(this)}partial(e){let t={};return f.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 f.util.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else {let a=this.shape[s];for(;a instanceof j;)a=a._def.innerType;t[s]=a;}}),new r({...this._def,shape:()=>t})}keyof(){return xs(f.util.objectKeys(this.shape))}};o.ZodObject=C;C.create=(r,e)=>new C({shape:()=>r,unknownKeys:"strip",catchall:L.create(),typeName:y.ZodObject,...g(e)});C.strictCreate=(r,e)=>new C({shape:()=>r,unknownKeys:"strict",catchall:L.create(),typeName:y.ZodObject,...g(e)});C.lazycreate=(r,e)=>new C({shape:r,unknownKeys:"strip",catchall:L.create(),typeName:y.ZodObject,...g(e)});var ye=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(let d of a)if(d.result.status==="valid")return d.result;for(let d of a)if(d.result.status==="dirty")return t.common.issues.push(...d.ctx.common.issues),d.result;let i=a.map(d=>new p.ZodError(d.ctx.common.issues));return (0, u.addIssueToContext)(t,{code:p.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},h=c._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,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 d=i.map(c=>new p.ZodError(c));return (0, u.addIssueToContext)(t,{code:p.ZodIssueCode.invalid_union,unionErrors:d}),u.INVALID}}get options(){return this._def.options}};o.ZodUnion=ye;ye.create=(r,e)=>new ye({options:r,typeName:y.ZodUnion,...g(e)});var G=r=>r instanceof ge?G(r.schema):r instanceof D?G(r.innerType()):r instanceof ve?[r.value]:r instanceof Te?r.options:r instanceof Ie?f.util.objectValues(r.enum):r instanceof Oe?G(r._def.innerType):r instanceof he?[void 0]:r instanceof me?[null]:r instanceof j?[void 0,...G(r.unwrap())]:r instanceof z?[null,...G(r.unwrap())]:r instanceof Je||r instanceof Re?G(r.unwrap()):r instanceof xe?G(r._def.innerType):[],kt=class r extends v{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.ZodParsedType.object)return (0, u.addIssueToContext)(t,{code:p.ZodIssueCode.invalid_type,expected:f.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:p.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=G(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 d of i){if(n.has(d))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(d)}`);n.set(d,a);}}return new r({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...g(s)})}};o.ZodDiscriminatedUnion=kt;function wr(r,e){let t=(0, f.getParsedType)(r),s=(0, f.getParsedType)(e);if(r===e)return {valid:!0,data:r};if(t===f.ZodParsedType.object&&s===f.ZodParsedType.object){let n=f.util.objectKeys(e),a=f.util.objectKeys(r).filter(d=>n.indexOf(d)!==-1),i={...r,...e};for(let d of a){let c=wr(r[d],e[d]);if(!c.valid)return {valid:!1};i[d]=c.data;}return {valid:!0,data:i}}else if(t===f.ZodParsedType.array&&s===f.ZodParsedType.array){if(r.length!==e.length)return {valid:!1};let n=[];for(let a=0;a<r.length;a++){let i=r[a],d=e[a],c=wr(i,d);if(!c.valid)return {valid:!1};n.push(c.data);}return {valid:!0,data:n}}else return t===f.ZodParsedType.date&&s===f.ZodParsedType.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var _e=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 d=wr(a.value,i.value);return d.valid?(((0, u.isDirty)(a)||(0, u.isDirty)(i))&&t.dirty(),{status:t.value,value:d.data}):((0, u.addIssueToContext)(s,{code:p.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}))}};o.ZodIntersection=_e;_e.create=(r,e,t)=>new _e({left:r,right:e,typeName:y.ZodIntersection,...g(t)});var K=class r extends v{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.ZodParsedType.array)return (0, u.addIssueToContext)(s,{code:p.ZodIssueCode.invalid_type,expected:f.ZodParsedType.array,received:s.parsedType}),u.INVALID;if(s.data.length<this._def.items.length)return (0, u.addIssueToContext)(s,{code:p.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:p.ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...s.data].map((i,d)=>{let c=this._def.items[d]||this._def.rest;return c?c._parse(new M(s,i,s.path,d)):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})}};o.ZodTuple=K;K.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new K({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!==f.ZodParsedType.object)return (0, u.addIssueToContext)(s,{code:p.ZodIssueCode.invalid_type,expected:f.ZodParsedType.object,received:s.parsedType}),u.INVALID;let n=[],a=this._def.keyType,i=this._def.valueType;for(let d in s.data)n.push({key:a._parse(new M(s,d,s.path,d)),value:i._parse(new M(s,s.data[d],s.path,d)),alwaysSet:d 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:se.create(),valueType:e,typeName:y.ZodRecord,...g(t)})}};o.ZodRecord=Ct;var Ze=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!==f.ZodParsedType.map)return (0, u.addIssueToContext)(s,{code:p.ZodIssueCode.invalid_type,expected:f.ZodParsedType.map,received:s.parsedType}),u.INVALID;let n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([d,c],l)=>({key:n._parse(new M(s,d,s.path,[l,"key"])),value:a._parse(new M(s,c,s.path,[l,"value"]))}));if(s.common.async){let d=new Map;return Promise.resolve().then(async()=>{for(let c of i){let l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return u.INVALID;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),d.set(l.value,h.value);}return {status:t.value,value:d}})}else {let d=new Map;for(let c of i){let l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return u.INVALID;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),d.set(l.value,h.value);}return {status:t.value,value:d}}}};o.ZodMap=Ze;Ze.create=(r,e,t)=>new Ze({valueType:e,keyType:r,typeName:y.ZodMap,...g(t)});var je=class r extends v{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.ZodParsedType.set)return (0, u.addIssueToContext)(s,{code:p.ZodIssueCode.invalid_type,expected:f.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:p.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:p.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 h of c){if(h.status==="aborted")return u.INVALID;h.status==="dirty"&&t.dirty(),l.add(h.value);}return {status:t.value,value:l}}let d=[...s.data.values()].map((c,l)=>a._parse(new M(s,c,s.path,l)));return s.common.async?Promise.all(d).then(c=>i(c)):i(d)}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)}};o.ZodSet=je;je.create=(r,e)=>new je({valueType:r,minSize:null,maxSize:null,typeName:y.ZodSet,...g(e)});var Nt=class r extends v{constructor(){super(...arguments),this.validate=this.implement;}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.ZodParsedType.function)return (0, u.addIssueToContext)(t,{code:p.ZodIssueCode.invalid_type,expected:f.ZodParsedType.function,received:t.parsedType}),u.INVALID;function s(d,c){return (0, u.makeIssue)({data:d,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,(0, Pt.getErrorMap)(),Pt.defaultErrorMap].filter(l=>!!l),issueData:{code:p.ZodIssueCode.invalid_arguments,argumentsError:c}})}function n(d,c){return (0, u.makeIssue)({data:d,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,(0, Pt.getErrorMap)(),Pt.defaultErrorMap].filter(l=>!!l),issueData:{code:p.ZodIssueCode.invalid_return_type,returnTypeError:c}})}let a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof ae){let d=this;return (0, u.OK)(async function(...c){let l=new p.ZodError([]),h=await d._def.args.parseAsync(c,a).catch(Q=>{throw l.addIssue(s(c,Q)),l}),E=await Reflect.apply(i,this,h);return await d._def.returns._def.type.parseAsync(E,a).catch(Q=>{throw l.addIssue(n(E,Q)),l})})}else {let d=this;return (0, u.OK)(function(...c){let l=d._def.args.safeParse(c,a);if(!l.success)throw new p.ZodError([s(c,l.error)]);let h=Reflect.apply(i,this,l.data),E=d._def.returns.safeParse(h,a);if(!E.success)throw new p.ZodError([n(h,E.error)]);return E.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:K.create(e).rest(Y.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||K.create([]).rest(Y.create()),returns:t||Y.create(),typeName:y.ZodFunction,...g(s)})}};o.ZodFunction=Nt;var ge=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})}};o.ZodLazy=ge;ge.create=(r,e)=>new ge({getter:r,typeName:y.ZodLazy,...g(e)});var ve=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:p.ZodIssueCode.invalid_literal,expected:this._def.value}),u.INVALID}return {status:"valid",value:e.data}}get value(){return this._def.value}};o.ZodLiteral=ve;ve.create=(r,e)=>new ve({value:r,typeName:y.ZodLiteral,...g(e)});function xs(r,e){return new Te({values:r,typeName:y.ZodEnum,...g(e)})}var Te=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:f.util.joinValues(s),received:t.parsedType,code:p.ZodIssueCode.invalid_type}),u.INVALID}if(At(this,Ge,"f")||vs(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:p.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})}};o.ZodEnum=Te;Ge=new WeakMap;Te.create=xs;var Ie=class extends v{constructor(){super(...arguments),Ye.set(this,void 0);}_parse(e){let t=f.util.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==f.ZodParsedType.string&&s.parsedType!==f.ZodParsedType.number){let n=f.util.objectValues(t);return (0, u.addIssueToContext)(s,{expected:f.util.joinValues(n),received:s.parsedType,code:p.ZodIssueCode.invalid_type}),u.INVALID}if(At(this,Ye,"f")||vs(this,Ye,new Set(f.util.getValidEnumValues(this._def.values)),"f"),!At(this,Ye,"f").has(e.data)){let n=f.util.objectValues(t);return (0, u.addIssueToContext)(s,{received:s.data,code:p.ZodIssueCode.invalid_enum_value,options:n}),u.INVALID}return (0, u.OK)(e.data)}get enum(){return this._def.values}};o.ZodNativeEnum=Ie;Ye=new WeakMap;Ie.create=(r,e)=>new Ie({values:r,typeName:y.ZodNativeEnum,...g(e)});var ae=class extends v{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.ZodParsedType.promise&&t.common.async===!1)return (0, u.addIssueToContext)(t,{code:p.ZodIssueCode.invalid_type,expected:f.ZodParsedType.promise,received:t.parsedType}),u.INVALID;let s=t.parsedType===f.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})))}};o.ZodPromise=ae;ae.create=(r,e)=>new ae({type:r,typeName:y.ZodPromise,...g(e)});var D=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 d=>{if(t.value==="aborted")return u.INVALID;let c=await this._def.schema._parseAsync({data:d,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 d=this._def.schema._parseSync({data:i,path:s.path,parent:s});return d.status==="aborted"?u.INVALID:d.status==="dirty"||t.value==="dirty"?(0, u.DIRTY)(d.value):d}}if(n.type==="refinement"){let i=d=>{let c=n.refinement(d,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 d};if(s.common.async===!1){let d=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return d.status==="aborted"?u.INVALID:(d.status==="dirty"&&t.dirty(),i(d.value),{status:t.value,value:d.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(d=>d.status==="aborted"?u.INVALID:(d.status==="dirty"&&t.dirty(),i(d.value).then(()=>({status:t.value,value:d.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 d=n.transform(i.value,a);if(d instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return {status:t.value,value:d}}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(d=>({status:t.value,value:d})):i);f.util.assertNever(n);}};o.ZodEffects=D;o.ZodTransformer=D;D.create=(r,e,t)=>new D({schema:r,typeName:y.ZodEffects,effect:e,...g(t)});D.createWithPreprocess=(r,e,t)=>new D({schema:e,effect:{type:"preprocess",transform:r},typeName:y.ZodEffects,...g(t)});var j=class extends v{_parse(e){return this._getType(e)===f.ZodParsedType.undefined?(0, u.OK)(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};o.ZodOptional=j;j.create=(r,e)=>new j({innerType:r,typeName:y.ZodOptional,...g(e)});var z=class extends v{_parse(e){return this._getType(e)===f.ZodParsedType.null?(0, u.OK)(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};o.ZodNullable=z;z.create=(r,e)=>new z({innerType:r,typeName:y.ZodNullable,...g(e)});var Oe=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return t.parsedType===f.ZodParsedType.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};o.ZodDefault=Oe;Oe.create=(r,e)=>new Oe({innerType:r,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...g(e)});var xe=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 p.ZodError(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new p.ZodError(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};o.ZodCatch=xe;xe.create=(r,e)=>new xe({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)!==f.ZodParsedType.nan){let s=this._getOrReturnCtx(e);return (0, u.addIssueToContext)(s,{code:p.ZodIssueCode.invalid_type,expected:f.ZodParsedType.nan,received:s.parsedType}),u.INVALID}return {status:"valid",value:e.data}}};o.ZodNaN=Me;Me.create=r=>new Me({typeName:y.ZodNaN,...g(r)});o.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}};o.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})}};o.ZodPipeline=Xe;var Re=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}};o.ZodReadonly=Re;Re.create=(r,e)=>new Re({innerType:r,typeName:y.ZodReadonly,...g(e)});function Rs(r,e={},t){return r?ne.create().superRefine((s,n)=>{var a,i;if(!r(s)){let d=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,c=(i=(a=d.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof d=="string"?{message:d}:d;n.addIssue({code:"custom",...l,fatal:c});}}):ne.create()}o.custom=Rs;o.late={object:C.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=o.ZodFirstPartyTypeKind||(o.ZodFirstPartyTypeKind={}));var Ln=(r,e={message:`Input not instance of ${r.name}`})=>Rs(t=>t instanceof r,e);o.instanceof=Ln;var Es=se.create;o.string=Es;var ws=ce.create;o.number=ws;var $n=Me.create;o.nan=$n;var qn=le.create;o.bigint=qn;var bs=pe.create;o.boolean=bs;var Fn=fe.create;o.date=Fn;var Wn=De.create;o.symbol=Wn;var Kn=he.create;o.undefined=Kn;var zn=me.create;o.null=zn;var Bn=ne.create;o.any=Bn;var Gn=Y.create;o.unknown=Gn;var Yn=L.create;o.never=Yn;var Jn=Se.create;o.void=Jn;var Xn=J.create;o.array=Xn;var Qn=C.create;o.object=Qn;var Hn=C.strictCreate;o.strictObject=Hn;var ea=ye.create;o.union=ea;var ta=kt.create;o.discriminatedUnion=ta;var ra=_e.create;o.intersection=ra;var sa=K.create;o.tuple=sa;var na=Ct.create;o.record=na;var aa=Ze.create;o.map=aa;var ia=je.create;o.set=ia;var oa=Nt.create;o.function=oa;var da=ge.create;o.lazy=da;var ua=ve.create;o.literal=ua;var ca=Te.create;o.enum=ca;var la=Ie.create;o.nativeEnum=la;var pa=ae.create;o.promise=pa;var Ps=D.create;o.effect=Ps;o.transformer=Ps;var fa=j.create;o.optional=fa;var ha=z.create;o.nullable=ha;var ma=D.createWithPreprocess;o.preprocess=ma;var ya=Xe.create;o.pipeline=ya;var _a=()=>Es().optional();o.ostring=_a;var ga=()=>ws().optional();o.onumber=ga;var va=()=>bs().optional();o.oboolean=va;o.coerce={string:r=>se.create({...r,coerce:!0}),number:r=>ce.create({...r,coerce:!0}),boolean:r=>pe.create({...r,coerce:!0}),bigint:r=>le.create({...r,coerce:!0}),date:r=>fe.create({...r,coerce:!0})};o.NEVER=u.INVALID;});var br=_(U=>{var Ta=U&&U.__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];}),Ue=U&&U.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Ta(e,r,t);};Object.defineProperty(U,"__esModule",{value:!0});Ue(bt(),U);Ue(Rr(),U);Ue(ys(),U);Ue(Ke(),U);Ue(As(),U);Ue(wt(),U);});var Dt=_(N=>{var ks=N&&N.__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];}),Ia=N&&N.__setModuleDefault||(Object.create?function(r,e){Object.defineProperty(r,"default",{enumerable:!0,value:e});}:function(r,e){r.default=e;}),Oa=N&&N.__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 Ia(e,r),e},xa=N&&N.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&ks(e,r,t);};Object.defineProperty(N,"__esModule",{value:!0});N.z=void 0;var Cs=Oa(br());N.z=Cs;xa(br(),N);N.default=Cs;});var Pr=_(St=>{Object.defineProperty(St,"__esModule",{value:!0});St.parseAnyDef=void 0;function Ra(){return {}}St.parseAnyDef=Ra;});var Ar=_(jt=>{Object.defineProperty(jt,"__esModule",{value:!0});jt.parseArrayDef=void 0;var Ea=Dt(),Zt=te(),wa=P();function ba(r,e){let t={type:"array"};return r.type?._def?.typeName!==Ea.ZodFirstPartyTypeKind.ZodAny&&(t.items=(0, wa.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=ba;});var kr=_(Mt=>{Object.defineProperty(Mt,"__esModule",{value:!0});Mt.parseBigintDef=void 0;var Ee=te();function Pa(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, Ee.setResponseValueAndErrors)(t,"minimum",s.value,s.message,e):(0, Ee.setResponseValueAndErrors)(t,"exclusiveMinimum",s.value,s.message,e):(s.inclusive||(t.exclusiveMinimum=!0),(0, Ee.setResponseValueAndErrors)(t,"minimum",s.value,s.message,e));break;case"max":e.target==="jsonSchema7"?s.inclusive?(0, Ee.setResponseValueAndErrors)(t,"maximum",s.value,s.message,e):(0, Ee.setResponseValueAndErrors)(t,"exclusiveMaximum",s.value,s.message,e):(s.inclusive||(t.exclusiveMaximum=!0),(0, Ee.setResponseValueAndErrors)(t,"maximum",s.value,s.message,e));break;case"multipleOf":(0, Ee.setResponseValueAndErrors)(t,"multipleOf",s.value,s.message,e);break}return t}Mt.parseBigintDef=Pa;});var Cr=_(Ut=>{Object.defineProperty(Ut,"__esModule",{value:!0});Ut.parseBooleanDef=void 0;function Aa(){return {type:"boolean"}}Ut.parseBooleanDef=Aa;});var Nr=_(Vt=>{Object.defineProperty(Vt,"__esModule",{value:!0});Vt.parseBrandedDef=void 0;var ka=P();function Ca(r,e){return (0, ka.parseDef)(r.type._def,e)}Vt.parseBrandedDef=Ca;});var Dr=_(Lt=>{Object.defineProperty(Lt,"__esModule",{value:!0});Lt.parseCatchDef=void 0;var Na=P(),Da=(r,e)=>(0, Na.parseDef)(r.innerType._def,e);Lt.parseCatchDef=Da;});var Sr=_($t=>{Object.defineProperty($t,"__esModule",{value:!0});$t.parseDateDef=void 0;var Ns=te();function Ds(r,e,t){let s=t??e.dateStrategy;if(Array.isArray(s))return {anyOf:s.map((n,a)=>Ds(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 Sa(r,e)}}$t.parseDateDef=Ds;var Sa=(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, Ns.setResponseValueAndErrors)(t,"minimum",s.value,s.message,e);break;case"max":(0, Ns.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 Za=P();function ja(r,e){return {...(0, Za.parseDef)(r.innerType._def,e),default:r.defaultValue()}}qt.parseDefaultDef=ja;});var jr=_(Ft=>{Object.defineProperty(Ft,"__esModule",{value:!0});Ft.parseEffectsDef=void 0;var Ma=P();function Ua(r,e){return e.effectStrategy==="input"?(0, Ma.parseDef)(r.schema._def,e):{}}Ft.parseEffectsDef=Ua;});var Mr=_(Wt=>{Object.defineProperty(Wt,"__esModule",{value:!0});Wt.parseEnumDef=void 0;function Va(r){return {type:"string",enum:r.values}}Wt.parseEnumDef=Va;});var Ur=_(Kt=>{Object.defineProperty(Kt,"__esModule",{value:!0});Kt.parseIntersectionDef=void 0;var Ss=P(),La=r=>"type"in r&&r.type==="string"?!1:"allOf"in r;function $a(r,e){let t=[(0, Ss.parseDef)(r.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),(0, Ss.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(La(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:d,...c}=a;i=c;}else s=void 0;n.push(i);}}),n.length?{allOf:n,...s}:void 0}Kt.parseIntersectionDef=$a;});var Vr=_(zt=>{Object.defineProperty(zt,"__esModule",{value:!0});zt.parseLiteralDef=void 0;function qa(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=qa;});var Bt=_(S=>{Object.defineProperty(S,"__esModule",{value:!0});S.parseStringDef=S.zodPatterns=void 0;var we=te();S.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 Fa(r,e){let t={type:"string"};function s(n){return e.patternStrategy==="escape"?Wa(n):n}if(r.checks)for(let n of r.checks)switch(n.kind){case"min":(0, we.setResponseValueAndErrors)(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,n.value):n.value,n.message,e);break;case"max":(0, we.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":$(t,"email",n.message,e);break;case"format:idn-email":$(t,"idn-email",n.message,e);break;case"pattern:zod":q(t,S.zodPatterns.email,n.message,e);break}break;case"url":$(t,"uri",n.message,e);break;case"uuid":$(t,"uuid",n.message,e);break;case"regex":q(t,n.regex,n.message,e);break;case"cuid":q(t,S.zodPatterns.cuid,n.message,e);break;case"cuid2":q(t,S.zodPatterns.cuid2,n.message,e);break;case"startsWith":q(t,RegExp(`^${s(n.value)}`),n.message,e);break;case"endsWith":q(t,RegExp(`${s(n.value)}$`),n.message,e);break;case"datetime":$(t,"date-time",n.message,e);break;case"date":$(t,"date",n.message,e);break;case"time":$(t,"time",n.message,e);break;case"duration":$(t,"duration",n.message,e);break;case"length":(0, we.setResponseValueAndErrors)(t,"minLength",typeof t.minLength=="number"?Math.max(t.minLength,n.value):n.value,n.message,e),(0, we.setResponseValueAndErrors)(t,"maxLength",typeof t.maxLength=="number"?Math.min(t.maxLength,n.value):n.value,n.message,e);break;case"includes":{q(t,RegExp(s(n.value)),n.message,e);break}case"ip":{n.version!=="v6"&&$(t,"ipv4",n.message,e),n.version!=="v4"&&$(t,"ipv6",n.message,e);break}case"emoji":q(t,S.zodPatterns.emoji,n.message,e);break;case"ulid":{q(t,S.zodPatterns.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{$(t,"binary",n.message,e);break}case"contentEncoding:base64":{(0, we.setResponseValueAndErrors)(t,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{q(t,S.zodPatterns.base64,n.message,e);break}}break}case"nanoid":q(t,S.zodPatterns.nanoid,n.message,e);}return t}S.parseStringDef=Fa;var Wa=r=>Array.from(r).map(e=>/[a-zA-Z0-9]/.test(e)?e:`\\${e}`).join(""),$=(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, we.setResponseValueAndErrors)(r,"format",e,t,s);},q=(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:Zs(e,s),...t&&s.errorMessages&&{errorMessage:{pattern:t}}})):(0, we.setResponseValueAndErrors)(r,"pattern",Zs(e,s),t,s);},Zs=(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,d=!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]/)){d?(n+=s[c],n+=`${s[c-2]}-${s[c]}`.toUpperCase(),d=!1):s[c+1]==="-"&&s[c+2]?.match(/[a-z]/)?(n+=s[c],d=!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
+ ]))`;continue}else if(s[c]==="$"){n+=`($|(?=[\r
20
+ ]))`;continue}}if(t.s&&s[c]==="."){n+=i?`${s[c]}\r
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(),js=P(),Ka=Bt();function za(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, js.parseDef)(r.valueType._def,{...e,currentPath:[...e.currentPath,"properties",n]})??{}}),{}),additionalProperties:!1};let t={type:"object",additionalProperties:(0, js.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, Ka.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=za;});var $r=_(Jt=>{Object.defineProperty(Jt,"__esModule",{value:!0});Jt.parseMapDef=void 0;var Ms=P(),Ba=Yt();function Ga(r,e){if(e.mapStrategy==="record")return (0, Ba.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=Ga;});var qr=_(Xt=>{Object.defineProperty(Xt,"__esModule",{value:!0});Xt.parseNativeEnumDef=void 0;function Ya(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=Ya;});var Fr=_(Qt=>{Object.defineProperty(Qt,"__esModule",{value:!0});Qt.parseNeverDef=void 0;function Ja(){return {not:{}}}Qt.parseNeverDef=Ja;});var Wr=_(Ht=>{Object.defineProperty(Ht,"__esModule",{value:!0});Ht.parseNullDef=void 0;function Xa(r){return r.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}Ht.parseNullDef=Xa;});var er=_(ie=>{Object.defineProperty(ie,"__esModule",{value:!0});ie.parseUnionDef=ie.primitiveMappings=void 0;var Qa=P();ie.primitiveMappings={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Ha(r,e){if(e.target==="openApi3")return Us(r,e);let t=r.options instanceof Map?Array.from(r.options.values()):r.options;if(t.every(s=>s._def.typeName in ie.primitiveMappings&&(!s._def.checks||!s._def.checks.length))){let s=t.reduce((n,a)=>{let i=ie.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,d)=>d.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 Us(r,e)}ie.parseUnionDef=Ha;var Us=(r,e)=>{let t=(r.options instanceof Map?Array.from(r.options.values()):r.options).map((s,n)=>(0, Qa.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 Vs=P(),Ls=er();function ei(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:Ls.primitiveMappings[r.innerType._def.typeName],nullable:!0}:{type:[Ls.primitiveMappings[r.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let s=(0, Vs.parseDef)(r.innerType._def,{...e,currentPath:[...e.currentPath]});return s&&"$ref"in s?{allOf:[s],nullable:!0}:s&&{...s,nullable:!0}}let t=(0, Vs.parseDef)(r.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return t&&{anyOf:[t,{type:"null"}]}}tr.parseNullableDef=ei;});var zr=_(rr=>{Object.defineProperty(rr,"__esModule",{value:!0});rr.parseNumberDef=void 0;var oe=te();function ti(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, oe.addErrorMessage)(t,"type",s.message,e);break;case"min":e.target==="jsonSchema7"?s.inclusive?(0, oe.setResponseValueAndErrors)(t,"minimum",s.value,s.message,e):(0, oe.setResponseValueAndErrors)(t,"exclusiveMinimum",s.value,s.message,e):(s.inclusive||(t.exclusiveMinimum=!0),(0, oe.setResponseValueAndErrors)(t,"minimum",s.value,s.message,e));break;case"max":e.target==="jsonSchema7"?s.inclusive?(0, oe.setResponseValueAndErrors)(t,"maximum",s.value,s.message,e):(0, oe.setResponseValueAndErrors)(t,"exclusiveMaximum",s.value,s.message,e):(s.inclusive||(t.exclusiveMaximum=!0),(0, oe.setResponseValueAndErrors)(t,"maximum",s.value,s.message,e));break;case"multipleOf":(0, oe.setResponseValueAndErrors)(t,"multipleOf",s.value,s.message,e);break}return t}rr.parseNumberDef=ti;});var Gr=_(Ve=>{Object.defineProperty(Ve,"__esModule",{value:!0});Ve.parseObjectDef=Ve.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 ri(r,e){Object.keys(r.shape()).reduce((s,n)=>{let a=r.shape()[n],i=a.isOptional();i||(a={...a._def.innerSchema});let d=(0, Qe.parseDef)(a._def,{...e,currentPath:[...e.currentPath,"properties",n],propertyPath:[...e.currentPath,"properties",n]});return d!==void 0&&(s.properties[n]=d,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}Ve.parseObjectDefX=ri;function si(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}Ve.parseObjectDef=si;});var Yr=_(sr=>{Object.defineProperty(sr,"__esModule",{value:!0});sr.parseOptionalDef=void 0;var $s=P(),ni=(r,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return (0, $s.parseDef)(r.innerType._def,e);let t=(0, $s.parseDef)(r.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return t?{anyOf:[{not:{}},t]}:{}};sr.parseOptionalDef=ni;});var Jr=_(ar=>{Object.defineProperty(ar,"__esModule",{value:!0});ar.parsePipelineDef=void 0;var nr=P(),ai=(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=ai;});var Xr=_(ir=>{Object.defineProperty(ir,"__esModule",{value:!0});ir.parsePromiseDef=void 0;var ii=P();function oi(r,e){return (0, ii.parseDef)(r.type._def,e)}ir.parsePromiseDef=oi;});var Qr=_(or=>{Object.defineProperty(or,"__esModule",{value:!0});or.parseSetDef=void 0;var qs=te(),di=P();function ui(r,e){let s={type:"array",uniqueItems:!0,items:(0, di.parseDef)(r.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return r.minSize&&(0, qs.setResponseValueAndErrors)(s,"minItems",r.minSize.value,r.minSize.message,e),r.maxSize&&(0, qs.setResponseValueAndErrors)(s,"maxItems",r.maxSize.value,r.maxSize.message,e),s}or.parseSetDef=ui;});var es=_(dr=>{Object.defineProperty(dr,"__esModule",{value:!0});dr.parseTupleDef=void 0;var Hr=P();function ci(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=ci;});var ts=_(ur=>{Object.defineProperty(ur,"__esModule",{value:!0});ur.parseUndefinedDef=void 0;function li(){return {not:{}}}ur.parseUndefinedDef=li;});var rs=_(cr=>{Object.defineProperty(cr,"__esModule",{value:!0});cr.parseUnknownDef=void 0;function pi(){return {}}cr.parseUnknownDef=pi;});var ss=_(lr=>{Object.defineProperty(lr,"__esModule",{value:!0});lr.parseReadonlyDef=void 0;var fi=P(),hi=(r,e)=>(0, fi.parseDef)(r.innerType._def,e);lr.parseReadonlyDef=hi;});var P=_(pr=>{Object.defineProperty(pr,"__esModule",{value:!0});pr.parseDef=void 0;var I=Dt(),mi=Pr(),yi=Ar(),_i=kr(),gi=Cr(),vi=Nr(),Ti=Dr(),Ii=Sr(),Oi=Zr(),xi=jr(),Ri=Mr(),Ei=Ur(),wi=Vr(),bi=$r(),Pi=qr(),Ai=Fr(),ki=Wr(),Ci=Kr(),Ni=zr(),Di=Gr(),Si=Yr(),Zi=Jr(),ji=Xr(),Mi=Yt(),Ui=Qr(),Vi=Bt(),Li=es(),$i=ts(),qi=er(),Fi=rs(),Wi=ss(),Ki=Rt();function Fs(r,e,t=!1){let s=e.seen.get(r);if(e.override){let i=e.override?.(r,e,s,t);if(i!==Ki.ignoreOverride)return i}if(s&&!t){let i=zi(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=Gi(r,r.typeName,e);return a&&Yi(r,e,a),n.jsonSchema=a,a}pr.parseDef=Fs;var zi=(r,e)=>{switch(e.$refStrategy){case"root":return {$ref:r.path.join("/")};case"relative":return {$ref:Bi(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}},Bi=(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("/")},Gi=(r,e,t)=>{switch(e){case I.ZodFirstPartyTypeKind.ZodString:return (0, Vi.parseStringDef)(r,t);case I.ZodFirstPartyTypeKind.ZodNumber:return (0, Ni.parseNumberDef)(r,t);case I.ZodFirstPartyTypeKind.ZodObject:return (0, Di.parseObjectDef)(r,t);case I.ZodFirstPartyTypeKind.ZodBigInt:return (0, _i.parseBigintDef)(r,t);case I.ZodFirstPartyTypeKind.ZodBoolean:return (0, gi.parseBooleanDef)();case I.ZodFirstPartyTypeKind.ZodDate:return (0, Ii.parseDateDef)(r,t);case I.ZodFirstPartyTypeKind.ZodUndefined:return (0, $i.parseUndefinedDef)();case I.ZodFirstPartyTypeKind.ZodNull:return (0, ki.parseNullDef)(t);case I.ZodFirstPartyTypeKind.ZodArray:return (0, yi.parseArrayDef)(r,t);case I.ZodFirstPartyTypeKind.ZodUnion:case I.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:return (0, qi.parseUnionDef)(r,t);case I.ZodFirstPartyTypeKind.ZodIntersection:return (0, Ei.parseIntersectionDef)(r,t);case I.ZodFirstPartyTypeKind.ZodTuple:return (0, Li.parseTupleDef)(r,t);case I.ZodFirstPartyTypeKind.ZodRecord:return (0, Mi.parseRecordDef)(r,t);case I.ZodFirstPartyTypeKind.ZodLiteral:return (0, wi.parseLiteralDef)(r,t);case I.ZodFirstPartyTypeKind.ZodEnum:return (0, Ri.parseEnumDef)(r);case I.ZodFirstPartyTypeKind.ZodNativeEnum:return (0, Pi.parseNativeEnumDef)(r);case I.ZodFirstPartyTypeKind.ZodNullable:return (0, Ci.parseNullableDef)(r,t);case I.ZodFirstPartyTypeKind.ZodOptional:return (0, Si.parseOptionalDef)(r,t);case I.ZodFirstPartyTypeKind.ZodMap:return (0, bi.parseMapDef)(r,t);case I.ZodFirstPartyTypeKind.ZodSet:return (0, Ui.parseSetDef)(r,t);case I.ZodFirstPartyTypeKind.ZodLazy:return Fs(r.getter()._def,t);case I.ZodFirstPartyTypeKind.ZodPromise:return (0, ji.parsePromiseDef)(r,t);case I.ZodFirstPartyTypeKind.ZodNaN:case I.ZodFirstPartyTypeKind.ZodNever:return (0, Ai.parseNeverDef)();case I.ZodFirstPartyTypeKind.ZodEffects:return (0, xi.parseEffectsDef)(r,t);case I.ZodFirstPartyTypeKind.ZodAny:return (0, mi.parseAnyDef)();case I.ZodFirstPartyTypeKind.ZodUnknown:return (0, Fi.parseUnknownDef)();case I.ZodFirstPartyTypeKind.ZodDefault:return (0, Oi.parseDefaultDef)(r,t);case I.ZodFirstPartyTypeKind.ZodBranded:return (0, vi.parseBrandedDef)(r,t);case I.ZodFirstPartyTypeKind.ZodReadonly:return (0, Wi.parseReadonlyDef)(r,t);case I.ZodFirstPartyTypeKind.ZodCatch:return (0, Ti.parseCatchDef)(r,t);case I.ZodFirstPartyTypeKind.ZodPipeline:return (0, Zi.parsePipelineDef)(r,t);case I.ZodFirstPartyTypeKind.ZodFunction:case I.ZodFirstPartyTypeKind.ZodVoid:case I.ZodFirstPartyTypeKind.ZodSymbol:return;default:return (s=>{})()}},Yi=(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 Ws=P(),Ji=Tr(),Xi=(r,e)=>{let t=(0, Ji.getRefs)(e),s=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[l,h])=>({...c,[l]:(0, Ws.parseDef)(h._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, Ws.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 d=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"?d.$schema="http://json-schema.org/draft-07/schema#":t.target==="jsonSchema2019-09"&&(d.$schema="https://json-schema.org/draft/2019-09/schema#"),d};fr.zodToJsonSchema=Xi;});var Ks=_(T=>{var Qi=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];}),O=T&&T.__exportStar||function(r,e){for(var t in r)t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Qi(e,r,t);};Object.defineProperty(T,"__esModule",{value:!0});O(Rt(),T);O(Tr(),T);O(te(),T);O(P(),T);O(Pr(),T);O(Ar(),T);O(kr(),T);O(Cr(),T);O(Nr(),T);O(Dr(),T);O(Sr(),T);O(Zr(),T);O(jr(),T);O(Mr(),T);O(Ur(),T);O(Vr(),T);O($r(),T);O(qr(),T);O(Fr(),T);O(Wr(),T);O(Kr(),T);O(zr(),T);O(Gr(),T);O(Yr(),T);O(Jr(),T);O(Xr(),T);O(ss(),T);O(Yt(),T);O(Qr(),T);O(Bt(),T);O(es(),T);O(ts(),T);O(er(),T);O(rs(),T);O(ns(),T);var Hi=ns();T.default=Hi.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 V=(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_API_KEY_ERROR="MissingApiKeyError",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))(V||{});var rt=(s=>(s.POST="POST",s.GET="GET",s.OPTIONS="OPTIONS",s))(rt||{});var B=class extends Error{data},st=class extends B{statusCode=404},Z=class extends B{statusCode=400},H=class extends B{statusCode=401},Pe=class extends B{statusCode=500},nt=class extends B{statusCode=409};var at=class extends Z{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 Z{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 Z{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 Z{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 Z{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 Z{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 Z{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 b={info:r=>Ae__default.default.blue(r),warning:r=>Ae__default.default.yellow(r),error:r=>Ae__default.default.red(r),success:r=>Ae__default.default.green(r),underline:r=>Ae__default.default.underline(r),bold:r=>Ae__default.default.bold(r)},A={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 os=(r,e="https://api.novu.co/v1")=>({post:async(t,s)=>await fetch(e+t,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`ApiKey ${r}`},body:JSON.stringify(s)})});var pt=class extends B{code="MethodNotAllowedError";statusCode=405;message=`Method not allowed. Please use one of ${vr(rt)}`},qe=class extends Z{code="InvalidActionError";constructor(e,t){super(`Invalid query string: \`action\`=\`${e}\`. Please use one of ${vr(t)}`);}};var ft=class extends Pe{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.`);}},ee=class extends st{constructor(e,t){super(`${lt(e)} with id: \`${t}\` does not exist. Please provide a valid id.`);}},ke=class extends Pe{constructor(e,t){super(`Failed to execute ${lt(e)} with id: \`${t}\`. Please try again later.`);}};var ht=class extends ee{code="ProviderNotFoundError";constructor(e){super("provider",e);}},mt=class extends ke{code="ProviderExecutionFailedError";constructor(e){super("workflow",e);}};var yt=class extends H{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 H{code="SignatureNotFoundError";constructor(){super("Signature not found. Please provide a signature in the `novu-signature` header");}},gt=class extends H{code="SignatureInvalidError";constructor(){super("Signature is invalid. Please provide a valid signature in the `novu-signature` header");}},vt=class extends H{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 H{code="SigningKeyNotFoundError";constructor(){super("Signature key not found. Please provide a valid key in the Client constructor `config.apiKey`");}};var It=class extends ee{code="StepNotFoundError";constructor(e){super("step",e);}};var We=class extends ee{code="WorkflowNotFoundError";constructor(e){super("workflow",e);}},Ot=class extends Fe{code="WorkflowAlreadyExistsError";constructor(e){super("workflow",e);}};var xt=class{ajv;compiledSchemas;constructor(){this.ajv=new en__default.default({useDefaults:!0,removeAdditional:"all"}),tn__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 Ks().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 zs=[new hr,new xt],Bs=async(r,e)=>{for(let t of zs)if(t.isSchema(r))return t.validate(e,r);throw new Error("Invalid schema")},Gs=r=>{for(let e of zs)if(e.isSchema(r))return e.transformToJsonSchema(r);throw new Error("Invalid schema")};var Ys={name:"@novu/framework",version:"0.24.3-alpha.10",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=Ys.version,mr="2024-06-26";jsonSchemaFaker.JSONSchemaFaker.random.shuffle=function(){return ["[placeholder]"]};jsonSchemaFaker.JSONSchemaFaker.option({useDefaultValue:!0,alwaysFakeOptionals:!0});var _r=class{discoveredWorkflows=[];templateEngine=new liquidjs.Liquid;apiKey;version=He;strictAuthentication;constructor(e){let t=this.buildOptions(e);this.apiKey=t.apiKey,this.strictAuthentication=t.strictAuthentication;}buildOptions(e){let t={apiKey:void 0,strictAuthentication:!0};return e?.apiKey!==void 0?t.apiKey=e.apiKey:process.env.NOVU_API_KEY!==void 0&&(t.apiKey=process.env.NOVU_API_KEY),e?.strictAuthentication!==void 0?t.strictAuthentication=e.strictAuthentication:process.env.NODE_ENV==="development"&&(t.strictAuthentication=!1),t}addWorkflows(e){for(let t of e){if(this.discoveredWorkflows.some(s=>s.workflowId===t.workflowId))throw new Ot(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 It(t)}getRegisteredWorkflows(){return this.discoveredWorkflows}discover(){return {workflows:this.getRegisteredWorkflows()}}mock(e){return jsonSchemaFaker.JSONSchemaFaker.generate(Gs(e))}async validate(e,t,s,n,a,i,d){let c=await Bs(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,d,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),d=ro(e),c=await this.createStepControls(i,d),l=e.action==="preview";if(!l&&await this.shouldSkip(a?.skip,c))return t({options:{skip:!0}}),{};let h=this.previewStep.bind(this),E=this.executeStep.bind(this),Q=await(l?h:E)(e,{...i,providers:i.providers.map(be=>{let Le=a?.providers?.[be.type];if(!Le)throw new ht(be.type);return {...be,resolve:Le}}),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(),d={outputs:{},providers:{},options:{}},c,l=new Promise(de=>{c=de;}),h=de=>{c(),d=de;},E;try{if(e.action==="execute"&&!e.payload&&!e.data)throw new $e(e.workflowId,{message:"Event `payload` is required"});let de=await this.createExecutionPayload(e,a);await Promise.race([l,a.execute({payload:de,environment:{},inputs:{},controls:{},subscriber:e.subscriber,step:{email:this.executeStepFactory(e,h),sms:this.executeStepFactory(e,h),inApp:this.executeStepFactory(e,h),digest:this.executeStepFactory(e,h),delay:this.executeStepFactory(e,h),push:this.executeStepFactory(e,h),chat:this.executeStepFactory(e,h),custom:this.executeStepFactory(e,h)}})]);}catch(de){E=de;}let X=process.hrtime(i),Q=X[0],be=X[1],Le=Q*1e3+be/1e6,Js=E?A.ERROR:A.SUCCESS,Xs=e.action==="execute"?"Executed":e.action==="preview"?"Previewed":"Invalid action";if(console.log(`${Js} ${Xs} workflowId: \`${e.workflowId}\``),this.prettyPrintExecute(e,Le,E),E)throw E;return {outputs:d.outputs,providers:d.providers,options:d.options,metadata:{status:"success",error:!1,duration:Le}}}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?A.ERROR:A.SUCCESS,a=e.action==="execute"?"Executed":e.action==="preview"?"Previewed":"Invalid action",i=s?"Failed to execute":a,d=s?b.error:b.success,c=`${n} ${i} workflowId: '${e.workflowId}`;console.log(`
24
+ ${b.bold(d(c))}'`),console.log(` \u251C ${A.STEP} stepId: '${e.stepId}'`),console.log(` \u251C ${A.ACTION} action: '${e.action}'`),console.log(` \u2514 ${A.DURATION} duration: '${t.toFixed(2)}ms'
25
+ `);}async executeProviders(e,t,s){return t.providers.reduce(async(n,a)=>{let i=await n,d=this.previewProvider.bind(this),c=this.executeProvider.bind(this),h=await(e.action==="preview"?d:c)(e,t,a,s);return {...i,[a.type]:h}},Promise.resolve({}))}previewProvider(e,t,s,n){return console.log(` ${A.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),d=await s.resolve({controls:i,outputs:n}),c=await this.validate(d,s.outputs.unknownSchema,"step","output",e.workflowId,t.stepId,s.type);return a.succeed(`Executed provider: \`${s.type}\``),c}else a.stopAndPersist({symbol:A.HYDRATED,text:`Hydrated provider: \`${s.type}\``});}catch(i){throw a.stopAndPersist({symbol:A.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),d=await this.validate(i,t.outputs.unknownSchema,"step","output",e.workflowId,t.stepId),c=await this.executeProviders(e,t,d);return s.succeed(`Executed stepId: \`${t.stepId}\``),{outputs:d,providers:c}}catch(n){throw s.stopAndPersist({prefixText:"",symbol:A.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:A.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:A.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),d=await this.validate(i,t.outputs.unknownSchema,"step","output",e.workflowId,t.stepId);return s.stopAndPersist({symbol:A.MOCK,text:`Mocked stepId: \`${t.stepId}\``}),{outputs:d,providers:await this.executeProviders(e,t,d)}}else {let n=this.mock(t.results.schema);return s.stopAndPersist({symbol:A.MOCK,text:`Mocked stepId: \`${t.stepId}\``}),{outputs:n,providers:await this.executeProviders(e,t,n)}}}catch(n){throw s.stopAndPersist({symbol:A.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 ro(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=os(this.client.apiKey),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")||"",d=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")||"",h={};try{s==="POST"&&(h=await e.body());}catch{}try{n!=="health-check"&&this.validateHmac(h,d);let E=this.getPostActionMap(h,a,i,n,c,l),X=this.getGetActionMap(a,i);if(s==="POST")return await this.handlePostAction(n,E);if(s==="GET")return await this.handleGetAction(n,X);if(s==="OPTIONS")return this.createResponse(200,{})}catch(E){return this.handleError(E)}return this.createError(new pt(s))}getPostActionMap(e,t,s,n,a,i){return {trigger:this.triggerAction({workflowId:t,...e}),execute:async()=>{let d=await this.client.executeWorkflow({...e,workflowId:t,stepId:s,action:n});return this.createResponse(200,d)},preview:async()=>{let d=await this.client.executeWorkflow({...e,workflowId:t,stepId:s,action:n});return this.createResponse(200,d)}}}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(V).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.apiKey)throw new Tt;let[s,n]=t.split(",");if(!s||!n)throw new gt;let[a,i]=s.split("="),[d,c]=n.split("=");if(Number(a)<Date.now()-1500)throw new vt;if(!(this.hashHmac(this.client.apiKey,`${i}.${JSON.stringify(e)}`)===c))throw new yt}hashHmac(e,t){return crypto.createHmac("sha256",e).update(t).digest("hex")}};var ao="express",Gu=r=>new gr({frameworkName:ao,...r,handler:(t,s)=>({body:()=>t.body,headers:n=>{let a=t.headers[n];return Array.isArray(a)?a[0]:a},method:()=>t.method||"GET",url:()=>{let n=t.headers.host||"",a=n?.includes("://")?"":`${t.protocol||"https"}://`;return new URL(t.originalUrl||t.url||"",`${a}${n||""}`)},queryString:n=>{let a=t.query[n];return Array.isArray(a)?a[0]:a},transformResponse:({body:n,headers:a,status:i})=>(Object.entries(a).forEach(([d,c])=>{s.setHeader(d,c);}),s.status(i).send(n))})}).createHandler();
27
+
28
+ exports.frameworkName = ao;
29
+ exports.serve = Gu;
package/dist/h3.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import * as h3 from 'h3';
2
+ import { H3Event } from 'h3';
3
+ import { l as SupportedFrameworkName, a as ServeHandlerOptions } from './handler-y6PZIhGI.js';
4
+ import 'json-schema-to-ts';
5
+ import 'zod';
6
+ import '@novu/shared';
7
+
8
+ declare const frameworkName: SupportedFrameworkName;
9
+ declare const serve: (options: ServeHandlerOptions) => (event: H3Event<h3.EventHandlerRequest>) => Promise<Promise<void>>;
10
+
11
+ export { frameworkName, serve };