@authhero/kysely-adapter 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/kysely-adapter.cjs +1 -1
- package/dist/kysely-adapter.d.ts +706 -648
- package/dist/kysely-adapter.iife.js +1 -1
- package/dist/kysely-adapter.mjs +710 -649
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
var kyselyAdapter=function(){"use strict";var qi=Object.defineProperty;var Wi=(Q,ae,R)=>ae in Q?qi(Q,ae,{enumerable:!0,configurable:!0,writable:!0,value:R}):Q[ae]=R;var _n=(Q,ae,R)=>Wi(Q,typeof ae!="symbol"?ae+"":ae,R);var Q=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});_n(this,"res");_n(this,"status");this.res=t==null?void 0:t.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}};function ae(n){return async(e,t)=>{const{identities:r,...s}=t,a={...s,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),tenant_id:e,email_verified:t.email_verified?1:0,is_social:t.is_social?1:0};try{await n.insertInto("users").values(a).execute()}catch(o){throw o.code==="SQLITE_CONSTRAINT_UNIQUE"||o.message.includes("AlreadyExists")?new Q(409,{message:"User already exists"}):(console.log(o.message),new Q(500,{message:`${o.code}, ${o.message}`}))}return{...a,email:a.email||"",email_verified:a.email_verified===1,is_social:a.is_social===1}}}function R(n){const e={...n};for(const t in e)e[t]===null?delete e[t]:typeof e[t]=="object"&&(Array.isArray(e[t])?e[t]=e[t].map(R):e[t]=R(e[t]));return e}function Yn(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}function Gn(n,e){var t;return((t=n==null?void 0:n._def)===null||t===void 0?void 0:t.typeName)===e}function Ye(n,e){const t=n.ZodType.prototype[e];n.ZodType.prototype[e]=function(...r){const s=t.apply(this,r);return s._def.openapi=this._def.openapi,s}}function Xn(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(s,a){var o,c,d,u,l,T;const A=typeof s=="string"?a:s,L=A??{},{param:te}=L,de=Yn(L,["param"]),we=Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o._internal),typeof s=="string"?{refId:s}:void 0),xe=Object.assign(Object.assign(Object.assign({},(c=this._def.openapi)===null||c===void 0?void 0:c.metadata),de),!((u=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||u===void 0)&&u.param||te?{param:Object.assign(Object.assign({},(T=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||T===void 0?void 0:T.param),te)}:void 0),be=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(we).length>0?{_internal:we}:void 0),Object.keys(xe).length>0?{metadata:xe}:void 0)}));if(Gn(this,"ZodObject")){const Je=this.extend;be.extend=function(...He){var ne,re,se,Te,Ee,Ae;const Re=Je.apply(this,He);return Re._def.openapi={_internal:{extendedFrom:!((re=(ne=this._def.openapi)===null||ne===void 0?void 0:ne._internal)===null||re===void 0)&&re.refId?{refId:(Te=(se=this._def.openapi)===null||se===void 0?void 0:se._internal)===null||Te===void 0?void 0:Te.refId,schema:this}:(Ee=this._def.openapi)===null||Ee===void 0?void 0:Ee._internal.extendedFrom},metadata:(Ae=Re._def.openapi)===null||Ae===void 0?void 0:Ae.metadata},Re}}return be},Ye(n,"optional"),Ye(n,"nullable"),Ye(n,"default"),Ye(n,"transform"),Ye(n,"refine");const e=n.ZodObject.prototype.deepPartial;n.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),a=e.apply(this),o=a._def.shape();return Object.entries(o).forEach(([c,d])=>{var u,l;d._def.openapi=(l=(u=s[c])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.openapi}),a._def.openapi=void 0,a};const t=n.ZodObject.prototype.pick;n.ZodObject.prototype.pick=function(...s){const a=t.apply(this,s);return a._def.openapi=void 0,a};const r=n.ZodObject.prototype.omit;n.ZodObject.prototype.omit=function(...s){const a=r.apply(this,s);return a._def.openapi=void 0,a}}new Set(".\\+*[^]$()");var I;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const a={};for(const o of s)a[o]=o;return a},n.getValidEnumValues=s=>{const a=n.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),o={};for(const c of a)o[c]=s[c];return n.objectValues(o)},n.objectValues=s=>n.objectKeys(s).map(function(a){return s[a]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&a.push(o);return a},n.find=(s,a)=>{for(const o of s)if(a(o))return o},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(I||(I={}));var Ht;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Ht||(Ht={}));const _=I.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ue=n=>{switch(typeof n){case"undefined":return _.undefined;case"string":return _.string;case"number":return isNaN(n)?_.nan:_.number;case"boolean":return _.boolean;case"function":return _.function;case"bigint":return _.bigint;case"symbol":return _.symbol;case"object":return Array.isArray(n)?_.array:n===null?_.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?_.promise:typeof Map<"u"&&n instanceof Map?_.map:typeof Set<"u"&&n instanceof Set?_.set:typeof Date<"u"&&n instanceof Date?_.date:_.object;default:return _.unknown}},p=I.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"]),er=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class V extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const 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){const t=e||function(a){return a.message},r={_errors:[]},s=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(t(o));else{let c=r,d=0;for(;d<o.path.length;){const u=o.path[d];d===o.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(o))):c[u]=c[u]||{_errors:[]},c=c[u],d++}}};return s(this),r}static assert(e){if(!(e instanceof V))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,I.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}V.create=n=>new V(n);const $e=(n,e)=>{let t;switch(n.code){case p.invalid_type:n.received===_.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case p.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,I.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:t=`Unrecognized key(s) in object: ${I.joinValues(n.keys,", ")}`;break;case p.invalid_union:t="Invalid input";break;case p.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${I.joinValues(n.options)}`;break;case p.invalid_enum_value:t=`Invalid enum value. Expected ${I.joinValues(n.options)}, received '${n.received}'`;break;case p.invalid_arguments:t="Invalid function arguments";break;case p.invalid_return_type:t="Invalid function return type";break;case p.invalid_date:t="Invalid date";break;case p.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:I.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case p.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case p.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case p.custom:t="Invalid input";break;case p.invalid_intersection_types:t="Intersection results could not be merged";break;case p.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case p.not_finite:t="Number must be finite";break;default:t=e.defaultError,I.assertNever(n)}return{message:t}};let gn=$e;function tr(n){gn=n}function At(){return gn}const Rt=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,a=[...t,...s.path||[]],o={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let c="";const d=r.filter(u=>!!u).slice().reverse();for(const u of d)c=u(o,{data:e,defaultError:c}).message;return{...s,path:a,message:c}},nr=[];function f(n,e){const t=At(),r=Rt({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===$e?void 0:$e].filter(s=>!!s)});n.common.issues.push(r)}class ${constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return b;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const a=await s.key,o=await s.value;r.push({key:a,value:o})}return $.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:a,value:o}=s;if(a.status==="aborted"||o.status==="aborted")return b;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[a.value]=o.value)}return{status:e.value,value:r}}}const b=Object.freeze({status:"aborted"}),$t=n=>({status:"dirty",value:n}),D=n=>({status:"valid",value:n}),Yt=n=>n.status==="aborted",Gt=n=>n.status==="dirty",Ge=n=>n.status==="valid",Xe=n=>typeof Promise<"u"&&n instanceof Promise;function Pt(n,e,t,r){if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function yn(n,e,t,r,s){if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}var y;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(y||(y={}));var et,tt;class J{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const vn=(n,e)=>{if(Ge(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new V(n.common.issues);return this._error=t,this._error}}};function O(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{var c,d;const{message:u}=n;return a.code==="invalid_enum_value"?{message:u??o.defaultError}:typeof o.data>"u"?{message:(c=u??r)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(d=u??t)!==null&&d!==void 0?d:o.defaultError}},description:s}}class Z{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 ue(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ue(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $,ctx:{common:e.parent.common,data:e.data,parsedType:ue(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Xe(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ue(e)},a=this._parseSync({data:e,path:s.path,parent:s});return vn(s,a)}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ue(e)},s=this._parse({data:e,path:r.path,parent:r}),a=await(Xe(s)?s:Promise.resolve(s));return vn(r,a)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const o=e(s),c=()=>a.addIssue({code:p.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new B({schema:this,typeName:k.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Y.create(this,this._def)}nullable(){return me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return z.create(this,this._def)}promise(){return Le.create(this,this._def)}or(e){return at.create([this,e],this._def)}and(e){return it.create(this,e,this._def)}transform(e){return new B({...O(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new lt({...O(this._def),innerType:this,defaultValue:t,typeName:k.ZodDefault})}brand(){return new tn({typeName:k.ZodBranded,type:this,...O(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new pt({...O(this._def),innerType:this,catchValue:t,typeName:k.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ht.create(this,e)}readonly(){return ft.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const rr=/^c[^\s-]{8,}$/i,sr=/^[0-9a-z]+$/,ar=/^[0-9A-HJKMNP-TV-Z]{26}$/,ir=/^[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,or=/^[a-z0-9_-]{21}$/i,cr=/^[-+]?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)?)??$/,dr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ur="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Xt;const lr=/^(?:(?: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])$/,pr=/^(([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})))$/,hr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,kn="((\\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])))",fr=new RegExp(`^${kn}$`);function wn(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function mr(n){return new RegExp(`^${wn(n)}$`)}function xn(n){let e=`${kn}T${wn(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function _r(n,e){return!!((e==="v4"||!e)&&lr.test(n)||(e==="v6"||!e)&&pr.test(n))}class F extends Z{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){const s=this._getOrReturnCtx(e);return f(s,{code:p.invalid_type,expected:_.string,received:s.parsedType}),b}const t=new $;let r;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:p.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:p.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,o=e.data.length<s.value;(a||o)&&(r=this._getOrReturnCtx(e,r),a?f(r,{code:p.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&f(r,{code:p.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")dr.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"email",code:p.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")Xt||(Xt=new RegExp(ur,"u")),Xt.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"emoji",code:p.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")ir.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"uuid",code:p.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")or.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"nanoid",code:p.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")rr.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"cuid",code:p.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")sr.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"cuid2",code:p.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")ar.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"ulid",code:p.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),f(r,{validation:"url",code:p.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"regex",code:p.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(r=this._getOrReturnCtx(e,r),f(r,{code:p.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(r=this._getOrReturnCtx(e,r),f(r,{code:p.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(r=this._getOrReturnCtx(e,r),f(r,{code:p.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?xn(s).test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:p.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?fr.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:p.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?mr(s).test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:p.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?cr.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"duration",code:p.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?_r(e.data,s.version)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"ip",code:p.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?hr.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"base64",code:p.invalid_string,message:s.message}),t.dirty()):I.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:p.invalid_string,...y.errToObj(r)})}_addCheck(e){return new F({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...y.errToObj(e)})}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...y.errToObj(e==null?void 0: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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...y.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...y.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...y.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...y.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...y.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...y.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...y.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...y.errToObj(t)})}nonempty(e){return this.min(1,y.errToObj(e))}trim(){return new F({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new F({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new F({...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(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}F.create=n=>{var e;return new F({checks:[],typeName:k.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...O(n)})};function gr(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,a=parseInt(n.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return a%o/Math.pow(10,s)}class le extends Z{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==_.number){const s=this._getOrReturnCtx(e);return f(s,{code:p.invalid_type,expected:_.number,received:s.parsedType}),b}let t;const r=new $;for(const s of this._def.checks)s.kind==="int"?I.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),f(t,{code:p.invalid_type,expected:"integer",received:"float",message:s.message}),r.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="multipleOf"?gr(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),f(t,{code:p.not_finite,message:s.message}),r.dirty()):I.assertNever(s);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,y.toString(t))}setLimit(e,t,r,s){return new le({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:y.toString(s)}]})}_addCheck(e){return new le({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:y.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const 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"&&I.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}le.create=n=>new le({checks:[],typeName:k.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...O(n)});class pe extends Z{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==_.bigint){const s=this._getOrReturnCtx(e);return f(s,{code:p.invalid_type,expected:_.bigint,received:s.parsedType}),b}let t;const r=new $;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):I.assertNever(s);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,y.toString(t))}setLimit(e,t,r,s){return new pe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:y.toString(s)}]})}_addCheck(e){return new pe({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}pe.create=n=>{var e;return new pe({checks:[],typeName:k.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...O(n)})};class nt extends Z{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.boolean,received:t.parsedType}),b}return D(e.data)}}nt.create=n=>new nt({typeName:k.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...O(n)});class Oe extends Z{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){const s=this._getOrReturnCtx(e);return f(s,{code:p.invalid_type,expected:_.date,received:s.parsedType}),b}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return f(s,{code:p.invalid_date}),b}const t=new $;let r;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:p.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:p.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):I.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Oe({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:y.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:y.toString(t)})}get minDate(){let e=null;for(const 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(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Oe.create=n=>new Oe({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:k.ZodDate,...O(n)});class Dt extends Z{_parse(e){if(this._getType(e)!==_.symbol){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.symbol,received:t.parsedType}),b}return D(e.data)}}Dt.create=n=>new Dt({typeName:k.ZodSymbol,...O(n)});class rt extends Z{_parse(e){if(this._getType(e)!==_.undefined){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.undefined,received:t.parsedType}),b}return D(e.data)}}rt.create=n=>new rt({typeName:k.ZodUndefined,...O(n)});class st extends Z{_parse(e){if(this._getType(e)!==_.null){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.null,received:t.parsedType}),b}return D(e.data)}}st.create=n=>new st({typeName:k.ZodNull,...O(n)});class Pe extends Z{constructor(){super(...arguments),this._any=!0}_parse(e){return D(e.data)}}Pe.create=n=>new Pe({typeName:k.ZodAny,...O(n)});class Se extends Z{constructor(){super(...arguments),this._unknown=!0}_parse(e){return D(e.data)}}Se.create=n=>new Se({typeName:k.ZodUnknown,...O(n)});class ie extends Z{_parse(e){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.never,received:t.parsedType}),b}}ie.create=n=>new ie({typeName:k.ZodNever,...O(n)});class Mt extends Z{_parse(e){if(this._getType(e)!==_.undefined){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.void,received:t.parsedType}),b}return D(e.data)}}Mt.create=n=>new Mt({typeName:k.ZodVoid,...O(n)});class z extends Z{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==_.array)return f(t,{code:p.invalid_type,expected:_.array,received:t.parsedType}),b;if(s.exactLength!==null){const o=t.data.length>s.exactLength.value,c=t.data.length<s.exactLength.value;(o||c)&&(f(t,{code:o?p.too_big:p.too_small,minimum:c?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(f(t,{code:p.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(f(t,{code:p.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>s.type._parseAsync(new J(t,o,t.path,c)))).then(o=>$.mergeArray(r,o));const a=[...t.data].map((o,c)=>s.type._parseSync(new J(t,o,t.path,c)));return $.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new z({...this._def,minLength:{value:e,message:y.toString(t)}})}max(e,t){return new z({...this._def,maxLength:{value:e,message:y.toString(t)}})}length(e,t){return new z({...this._def,exactLength:{value:e,message:y.toString(t)}})}nonempty(e){return this.min(1,e)}}z.create=(n,e)=>new z({type:n,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...O(e)});function De(n){if(n instanceof N){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=Y.create(De(r))}return new N({...n._def,shape:()=>e})}else return n instanceof z?new z({...n._def,type:De(n.element)}):n instanceof Y?Y.create(De(n.unwrap())):n instanceof me?me.create(De(n.unwrap())):n instanceof H?H.create(n.items.map(e=>De(e))):n}class N extends Z{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=I.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==_.object){const d=this._getOrReturnCtx(e);return f(d,{code:p.invalid_type,expected:_.object,received:d.parsedType}),b}const{status:t,ctx:r}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof ie&&this._def.unknownKeys==="strip"))for(const d in r.data)a.includes(d)||o.push(d);const c=[];for(const d of a){const u=s[d],l=r.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new J(r,l,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof ie){const d=this._def.unknownKeys;if(d==="passthrough")for(const u of o)c.push({key:{status:"valid",value:u},value:{status:"valid",value:r.data[u]}});else if(d==="strict")o.length>0&&(f(r,{code:p.unrecognized_keys,keys:o}),t.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const u of o){const l=r.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new J(r,l,r.path,u)),alwaysSet:u in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const d=[];for(const u of c){const l=await u.key,T=await u.value;d.push({key:l,value:T,alwaysSet:u.alwaysSet})}return d}).then(d=>$.mergeObjectSync(t,d)):$.mergeObjectSync(t,c)}get shape(){return this._def.shape()}strict(e){return y.errToObj,new N({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,a,o,c;const d=(o=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,r).message)!==null&&o!==void 0?o:r.defaultError;return t.code==="unrecognized_keys"?{message:(c=y.errToObj(e).message)!==null&&c!==void 0?c:d}:{message:d}}}:{}})}strip(){return new N({...this._def,unknownKeys:"strip"})}passthrough(){return new N({...this._def,unknownKeys:"passthrough"})}extend(e){return new N({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new N({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:k.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new N({...this._def,catchall:e})}pick(e){const t={};return I.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new N({...this._def,shape:()=>t})}omit(e){const t={};return I.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new N({...this._def,shape:()=>t})}deepPartial(){return De(this)}partial(e){const t={};return I.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new N({...this._def,shape:()=>t})}required(e){const t={};return I.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Y;)s=s._def.innerType;t[r]=s}}),new N({...this._def,shape:()=>t})}keyof(){return bn(I.objectKeys(this.shape))}}N.create=(n,e)=>new N({shape:()=>n,unknownKeys:"strip",catchall:ie.create(),typeName:k.ZodObject,...O(e)}),N.strictCreate=(n,e)=>new N({shape:()=>n,unknownKeys:"strict",catchall:ie.create(),typeName:k.ZodObject,...O(e)}),N.lazycreate=(n,e)=>new N({shape:n,unknownKeys:"strip",catchall:ie.create(),typeName:k.ZodObject,...O(e)});class at extends Z{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(a){for(const c of a)if(c.result.status==="valid")return c.result;for(const c of a)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=a.map(c=>new V(c.ctx.common.issues));return f(t,{code:p.invalid_union,unionErrors:o}),b}if(t.common.async)return Promise.all(r.map(async a=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(s);{let a;const o=[];for(const d of r){const u={...t,common:{...t.common,issues:[]},parent:null},l=d._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const c=o.map(d=>new V(d));return f(t,{code:p.invalid_union,unionErrors:c}),b}}get options(){return this._def.options}}at.create=(n,e)=>new at({options:n,typeName:k.ZodUnion,...O(e)});const he=n=>n instanceof ct?he(n.schema):n instanceof B?he(n.innerType()):n instanceof dt?[n.value]:n instanceof fe?n.options:n instanceof ut?I.objectValues(n.enum):n instanceof lt?he(n._def.innerType):n instanceof rt?[void 0]:n instanceof st?[null]:n instanceof Y?[void 0,...he(n.unwrap())]:n instanceof me?[null,...he(n.unwrap())]:n instanceof tn||n instanceof ft?he(n.unwrap()):n instanceof pt?he(n._def.innerType):[];class Lt extends Z{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.object)return f(t,{code:p.invalid_type,expected:_.object,received:t.parsedType}),b;const r=this.discriminator,s=t.data[r],a=this.optionsMap.get(s);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}):(f(t,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),b)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const a of t){const o=he(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(s.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);s.set(c,a)}}return new Lt({typeName:k.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...O(r)})}}function en(n,e){const t=ue(n),r=ue(e);if(n===e)return{valid:!0,data:n};if(t===_.object&&r===_.object){const s=I.objectKeys(e),a=I.objectKeys(n).filter(c=>s.indexOf(c)!==-1),o={...n,...e};for(const c of a){const d=en(n[c],e[c]);if(!d.valid)return{valid:!1};o[c]=d.data}return{valid:!0,data:o}}else if(t===_.array&&r===_.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<n.length;a++){const o=n[a],c=e[a],d=en(o,c);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return t===_.date&&r===_.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class it extends Z{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(a,o)=>{if(Yt(a)||Yt(o))return b;const c=en(a.value,o.value);return c.valid?((Gt(a)||Gt(o))&&t.dirty(),{status:t.value,value:c.data}):(f(r,{code:p.invalid_intersection_types}),b)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,o])=>s(a,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}it.create=(n,e,t)=>new it({left:n,right:e,typeName:k.ZodIntersection,...O(t)});class H extends Z{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==_.array)return f(r,{code:p.invalid_type,expected:_.array,received:r.parsedType}),b;if(r.data.length<this._def.items.length)return f(r,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),b;!this._def.rest&&r.data.length>this._def.items.length&&(f(r,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...r.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new J(r,a,r.path,o)):null}).filter(a=>!!a);return r.common.async?Promise.all(s).then(a=>$.mergeArray(t,a)):$.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new H({...this._def,rest:e})}}H.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new H({items:n,typeName:k.ZodTuple,rest:null,...O(e)})};class ot extends Z{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==_.object)return f(r,{code:p.invalid_type,expected:_.object,received:r.parsedType}),b;const s=[],a=this._def.keyType,o=this._def.valueType;for(const c in r.data)s.push({key:a._parse(new J(r,c,r.path,c)),value:o._parse(new J(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?$.mergeObjectAsync(t,s):$.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof Z?new ot({keyType:e,valueType:t,typeName:k.ZodRecord,...O(r)}):new ot({keyType:F.create(),valueType:e,typeName:k.ZodRecord,...O(t)})}}class Vt extends Z{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==_.map)return f(r,{code:p.invalid_type,expected:_.map,received:r.parsedType}),b;const s=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([c,d],u)=>({key:s._parse(new J(r,c,r.path,[u,"key"])),value:a._parse(new J(r,d,r.path,[u,"value"]))}));if(r.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const d of o){const u=await d.key,l=await d.value;if(u.status==="aborted"||l.status==="aborted")return b;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),c.set(u.value,l.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const d of o){const u=d.key,l=d.value;if(u.status==="aborted"||l.status==="aborted")return b;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),c.set(u.value,l.value)}return{status:t.value,value:c}}}}Vt.create=(n,e,t)=>new Vt({valueType:e,keyType:n,typeName:k.ZodMap,...O(t)});class Ze extends Z{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==_.set)return f(r,{code:p.invalid_type,expected:_.set,received:r.parsedType}),b;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(f(r,{code:p.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(f(r,{code:p.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function o(d){const u=new Set;for(const l of d){if(l.status==="aborted")return b;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const c=[...r.data.values()].map((d,u)=>a._parse(new J(r,d,r.path,u)));return r.common.async?Promise.all(c).then(d=>o(d)):o(c)}min(e,t){return new Ze({...this._def,minSize:{value:e,message:y.toString(t)}})}max(e,t){return new Ze({...this._def,maxSize:{value:e,message:y.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ze.create=(n,e)=>new Ze({valueType:n,minSize:null,maxSize:null,typeName:k.ZodSet,...O(e)});class Me extends Z{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.function)return f(t,{code:p.invalid_type,expected:_.function,received:t.parsedType}),b;function r(c,d){return Rt({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,At(),$e].filter(u=>!!u),issueData:{code:p.invalid_arguments,argumentsError:d}})}function s(c,d){return Rt({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,At(),$e].filter(u=>!!u),issueData:{code:p.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Le){const c=this;return D(async function(...d){const u=new V([]),l=await c._def.args.parseAsync(d,a).catch(A=>{throw u.addIssue(r(d,A)),u}),T=await Reflect.apply(o,this,l);return await c._def.returns._def.type.parseAsync(T,a).catch(A=>{throw u.addIssue(s(T,A)),u})})}else{const c=this;return D(function(...d){const u=c._def.args.safeParse(d,a);if(!u.success)throw new V([r(d,u.error)]);const l=Reflect.apply(o,this,u.data),T=c._def.returns.safeParse(l,a);if(!T.success)throw new V([s(l,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Me({...this._def,args:H.create(e).rest(Se.create())})}returns(e){return new Me({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new Me({args:e||H.create([]).rest(Se.create()),returns:t||Se.create(),typeName:k.ZodFunction,...O(r)})}}class ct extends Z{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ct.create=(n,e)=>new ct({getter:n,typeName:k.ZodLazy,...O(e)});class dt extends Z{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:p.invalid_literal,expected:this._def.value}),b}return{status:"valid",value:e.data}}get value(){return this._def.value}}dt.create=(n,e)=>new dt({value:n,typeName:k.ZodLiteral,...O(e)});function bn(n,e){return new fe({values:n,typeName:k.ZodEnum,...O(e)})}class fe extends Z{constructor(){super(...arguments),et.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return f(t,{expected:I.joinValues(r),received:t.parsedType,code:p.invalid_type}),b}if(Pt(this,et)||yn(this,et,new Set(this._def.values)),!Pt(this,et).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return f(t,{received:t.data,code:p.invalid_enum_value,options:r}),b}return D(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return fe.create(e,{...this._def,...t})}exclude(e,t=this._def){return fe.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}et=new WeakMap,fe.create=bn;class ut extends Z{constructor(){super(...arguments),tt.set(this,void 0)}_parse(e){const t=I.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==_.string&&r.parsedType!==_.number){const s=I.objectValues(t);return f(r,{expected:I.joinValues(s),received:r.parsedType,code:p.invalid_type}),b}if(Pt(this,tt)||yn(this,tt,new Set(I.getValidEnumValues(this._def.values))),!Pt(this,tt).has(e.data)){const s=I.objectValues(t);return f(r,{received:r.data,code:p.invalid_enum_value,options:s}),b}return D(e.data)}get enum(){return this._def.values}}tt=new WeakMap,ut.create=(n,e)=>new ut({values:n,typeName:k.ZodNativeEnum,...O(e)});class Le extends Z{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.promise&&t.common.async===!1)return f(t,{code:p.invalid_type,expected:_.promise,received:t.parsedType}),b;const r=t.parsedType===_.promise?t.data:Promise.resolve(t.data);return D(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Le.create=(n,e)=>new Le({type:n,typeName:k.ZodPromise,...O(e)});class B extends Z{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===k.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:o=>{f(r,o),o.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const o=s.transform(r.data,a);if(r.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return b;const d=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return d.status==="aborted"?b:d.status==="dirty"||t.value==="dirty"?$t(d.value):d});{if(t.value==="aborted")return b;const c=this._def.schema._parseSync({data:o,path:r.path,parent:r});return c.status==="aborted"?b:c.status==="dirty"||t.value==="dirty"?$t(c.value):c}}if(s.type==="refinement"){const o=c=>{const d=s.refinement(c,a);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){const c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?b:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?b:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ge(o))return o;const c=s.transform(o.value,a);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Ge(o)?Promise.resolve(s.transform(o.value,a)).then(c=>({status:t.value,value:c})):o);I.assertNever(s)}}B.create=(n,e,t)=>new B({schema:n,typeName:k.ZodEffects,effect:e,...O(t)}),B.createWithPreprocess=(n,e,t)=>new B({schema:e,effect:{type:"preprocess",transform:n},typeName:k.ZodEffects,...O(t)});class Y extends Z{_parse(e){return this._getType(e)===_.undefined?D(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Y.create=(n,e)=>new Y({innerType:n,typeName:k.ZodOptional,...O(e)});class me extends Z{_parse(e){return this._getType(e)===_.null?D(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}me.create=(n,e)=>new me({innerType:n,typeName:k.ZodNullable,...O(e)});class lt extends Z{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===_.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}lt.create=(n,e)=>new lt({innerType:n,typeName:k.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...O(e)});class pt extends Z{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Xe(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new V(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new V(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}pt.create=(n,e)=>new pt({innerType:n,typeName:k.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...O(e)});class Ut extends Z{_parse(e){if(this._getType(e)!==_.nan){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.nan,received:t.parsedType}),b}return{status:"valid",value:e.data}}}Ut.create=n=>new Ut({typeName:k.ZodNaN,...O(n)});const yr=Symbol("zod_brand");class tn extends Z{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class ht extends Z{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?b:s.status==="dirty"?(t.dirty(),$t(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?b:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new ht({in:e,out:t,typeName:k.ZodPipeline})}}class ft extends Z{_parse(e){const t=this._def.innerType._parse(e),r=s=>(Ge(s)&&(s.value=Object.freeze(s.value)),s);return Xe(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}ft.create=(n,e)=>new ft({innerType:n,typeName:k.ZodReadonly,...O(e)});function Tn(n,e={},t){return n?Pe.create().superRefine((r,s)=>{var a,o;if(!n(r)){const c=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,d=(o=(a=c.fatal)!==null&&a!==void 0?a:t)!==null&&o!==void 0?o:!0,u=typeof c=="string"?{message:c}:c;s.addIssue({code:"custom",...u,fatal:d})}}):Pe.create()}const vr={object:N.lazycreate};var k;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(k||(k={}));const kr=(n,e={message:`Input not instance of ${n.name}`})=>Tn(t=>t instanceof n,e),On=F.create,Sn=le.create,wr=Ut.create,xr=pe.create,Zn=nt.create,br=Oe.create,Tr=Dt.create,Or=rt.create,Sr=st.create,Zr=Pe.create,jr=Se.create,Ir=ie.create,Cr=Mt.create,Nr=z.create,Er=N.create,Ar=N.strictCreate,Rr=at.create,$r=Lt.create,Pr=it.create,Dr=H.create,Mr=ot.create,Lr=Vt.create,Vr=Ze.create,Ur=Me.create,Fr=ct.create,zr=dt.create,Br=fe.create,qr=ut.create,Wr=Le.create,jn=B.create,Kr=Y.create,Qr=me.create,Jr=B.createWithPreprocess,Hr=ht.create;var i=Object.freeze({__proto__:null,defaultErrorMap:$e,setErrorMap:tr,getErrorMap:At,makeIssue:Rt,EMPTY_PATH:nr,addIssueToContext:f,ParseStatus:$,INVALID:b,DIRTY:$t,OK:D,isAborted:Yt,isDirty:Gt,isValid:Ge,isAsync:Xe,get util(){return I},get objectUtil(){return Ht},ZodParsedType:_,getParsedType:ue,ZodType:Z,datetimeRegex:xn,ZodString:F,ZodNumber:le,ZodBigInt:pe,ZodBoolean:nt,ZodDate:Oe,ZodSymbol:Dt,ZodUndefined:rt,ZodNull:st,ZodAny:Pe,ZodUnknown:Se,ZodNever:ie,ZodVoid:Mt,ZodArray:z,ZodObject:N,ZodUnion:at,ZodDiscriminatedUnion:Lt,ZodIntersection:it,ZodTuple:H,ZodRecord:ot,ZodMap:Vt,ZodSet:Ze,ZodFunction:Me,ZodLazy:ct,ZodLiteral:dt,ZodEnum:fe,ZodNativeEnum:ut,ZodPromise:Le,ZodEffects:B,ZodTransformer:B,ZodOptional:Y,ZodNullable:me,ZodDefault:lt,ZodCatch:pt,ZodNaN:Ut,BRAND:yr,ZodBranded:tn,ZodPipeline:ht,ZodReadonly:ft,custom:Tn,Schema:Z,ZodSchema:Z,late:vr,get ZodFirstPartyTypeKind(){return k},coerce:{string:n=>F.create({...n,coerce:!0}),number:n=>le.create({...n,coerce:!0}),boolean:n=>nt.create({...n,coerce:!0}),bigint:n=>pe.create({...n,coerce:!0}),date:n=>Oe.create({...n,coerce:!0})},any:Zr,array:Nr,bigint:xr,boolean:Zn,date:br,discriminatedUnion:$r,effect:jn,enum:Br,function:Ur,instanceof:kr,intersection:Pr,lazy:Fr,literal:zr,map:Lr,nan:wr,nativeEnum:qr,never:Ir,null:Sr,nullable:Qr,number:Sn,object:Er,oboolean:()=>Zn().optional(),onumber:()=>Sn().optional(),optional:Kr,ostring:()=>On().optional(),pipeline:Hr,preprocess:Jr,promise:Wr,record:Mr,set:Vr,strictObject:Ar,string:On,symbol:Tr,transformer:jn,tuple:Dr,undefined:Or,union:Rr,unknown:jr,void:Cr,NEVER:b,ZodIssueCode:p,quotelessJson:er,ZodError:V});Xn(i),i.object({start:i.number(),limit:i.number(),length:i.number()});const nn=i.object({created_at:i.string(),updated_at:i.string()}),Yr=i.object({email:i.string().optional(),email_verified:i.boolean().optional(),name:i.string().optional(),username:i.string().optional(),given_name:i.string().optional(),phone_number:i.string().optional(),phone_verified:i.boolean().optional(),family_name:i.string().optional()}).catchall(i.any()),Gr=i.object({connection:i.string(),user_id:i.string(),provider:i.string(),isSocial:i.boolean(),access_token:i.string().optional(),access_token_secret:i.string().optional(),refresh_token:i.string().optional(),profileData:Yr.optional()}),In=i.object({email:i.string().optional(),username:i.string().optional(),given_name:i.string().optional(),family_name:i.string().optional(),nickname:i.string().optional(),name:i.string().optional(),picture:i.string().optional(),locale:i.string().optional(),linked_to:i.string().optional(),profileData:i.string().optional(),user_id:i.string().optional()});In.extend({email_verified:i.boolean().default(!1),verify_email:i.boolean().optional(),last_ip:i.string().optional(),last_login:i.string().optional(),user_id:i.string().optional(),provider:i.string().default("email"),connection:i.string().default("email")}).extend(nn.shape).extend({user_id:i.string(),email:i.string(),is_social:i.boolean(),login_count:i.number(),identities:i.array(Gr).optional()}),In.extend({email:i.string(),login_count:i.number(),multifactor:i.array(i.string()).optional(),last_ip:i.string().optional(),last_login:i.string().optional(),user_id:i.string()}).catchall(i.any());const Xr=i.object({id:i.string(),name:i.string(),allowed_web_origins:i.string().transform(n=>n===null?"":n).default(""),allowed_callback_urls:i.string().transform(n=>n===null?"":n).default(""),allowed_logout_urls:i.string().transform(n=>n===null?"":n).default(""),email_validation:i.enum(["enabled","disabled","enforced"]).default("enforced"),client_secret:i.string().default(""),disable_sign_ups:i.boolean().default(!1)});i.object({created_at:i.string().transform(n=>n===null?"":n),updated_at:i.string().transform(n=>n===null?"":n)}).extend(Xr.shape);var Cn=(n=>(n.TOKEN="token",n.TOKEN_ID_TOKEN="token id_token",n.CODE="code",n))(Cn||{}),Nn=(n=>(n.QUERY="query",n.FRAGMENT="fragment",n.FORM_POST="form_post",n.WEB_MESSAGE="web_message",n))(Nn||{}),En=(n=>(n.S265="S256",n.plain="plain",n))(En||{});const rn=i.object({client_id:i.string(),vendor_id:i.string().optional(),response_type:i.nativeEnum(Cn).optional(),response_mode:i.nativeEnum(Nn).optional(),redirect_uri:i.string().optional(),audience:i.string().optional(),state:i.string().optional(),nonce:i.string().optional(),scope:i.string().optional(),code_challenge_method:i.nativeEnum(En).optional(),code_challenge:i.string().optional(),username:i.string().optional()}),es=i.object({authParams:rn,code:i.string(),user_id:i.string(),created_at:i.string(),expires_at:i.string(),used_at:i.string().optional()});i.object({...es.shape,created_at:i.string()}),i.object({colors:i.object({primary:i.string(),page_background:i.object({type:i.string().optional(),start:i.string().optional(),end:i.string().optional(),angle_deg:i.number().optional()}).optional()}).optional(),logo_url:i.string().optional(),favicon_url:i.string().optional(),font:i.object({url:i.string()}).optional()});const ts=i.object({id:i.string().optional(),name:i.string(),client_id:i.string().optional(),client_secret:i.string().optional(),authorization_endpoint:i.string().optional(),response_type:i.custom().optional(),response_mode:i.custom().optional(),private_key:i.string().optional(),kid:i.string().optional(),team_id:i.string().optional(),token_endpoint:i.string().optional(),token_exchange_basic_auth:i.boolean().optional(),userinfo_endpoint:i.string().optional(),scope:i.string().optional()}),sn=i.object({id:i.string(),created_at:i.string().transform(n=>n===null?"":n),updated_at:i.string().transform(n=>n===null?"":n)}).extend(ts.shape),ns=i.object({domain:i.string(),dkim_private_key:i.string().optional(),dkim_public_key:i.string().optional(),email_api_key:i.string().optional(),email_service:i.union([i.literal("mailgun"),i.literal("mailchannels")]).optional()}),An=i.object({id:i.string(),name:i.string(),domains:i.array(ns),allowed_callback_urls:i.array(i.string()),allowed_logout_urls:i.array(i.string()),allowed_web_origins:i.array(i.string()),email_validation:i.union([i.literal("enabled"),i.literal("disabled"),i.literal("enforced")]),tenant_id:i.string(),client_secret:i.string(),disable_sign_ups:i.boolean(),tenant:i.object({name:i.string(),audience:i.string().optional(),logo:i.string().optional(),primary_color:i.string().optional(),secondary_color:i.string().optional(),sender_email:i.string(),sender_name:i.string(),support_url:i.string().optional(),language:i.string().length(2).optional()})});An.extend({connections:i.array(sn)}),An.extend({connections:i.array(sn.partial())});const rs=i.object({domain:i.string(),dkim_private_key:i.string().optional(),dkim_public_key:i.string().optional(),email_api_key:i.string().optional(),email_service:i.enum(["mailgun","mailchannels"])});nn.extend({...rs.shape,id:i.string()}),i.object({trigger_id:i.enum(["post-user-registration","post-user-login"]),enabled:i.boolean().default(!1),url:i.string(),hook_id:i.string().optional()}).extend({...nn.shape,hook_id:i.string()});const ss=i.object({alg:i.string(),e:i.string(),kid:i.string(),kty:i.string(),n:i.string(),use:i.string().optional()});i.object({keys:i.array(ss)}),i.object({issuer:i.string(),authorization_endpoint:i.string(),token_endpoint:i.string(),device_authorization_endpoint:i.string(),userinfo_endpoint:i.string(),mfa_challenge_endpoint:i.string(),jwks_uri:i.string(),registration_endpoint:i.string(),revocation_endpoint:i.string(),scopes_supported:i.array(i.string()),response_types_supported:i.array(i.string()),code_challenge_methods_supported:i.array(i.string()),response_modes_supported:i.array(i.string()),subject_types_supported:i.array(i.string()),id_token_signing_alg_values_supported:i.array(i.string()),token_endpoint_auth_methods_supported:i.array(i.string()),claims_supported:i.array(i.string()),request_uri_parameter_supported:i.boolean(),request_parameter_supported:i.boolean(),token_endpoint_auth_signing_alg_values_supported:i.array(i.string())});const as=i.enum(["sapi","ssa","fsa","ss","ssa","fs","s","f","fp","slo","scoa","fcoa","seccft","cls","seacft","serft"]),is=i.object({name:i.string(),version:i.string(),env:i.object({node:i.string().optional()}).optional()});i.object({type:as,date:i.string(),description:i.string().optional(),log_id:i.string().optional(),_id:i.string().optional(),ip:i.string(),user_agent:i.string(),details:i.any().optional(),isMobile:i.boolean(),user_id:i.string().optional(),user_name:i.string().optional(),connection:i.string().optional(),connection_id:i.string().optional(),client_id:i.string().optional(),client_name:i.string().optional(),audience:i.string().optional(),scope:i.array(i.string()).optional(),strategy:i.string().optional(),strategy_type:i.string().optional(),hostname:i.string().optional(),auth0_client:is.optional()});const os=i.object({id:i.string(),email:i.string(),code:i.string(),ip:i.string().optional(),send:i.enum(["code","link"]),authParams:rn,expires_at:i.string(),used_at:i.string().optional(),user_id:i.string().optional()});i.object({created_at:i.string(),...os.shape});const cs=i.object({user_id:i.string(),password:i.string()});i.object({...cs.shape,created_at:i.string(),updated_at:i.string()});const ds=i.object({session_id:i.string(),client_id:i.string(),expires_at:i.string(),used_at:i.string(),deleted_at:i.string().optional(),user_id:i.string()});i.object({created_at:i.string(),...ds.shape}),i.object({private_key:i.string(),public_key:i.string(),kid:i.string(),created_at:i.string(),revoked_at:i.string().optional()}),i.object({kid:i.string().openapi({description:"The key id of the signing key"}),cert:i.string().openapi({description:"The public certificate of the signing key"}),fingerprint:i.string().openapi({description:"The cert fingerprint"}),thumbprint:i.string().openapi({description:"The cert thumbprint"}),pkcs7:i.string().optional().openapi({description:"The public certificate of the signing key in pkcs7 format"}),current:i.boolean().optional().openapi({description:"True if the key is the current key"}),next:i.boolean().optional().openapi({description:"True if the key is the next key"}),previous:i.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:i.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:i.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:i.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:i.string().optional().openapi({description:"The date and time when the key was revoked"})}),i.object({name:i.string(),audience:i.string(),sender_email:i.string().email(),sender_name:i.string(),support_url:i.string().url().optional(),logo:i.string().url().optional(),primary_color:i.string().optional(),secondary_color:i.string().optional(),language:i.string().optional()}).extend({created_at:i.string().transform(n=>n===null?"":n),updated_at:i.string().transform(n=>n===null?"":n)}),i.object({logoUrl:i.string(),loginBackgroundImage:i.string().nullish(),style:i.object({primaryColor:i.string(),buttonTextColor:i.string(),primaryHoverColor:i.string()}),supportEmail:i.string().nullable(),supportUrl:i.string().nullable(),name:i.string(),showGreyishBackground:i.boolean().optional(),termsAndConditionsUrl:i.string().nullable(),companyName:i.string().optional(),checkoutHideSocial:i.boolean().optional(),siteUrl:i.string().nullable(),manageSubscriptionsUrl:i.string().optional()});var Rn=(n=>(n.RefreshToken="refresh_token",n.AuthorizationCode="authorization_code",n.ClientCredential="client_credentials",n.Passwordless="passwordless",n.Password="password",n))(Rn||{});const an=i.nativeEnum(Rn);i.object({grant_type:an.refine(n=>n==="authorization_code"),code:i.string(),client_secret:i.string(),client_id:i.string()}),i.object({grant_type:an.refine(n=>n==="authorization_code"),code:i.string(),code_verifier:i.string(),client_id:i.string().optional(),redirect_uri:i.string()}),i.object({grant_type:an.refine(n=>n==="client_credentials"),scope:i.string().optional(),client_secret:i.string(),client_id:i.string(),audience:i.string().optional()}),i.object({access_token:i.string(),id_token:i.string().optional(),scope:i.string().optional(),state:i.string().optional(),refresh_token:i.string().optional(),token_type:i.string(),expires_in:i.number()}),i.object({code:i.string(),state:i.string().optional()});const us=i.object({id:i.string(),expires_at:i.string(),auth0Client:i.string().optional(),authParams:rn});i.object({...us.shape,created_at:i.string(),updated_at:i.string()});const ls=i.object({button_border_radius:i.number(),button_border_weight:i.number(),buttons_style:i.enum(["pill"]),input_border_radius:i.number(),input_border_weight:i.number(),inputs_style:i.enum(["pill"]),show_widget_shadow:i.boolean(),widget_border_weight:i.number(),widget_corner_radius:i.number()}),ps=i.object({base_focus_color:i.string(),base_hover_color:i.string(),body_text:i.string(),captcha_widget_theme:i.enum(["auto"]),error:i.string(),header:i.string(),icons:i.string(),input_background:i.string(),input_border:i.string(),input_filled_text:i.string(),input_labels_placeholders:i.string(),links_focused_components:i.string(),primary_button:i.string(),primary_button_label:i.string(),secondary_button_border:i.string(),secondary_button_label:i.string(),success:i.string(),widget_background:i.string(),widget_border:i.string()}),Ve=i.object({bold:i.boolean(),size:i.number()}),hs=i.object({body_text:Ve,buttons_text:Ve,font_url:i.string(),input_labels:Ve,links:Ve,links_style:i.enum(["normal"]),reference_text_size:i.number(),subtitle:Ve,title:Ve}),fs=i.object({background_color:i.string(),background_image_url:i.string(),page_layout:i.enum(["center"])}),ms=i.object({header_text_alignment:i.enum(["center"]),logo_height:i.number(),logo_position:i.enum(["center"]),logo_url:i.string(),social_buttons_layout:i.enum(["bottom"])});i.object({borders:ls,colors:ps,displayName:i.string(),fonts:hs,page_background:fs,widget:ms}).extend({themeId:i.string()});function on(n){const[e,t]=n.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${n}`);return{connection:e,id:t}}function $n(n){let e={};try{e=JSON.parse(n.profileData||"{}")}catch(t){console.error("Error parsing profileData",t)}return{connection:n.connection,provider:n.provider,user_id:on(n.user_id).id,isSocial:!!n.is_social,profileData:{email:n.email,email_verified:!!n.email_verified,...e}}}function _s(n){return async(e,t)=>{const[r,s]=await Promise.all([n.selectFrom("users").where("users.tenant_id","=",e).where("users.user_id","=",t).selectAll().executeTakeFirst(),n.selectFrom("users").where("users.tenant_id","=",e).where("users.linked_to","=",t).selectAll().execute()]);if(!r)return null;const{tenant_id:a,...o}=r,c={...o,email:r.email||"",email_verified:r.email_verified===1,is_social:r.is_social===1,identities:[{connection:r.connection,provider:r.provider,user_id:on(r.user_id).id,isSocial:!!r.is_social},...s.map($n)]};return R(c)}}function Ue(n,e,t,r){return t.split(/\s+/).map(a=>a.replace("=",":")).map(a=>{let o=a.startsWith("-"),c,d,u;return a.startsWith("-_exists_:")?(c=a.substring(10),u=!0,o=!0):a.startsWith("_exists_:")?(c=a.substring(9),u=!0,o=!1):a.includes(":")?(o=a.startsWith("-"),[c,d]=o?a.substring(1).split(":"):a.split(":"),u=!1):(c=null,d=a,u=!1),{key:c,value:d,isNegation:o,isExistsQuery:u}}).forEach(({key:a,value:o,isNegation:c,isExistsQuery:d})=>{if(a)d?c?e=e.where(a,"is",null):e=e.where(a,"is not",null):c?e=e.where(a,"!=",o):e=e.where(a,"=",o);else{const{ref:u}=n.dynamic;e=e.where(l=>l.or(r.map(T=>l(u(T),"like",`%${o}%`))))}}),e}function je(n){return typeof n=="string"?parseInt(n,10):typeof n=="bigint"?Number(n):n}function gs(n){return async(e,t)=>{let r=n.selectFrom("users").where("users.tenant_id","=",e);if(t.q&&(r=Ue(n,r,t.q,["email","name"])),t.sort&&t.sort.sort_by){const{ref:l}=n.dynamic;r=r.orderBy(l(t.sort.sort_by),t.sort.sort_order)}const a=await r.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),o=a.map(l=>l.user_id),c=o.length?await n.selectFrom("users").selectAll().where("users.tenant_id","=",e).where("users.linked_to","in",o).execute():[],d=a.map(l=>{const T=c.filter(A=>A.linked_to===l.user_id);return R({...l,email_verified:l.email_verified===1,is_social:l.is_social===1,identities:[{connection:l.connection,provider:l.provider,user_id:on(l.user_id).id,isSocial:!!l.is_social},...T.map($n)]})}),{count:u}=await r.select(l=>l.fn.countAll().as("count")).executeTakeFirstOrThrow();return{users:d,start:t.page*t.per_page,limit:t.per_page,length:je(u)}}}function ys(n){return async(e,t)=>(await n.deleteFrom("users").where("users.tenant_id","=",e).where("users.linked_to","=",t).execute(),(await n.deleteFrom("users").where("users.tenant_id","=",e).where("users.user_id","=",t).execute()).length===1)}function vs(n){if(n.email_verified!==void 0)return n.email_verified?1:0}function ks(n){return async(e,t,r)=>{const s={...r,email_verified:vs(r),updated_at:new Date().toISOString()};return(await n.updateTable("users").set(s).where("users.tenant_id","=",e).where("users.user_id","=",t).execute()).length===1}}function ws(n){return async(e,t,r,s)=>{const a={linked_to:null};return(await n.updateTable("users").set(a).where("users.tenant_id","=",e).where("users.user_id","=",`${r}|${s}`).where("users.linked_to","=",`${t}`).execute()).length===1}}function xs(n){return{create:ae(n),remove:ys(n),get:_s(n),list:gs(n),update:ks(n),unlink:ws(n)}}const bs="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Fe=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n));for(;n--;)e+=bs[t[n]&63];return e};function Ts(n){return async e=>{const t={id:e.id||Fe(),created_at:new Date().toISOString(),updated_at:new Date().toISOString(),...e};return await n.insertInto("tenants").values(t).execute(),t}}function Os(n){return async e=>{const t=await n.selectFrom("tenants").where("tenants.id","=",e).selectAll().executeTakeFirst();return t?R(t):null}}function Ss(n){return async e=>{let t=n.selectFrom("tenants");if(e.sort&&e.sort.sort_by){const{ref:c}=n.dynamic;t=t.orderBy(c(e.sort.sort_by),e.sort.sort_order)}e.q&&(t=t.where(c=>c.or([c("name","like",`%${e.q}%`)])));const s=await t.offset(e.page*e.per_page).limit(e.per_page).selectAll().execute();if(!e.include_totals)return{tenants:s};const{count:a}=await t.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow(),o=je(a);return{tenants:s.map(R),start:(e.page-1)*e.per_page,limit:e.per_page,length:o}}}function Zs(n){return async(e,t)=>{const r={...t,id:e,updated_at:new Date().toISOString()};await n.updateTable("tenants").set(r).where("id","=",e).execute()}}function js(n){return async e=>(await n.deleteFrom("tenants").where("tenants.id","=",e).execute()).length===1}function Is(n){return{create:Ts(n),get:Os(n),list:Ss(n),update:Zs(n),remove:js(n)}}function Pn(n){return n?JSON.stringify(n):void 0}const Cs=1024;function Ns(n){return async(e,t)=>{var s,a;const r={id:Fe(),...t,user_agent:t.user_agent.slice(0,Cs)};return await n.insertInto("logs").values({...r,isMobile:t.isMobile?1:0,tenant_id:e,scope:(s=t.scope)==null?void 0:s.join(","),auth0_client:Pn(t.auth0_client),details:(a=Pn(t.details))==null?void 0:a.substring(0,8192)}).execute(),r}}function Dn(n){if(!n)return"";try{return JSON.parse(n)}catch{return n}}function Mn(n){return{...n,client_id:n.client_id,client_name:"",auth0_client:Dn(n.auth0_client),details:Dn(n.details),isMobile:!!n.isMobile,scope:n.scope?n.scope.split(","):void 0,log_id:n.id,_id:n.id}}function Es(n){return async(e,t)=>{let r=n.selectFrom("logs").where("logs.tenant_id","=",e);t.q&&(r=Ue(n,r,t.q,["user_id","ip"]));let s=r;if(t.sort&&t.sort.sort_by){const{ref:c}=n.dynamic;s=s.orderBy(c(t.sort.sort_by),t.sort.sort_order)}s=s.offset(t.page*t.per_page).limit(t.per_page);const a=await s.selectAll().execute(),{count:o}=await r.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{logs:a.map(Mn),start:t.page*t.per_page,limit:t.per_page,length:je(o)}}}function As(n){return async(e,t)=>{const r=await n.selectFrom("logs").where("logs.tenant_id","=",e).where("logs.id","=",t).selectAll().executeTakeFirst();return r?Mn(r):null}}function Rs(n){return{create:Ns(n),list:Es(n),get:As(n)}}function $s(n){return async(e,t)=>await n.selectFrom("sessions").where("sessions.tenant_id","=",e).where("sessions.session_id","=",t).where("sessions.deleted_at","is",null).selectAll().executeTakeFirst()??null}function Ps(n){return async(e,t)=>{const r={...t,created_at:new Date().toISOString(),expires_at:new Date().toISOString()};return await n.insertInto("sessions").values({...r,tenant_id:e}).execute(),{...t,...r}}}function Ds(n){return async(e,t)=>!!(await n.updateTable("sessions").set({deleted_at:new Date().toISOString()}).where("tenant_id","=",e).where("sessions.session_id","=",t).where("sessions.deleted_at","is",null).execute()).length}function Ms(n){return async(e,t,r)=>!!(await n.updateTable("sessions").set(r).where("tenant_id","=",e).where("sessions.session_id","=",t).where("sessions.deleted_at","is",null).execute()).length}function Ls(n){return async(e,t)=>{let r=n.selectFrom("sessions").where("sessions.tenant_id","=",e);t.q&&(r=Ue(n,r,t.q,["user_id","session_id"]));let s=r;if(t.sort&&t.sort.sort_by){const{ref:d}=n.dynamic;s=s.orderBy(d(t.sort.sort_by),t.sort.sort_order)}s=s.offset(t.page*t.per_page).limit(t.per_page);const a=await s.selectAll().execute(),{count:o}=await r.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow(),c=je(o);return{sessions:a,start:t.page*t.per_page,limit:t.per_page,length:c}}}function Vs(n){return{create:Ps(n),get:$s(n),list:Ls(n),remove:Ds(n),update:Ms(n)}}function Us(n){return async(e,t)=>{const r=await n.selectFrom("tickets").where("tickets.tenant_id","=",e).where("tickets.id","=",t).where("tickets.used_at","is",null).selectAll().executeTakeFirst();if(!r)return null;const{nonce:s,state:a,scope:o,response_type:c,response_mode:d,redirect_uri:u,...l}=r;return{...l,authParams:{nonce:s,state:a,scope:o,response_type:c,response_mode:d,redirect_uri:u},created_at:new Date(r.created_at),expires_at:new Date(r.expires_at),used_at:r.used_at?new Date(r.used_at):void 0}}}function Fs(n){return async e=>{const{authParams:t,...r}=e,s={...r,...t,created_at:e.created_at.toISOString(),expires_at:e.expires_at.toISOString(),used_at:e.used_at?e.used_at.toISOString():void 0};await n.insertInto("tickets").values(s).execute()}}function zs(n){return async(e,t)=>{await n.updateTable("tickets").set({used_at:new Date().toISOString()}).where("tickets.tenant_id","=",e).where("tickets.id","=",t).execute()}}function Bs(n){return{create:Fs(n),get:Us(n),remove:zs(n)}}function qs(n){return async(e,t)=>{const r=new Date().toISOString();return(await n.selectFrom("otps").where("otps.tenant_id","=",e).where("otps.email","=",t).where("otps.expires_at",">",r).where("otps.used_at","is",null).selectAll().execute()).map(a=>{const{nonce:o,state:c,scope:d,response_type:u,redirect_uri:l,client_id:T,...A}=a;return{...A,client_id:T,authParams:{client_id:T,nonce:o,state:c,scope:d,response_type:u,redirect_uri:l},created_at:a.created_at,expires_at:a.expires_at}})}}function Ws(n){return async(e,t)=>{const{authParams:r,...s}=t;await n.insertInto("otps").values({...s,...r,created_at:new Date().toISOString(),tenant_id:e,send:t.send==="code"?"code":"link"}).execute()}}function Ks(n){return async(e,t)=>(await n.updateTable("otps").set({used_at:new Date().toISOString()}).where("otps.tenant_id","=",e).where("otps.id","=",t).execute()).length>0}function Qs(n){return{create:Ws(n),list:qs(n),remove:Ks(n)}}function Js(n){return async(e,t)=>{const r=await n.selectFrom("passwords").where("passwords.tenant_id","=",e).where("passwords.user_id","=",t).selectAll().executeTakeFirstOrThrow(),{tenant_id:s,...a}=r;return a}}function Hs(n){return async(e,t)=>{const r={...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("passwords").values({...r,tenant_id:e}).execute(),r}}function Ys(n){return async(e,t)=>(await n.updateTable("passwords").set({password:t.password,updated_at:new Date().toISOString()}).where("tenant_id","=",e).where("user_id","=",t.user_id).execute()).length===1}function Gs(n){return{create:Hs(n),update:Ys(n),get:Js(n)}}function Xs(n){return async(e,t)=>{const r=new Date().toISOString();return(await n.selectFrom("codes").where("codes.tenant_id","=",e).where("codes.user_id","=",t).where("codes.used_at","is",null).where("codes.expires_at",">",r).selectAll().execute()).map(a=>{const{tenant_id:o,...c}=a;return c})}}function ea(n){return async(e,t)=>{await n.insertInto("codes").values({...t,tenant_id:e}).execute()}}function ta(n){return{create:ea(n),list:Xs(n)}}function na(n){return async e=>{const t=new Date().toISOString(),r=await n.selectFrom("universal_login_sessions").where("universal_login_sessions.expires_at",">",t).where("universal_login_sessions.id","=",e).selectAll().executeTakeFirst();if(!r)return null;const{response_type:s,response_mode:a,redirect_uri:o,audience:c,state:d,nonce:u,scope:l,code_challenge_method:T,code_challenge:A,username:L,vendor_id:te,...de}=r;return{...de,authParams:{client_id:de.client_id,vendor_id:te,response_type:s,response_mode:a,redirect_uri:o,audience:c,state:d,nonce:u,scope:l,code_challenge_method:T,code_challenge:A,username:L}}}}function ra(n){return async(e,t)=>{const{authParams:r,...s}=t,a={created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("universal_login_sessions").values({...r,...s,...a,tenant_id:e}).execute(),{...t,...a}}}function sa(n){return async(e,t,r)=>{const{authParams:s,...a}=r;return(await n.updateTable("universal_login_sessions").set({...s,...a}).where("id","=",t).where("tenant_id","=",e).execute()).length===1}}function aa(n){return{create:ra(n),get:na(n),update:sa(n)}}function ia(n){return async(e,t)=>{const r={created_at:new Date().toISOString(),updated_at:new Date().toISOString(),...t,disable_sign_ups:t.disable_sign_ups?1:0};return await n.insertInto("applications").values({...r,tenant_id:e}).execute(),r}}function oa(n){return async e=>({applications:await n.selectFrom("applications").where("applications.tenant_id","=",e).selectAll().execute()})}function ca(n){return async(e,t)=>{const r=await n.selectFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",t).selectAll().executeTakeFirst();return r?(r.disable_sign_ups=!!r.disable_sign_ups,R(r)):null}}function da(n){return async(e,t)=>(await n.deleteFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",t).executeTakeFirst()).numDeletedRows>0}function ua(n){return async(e,t,r)=>{const s={...r,updated_at:new Date().toISOString()};return await n.updateTable("applications").set(s).where("applications.id","=",t).where("applications.tenant_id","=",e).execute(),!0}}function la(n){return{create:ia(n),list:oa(n),get:ca(n),remove:da(n),update:ua(n)}}function pa(n){return async(e,t)=>{const r={id:Fe(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("connections").values({...r,tenant_id:e}).execute(),r}}function ha(n){return async(e,t)=>{let r=n.selectFrom("connections").where("connections.tenant_id","=",e);t.q&&(r=Ue(n,r,t.q,["user_id","ip"]));const a=await r.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await r.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{connections:a.map(R),start:t.page*t.per_page,limit:t.per_page,length:je(o)}}}function fa(n){return async(e,t)=>(await n.deleteFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",t).executeTakeFirst()).numDeletedRows>0}function ma(n){return async(e,t)=>{const r=await n.selectFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",t).selectAll().executeTakeFirst();return r?R(r):null}}function _a(n){return async(e,t,r)=>{const s={...r,updated_at:new Date().toISOString()};return await n.updateTable("connections").set(s).where("connections.id","=",t).where("connections.tenant_id","=",e).execute(),!0}}function ga(n){return{create:pa(n),get:ma(n),list:ha(n),remove:fa(n),update:_a(n)}}function cn(n){return n!=null&&n.length?n.split(",").map(e=>e.trim()):[]}function ya(n){return{get:async e=>{const t=await n.selectFrom("applications").selectAll().where("id","=",e).executeTakeFirst();if(!t)return null;const r=await n.selectFrom("tenants").selectAll().where("id","=",t.tenant_id).executeTakeFirst();if(!r)throw new Q(404,{message:"Tenant not found"});const s=await n.selectFrom("connections").where("tenant_id","=",t.tenant_id).selectAll().execute(),a=await n.selectFrom("domains").where("tenant_id","=",t.tenant_id).selectAll().execute();return{id:t.id,name:t.name,connections:s.map(c=>sn.parse(R(c))),domains:a,tenant_id:r.id,allowed_callback_urls:cn(t.allowed_callback_urls),allowed_logout_urls:cn(t.allowed_logout_urls),allowed_web_origins:cn(t.allowed_web_origins),email_validation:t.email_validation,client_secret:t.client_secret,tenant:R(r),disable_sign_ups:!!t.disable_sign_ups}}}}function va(n){return async()=>await n.selectFrom("keys").where("revoked_at","is",null).selectAll().execute()}function ka(n){return async e=>{await n.insertInto("keys").values(e).execute()}}function wa(n){return async(e,t)=>!!(await n.updateTable("keys").set({revoked_at:t.toISOString()}).where("kid","=",e).execute()).length}function xa(n){return{create:ka(n),list:va(n),revoke:wa(n)}}function ba(n){return async(e,t)=>{const r={created_at:new Date().toISOString(),updated_at:new Date().toISOString(),tenant_id:e,id:Fe(),...t};return await n.insertInto("domains").values(r).execute(),r}}function Ta(n){return async(e,t)=>{let r=n.selectFrom("domains").where("domains.tenant_id","=",e);t.q&&(r=Ue(n,r,t.q,["user_id","ip"]));const a=await r.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await r.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{domains:a,start:t.page*t.per_page,limit:t.per_page,length:je(o)}}}function Oa(n){return{create:ba(n),list:Ta(n)}}function Sa(n){return async e=>{const[t]=await n.selectFrom("branding").where("branding.tenant_id","=",e).selectAll().execute();if(!t)return null;const{tenant_id:r,colors_primary:s,colors_page_background_type:a,colors_page_background_start:o,colors_page_background_end:c,colors_page_background_angle_dev:d,font_url:u,...l}=t;return R({...l,colors:{primary:s,page_background:{type:a,start:o,end:c,angle_deg:d}},font:u?{url:u}:void 0})}}function Za(n){return async(e,t)=>{var o,c,d,u,l,T,A,L,te,de,we,xe,be,Je,He,ne,re,se;const{colors:r,font:s,...a}=t;try{await n.insertInto("branding").values({...a,colors_primary:r==null?void 0:r.primary,colors_page_background_type:(c=(o=t.colors)==null?void 0:o.page_background)==null?void 0:c.type,colors_page_background_start:(u=(d=t.colors)==null?void 0:d.page_background)==null?void 0:u.start,colors_page_background_end:(T=(l=t.colors)==null?void 0:l.page_background)==null?void 0:T.end,colors_page_background_angle_dev:(L=(A=t.colors)==null?void 0:A.page_background)==null?void 0:L.angle_deg,font_url:(te=t.font)==null?void 0:te.url,tenant_id:e}).execute()}catch{await n.updateTable("branding").set({...a,colors_primary:r==null?void 0:r.primary,colors_page_background_type:(we=(de=t.colors)==null?void 0:de.page_background)==null?void 0:we.type,colors_page_background_start:(be=(xe=t.colors)==null?void 0:xe.page_background)==null?void 0:be.start,colors_page_background_end:(He=(Je=t.colors)==null?void 0:Je.page_background)==null?void 0:He.end,colors_page_background_angle_dev:(re=(ne=t.colors)==null?void 0:ne.page_background)==null?void 0:re.angle_deg,font_url:(se=t.font)==null?void 0:se.url}).where("tenant_id","=",e).execute()}}}function ja(n){return{get:Sa(n),set:Za(n)}}function Ia(n){return async(e,t)=>{const r=await n.selectFrom("authentication_codes").where("tenant_id","=",e).where("code","=",t).selectAll().executeTakeFirst();if(!r)throw new Q(403,{message:"Code not found or expired"});const{state:s,nonce:a,scope:o,client_id:c,response_type:d,response_mode:u,...l}=r;return{...l,authParams:{state:s,nonce:a,scope:o,client_id:c,response_type:d,response_mode:u}}}}function Ca(n){return async(e,t)=>{const{authParams:r,...s}=t;await n.insertInto("authentication_codes").values({...s,...r,tenant_id:e}).execute()}}function Na(n){return{create:Ca(n),get:Ia(n)}}function Ea(n){return async(e,t)=>{let r=n.selectFrom("hooks").where("hooks.tenant_id","=",e);t.q&&(r=Ue(n,r,t.q,["url"]));const a=await r.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await r.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow();return{hooks:a.map(d=>{const{tenant_id:u,enabled:l,...T}=d;return R({...T,enabled:!!l})}),start:t.page*t.per_page,limit:t.per_page,length:je(o)}}}function Aa(n){return async(e,t)=>{const r=await n.selectFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",t).selectAll().executeTakeFirst();return r?(r.enabled=!!r.enabled,R(r)):null}}function Ra(n){return async(e,t)=>(await n.deleteFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",t).executeTakeFirst()).numDeletedRows>0}function $a(n){return async(e,t)=>{const r={hook_id:Fe(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("hooks").values({...r,tenant_id:e}).execute(),r}}function Pa(n){return async(e,t,r)=>{const s={...r,updated_at:new Date().toISOString()};return await n.updateTable("hooks").set(s).where("hooks.hook_id","=",t).where("hooks.tenant_id","=",e).execute(),!0}}function Da(n){return{create:$a(n),get:Aa(n),list:Ea(n),update:Pa(n),remove:Ra(n)}}function Ma(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}typeof SuppressedError=="function"&&SuppressedError;function La(n,e){var t;return((t=n==null?void 0:n._def)===null||t===void 0?void 0:t.typeName)===e}function mt(n,e){const t=n.ZodType.prototype[e];n.ZodType.prototype[e]=function(...r){const s=t.apply(this,r);return s._def.openapi=this._def.openapi,s}}function Va(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(s,a){var o,c,d,u,l,T;const A=typeof s=="string"?a:s,L=A??{},{param:te}=L,de=Ma(L,["param"]),we=Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o._internal),typeof s=="string"?{refId:s}:void 0),xe=Object.assign(Object.assign(Object.assign({},(c=this._def.openapi)===null||c===void 0?void 0:c.metadata),de),!((u=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||u===void 0)&&u.param||te?{param:Object.assign(Object.assign({},(T=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||T===void 0?void 0:T.param),te)}:void 0),be=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(we).length>0?{_internal:we}:void 0),Object.keys(xe).length>0?{metadata:xe}:void 0)}));if(La(this,"ZodObject")){const Je=this.extend;be.extend=function(...He){var ne,re,se,Te,Ee,Ae;const Re=Je.apply(this,He);return Re._def.openapi={_internal:{extendedFrom:!((re=(ne=this._def.openapi)===null||ne===void 0?void 0:ne._internal)===null||re===void 0)&&re.refId?{refId:(Te=(se=this._def.openapi)===null||se===void 0?void 0:se._internal)===null||Te===void 0?void 0:Te.refId,schema:this}:(Ee=this._def.openapi)===null||Ee===void 0?void 0:Ee._internal.extendedFrom},metadata:(Ae=Re._def.openapi)===null||Ae===void 0?void 0:Ae.metadata},Re}}return be},mt(n,"optional"),mt(n,"nullable"),mt(n,"default"),mt(n,"transform"),mt(n,"refine");const e=n.ZodObject.prototype.deepPartial;n.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),a=e.apply(this),o=a._def.shape();return Object.entries(o).forEach(([c,d])=>{var u,l;d._def.openapi=(l=(u=s[c])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.openapi}),a._def.openapi=void 0,a};const t=n.ZodObject.prototype.pick;n.ZodObject.prototype.pick=function(...s){const a=t.apply(this,s);return a._def.openapi=void 0,a};const r=n.ZodObject.prototype.omit;n.ZodObject.prototype.omit=function(...s){const a=r.apply(this,s);return a._def.openapi=void 0,a}}new Set(".\\+*[^]$()");var C;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const a={};for(const o of s)a[o]=o;return a},n.getValidEnumValues=s=>{const a=n.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),o={};for(const c of a)o[c]=s[c];return n.objectValues(o)},n.objectValues=s=>n.objectKeys(s).map(function(a){return s[a]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&a.push(o);return a},n.find=(s,a)=>{for(const o of s)if(a(o))return o},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(C||(C={}));var dn;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(dn||(dn={}));const g=C.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),_e=n=>{switch(typeof n){case"undefined":return g.undefined;case"string":return g.string;case"number":return isNaN(n)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(n)?g.array:n===null?g.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?g.promise:typeof Map<"u"&&n instanceof Map?g.map:typeof Set<"u"&&n instanceof Set?g.set:typeof Date<"u"&&n instanceof Date?g.date:g.object;default:return g.unknown}},h=C.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"]),Ua=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class U extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const 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){const t=e||function(a){return a.message},r={_errors:[]},s=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(t(o));else{let c=r,d=0;for(;d<o.path.length;){const u=o.path[d];d===o.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(o))):c[u]=c[u]||{_errors:[]},c=c[u],d++}}};return s(this),r}static assert(e){if(!(e instanceof U))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,C.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}U.create=n=>new U(n);const ze=(n,e)=>{let t;switch(n.code){case h.invalid_type:n.received===g.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case h.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,C.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:t=`Unrecognized key(s) in object: ${C.joinValues(n.keys,", ")}`;break;case h.invalid_union:t="Invalid input";break;case h.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${C.joinValues(n.options)}`;break;case h.invalid_enum_value:t=`Invalid enum value. Expected ${C.joinValues(n.options)}, received '${n.received}'`;break;case h.invalid_arguments:t="Invalid function arguments";break;case h.invalid_return_type:t="Invalid function return type";break;case h.invalid_date:t="Invalid date";break;case h.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:C.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case h.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case h.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case h.custom:t="Invalid input";break;case h.invalid_intersection_types:t="Intersection results could not be merged";break;case h.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case h.not_finite:t="Number must be finite";break;default:t=e.defaultError,C.assertNever(n)}return{message:t}};let Ln=ze;function Fa(n){Ln=n}function Ft(){return Ln}const zt=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,a=[...t,...s.path||[]],o={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let c="";const d=r.filter(u=>!!u).slice().reverse();for(const u of d)c=u(o,{data:e,defaultError:c}).message;return{...s,path:a,message:c}},za=[];function m(n,e){const t=Ft(),r=zt({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===ze?void 0:ze].filter(s=>!!s)});n.common.issues.push(r)}class P{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return x;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const a=await s.key,o=await s.value;r.push({key:a,value:o})}return P.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:a,value:o}=s;if(a.status==="aborted"||o.status==="aborted")return x;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[a.value]=o.value)}return{status:e.value,value:r}}}const x=Object.freeze({status:"aborted"}),Be=n=>({status:"dirty",value:n}),M=n=>({status:"valid",value:n}),un=n=>n.status==="aborted",ln=n=>n.status==="dirty",_t=n=>n.status==="valid",gt=n=>typeof Promise<"u"&&n instanceof Promise;function Bt(n,e,t,r){if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Vn(n,e,t,r,s){if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}typeof SuppressedError=="function"&&SuppressedError;var v;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(v||(v={}));var yt,vt;class G{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Un=(n,e)=>{if(_t(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new U(n.common.issues);return this._error=t,this._error}}};function S(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,c)=>{var d,u;const{message:l}=n;return o.code==="invalid_enum_value"?{message:l??c.defaultError}:typeof c.data>"u"?{message:(d=l??r)!==null&&d!==void 0?d:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(u=l??t)!==null&&u!==void 0?u:c.defaultError}},description:s}}class j{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 _e(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:_e(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new P,ctx:{common:e.parent.common,data:e.data,parsedType:_e(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(gt(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_e(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Un(s,a)}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_e(e)},s=this._parse({data:e,path:r.path,parent:r}),a=await(gt(s)?s:Promise.resolve(s));return Un(r,a)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const o=e(s),c=()=>a.addIssue({code:h.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new K({schema:this,typeName:w.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ee.create(this,this._def)}nullable(){return ke.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return W.create(this,this._def)}promise(){return Qe.create(this,this._def)}or(e){return bt.create([this,e],this._def)}and(e){return Tt.create(this,e,this._def)}transform(e){return new K({...S(this._def),schema:this,typeName:w.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new It({...S(this._def),innerType:this,defaultValue:t,typeName:w.ZodDefault})}brand(){return new fn({typeName:w.ZodBranded,type:this,...S(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ct({...S(this._def),innerType:this,catchValue:t,typeName:w.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Nt.create(this,e)}readonly(){return Et.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ba=/^c[^\s-]{8,}$/i,qa=/^[0-9a-z]+$/,Wa=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ka=/^[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,Qa=/^[a-z0-9_-]{21}$/i,Ja=/^[-+]?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)?)??$/,Ha=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ya="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let pn;const Ga=/^(?:(?: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])$/,Xa=/^(([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})))$/,ei=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Fn="((\\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])))",ti=new RegExp(`^${Fn}$`);function zn(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function ni(n){return new RegExp(`^${zn(n)}$`)}function Bn(n){let e=`${Fn}T${zn(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function ri(n,e){return!!((e==="v4"||!e)&&Ga.test(n)||(e==="v6"||!e)&&Xa.test(n))}class q extends j{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_type,expected:g.string,received:a.parsedType}),x}const r=new P;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const o=e.data.length>a.value,c=e.data.length<a.value;(o||c)&&(s=this._getOrReturnCtx(e,s),o?m(s,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):c&&m(s,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")Ha.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"email",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")pn||(pn=new RegExp(Ya,"u")),pn.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"emoji",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")Ka.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"uuid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")Qa.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"nanoid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")Ba.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")qa.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid2",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")Wa.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ulid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),m(s,{validation:"url",code:h.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"regex",code:h.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),m(s,{code:h.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:h.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:h.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?Bn(a).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:h.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?ti.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:h.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?ni(a).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:h.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?Ja.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"duration",code:h.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?ri(e.data,a.version)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ip",code:h.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?ei.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"base64",code:h.invalid_string,message:a.message}),r.dirty()):C.assertNever(a);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:h.invalid_string,...v.errToObj(r)})}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...v.errToObj(e)})}url(e){return this._addCheck({kind:"url",...v.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...v.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...v.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...v.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...v.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...v.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...v.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...v.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...v.errToObj(e)})}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...v.errToObj(e==null?void 0: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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...v.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...v.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...v.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...v.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...v.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...v.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...v.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...v.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...v.errToObj(t)})}nonempty(e){return this.min(1,v.errToObj(e))}trim(){return new q({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new q({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new q({...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(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}q.create=n=>{var e;return new q({checks:[],typeName:w.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...S(n)})};function si(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,a=parseInt(n.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return a%o/Math.pow(10,s)}class ge extends j{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)!==g.number){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_type,expected:g.number,received:a.parsedType}),x}let r;const s=new P;for(const a of this._def.checks)a.kind==="int"?C.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?si(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.not_finite,message:a.message}),s.dirty()):C.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,t,r,s){return new ge({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:v.toString(s)}]})}_addCheck(e){return new ge({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:v.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:v.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:v.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:v.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const 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"&&C.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ge.create=n=>new ge({checks:[],typeName:w.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...S(n)});class ye extends j{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)!==g.bigint){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_type,expected:g.bigint,received:a.parsedType}),x}let r;const s=new P;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):C.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,t,r,s){return new ye({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:v.toString(s)}]})}_addCheck(e){return new ye({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ye.create=n=>{var e;return new ye({checks:[],typeName:w.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...S(n)})};class kt extends j{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){const r=this._getOrReturnCtx(e);return m(r,{code:h.invalid_type,expected:g.boolean,received:r.parsedType}),x}return M(e.data)}}kt.create=n=>new kt({typeName:w.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...S(n)});class Ie extends j{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_type,expected:g.date,received:a.parsedType}),x}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_date}),x}const r=new P;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):C.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ie({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:v.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:v.toString(t)})}get minDate(){let e=null;for(const 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(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Ie.create=n=>new Ie({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:w.ZodDate,...S(n)});class qt extends j{_parse(e){if(this._getType(e)!==g.symbol){const r=this._getOrReturnCtx(e);return m(r,{code:h.invalid_type,expected:g.symbol,received:r.parsedType}),x}return M(e.data)}}qt.create=n=>new qt({typeName:w.ZodSymbol,...S(n)});class wt extends j{_parse(e){if(this._getType(e)!==g.undefined){const r=this._getOrReturnCtx(e);return m(r,{code:h.invalid_type,expected:g.undefined,received:r.parsedType}),x}return M(e.data)}}wt.create=n=>new wt({typeName:w.ZodUndefined,...S(n)});class xt extends j{_parse(e){if(this._getType(e)!==g.null){const r=this._getOrReturnCtx(e);return m(r,{code:h.invalid_type,expected:g.null,received:r.parsedType}),x}return M(e.data)}}xt.create=n=>new xt({typeName:w.ZodNull,...S(n)});class qe extends j{constructor(){super(...arguments),this._any=!0}_parse(e){return M(e.data)}}qe.create=n=>new qe({typeName:w.ZodAny,...S(n)});class Ce extends j{constructor(){super(...arguments),this._unknown=!0}_parse(e){return M(e.data)}}Ce.create=n=>new Ce({typeName:w.ZodUnknown,...S(n)});class oe extends j{_parse(e){const t=this._getOrReturnCtx(e);return m(t,{code:h.invalid_type,expected:g.never,received:t.parsedType}),x}}oe.create=n=>new oe({typeName:w.ZodNever,...S(n)});class Wt extends j{_parse(e){if(this._getType(e)!==g.undefined){const r=this._getOrReturnCtx(e);return m(r,{code:h.invalid_type,expected:g.void,received:r.parsedType}),x}return M(e.data)}}Wt.create=n=>new Wt({typeName:w.ZodVoid,...S(n)});class W extends j{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==g.array)return m(t,{code:h.invalid_type,expected:g.array,received:t.parsedType}),x;if(s.exactLength!==null){const o=t.data.length>s.exactLength.value,c=t.data.length<s.exactLength.value;(o||c)&&(m(t,{code:o?h.too_big:h.too_small,minimum:c?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(m(t,{code:h.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(m(t,{code:h.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>s.type._parseAsync(new G(t,o,t.path,c)))).then(o=>P.mergeArray(r,o));const a=[...t.data].map((o,c)=>s.type._parseSync(new G(t,o,t.path,c)));return P.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new W({...this._def,minLength:{value:e,message:v.toString(t)}})}max(e,t){return new W({...this._def,maxLength:{value:e,message:v.toString(t)}})}length(e,t){return new W({...this._def,exactLength:{value:e,message:v.toString(t)}})}nonempty(e){return this.min(1,e)}}W.create=(n,e)=>new W({type:n,minLength:null,maxLength:null,exactLength:null,typeName:w.ZodArray,...S(e)});function We(n){if(n instanceof E){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=ee.create(We(r))}return new E({...n._def,shape:()=>e})}else return n instanceof W?new W({...n._def,type:We(n.element)}):n instanceof ee?ee.create(We(n.unwrap())):n instanceof ke?ke.create(We(n.unwrap())):n instanceof X?X.create(n.items.map(e=>We(e))):n}class E extends j{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=C.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==g.object){const u=this._getOrReturnCtx(e);return m(u,{code:h.invalid_type,expected:g.object,received:u.parsedType}),x}const{status:r,ctx:s}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof oe&&this._def.unknownKeys==="strip"))for(const u in s.data)o.includes(u)||c.push(u);const d=[];for(const u of o){const l=a[u],T=s.data[u];d.push({key:{status:"valid",value:u},value:l._parse(new G(s,T,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof oe){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of c)d.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")c.length>0&&(m(s,{code:h.unrecognized_keys,keys:c}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of c){const T=s.data[l];d.push({key:{status:"valid",value:l},value:u._parse(new G(s,T,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of d){const T=await l.key,A=await l.value;u.push({key:T,value:A,alwaysSet:l.alwaysSet})}return u}).then(u=>P.mergeObjectSync(r,u)):P.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return v.errToObj,new E({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,a,o,c;const d=(o=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,r).message)!==null&&o!==void 0?o:r.defaultError;return t.code==="unrecognized_keys"?{message:(c=v.errToObj(e).message)!==null&&c!==void 0?c:d}:{message:d}}}:{}})}strip(){return new E({...this._def,unknownKeys:"strip"})}passthrough(){return new E({...this._def,unknownKeys:"passthrough"})}extend(e){return new E({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new E({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:w.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new E({...this._def,catchall:e})}pick(e){const t={};return C.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new E({...this._def,shape:()=>t})}omit(e){const t={};return C.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new E({...this._def,shape:()=>t})}deepPartial(){return We(this)}partial(e){const t={};return C.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new E({...this._def,shape:()=>t})}required(e){const t={};return C.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof ee;)a=a._def.innerType;t[r]=a}}),new E({...this._def,shape:()=>t})}keyof(){return qn(C.objectKeys(this.shape))}}E.create=(n,e)=>new E({shape:()=>n,unknownKeys:"strip",catchall:oe.create(),typeName:w.ZodObject,...S(e)}),E.strictCreate=(n,e)=>new E({shape:()=>n,unknownKeys:"strict",catchall:oe.create(),typeName:w.ZodObject,...S(e)}),E.lazycreate=(n,e)=>new E({shape:n,unknownKeys:"strip",catchall:oe.create(),typeName:w.ZodObject,...S(e)});class bt extends j{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(a){for(const c of a)if(c.result.status==="valid")return c.result;for(const c of a)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=a.map(c=>new U(c.ctx.common.issues));return m(t,{code:h.invalid_union,unionErrors:o}),x}if(t.common.async)return Promise.all(r.map(async a=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(s);{let a;const o=[];for(const d of r){const u={...t,common:{...t.common,issues:[]},parent:null},l=d._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const c=o.map(d=>new U(d));return m(t,{code:h.invalid_union,unionErrors:c}),x}}get options(){return this._def.options}}bt.create=(n,e)=>new bt({options:n,typeName:w.ZodUnion,...S(e)});const ce=n=>n instanceof St?ce(n.schema):n instanceof K?ce(n.innerType()):n instanceof Zt?[n.value]:n instanceof ve?n.options:n instanceof jt?C.objectValues(n.enum):n instanceof It?ce(n._def.innerType):n instanceof wt?[void 0]:n instanceof xt?[null]:n instanceof ee?[void 0,...ce(n.unwrap())]:n instanceof ke?[null,...ce(n.unwrap())]:n instanceof fn||n instanceof Et?ce(n.unwrap()):n instanceof Ct?ce(n._def.innerType):[];class Kt extends j{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.object)return m(t,{code:h.invalid_type,expected:g.object,received:t.parsedType}),x;const r=this.discriminator,s=t.data[r],a=this.optionsMap.get(s);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}):(m(t,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const a of t){const o=ce(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(s.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);s.set(c,a)}}return new Kt({typeName:w.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...S(r)})}}function hn(n,e){const t=_e(n),r=_e(e);if(n===e)return{valid:!0,data:n};if(t===g.object&&r===g.object){const s=C.objectKeys(e),a=C.objectKeys(n).filter(c=>s.indexOf(c)!==-1),o={...n,...e};for(const c of a){const d=hn(n[c],e[c]);if(!d.valid)return{valid:!1};o[c]=d.data}return{valid:!0,data:o}}else if(t===g.array&&r===g.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<n.length;a++){const o=n[a],c=e[a],d=hn(o,c);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return t===g.date&&r===g.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Tt extends j{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(a,o)=>{if(un(a)||un(o))return x;const c=hn(a.value,o.value);return c.valid?((ln(a)||ln(o))&&t.dirty(),{status:t.value,value:c.data}):(m(r,{code:h.invalid_intersection_types}),x)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,o])=>s(a,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Tt.create=(n,e,t)=>new Tt({left:n,right:e,typeName:w.ZodIntersection,...S(t)});class X extends j{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.array)return m(r,{code:h.invalid_type,expected:g.array,received:r.parsedType}),x;if(r.data.length<this._def.items.length)return m(r,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&r.data.length>this._def.items.length&&(m(r,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...r.data].map((o,c)=>{const d=this._def.items[c]||this._def.rest;return d?d._parse(new G(r,o,r.path,c)):null}).filter(o=>!!o);return r.common.async?Promise.all(a).then(o=>P.mergeArray(t,o)):P.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new X({...this._def,rest:e})}}X.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new X({items:n,typeName:w.ZodTuple,rest:null,...S(e)})};class Ot extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.object)return m(r,{code:h.invalid_type,expected:g.object,received:r.parsedType}),x;const s=[],a=this._def.keyType,o=this._def.valueType;for(const c in r.data)s.push({key:a._parse(new G(r,c,r.path,c)),value:o._parse(new G(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?P.mergeObjectAsync(t,s):P.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof j?new Ot({keyType:e,valueType:t,typeName:w.ZodRecord,...S(r)}):new Ot({keyType:q.create(),valueType:e,typeName:w.ZodRecord,...S(t)})}}class Qt extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.map)return m(r,{code:h.invalid_type,expected:g.map,received:r.parsedType}),x;const s=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([c,d],u)=>({key:s._parse(new G(r,c,r.path,[u,"key"])),value:a._parse(new G(r,d,r.path,[u,"value"]))}));if(r.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const d of o){const u=await d.key,l=await d.value;if(u.status==="aborted"||l.status==="aborted")return x;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),c.set(u.value,l.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const d of o){const u=d.key,l=d.value;if(u.status==="aborted"||l.status==="aborted")return x;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),c.set(u.value,l.value)}return{status:t.value,value:c}}}}Qt.create=(n,e,t)=>new Qt({valueType:e,keyType:n,typeName:w.ZodMap,...S(t)});class Ne extends j{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.set)return m(r,{code:h.invalid_type,expected:g.set,received:r.parsedType}),x;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(m(r,{code:h.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(m(r,{code:h.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function o(d){const u=new Set;for(const l of d){if(l.status==="aborted")return x;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const c=[...r.data.values()].map((d,u)=>a._parse(new G(r,d,r.path,u)));return r.common.async?Promise.all(c).then(d=>o(d)):o(c)}min(e,t){return new Ne({...this._def,minSize:{value:e,message:v.toString(t)}})}max(e,t){return new Ne({...this._def,maxSize:{value:e,message:v.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ne.create=(n,e)=>new Ne({valueType:n,minSize:null,maxSize:null,typeName:w.ZodSet,...S(e)});class Ke extends j{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.function)return m(t,{code:h.invalid_type,expected:g.function,received:t.parsedType}),x;function r(c,d){return zt({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ft(),ze].filter(u=>!!u),issueData:{code:h.invalid_arguments,argumentsError:d}})}function s(c,d){return zt({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ft(),ze].filter(u=>!!u),issueData:{code:h.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Qe){const c=this;return M(async function(...d){const u=new U([]),l=await c._def.args.parseAsync(d,a).catch(L=>{throw u.addIssue(r(d,L)),u}),T=await Reflect.apply(o,this,l);return await c._def.returns._def.type.parseAsync(T,a).catch(L=>{throw u.addIssue(s(T,L)),u})})}else{const c=this;return M(function(...d){const u=c._def.args.safeParse(d,a);if(!u.success)throw new U([r(d,u.error)]);const l=Reflect.apply(o,this,u.data),T=c._def.returns.safeParse(l,a);if(!T.success)throw new U([s(l,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ke({...this._def,args:X.create(e).rest(Ce.create())})}returns(e){return new Ke({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new Ke({args:e||X.create([]).rest(Ce.create()),returns:t||Ce.create(),typeName:w.ZodFunction,...S(r)})}}class St extends j{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}St.create=(n,e)=>new St({getter:n,typeName:w.ZodLazy,...S(e)});class Zt extends j{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return m(t,{received:t.data,code:h.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}}Zt.create=(n,e)=>new Zt({value:n,typeName:w.ZodLiteral,...S(e)});function qn(n,e){return new ve({values:n,typeName:w.ZodEnum,...S(e)})}class ve extends j{constructor(){super(...arguments),yt.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return m(t,{expected:C.joinValues(r),received:t.parsedType,code:h.invalid_type}),x}if(Bt(this,yt)||Vn(this,yt,new Set(this._def.values)),!Bt(this,yt).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return m(t,{received:t.data,code:h.invalid_enum_value,options:r}),x}return M(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ve.create(e,{...this._def,...t})}exclude(e,t=this._def){return ve.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}yt=new WeakMap,ve.create=qn;class jt extends j{constructor(){super(...arguments),vt.set(this,void 0)}_parse(e){const t=C.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==g.string&&r.parsedType!==g.number){const s=C.objectValues(t);return m(r,{expected:C.joinValues(s),received:r.parsedType,code:h.invalid_type}),x}if(Bt(this,vt)||Vn(this,vt,new Set(C.getValidEnumValues(this._def.values))),!Bt(this,vt).has(e.data)){const s=C.objectValues(t);return m(r,{received:r.data,code:h.invalid_enum_value,options:s}),x}return M(e.data)}get enum(){return this._def.values}}vt=new WeakMap,jt.create=(n,e)=>new jt({values:n,typeName:w.ZodNativeEnum,...S(e)});class Qe extends j{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.promise&&t.common.async===!1)return m(t,{code:h.invalid_type,expected:g.promise,received:t.parsedType}),x;const r=t.parsedType===g.promise?t.data:Promise.resolve(t.data);return M(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Qe.create=(n,e)=>new Qe({type:n,typeName:w.ZodPromise,...S(e)});class K extends j{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===w.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:o=>{m(r,o),o.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const o=s.transform(r.data,a);if(r.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return x;const d=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return d.status==="aborted"?x:d.status==="dirty"||t.value==="dirty"?Be(d.value):d});{if(t.value==="aborted")return x;const c=this._def.schema._parseSync({data:o,path:r.path,parent:r});return c.status==="aborted"?x:c.status==="dirty"||t.value==="dirty"?Be(c.value):c}}if(s.type==="refinement"){const o=c=>{const d=s.refinement(c,a);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){const c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?x:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?x:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!_t(o))return o;const c=s.transform(o.value,a);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>_t(o)?Promise.resolve(s.transform(o.value,a)).then(c=>({status:t.value,value:c})):o);C.assertNever(s)}}K.create=(n,e,t)=>new K({schema:n,typeName:w.ZodEffects,effect:e,...S(t)}),K.createWithPreprocess=(n,e,t)=>new K({schema:e,effect:{type:"preprocess",transform:n},typeName:w.ZodEffects,...S(t)});class ee extends j{_parse(e){return this._getType(e)===g.undefined?M(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ee.create=(n,e)=>new ee({innerType:n,typeName:w.ZodOptional,...S(e)});class ke extends j{_parse(e){return this._getType(e)===g.null?M(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ke.create=(n,e)=>new ke({innerType:n,typeName:w.ZodNullable,...S(e)});class It extends j{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===g.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}It.create=(n,e)=>new It({innerType:n,typeName:w.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...S(e)});class Ct extends j{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return gt(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new U(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new U(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Ct.create=(n,e)=>new Ct({innerType:n,typeName:w.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...S(e)});class Jt extends j{_parse(e){if(this._getType(e)!==g.nan){const r=this._getOrReturnCtx(e);return m(r,{code:h.invalid_type,expected:g.nan,received:r.parsedType}),x}return{status:"valid",value:e.data}}}Jt.create=n=>new Jt({typeName:w.ZodNaN,...S(n)});const ai=Symbol("zod_brand");class fn extends j{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class Nt extends j{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?x:a.status==="dirty"?(t.dirty(),Be(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?x:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new Nt({in:e,out:t,typeName:w.ZodPipeline})}}class Et extends j{_parse(e){const t=this._def.innerType._parse(e),r=s=>(_t(s)&&(s.value=Object.freeze(s.value)),s);return gt(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}Et.create=(n,e)=>new Et({innerType:n,typeName:w.ZodReadonly,...S(e)});function Wn(n,e={},t){return n?qe.create().superRefine((r,s)=>{var a,o;if(!n(r)){const c=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,d=(o=(a=c.fatal)!==null&&a!==void 0?a:t)!==null&&o!==void 0?o:!0,u=typeof c=="string"?{message:c}:c;s.addIssue({code:"custom",...u,fatal:d})}}):qe.create()}const ii={object:E.lazycreate};var w;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(w||(w={}));const oi=(n,e={message:`Input not instance of ${n.name}`})=>Wn(t=>t instanceof n,e),Kn=q.create,Qn=ge.create,ci=Jt.create,di=ye.create,Jn=kt.create,ui=Ie.create,li=qt.create,pi=wt.create,hi=xt.create,fi=qe.create,mi=Ce.create,_i=oe.create,gi=Wt.create,yi=W.create,vi=E.create,ki=E.strictCreate,wi=bt.create,xi=Kt.create,bi=Tt.create,Ti=X.create,Oi=Ot.create,Si=Qt.create,Zi=Ne.create,ji=Ke.create,Ii=St.create,Ci=Zt.create,Ni=ve.create,Ei=jt.create,Ai=Qe.create,Hn=K.create,Ri=ee.create,$i=ke.create,Pi=K.createWithPreprocess,Di=Nt.create;var Mi=Object.freeze({__proto__:null,defaultErrorMap:ze,setErrorMap:Fa,getErrorMap:Ft,makeIssue:zt,EMPTY_PATH:za,addIssueToContext:m,ParseStatus:P,INVALID:x,DIRTY:Be,OK:M,isAborted:un,isDirty:ln,isValid:_t,isAsync:gt,get util(){return C},get objectUtil(){return dn},ZodParsedType:g,getParsedType:_e,ZodType:j,datetimeRegex:Bn,ZodString:q,ZodNumber:ge,ZodBigInt:ye,ZodBoolean:kt,ZodDate:Ie,ZodSymbol:qt,ZodUndefined:wt,ZodNull:xt,ZodAny:qe,ZodUnknown:Ce,ZodNever:oe,ZodVoid:Wt,ZodArray:W,ZodObject:E,ZodUnion:bt,ZodDiscriminatedUnion:Kt,ZodIntersection:Tt,ZodTuple:X,ZodRecord:Ot,ZodMap:Qt,ZodSet:Ne,ZodFunction:Ke,ZodLazy:St,ZodLiteral:Zt,ZodEnum:ve,ZodNativeEnum:jt,ZodPromise:Qe,ZodEffects:K,ZodTransformer:K,ZodOptional:ee,ZodNullable:ke,ZodDefault:It,ZodCatch:Ct,ZodNaN:Jt,BRAND:ai,ZodBranded:fn,ZodPipeline:Nt,ZodReadonly:Et,custom:Wn,Schema:j,ZodSchema:j,late:ii,get ZodFirstPartyTypeKind(){return w},coerce:{string:n=>q.create({...n,coerce:!0}),number:n=>ge.create({...n,coerce:!0}),boolean:n=>kt.create({...n,coerce:!0}),bigint:n=>ye.create({...n,coerce:!0}),date:n=>Ie.create({...n,coerce:!0})},any:fi,array:yi,bigint:di,boolean:Jn,date:ui,discriminatedUnion:xi,effect:Hn,enum:Ni,function:ji,instanceof:oi,intersection:bi,lazy:Ii,literal:Ci,map:Si,nan:ci,nativeEnum:Ei,never:_i,null:hi,nullable:$i,number:Qn,object:vi,oboolean:()=>Jn().optional(),onumber:()=>Qn().optional(),optional:Ri,ostring:()=>Kn().optional(),pipeline:Di,preprocess:Pi,promise:Ai,record:Oi,set:Zi,strictObject:ki,string:Kn,symbol:li,transformer:Hn,tuple:Ti,undefined:pi,union:wi,unknown:mi,void:gi,NEVER:x,ZodIssueCode:h,quotelessJson:Ua,ZodError:U});Va(Mi);function mn(n,e="",t={}){for(let r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const s=e?`${e}_${r}`:r;typeof n[r]=="object"&&n[r]!==null&&!Array.isArray(n[r])?mn(n[r],s,t):t[s]=n[r]}return t}function Li(n){return async(e,t)=>{const r={themeId:Fe(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("themes").values({...mn(r),tenant_id:e}).execute(),r}}function Vi(n){return async(e,t)=>(await n.deleteFrom("themes").where("themes.tenant_id","=",e).where("themes.theme_id","=",t).executeTakeFirst()).numDeletedRows>0}function Ui(n){return async(e,t)=>{const r=await n.selectFrom("themes").where("themes.tenant_id","=",e).where("themes.theme_id","=",t).selectAll().executeTakeFirst();return r?R(r):null}}function Fi(n){return async(e,t,r)=>{const s=mn({...r,updated_at:new Date().toISOString()});return await n.updateTable("themes").set(s).where("themes.id","=",t).where("themes.tenant_id","=",e).execute(),!0}}function zi(n){return{create:Li(n),get:Ui(n),remove:Vi(n),update:Fi(n)}}function Bi(n){return{applications:la(n),authenticationCodes:Na(n),branding:ja(n),clients:ya(n),codes:ta(n),connections:ga(n),domains:Oa(n),hooks:Da(n),keys:xa(n),logs:Rs(n),OTP:Qs(n),passwords:Gs(n),users:xs(n),sessions:Vs(n),tenants:Is(n),themes:zi(n),tickets:Bs(n),universalLoginSessions:aa(n)}}return Bi}();
|
|
1
|
+
var kyselyAdapter=function(){"use strict";var Hi=Object.defineProperty;var Yi=(Q,ae,A)=>ae in Q?Hi(Q,ae,{enumerable:!0,configurable:!0,writable:!0,value:A}):Q[ae]=A;var _n=(Q,ae,A)=>Yi(Q,typeof ae!="symbol"?ae+"":ae,A);var Q=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});_n(this,"res");_n(this,"status");this.res=t==null?void 0:t.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}};function ae(n){return async(e,t)=>{const{identities:r,...s}=t,a={...s,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),tenant_id:e,email_verified:t.email_verified?1:0,is_social:t.is_social?1:0};try{await n.insertInto("users").values(a).execute()}catch(o){throw o.code==="SQLITE_CONSTRAINT_UNIQUE"||o.message.includes("AlreadyExists")?new Q(409,{message:"User already exists"}):(console.log(o.message),new Q(500,{message:`${o.code}, ${o.message}`}))}return{...a,email:a.email||"",email_verified:a.email_verified===1,is_social:a.is_social===1}}}function A(n){const e={...n};for(const t in e)e[t]===null?delete e[t]:typeof e[t]=="object"&&(Array.isArray(e[t])?e[t]=e[t].map(A):e[t]=A(e[t]));return e}function Yn(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}function Gn(n,e){var t;return((t=n==null?void 0:n._def)===null||t===void 0?void 0:t.typeName)===e}function Ye(n,e){const t=n.ZodType.prototype[e];n.ZodType.prototype[e]=function(...r){const s=t.apply(this,r);return s._def.openapi=this._def.openapi,s}}function Xn(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(s,a){var o,c,d,u,l,T;const R=typeof s=="string"?a:s,L=R??{},{param:te}=L,de=Yn(L,["param"]),xe=Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o._internal),typeof s=="string"?{refId:s}:void 0),be=Object.assign(Object.assign(Object.assign({},(c=this._def.openapi)===null||c===void 0?void 0:c.metadata),de),!((u=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||u===void 0)&&u.param||te?{param:Object.assign(Object.assign({},(T=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||T===void 0?void 0:T.param),te)}:void 0),Te=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(xe).length>0?{_internal:xe}:void 0),Object.keys(be).length>0?{metadata:be}:void 0)}));if(Gn(this,"ZodObject")){const Je=this.extend;Te.extend=function(...He){var ne,re,se,Oe,Ae,Re;const $e=Je.apply(this,He);return $e._def.openapi={_internal:{extendedFrom:!((re=(ne=this._def.openapi)===null||ne===void 0?void 0:ne._internal)===null||re===void 0)&&re.refId?{refId:(Oe=(se=this._def.openapi)===null||se===void 0?void 0:se._internal)===null||Oe===void 0?void 0:Oe.refId,schema:this}:(Ae=this._def.openapi)===null||Ae===void 0?void 0:Ae._internal.extendedFrom},metadata:(Re=$e._def.openapi)===null||Re===void 0?void 0:Re.metadata},$e}}return Te},Ye(n,"optional"),Ye(n,"nullable"),Ye(n,"default"),Ye(n,"transform"),Ye(n,"refine");const e=n.ZodObject.prototype.deepPartial;n.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),a=e.apply(this),o=a._def.shape();return Object.entries(o).forEach(([c,d])=>{var u,l;d._def.openapi=(l=(u=s[c])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.openapi}),a._def.openapi=void 0,a};const t=n.ZodObject.prototype.pick;n.ZodObject.prototype.pick=function(...s){const a=t.apply(this,s);return a._def.openapi=void 0,a};const r=n.ZodObject.prototype.omit;n.ZodObject.prototype.omit=function(...s){const a=r.apply(this,s);return a._def.openapi=void 0,a}}new Set(".\\+*[^]$()");var I;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const a={};for(const o of s)a[o]=o;return a},n.getValidEnumValues=s=>{const a=n.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),o={};for(const c of a)o[c]=s[c];return n.objectValues(o)},n.objectValues=s=>n.objectKeys(s).map(function(a){return s[a]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&a.push(o);return a},n.find=(s,a)=>{for(const o of s)if(a(o))return o},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(I||(I={}));var Yt;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Yt||(Yt={}));const _=I.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ue=n=>{switch(typeof n){case"undefined":return _.undefined;case"string":return _.string;case"number":return isNaN(n)?_.nan:_.number;case"boolean":return _.boolean;case"function":return _.function;case"bigint":return _.bigint;case"symbol":return _.symbol;case"object":return Array.isArray(n)?_.array:n===null?_.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?_.promise:typeof Map<"u"&&n instanceof Map?_.map:typeof Set<"u"&&n instanceof Set?_.set:typeof Date<"u"&&n instanceof Date?_.date:_.object;default:return _.unknown}},p=I.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"]),er=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class V extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const 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){const t=e||function(a){return a.message},r={_errors:[]},s=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(t(o));else{let c=r,d=0;for(;d<o.path.length;){const u=o.path[d];d===o.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(o))):c[u]=c[u]||{_errors:[]},c=c[u],d++}}};return s(this),r}static assert(e){if(!(e instanceof V))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,I.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}V.create=n=>new V(n);const Pe=(n,e)=>{let t;switch(n.code){case p.invalid_type:n.received===_.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case p.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,I.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:t=`Unrecognized key(s) in object: ${I.joinValues(n.keys,", ")}`;break;case p.invalid_union:t="Invalid input";break;case p.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${I.joinValues(n.options)}`;break;case p.invalid_enum_value:t=`Invalid enum value. Expected ${I.joinValues(n.options)}, received '${n.received}'`;break;case p.invalid_arguments:t="Invalid function arguments";break;case p.invalid_return_type:t="Invalid function return type";break;case p.invalid_date:t="Invalid date";break;case p.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:I.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case p.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case p.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case p.custom:t="Invalid input";break;case p.invalid_intersection_types:t="Intersection results could not be merged";break;case p.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case p.not_finite:t="Number must be finite";break;default:t=e.defaultError,I.assertNever(n)}return{message:t}};let gn=Pe;function tr(n){gn=n}function At(){return gn}const Rt=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,a=[...t,...s.path||[]],o={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let c="";const d=r.filter(u=>!!u).slice().reverse();for(const u of d)c=u(o,{data:e,defaultError:c}).message;return{...s,path:a,message:c}},nr=[];function f(n,e){const t=At(),r=Rt({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===Pe?void 0:Pe].filter(s=>!!s)});n.common.issues.push(r)}class ${constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return b;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const a=await s.key,o=await s.value;r.push({key:a,value:o})}return $.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:a,value:o}=s;if(a.status==="aborted"||o.status==="aborted")return b;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[a.value]=o.value)}return{status:e.value,value:r}}}const b=Object.freeze({status:"aborted"}),$t=n=>({status:"dirty",value:n}),D=n=>({status:"valid",value:n}),Gt=n=>n.status==="aborted",Xt=n=>n.status==="dirty",Ge=n=>n.status==="valid",Xe=n=>typeof Promise<"u"&&n instanceof Promise;function Pt(n,e,t,r){if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function yn(n,e,t,r,s){if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}var y;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(y||(y={}));var et,tt;class J{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const vn=(n,e)=>{if(Ge(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new V(n.common.issues);return this._error=t,this._error}}};function O(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,o)=>{var c,d;const{message:u}=n;return a.code==="invalid_enum_value"?{message:u??o.defaultError}:typeof o.data>"u"?{message:(c=u??r)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(d=u??t)!==null&&d!==void 0?d:o.defaultError}},description:s}}class Z{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 ue(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ue(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $,ctx:{common:e.parent.common,data:e.data,parsedType:ue(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Xe(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ue(e)},a=this._parseSync({data:e,path:s.path,parent:s});return vn(s,a)}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ue(e)},s=this._parse({data:e,path:r.path,parent:r}),a=await(Xe(s)?s:Promise.resolve(s));return vn(r,a)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const o=e(s),c=()=>a.addIssue({code:p.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new B({schema:this,typeName:w.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Y.create(this,this._def)}nullable(){return me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return z.create(this,this._def)}promise(){return Ve.create(this,this._def)}or(e){return at.create([this,e],this._def)}and(e){return it.create(this,e,this._def)}transform(e){return new B({...O(this._def),schema:this,typeName:w.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new lt({...O(this._def),innerType:this,defaultValue:t,typeName:w.ZodDefault})}brand(){return new nn({typeName:w.ZodBranded,type:this,...O(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new pt({...O(this._def),innerType:this,catchValue:t,typeName:w.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ht.create(this,e)}readonly(){return ft.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const rr=/^c[^\s-]{8,}$/i,sr=/^[0-9a-z]+$/,ar=/^[0-9A-HJKMNP-TV-Z]{26}$/,ir=/^[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,or=/^[a-z0-9_-]{21}$/i,cr=/^[-+]?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)?)??$/,dr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ur="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let en;const lr=/^(?:(?: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])$/,pr=/^(([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})))$/,hr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,wn="((\\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])))",fr=new RegExp(`^${wn}$`);function kn(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function mr(n){return new RegExp(`^${kn(n)}$`)}function xn(n){let e=`${wn}T${kn(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function _r(n,e){return!!((e==="v4"||!e)&&lr.test(n)||(e==="v6"||!e)&&pr.test(n))}class F extends Z{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){const s=this._getOrReturnCtx(e);return f(s,{code:p.invalid_type,expected:_.string,received:s.parsedType}),b}const t=new $;let r;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:p.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:p.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,o=e.data.length<s.value;(a||o)&&(r=this._getOrReturnCtx(e,r),a?f(r,{code:p.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):o&&f(r,{code:p.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")dr.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"email",code:p.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")en||(en=new RegExp(ur,"u")),en.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"emoji",code:p.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")ir.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"uuid",code:p.invalid_string,message:s.message}),t.dirty());else if(s.kind==="nanoid")or.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"nanoid",code:p.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")rr.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"cuid",code:p.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")sr.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"cuid2",code:p.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")ar.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"ulid",code:p.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),f(r,{validation:"url",code:p.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"regex",code:p.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(r=this._getOrReturnCtx(e,r),f(r,{code:p.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(r=this._getOrReturnCtx(e,r),f(r,{code:p.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(r=this._getOrReturnCtx(e,r),f(r,{code:p.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?xn(s).test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:p.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="date"?fr.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:p.invalid_string,validation:"date",message:s.message}),t.dirty()):s.kind==="time"?mr(s).test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:p.invalid_string,validation:"time",message:s.message}),t.dirty()):s.kind==="duration"?cr.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"duration",code:p.invalid_string,message:s.message}),t.dirty()):s.kind==="ip"?_r(e.data,s.version)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"ip",code:p.invalid_string,message:s.message}),t.dirty()):s.kind==="base64"?hr.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"base64",code:p.invalid_string,message:s.message}),t.dirty()):I.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:p.invalid_string,...y.errToObj(r)})}_addCheck(e){return new F({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...y.errToObj(e)})}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...y.errToObj(e==null?void 0: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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...y.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...y.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...y.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...y.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...y.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...y.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...y.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...y.errToObj(t)})}nonempty(e){return this.min(1,y.errToObj(e))}trim(){return new F({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new F({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new F({...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(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}F.create=n=>{var e;return new F({checks:[],typeName:w.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...O(n)})};function gr(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,a=parseInt(n.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return a%o/Math.pow(10,s)}class le extends Z{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==_.number){const s=this._getOrReturnCtx(e);return f(s,{code:p.invalid_type,expected:_.number,received:s.parsedType}),b}let t;const r=new $;for(const s of this._def.checks)s.kind==="int"?I.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),f(t,{code:p.invalid_type,expected:"integer",received:"float",message:s.message}),r.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="multipleOf"?gr(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),f(t,{code:p.not_finite,message:s.message}),r.dirty()):I.assertNever(s);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,y.toString(t))}setLimit(e,t,r,s){return new le({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:y.toString(s)}]})}_addCheck(e){return new le({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:y.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const 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"&&I.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}le.create=n=>new le({checks:[],typeName:w.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...O(n)});class pe extends Z{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==_.bigint){const s=this._getOrReturnCtx(e);return f(s,{code:p.invalid_type,expected:_.bigint,received:s.parsedType}),b}let t;const r=new $;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):I.assertNever(s);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,y.toString(t))}setLimit(e,t,r,s){return new pe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:y.toString(s)}]})}_addCheck(e){return new pe({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}pe.create=n=>{var e;return new pe({checks:[],typeName:w.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...O(n)})};class nt extends Z{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.boolean,received:t.parsedType}),b}return D(e.data)}}nt.create=n=>new nt({typeName:w.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...O(n)});class Se extends Z{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){const s=this._getOrReturnCtx(e);return f(s,{code:p.invalid_type,expected:_.date,received:s.parsedType}),b}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return f(s,{code:p.invalid_date}),b}const t=new $;let r;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:p.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:p.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):I.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Se({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:y.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:y.toString(t)})}get minDate(){let e=null;for(const 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(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Se.create=n=>new Se({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:w.ZodDate,...O(n)});class Dt extends Z{_parse(e){if(this._getType(e)!==_.symbol){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.symbol,received:t.parsedType}),b}return D(e.data)}}Dt.create=n=>new Dt({typeName:w.ZodSymbol,...O(n)});class rt extends Z{_parse(e){if(this._getType(e)!==_.undefined){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.undefined,received:t.parsedType}),b}return D(e.data)}}rt.create=n=>new rt({typeName:w.ZodUndefined,...O(n)});class st extends Z{_parse(e){if(this._getType(e)!==_.null){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.null,received:t.parsedType}),b}return D(e.data)}}st.create=n=>new st({typeName:w.ZodNull,...O(n)});class De extends Z{constructor(){super(...arguments),this._any=!0}_parse(e){return D(e.data)}}De.create=n=>new De({typeName:w.ZodAny,...O(n)});class Ze extends Z{constructor(){super(...arguments),this._unknown=!0}_parse(e){return D(e.data)}}Ze.create=n=>new Ze({typeName:w.ZodUnknown,...O(n)});class ie extends Z{_parse(e){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.never,received:t.parsedType}),b}}ie.create=n=>new ie({typeName:w.ZodNever,...O(n)});class Mt extends Z{_parse(e){if(this._getType(e)!==_.undefined){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.void,received:t.parsedType}),b}return D(e.data)}}Mt.create=n=>new Mt({typeName:w.ZodVoid,...O(n)});class z extends Z{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==_.array)return f(t,{code:p.invalid_type,expected:_.array,received:t.parsedType}),b;if(s.exactLength!==null){const o=t.data.length>s.exactLength.value,c=t.data.length<s.exactLength.value;(o||c)&&(f(t,{code:o?p.too_big:p.too_small,minimum:c?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(f(t,{code:p.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(f(t,{code:p.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>s.type._parseAsync(new J(t,o,t.path,c)))).then(o=>$.mergeArray(r,o));const a=[...t.data].map((o,c)=>s.type._parseSync(new J(t,o,t.path,c)));return $.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new z({...this._def,minLength:{value:e,message:y.toString(t)}})}max(e,t){return new z({...this._def,maxLength:{value:e,message:y.toString(t)}})}length(e,t){return new z({...this._def,exactLength:{value:e,message:y.toString(t)}})}nonempty(e){return this.min(1,e)}}z.create=(n,e)=>new z({type:n,minLength:null,maxLength:null,exactLength:null,typeName:w.ZodArray,...O(e)});function Me(n){if(n instanceof N){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=Y.create(Me(r))}return new N({...n._def,shape:()=>e})}else return n instanceof z?new z({...n._def,type:Me(n.element)}):n instanceof Y?Y.create(Me(n.unwrap())):n instanceof me?me.create(Me(n.unwrap())):n instanceof H?H.create(n.items.map(e=>Me(e))):n}class N extends Z{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=I.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==_.object){const d=this._getOrReturnCtx(e);return f(d,{code:p.invalid_type,expected:_.object,received:d.parsedType}),b}const{status:t,ctx:r}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof ie&&this._def.unknownKeys==="strip"))for(const d in r.data)a.includes(d)||o.push(d);const c=[];for(const d of a){const u=s[d],l=r.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new J(r,l,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof ie){const d=this._def.unknownKeys;if(d==="passthrough")for(const u of o)c.push({key:{status:"valid",value:u},value:{status:"valid",value:r.data[u]}});else if(d==="strict")o.length>0&&(f(r,{code:p.unrecognized_keys,keys:o}),t.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const u of o){const l=r.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new J(r,l,r.path,u)),alwaysSet:u in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const d=[];for(const u of c){const l=await u.key,T=await u.value;d.push({key:l,value:T,alwaysSet:u.alwaysSet})}return d}).then(d=>$.mergeObjectSync(t,d)):$.mergeObjectSync(t,c)}get shape(){return this._def.shape()}strict(e){return y.errToObj,new N({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,a,o,c;const d=(o=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,r).message)!==null&&o!==void 0?o:r.defaultError;return t.code==="unrecognized_keys"?{message:(c=y.errToObj(e).message)!==null&&c!==void 0?c:d}:{message:d}}}:{}})}strip(){return new N({...this._def,unknownKeys:"strip"})}passthrough(){return new N({...this._def,unknownKeys:"passthrough"})}extend(e){return new N({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new N({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:w.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new N({...this._def,catchall:e})}pick(e){const t={};return I.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new N({...this._def,shape:()=>t})}omit(e){const t={};return I.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new N({...this._def,shape:()=>t})}deepPartial(){return Me(this)}partial(e){const t={};return I.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new N({...this._def,shape:()=>t})}required(e){const t={};return I.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Y;)s=s._def.innerType;t[r]=s}}),new N({...this._def,shape:()=>t})}keyof(){return bn(I.objectKeys(this.shape))}}N.create=(n,e)=>new N({shape:()=>n,unknownKeys:"strip",catchall:ie.create(),typeName:w.ZodObject,...O(e)}),N.strictCreate=(n,e)=>new N({shape:()=>n,unknownKeys:"strict",catchall:ie.create(),typeName:w.ZodObject,...O(e)}),N.lazycreate=(n,e)=>new N({shape:n,unknownKeys:"strip",catchall:ie.create(),typeName:w.ZodObject,...O(e)});class at extends Z{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(a){for(const c of a)if(c.result.status==="valid")return c.result;for(const c of a)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=a.map(c=>new V(c.ctx.common.issues));return f(t,{code:p.invalid_union,unionErrors:o}),b}if(t.common.async)return Promise.all(r.map(async a=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(s);{let a;const o=[];for(const d of r){const u={...t,common:{...t.common,issues:[]},parent:null},l=d._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const c=o.map(d=>new V(d));return f(t,{code:p.invalid_union,unionErrors:c}),b}}get options(){return this._def.options}}at.create=(n,e)=>new at({options:n,typeName:w.ZodUnion,...O(e)});const he=n=>n instanceof ct?he(n.schema):n instanceof B?he(n.innerType()):n instanceof dt?[n.value]:n instanceof fe?n.options:n instanceof ut?I.objectValues(n.enum):n instanceof lt?he(n._def.innerType):n instanceof rt?[void 0]:n instanceof st?[null]:n instanceof Y?[void 0,...he(n.unwrap())]:n instanceof me?[null,...he(n.unwrap())]:n instanceof nn||n instanceof ft?he(n.unwrap()):n instanceof pt?he(n._def.innerType):[];class Lt extends Z{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.object)return f(t,{code:p.invalid_type,expected:_.object,received:t.parsedType}),b;const r=this.discriminator,s=t.data[r],a=this.optionsMap.get(s);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}):(f(t,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),b)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const a of t){const o=he(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(s.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);s.set(c,a)}}return new Lt({typeName:w.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...O(r)})}}function tn(n,e){const t=ue(n),r=ue(e);if(n===e)return{valid:!0,data:n};if(t===_.object&&r===_.object){const s=I.objectKeys(e),a=I.objectKeys(n).filter(c=>s.indexOf(c)!==-1),o={...n,...e};for(const c of a){const d=tn(n[c],e[c]);if(!d.valid)return{valid:!1};o[c]=d.data}return{valid:!0,data:o}}else if(t===_.array&&r===_.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<n.length;a++){const o=n[a],c=e[a],d=tn(o,c);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return t===_.date&&r===_.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class it extends Z{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(a,o)=>{if(Gt(a)||Gt(o))return b;const c=tn(a.value,o.value);return c.valid?((Xt(a)||Xt(o))&&t.dirty(),{status:t.value,value:c.data}):(f(r,{code:p.invalid_intersection_types}),b)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,o])=>s(a,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}it.create=(n,e,t)=>new it({left:n,right:e,typeName:w.ZodIntersection,...O(t)});class H extends Z{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==_.array)return f(r,{code:p.invalid_type,expected:_.array,received:r.parsedType}),b;if(r.data.length<this._def.items.length)return f(r,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),b;!this._def.rest&&r.data.length>this._def.items.length&&(f(r,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...r.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new J(r,a,r.path,o)):null}).filter(a=>!!a);return r.common.async?Promise.all(s).then(a=>$.mergeArray(t,a)):$.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new H({...this._def,rest:e})}}H.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new H({items:n,typeName:w.ZodTuple,rest:null,...O(e)})};class ot extends Z{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==_.object)return f(r,{code:p.invalid_type,expected:_.object,received:r.parsedType}),b;const s=[],a=this._def.keyType,o=this._def.valueType;for(const c in r.data)s.push({key:a._parse(new J(r,c,r.path,c)),value:o._parse(new J(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?$.mergeObjectAsync(t,s):$.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof Z?new ot({keyType:e,valueType:t,typeName:w.ZodRecord,...O(r)}):new ot({keyType:F.create(),valueType:e,typeName:w.ZodRecord,...O(t)})}}class Vt extends Z{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==_.map)return f(r,{code:p.invalid_type,expected:_.map,received:r.parsedType}),b;const s=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([c,d],u)=>({key:s._parse(new J(r,c,r.path,[u,"key"])),value:a._parse(new J(r,d,r.path,[u,"value"]))}));if(r.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const d of o){const u=await d.key,l=await d.value;if(u.status==="aborted"||l.status==="aborted")return b;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),c.set(u.value,l.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const d of o){const u=d.key,l=d.value;if(u.status==="aborted"||l.status==="aborted")return b;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),c.set(u.value,l.value)}return{status:t.value,value:c}}}}Vt.create=(n,e,t)=>new Vt({valueType:e,keyType:n,typeName:w.ZodMap,...O(t)});class je extends Z{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==_.set)return f(r,{code:p.invalid_type,expected:_.set,received:r.parsedType}),b;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(f(r,{code:p.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(f(r,{code:p.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function o(d){const u=new Set;for(const l of d){if(l.status==="aborted")return b;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const c=[...r.data.values()].map((d,u)=>a._parse(new J(r,d,r.path,u)));return r.common.async?Promise.all(c).then(d=>o(d)):o(c)}min(e,t){return new je({...this._def,minSize:{value:e,message:y.toString(t)}})}max(e,t){return new je({...this._def,maxSize:{value:e,message:y.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}je.create=(n,e)=>new je({valueType:n,minSize:null,maxSize:null,typeName:w.ZodSet,...O(e)});class Le extends Z{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.function)return f(t,{code:p.invalid_type,expected:_.function,received:t.parsedType}),b;function r(c,d){return Rt({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,At(),Pe].filter(u=>!!u),issueData:{code:p.invalid_arguments,argumentsError:d}})}function s(c,d){return Rt({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,At(),Pe].filter(u=>!!u),issueData:{code:p.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Ve){const c=this;return D(async function(...d){const u=new V([]),l=await c._def.args.parseAsync(d,a).catch(R=>{throw u.addIssue(r(d,R)),u}),T=await Reflect.apply(o,this,l);return await c._def.returns._def.type.parseAsync(T,a).catch(R=>{throw u.addIssue(s(T,R)),u})})}else{const c=this;return D(function(...d){const u=c._def.args.safeParse(d,a);if(!u.success)throw new V([r(d,u.error)]);const l=Reflect.apply(o,this,u.data),T=c._def.returns.safeParse(l,a);if(!T.success)throw new V([s(l,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Le({...this._def,args:H.create(e).rest(Ze.create())})}returns(e){return new Le({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new Le({args:e||H.create([]).rest(Ze.create()),returns:t||Ze.create(),typeName:w.ZodFunction,...O(r)})}}class ct extends Z{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ct.create=(n,e)=>new ct({getter:n,typeName:w.ZodLazy,...O(e)});class dt extends Z{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:p.invalid_literal,expected:this._def.value}),b}return{status:"valid",value:e.data}}get value(){return this._def.value}}dt.create=(n,e)=>new dt({value:n,typeName:w.ZodLiteral,...O(e)});function bn(n,e){return new fe({values:n,typeName:w.ZodEnum,...O(e)})}class fe extends Z{constructor(){super(...arguments),et.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return f(t,{expected:I.joinValues(r),received:t.parsedType,code:p.invalid_type}),b}if(Pt(this,et)||yn(this,et,new Set(this._def.values)),!Pt(this,et).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return f(t,{received:t.data,code:p.invalid_enum_value,options:r}),b}return D(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return fe.create(e,{...this._def,...t})}exclude(e,t=this._def){return fe.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}et=new WeakMap,fe.create=bn;class ut extends Z{constructor(){super(...arguments),tt.set(this,void 0)}_parse(e){const t=I.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==_.string&&r.parsedType!==_.number){const s=I.objectValues(t);return f(r,{expected:I.joinValues(s),received:r.parsedType,code:p.invalid_type}),b}if(Pt(this,tt)||yn(this,tt,new Set(I.getValidEnumValues(this._def.values))),!Pt(this,tt).has(e.data)){const s=I.objectValues(t);return f(r,{received:r.data,code:p.invalid_enum_value,options:s}),b}return D(e.data)}get enum(){return this._def.values}}tt=new WeakMap,ut.create=(n,e)=>new ut({values:n,typeName:w.ZodNativeEnum,...O(e)});class Ve extends Z{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.promise&&t.common.async===!1)return f(t,{code:p.invalid_type,expected:_.promise,received:t.parsedType}),b;const r=t.parsedType===_.promise?t.data:Promise.resolve(t.data);return D(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ve.create=(n,e)=>new Ve({type:n,typeName:w.ZodPromise,...O(e)});class B extends Z{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===w.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:o=>{f(r,o),o.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const o=s.transform(r.data,a);if(r.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return b;const d=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return d.status==="aborted"?b:d.status==="dirty"||t.value==="dirty"?$t(d.value):d});{if(t.value==="aborted")return b;const c=this._def.schema._parseSync({data:o,path:r.path,parent:r});return c.status==="aborted"?b:c.status==="dirty"||t.value==="dirty"?$t(c.value):c}}if(s.type==="refinement"){const o=c=>{const d=s.refinement(c,a);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){const c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?b:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?b:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Ge(o))return o;const c=s.transform(o.value,a);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Ge(o)?Promise.resolve(s.transform(o.value,a)).then(c=>({status:t.value,value:c})):o);I.assertNever(s)}}B.create=(n,e,t)=>new B({schema:n,typeName:w.ZodEffects,effect:e,...O(t)}),B.createWithPreprocess=(n,e,t)=>new B({schema:e,effect:{type:"preprocess",transform:n},typeName:w.ZodEffects,...O(t)});class Y extends Z{_parse(e){return this._getType(e)===_.undefined?D(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Y.create=(n,e)=>new Y({innerType:n,typeName:w.ZodOptional,...O(e)});class me extends Z{_parse(e){return this._getType(e)===_.null?D(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}me.create=(n,e)=>new me({innerType:n,typeName:w.ZodNullable,...O(e)});class lt extends Z{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===_.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}lt.create=(n,e)=>new lt({innerType:n,typeName:w.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...O(e)});class pt extends Z{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Xe(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new V(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new V(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}pt.create=(n,e)=>new pt({innerType:n,typeName:w.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...O(e)});class Ut extends Z{_parse(e){if(this._getType(e)!==_.nan){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.nan,received:t.parsedType}),b}return{status:"valid",value:e.data}}}Ut.create=n=>new Ut({typeName:w.ZodNaN,...O(n)});const yr=Symbol("zod_brand");class nn extends Z{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class ht extends Z{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?b:s.status==="dirty"?(t.dirty(),$t(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?b:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new ht({in:e,out:t,typeName:w.ZodPipeline})}}class ft extends Z{_parse(e){const t=this._def.innerType._parse(e),r=s=>(Ge(s)&&(s.value=Object.freeze(s.value)),s);return Xe(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}ft.create=(n,e)=>new ft({innerType:n,typeName:w.ZodReadonly,...O(e)});function Tn(n,e={},t){return n?De.create().superRefine((r,s)=>{var a,o;if(!n(r)){const c=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,d=(o=(a=c.fatal)!==null&&a!==void 0?a:t)!==null&&o!==void 0?o:!0,u=typeof c=="string"?{message:c}:c;s.addIssue({code:"custom",...u,fatal:d})}}):De.create()}const vr={object:N.lazycreate};var w;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(w||(w={}));const wr=(n,e={message:`Input not instance of ${n.name}`})=>Tn(t=>t instanceof n,e),On=F.create,Sn=le.create,kr=Ut.create,xr=pe.create,Zn=nt.create,br=Se.create,Tr=Dt.create,Or=rt.create,Sr=st.create,Zr=De.create,jr=Ze.create,Ir=ie.create,Cr=Mt.create,Nr=z.create,Er=N.create,Ar=N.strictCreate,Rr=at.create,$r=Lt.create,Pr=it.create,Dr=H.create,Mr=ot.create,Lr=Vt.create,Vr=je.create,Ur=Le.create,Fr=ct.create,zr=dt.create,Br=fe.create,qr=ut.create,Wr=Ve.create,jn=B.create,Kr=Y.create,Qr=me.create,Jr=B.createWithPreprocess,Hr=ht.create;var i=Object.freeze({__proto__:null,defaultErrorMap:Pe,setErrorMap:tr,getErrorMap:At,makeIssue:Rt,EMPTY_PATH:nr,addIssueToContext:f,ParseStatus:$,INVALID:b,DIRTY:$t,OK:D,isAborted:Gt,isDirty:Xt,isValid:Ge,isAsync:Xe,get util(){return I},get objectUtil(){return Yt},ZodParsedType:_,getParsedType:ue,ZodType:Z,datetimeRegex:xn,ZodString:F,ZodNumber:le,ZodBigInt:pe,ZodBoolean:nt,ZodDate:Se,ZodSymbol:Dt,ZodUndefined:rt,ZodNull:st,ZodAny:De,ZodUnknown:Ze,ZodNever:ie,ZodVoid:Mt,ZodArray:z,ZodObject:N,ZodUnion:at,ZodDiscriminatedUnion:Lt,ZodIntersection:it,ZodTuple:H,ZodRecord:ot,ZodMap:Vt,ZodSet:je,ZodFunction:Le,ZodLazy:ct,ZodLiteral:dt,ZodEnum:fe,ZodNativeEnum:ut,ZodPromise:Ve,ZodEffects:B,ZodTransformer:B,ZodOptional:Y,ZodNullable:me,ZodDefault:lt,ZodCatch:pt,ZodNaN:Ut,BRAND:yr,ZodBranded:nn,ZodPipeline:ht,ZodReadonly:ft,custom:Tn,Schema:Z,ZodSchema:Z,late:vr,get ZodFirstPartyTypeKind(){return w},coerce:{string:n=>F.create({...n,coerce:!0}),number:n=>le.create({...n,coerce:!0}),boolean:n=>nt.create({...n,coerce:!0}),bigint:n=>pe.create({...n,coerce:!0}),date:n=>Se.create({...n,coerce:!0})},any:Zr,array:Nr,bigint:xr,boolean:Zn,date:br,discriminatedUnion:$r,effect:jn,enum:Br,function:Ur,instanceof:wr,intersection:Pr,lazy:Fr,literal:zr,map:Lr,nan:kr,nativeEnum:qr,never:Ir,null:Sr,nullable:Qr,number:Sn,object:Er,oboolean:()=>Zn().optional(),onumber:()=>Sn().optional(),optional:Kr,ostring:()=>On().optional(),pipeline:Hr,preprocess:Jr,promise:Wr,record:Mr,set:Vr,strictObject:Ar,string:On,symbol:Tr,transformer:jn,tuple:Dr,undefined:Or,union:Rr,unknown:jr,void:Cr,NEVER:b,ZodIssueCode:p,quotelessJson:er,ZodError:V});Xn(i),i.object({start:i.number(),limit:i.number(),length:i.number()});const rn=i.object({created_at:i.string(),updated_at:i.string()}),Yr=i.object({email:i.string().optional(),email_verified:i.boolean().optional(),name:i.string().optional(),username:i.string().optional(),given_name:i.string().optional(),phone_number:i.string().optional(),phone_verified:i.boolean().optional(),family_name:i.string().optional()}).catchall(i.any()),Gr=i.object({connection:i.string(),user_id:i.string(),provider:i.string(),isSocial:i.boolean(),access_token:i.string().optional(),access_token_secret:i.string().optional(),refresh_token:i.string().optional(),profileData:Yr.optional()}),In=i.object({email:i.string().optional(),username:i.string().optional(),given_name:i.string().optional(),family_name:i.string().optional(),nickname:i.string().optional(),name:i.string().optional(),picture:i.string().optional(),locale:i.string().optional(),linked_to:i.string().optional(),profileData:i.string().optional(),user_id:i.string().optional()});In.extend({email_verified:i.boolean().default(!1),verify_email:i.boolean().optional(),last_ip:i.string().optional(),last_login:i.string().optional(),user_id:i.string().optional(),provider:i.string().default("email"),connection:i.string().default("email")}).extend(rn.shape).extend({user_id:i.string(),email:i.string(),is_social:i.boolean(),login_count:i.number(),identities:i.array(Gr).optional()}),In.extend({email:i.string(),login_count:i.number(),multifactor:i.array(i.string()).optional(),last_ip:i.string().optional(),last_login:i.string().optional(),user_id:i.string()}).catchall(i.any());const Xr=i.object({id:i.string(),name:i.string(),allowed_web_origins:i.string().transform(n=>n===null?"":n).default(""),allowed_callback_urls:i.string().transform(n=>n===null?"":n).default(""),allowed_logout_urls:i.string().transform(n=>n===null?"":n).default(""),email_validation:i.enum(["enabled","disabled","enforced"]).default("enforced"),client_secret:i.string().default(""),disable_sign_ups:i.boolean().default(!1)});i.object({created_at:i.string().transform(n=>n===null?"":n),updated_at:i.string().transform(n=>n===null?"":n)}).extend(Xr.shape);var Cn=(n=>(n.TOKEN="token",n.TOKEN_ID_TOKEN="token id_token",n.CODE="code",n))(Cn||{}),Nn=(n=>(n.QUERY="query",n.FRAGMENT="fragment",n.FORM_POST="form_post",n.WEB_MESSAGE="web_message",n))(Nn||{}),En=(n=>(n.S265="S256",n.plain="plain",n))(En||{});const Ft=i.object({client_id:i.string(),vendor_id:i.string().optional(),response_type:i.nativeEnum(Cn).optional(),response_mode:i.nativeEnum(Nn).optional(),redirect_uri:i.string().optional(),audience:i.string().optional(),state:i.string().optional(),nonce:i.string().optional(),scope:i.string().optional(),code_challenge_method:i.nativeEnum(En).optional(),code_challenge:i.string().optional(),username:i.string().optional()});i.object({colors:i.object({primary:i.string(),page_background:i.object({type:i.string().optional(),start:i.string().optional(),end:i.string().optional(),angle_deg:i.number().optional()}).optional()}).optional(),logo_url:i.string().optional(),favicon_url:i.string().optional(),font:i.object({url:i.string()}).optional()});const es=i.object({id:i.string().optional(),name:i.string(),client_id:i.string().optional(),client_secret:i.string().optional(),authorization_endpoint:i.string().optional(),response_type:i.custom().optional(),response_mode:i.custom().optional(),private_key:i.string().optional(),kid:i.string().optional(),team_id:i.string().optional(),token_endpoint:i.string().optional(),token_exchange_basic_auth:i.boolean().optional(),userinfo_endpoint:i.string().optional(),scope:i.string().optional()}),sn=i.object({id:i.string(),created_at:i.string().transform(n=>n===null?"":n),updated_at:i.string().transform(n=>n===null?"":n)}).extend(es.shape),ts=i.object({domain:i.string(),dkim_private_key:i.string().optional(),dkim_public_key:i.string().optional(),email_api_key:i.string().optional(),email_service:i.union([i.literal("mailgun"),i.literal("mailchannels")]).optional()}),An=i.object({id:i.string(),name:i.string(),domains:i.array(ts),allowed_callback_urls:i.array(i.string()),allowed_logout_urls:i.array(i.string()),allowed_web_origins:i.array(i.string()),email_validation:i.union([i.literal("enabled"),i.literal("disabled"),i.literal("enforced")]),tenant_id:i.string(),client_secret:i.string(),disable_sign_ups:i.boolean(),tenant:i.object({name:i.string(),audience:i.string().optional(),logo:i.string().optional(),primary_color:i.string().optional(),secondary_color:i.string().optional(),sender_email:i.string(),sender_name:i.string(),support_url:i.string().optional(),language:i.string().length(2).optional()})});An.extend({connections:i.array(sn)}),An.extend({connections:i.array(sn.partial())});const ns=i.enum(["password_reset","email_verification","otp","oauth2","oauth2_state","ticket"]),rs=i.object({code_id:i.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:i.string().openapi({description:"The id of the login session that the code is connected to"}),code_type:ns,created_at:i.string(),expires_at:i.string(),used_at:i.string().optional()}),ss=i.object({domain:i.string(),dkim_private_key:i.string().optional(),dkim_public_key:i.string().optional(),email_api_key:i.string().optional(),email_service:i.enum(["mailgun","mailchannels"])});rn.extend({...ss.shape,id:i.string()}),i.object({trigger_id:i.enum(["post-user-registration","post-user-login"]),enabled:i.boolean().default(!1),url:i.string(),hook_id:i.string().optional()}).extend({...rn.shape,hook_id:i.string()});const as=i.object({alg:i.string(),e:i.string(),kid:i.string(),kty:i.string(),n:i.string(),use:i.string().optional()});i.object({keys:i.array(as)}),i.object({issuer:i.string(),authorization_endpoint:i.string(),token_endpoint:i.string(),device_authorization_endpoint:i.string(),userinfo_endpoint:i.string(),mfa_challenge_endpoint:i.string(),jwks_uri:i.string(),registration_endpoint:i.string(),revocation_endpoint:i.string(),scopes_supported:i.array(i.string()),response_types_supported:i.array(i.string()),code_challenge_methods_supported:i.array(i.string()),response_modes_supported:i.array(i.string()),subject_types_supported:i.array(i.string()),id_token_signing_alg_values_supported:i.array(i.string()),token_endpoint_auth_methods_supported:i.array(i.string()),claims_supported:i.array(i.string()),request_uri_parameter_supported:i.boolean(),request_parameter_supported:i.boolean(),token_endpoint_auth_signing_alg_values_supported:i.array(i.string())});const is=i.object({login_id:i.string().openapi({description:"This is is used as the state in the universal login"}),auth0Client:i.string().optional(),authParams:Ft,expires_at:i.string(),deleted_at:i.string(),ip:i.string().optional()}).openapi({description:"This represents a login sesion"});i.object({...is.shape,created_at:i.string(),updated_at:i.string()});const os=i.enum(["sapi","ssa","fsa","ss","ssa","fs","s","f","fp","slo","scoa","fcoa","seccft","cls","seacft","serft"]),cs=i.object({name:i.string(),version:i.string(),env:i.object({node:i.string().optional()}).optional()});i.object({type:os,date:i.string(),description:i.string().optional(),log_id:i.string().optional(),_id:i.string().optional(),ip:i.string(),user_agent:i.string(),details:i.any().optional(),isMobile:i.boolean(),user_id:i.string().optional(),user_name:i.string().optional(),connection:i.string().optional(),connection_id:i.string().optional(),client_id:i.string().optional(),client_name:i.string().optional(),audience:i.string().optional(),scope:i.array(i.string()).optional(),strategy:i.string().optional(),strategy_type:i.string().optional(),hostname:i.string().optional(),auth0_client:cs.optional()});const ds=i.object({user_id:i.string(),password:i.string(),algorithm:i.enum(["bcrypt","argon2id"]).default("argon2id")});i.object({...ds.shape,created_at:i.string(),updated_at:i.string()});const us=i.object({session_id:i.string(),client_id:i.string(),expires_at:i.string(),used_at:i.string(),deleted_at:i.string().optional(),user_id:i.string()});i.object({created_at:i.string(),...us.shape}),i.object({private_key:i.string(),public_key:i.string(),kid:i.string(),created_at:i.string(),revoked_at:i.string().optional()}),i.object({kid:i.string().openapi({description:"The key id of the signing key"}),cert:i.string().openapi({description:"The public certificate of the signing key"}),fingerprint:i.string().openapi({description:"The cert fingerprint"}),thumbprint:i.string().openapi({description:"The cert thumbprint"}),pkcs7:i.string().optional().openapi({description:"The public certificate of the signing key in pkcs7 format"}),current:i.boolean().optional().openapi({description:"True if the key is the current key"}),next:i.boolean().optional().openapi({description:"True if the key is the next key"}),previous:i.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:i.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:i.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:i.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:i.string().optional().openapi({description:"The date and time when the key was revoked"})}),i.object({name:i.string(),audience:i.string(),sender_email:i.string().email(),sender_name:i.string(),support_url:i.string().url().optional(),logo:i.string().url().optional(),primary_color:i.string().optional(),secondary_color:i.string().optional(),language:i.string().optional()}).extend({created_at:i.string().transform(n=>n===null?"":n),updated_at:i.string().transform(n=>n===null?"":n)}),i.object({logoUrl:i.string(),loginBackgroundImage:i.string().nullish(),style:i.object({primaryColor:i.string(),buttonTextColor:i.string(),primaryHoverColor:i.string()}),supportEmail:i.string().nullable(),supportUrl:i.string().nullable(),name:i.string(),showGreyishBackground:i.boolean().optional(),termsAndConditionsUrl:i.string().nullable(),companyName:i.string().optional(),checkoutHideSocial:i.boolean().optional(),siteUrl:i.string().nullable(),manageSubscriptionsUrl:i.string().optional()});var Rn=(n=>(n.RefreshToken="refresh_token",n.AuthorizationCode="authorization_code",n.ClientCredential="client_credentials",n.Passwordless="passwordless",n.Password="password",n))(Rn||{});const an=i.nativeEnum(Rn);i.object({grant_type:an.refine(n=>n==="authorization_code"),code:i.string(),client_secret:i.string(),client_id:i.string()}),i.object({grant_type:an.refine(n=>n==="authorization_code"),code:i.string(),code_verifier:i.string(),client_id:i.string().optional(),redirect_uri:i.string()}),i.object({grant_type:an.refine(n=>n==="client_credentials"),scope:i.string().optional(),client_secret:i.string(),client_id:i.string(),audience:i.string().optional()}),i.object({access_token:i.string(),id_token:i.string().optional(),scope:i.string().optional(),state:i.string().optional(),refresh_token:i.string().optional(),token_type:i.string(),expires_in:i.number()}),i.object({code:i.string(),state:i.string().optional()});const ls=i.object({button_border_radius:i.number(),button_border_weight:i.number(),buttons_style:i.enum(["pill"]),input_border_radius:i.number(),input_border_weight:i.number(),inputs_style:i.enum(["pill"]),show_widget_shadow:i.boolean(),widget_border_weight:i.number(),widget_corner_radius:i.number()}),ps=i.object({base_focus_color:i.string(),base_hover_color:i.string(),body_text:i.string(),captcha_widget_theme:i.enum(["auto"]),error:i.string(),header:i.string(),icons:i.string(),input_background:i.string(),input_border:i.string(),input_filled_text:i.string(),input_labels_placeholders:i.string(),links_focused_components:i.string(),primary_button:i.string(),primary_button_label:i.string(),secondary_button_border:i.string(),secondary_button_label:i.string(),success:i.string(),widget_background:i.string(),widget_border:i.string()}),Ue=i.object({bold:i.boolean(),size:i.number()}),hs=i.object({body_text:Ue,buttons_text:Ue,font_url:i.string(),input_labels:Ue,links:Ue,links_style:i.enum(["normal"]),reference_text_size:i.number(),subtitle:Ue,title:Ue}),fs=i.object({background_color:i.string(),background_image_url:i.string(),page_layout:i.enum(["center"])}),ms=i.object({header_text_alignment:i.enum(["center"]),logo_height:i.number(),logo_position:i.enum(["center"]),logo_url:i.string(),social_buttons_layout:i.enum(["bottom"])});i.object({borders:ls,colors:ps,displayName:i.string(),fonts:hs,page_background:fs,widget:ms}).extend({themeId:i.string()});const _s=i.object({id:i.string(),expires_at:i.string(),auth0Client:i.string().optional(),authParams:Ft});i.object({..._s.shape,created_at:i.string(),updated_at:i.string()});const gs=i.object({id:i.string(),email:i.string(),code:i.string(),ip:i.string().optional(),send:i.enum(["code","link"]),authParams:Ft,expires_at:i.string(),used_at:i.string().optional(),user_id:i.string().optional()});i.object({created_at:i.string(),...gs.shape});const ys=i.object({authParams:Ft,code:i.string(),user_id:i.string(),created_at:i.string(),expires_at:i.string(),used_at:i.string().optional()});i.object({...ys.shape,created_at:i.string()});function on(n){const[e,t]=n.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${n}`);return{connection:e,id:t}}function $n(n){let e={};try{e=JSON.parse(n.profileData||"{}")}catch(t){console.error("Error parsing profileData",t)}return{connection:n.connection,provider:n.provider,user_id:on(n.user_id).id,isSocial:!!n.is_social,profileData:{email:n.email,email_verified:!!n.email_verified,...e}}}function vs(n){return async(e,t)=>{const[r,s]=await Promise.all([n.selectFrom("users").where("users.tenant_id","=",e).where("users.user_id","=",t).selectAll().executeTakeFirst(),n.selectFrom("users").where("users.tenant_id","=",e).where("users.linked_to","=",t).selectAll().execute()]);if(!r)return null;const{tenant_id:a,...o}=r,c={...o,email:r.email||"",email_verified:r.email_verified===1,is_social:r.is_social===1,identities:[{connection:r.connection,provider:r.provider,user_id:on(r.user_id).id,isSocial:!!r.is_social},...s.map($n)]};return A(c)}}function Ie(n,e,t,r){return t.split(/\s+/).map(a=>a.replace("=",":")).map(a=>{let o=a.startsWith("-"),c,d,u;return a.startsWith("-_exists_:")?(c=a.substring(10),u=!0,o=!0):a.startsWith("_exists_:")?(c=a.substring(9),u=!0,o=!1):a.includes(":")?(o=a.startsWith("-"),[c,d]=o?a.substring(1).split(":"):a.split(":"),u=!1):(c=null,d=a,u=!1),{key:c,value:d,isNegation:o,isExistsQuery:u}}).forEach(({key:a,value:o,isNegation:c,isExistsQuery:d})=>{if(a)d?c?e=e.where(a,"is",null):e=e.where(a,"is not",null):c?e=e.where(a,"!=",o):e=e.where(a,"=",o);else{const{ref:u}=n.dynamic;e=e.where(l=>l.or(r.map(T=>l(u(T),"like",`%${o}%`))))}}),e}function _e(n){return typeof n=="string"?parseInt(n,10):typeof n=="bigint"?Number(n):n}function ws(n){return async(e,t)=>{let r=n.selectFrom("users").where("users.tenant_id","=",e);if(t.q&&(r=Ie(n,r,t.q,["email","name"])),t.sort&&t.sort.sort_by){const{ref:l}=n.dynamic;r=r.orderBy(l(t.sort.sort_by),t.sort.sort_order)}const a=await r.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),o=a.map(l=>l.user_id),c=o.length?await n.selectFrom("users").selectAll().where("users.tenant_id","=",e).where("users.linked_to","in",o).execute():[],d=a.map(l=>{const T=c.filter(R=>R.linked_to===l.user_id);return A({...l,email_verified:l.email_verified===1,is_social:l.is_social===1,identities:[{connection:l.connection,provider:l.provider,user_id:on(l.user_id).id,isSocial:!!l.is_social},...T.map($n)]})}),{count:u}=await r.select(l=>l.fn.countAll().as("count")).executeTakeFirstOrThrow();return{users:d,start:t.page*t.per_page,limit:t.per_page,length:_e(u)}}}function ks(n){return async(e,t)=>(await n.deleteFrom("users").where("users.tenant_id","=",e).where("users.linked_to","=",t).execute(),(await n.deleteFrom("users").where("users.tenant_id","=",e).where("users.user_id","=",t).execute()).length===1)}function xs(n){if(n.email_verified!==void 0)return n.email_verified?1:0}function bs(n){return async(e,t,r)=>{const s={...r,email_verified:xs(r),updated_at:new Date().toISOString()};return(await n.updateTable("users").set(s).where("users.tenant_id","=",e).where("users.user_id","=",t).execute()).length===1}}function Ts(n){return async(e,t,r,s)=>{const a={linked_to:null};return(await n.updateTable("users").set(a).where("users.tenant_id","=",e).where("users.user_id","=",`${r}|${s}`).where("users.linked_to","=",`${t}`).execute()).length===1}}function Os(n){return{create:ae(n),remove:ks(n),get:vs(n),list:ws(n),update:bs(n),unlink:Ts(n)}}const Ss="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Fe=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n));for(;n--;)e+=Ss[t[n]&63];return e};function Zs(n){return async e=>{const t={id:e.id||Fe(),created_at:new Date().toISOString(),updated_at:new Date().toISOString(),...e};return await n.insertInto("tenants").values(t).execute(),t}}function js(n){return async e=>{const t=await n.selectFrom("tenants").where("tenants.id","=",e).selectAll().executeTakeFirst();return t?A(t):null}}function Is(n){return async e=>{let t=n.selectFrom("tenants");if(e.sort&&e.sort.sort_by){const{ref:c}=n.dynamic;t=t.orderBy(c(e.sort.sort_by),e.sort.sort_order)}e.q&&(t=t.where(c=>c.or([c("name","like",`%${e.q}%`)])));const s=await t.offset(e.page*e.per_page).limit(e.per_page).selectAll().execute();if(!e.include_totals)return{tenants:s};const{count:a}=await t.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow(),o=_e(a);return{tenants:s.map(A),start:(e.page-1)*e.per_page,limit:e.per_page,length:o}}}function Cs(n){return async(e,t)=>{const r={...t,id:e,updated_at:new Date().toISOString()};await n.updateTable("tenants").set(r).where("id","=",e).execute()}}function Ns(n){return async e=>(await n.deleteFrom("tenants").where("tenants.id","=",e).execute()).length===1}function Es(n){return{create:Zs(n),get:js(n),list:Is(n),update:Cs(n),remove:Ns(n)}}function Pn(n){return n?JSON.stringify(n):void 0}const As=1024;function Rs(n){return async(e,t)=>{var s,a;const r={id:Fe(),...t,user_agent:t.user_agent.slice(0,As)};return await n.insertInto("logs").values({...r,isMobile:t.isMobile?1:0,tenant_id:e,scope:(s=t.scope)==null?void 0:s.join(","),auth0_client:Pn(t.auth0_client),details:(a=Pn(t.details))==null?void 0:a.substring(0,8192)}).execute(),r}}function Dn(n){if(!n)return"";try{return JSON.parse(n)}catch{return n}}function Mn(n){return{...n,client_id:n.client_id,client_name:"",auth0_client:Dn(n.auth0_client),details:Dn(n.details),isMobile:!!n.isMobile,scope:n.scope?n.scope.split(","):void 0,log_id:n.id,_id:n.id}}function $s(n){return async(e,t)=>{let r=n.selectFrom("logs").where("logs.tenant_id","=",e);t.q&&(r=Ie(n,r,t.q,["user_id","ip"]));let s=r;if(t.sort&&t.sort.sort_by){const{ref:c}=n.dynamic;s=s.orderBy(c(t.sort.sort_by),t.sort.sort_order)}s=s.offset(t.page*t.per_page).limit(t.per_page);const a=await s.selectAll().execute(),{count:o}=await r.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{logs:a.map(Mn),start:t.page*t.per_page,limit:t.per_page,length:_e(o)}}}function Ps(n){return async(e,t)=>{const r=await n.selectFrom("logs").where("logs.tenant_id","=",e).where("logs.id","=",t).selectAll().executeTakeFirst();return r?Mn(r):null}}function Ds(n){return{create:Rs(n),list:$s(n),get:Ps(n)}}function Ms(n){return async(e,t)=>await n.selectFrom("sessions").where("sessions.tenant_id","=",e).where("sessions.session_id","=",t).where("sessions.deleted_at","is",null).selectAll().executeTakeFirst()??null}function Ls(n){return async(e,t)=>{const r={...t,created_at:new Date().toISOString(),expires_at:new Date().toISOString()};return await n.insertInto("sessions").values({...r,tenant_id:e}).execute(),{...t,...r}}}function Vs(n){return async(e,t)=>!!(await n.updateTable("sessions").set({deleted_at:new Date().toISOString()}).where("tenant_id","=",e).where("sessions.session_id","=",t).where("sessions.deleted_at","is",null).execute()).length}function Us(n){return async(e,t,r)=>!!(await n.updateTable("sessions").set(r).where("tenant_id","=",e).where("sessions.session_id","=",t).where("sessions.deleted_at","is",null).execute()).length}function Fs(n){return async(e,t)=>{let r=n.selectFrom("sessions").where("sessions.tenant_id","=",e);t.q&&(r=Ie(n,r,t.q,["user_id","session_id"]));let s=r;if(t.sort&&t.sort.sort_by){const{ref:d}=n.dynamic;s=s.orderBy(d(t.sort.sort_by),t.sort.sort_order)}s=s.offset(t.page*t.per_page).limit(t.per_page);const a=await s.selectAll().execute(),{count:o}=await r.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow(),c=_e(o);return{sessions:a,start:t.page*t.per_page,limit:t.per_page,length:c}}}function zs(n){return{create:Ls(n),get:Ms(n),list:Fs(n),remove:Vs(n),update:Us(n)}}function Bs(n){return async(e,t)=>{const r=await n.selectFrom("tickets").where("tickets.tenant_id","=",e).where("tickets.id","=",t).where("tickets.used_at","is",null).selectAll().executeTakeFirst();if(!r)return null;const{nonce:s,state:a,scope:o,response_type:c,response_mode:d,redirect_uri:u,...l}=r;return{...l,authParams:{nonce:s,state:a,scope:o,response_type:c,response_mode:d,redirect_uri:u},created_at:new Date(r.created_at),expires_at:new Date(r.expires_at),used_at:r.used_at?new Date(r.used_at):void 0}}}function qs(n){return async e=>{const{authParams:t,...r}=e,s={...r,...t,created_at:e.created_at.toISOString(),expires_at:e.expires_at.toISOString(),used_at:e.used_at?e.used_at.toISOString():void 0};await n.insertInto("tickets").values(s).execute()}}function Ws(n){return async(e,t)=>{await n.updateTable("tickets").set({used_at:new Date().toISOString()}).where("tickets.tenant_id","=",e).where("tickets.id","=",t).execute()}}function Ks(n){return{create:qs(n),get:Bs(n),remove:Ws(n)}}function Qs(n){return async(e,t)=>{const r=new Date().toISOString();return(await n.selectFrom("otps").where("otps.tenant_id","=",e).where("otps.email","=",t).where("otps.expires_at",">",r).where("otps.used_at","is",null).selectAll().execute()).map(a=>{const{nonce:o,state:c,scope:d,response_type:u,redirect_uri:l,client_id:T,...R}=a;return{...R,client_id:T,authParams:{client_id:T,nonce:o,state:c,scope:d,response_type:u,redirect_uri:l},created_at:a.created_at,expires_at:a.expires_at}})}}function Js(n){return async(e,t)=>{const{authParams:r,...s}=t;await n.insertInto("otps").values({...s,...r,created_at:new Date().toISOString(),tenant_id:e,send:t.send==="code"?"code":"link"}).execute()}}function Hs(n){return async(e,t)=>(await n.updateTable("otps").set({used_at:new Date().toISOString()}).where("otps.tenant_id","=",e).where("otps.id","=",t).execute()).length>0}function Ys(n){return{create:Js(n),list:Qs(n),remove:Hs(n)}}function Gs(n){return async(e,t)=>{const r=await n.selectFrom("passwords").where("passwords.tenant_id","=",e).where("passwords.user_id","=",t).selectAll().executeTakeFirstOrThrow(),{tenant_id:s,...a}=r;return a}}function Xs(n){return async(e,t)=>{const r={...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("passwords").values({...r,tenant_id:e}).execute(),r}}function ea(n){return async(e,t)=>(await n.updateTable("passwords").set({password:t.password,updated_at:new Date().toISOString()}).where("tenant_id","=",e).where("user_id","=",t.user_id).execute()).length===1}function ta(n){return{create:Xs(n),update:ea(n),get:Gs(n)}}function na(n){return async(e,t)=>{let r=n.selectFrom("codes").where("codes.tenant_id","=",e);t.q&&(r=Ie(n,r,t.q,["code","login_id"]));const a=await r.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await r.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow();return{codes:a.map(d=>{const{tenant_id:u,...l}=d;return rs.parse(A(l))}),start:t.page*t.per_page,limit:t.per_page,length:_e(o)}}}function ra(n){return async(e,t)=>{const r={...t,tenant_id:e,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("codes").values({...r,tenant_id:e}).execute(),r}}function sa(n){return async(e,t)=>(await n.deleteFrom("codes").where("codes.tenant_id","=",e).where("codes.code_id","=",t).executeTakeFirst()).numDeletedRows>0}function aa(n){return async(e,t,r)=>{const s=await n.selectFrom("codes").where("codes.tenant_id","=",e).where("codes.code_id","=",t).where("codes.code_type","=",r).selectAll().executeTakeFirst();return s?A(s):null}}function ia(n){return{create:ra(n),list:na(n),remove:sa(n),get:aa(n)}}function oa(n){return async e=>{const t=new Date().toISOString(),r=await n.selectFrom("universal_login_sessions").where("universal_login_sessions.expires_at",">",t).where("universal_login_sessions.id","=",e).selectAll().executeTakeFirst();if(!r)return null;const{response_type:s,response_mode:a,redirect_uri:o,audience:c,state:d,nonce:u,scope:l,code_challenge_method:T,code_challenge:R,username:L,vendor_id:te,...de}=r;return{...de,authParams:{client_id:de.client_id,vendor_id:te,response_type:s,response_mode:a,redirect_uri:o,audience:c,state:d,nonce:u,scope:l,code_challenge_method:T,code_challenge:R,username:L}}}}function ca(n){return async(e,t)=>{const{authParams:r,...s}=t,a={created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("universal_login_sessions").values({...r,...s,...a,tenant_id:e}).execute(),{...t,...a}}}function da(n){return async(e,t,r)=>{const{authParams:s,...a}=r;return(await n.updateTable("universal_login_sessions").set({...s,...a}).where("id","=",t).where("tenant_id","=",e).execute()).length===1}}function ua(n){return{create:ca(n),get:oa(n),update:da(n)}}function la(n){return async(e,t)=>{const r={created_at:new Date().toISOString(),updated_at:new Date().toISOString(),...t,disable_sign_ups:t.disable_sign_ups?1:0};return await n.insertInto("applications").values({...r,tenant_id:e}).execute(),r}}function pa(n){return async e=>({applications:await n.selectFrom("applications").where("applications.tenant_id","=",e).selectAll().execute()})}function ha(n){return async(e,t)=>{const r=await n.selectFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",t).selectAll().executeTakeFirst();return r?(r.disable_sign_ups=!!r.disable_sign_ups,A(r)):null}}function fa(n){return async(e,t)=>(await n.deleteFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",t).executeTakeFirst()).numDeletedRows>0}function ma(n){return async(e,t,r)=>{const s={...r,updated_at:new Date().toISOString()};return await n.updateTable("applications").set(s).where("applications.id","=",t).where("applications.tenant_id","=",e).execute(),!0}}function _a(n){return{create:la(n),list:pa(n),get:ha(n),remove:fa(n),update:ma(n)}}function ga(n){return async(e,t)=>{const r={id:Fe(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("connections").values({...r,tenant_id:e}).execute(),r}}function ya(n){return async(e,t)=>{let r=n.selectFrom("connections").where("connections.tenant_id","=",e);t.q&&(r=Ie(n,r,t.q,["user_id","ip"]));const a=await r.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await r.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{connections:a.map(A),start:t.page*t.per_page,limit:t.per_page,length:_e(o)}}}function va(n){return async(e,t)=>(await n.deleteFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",t).executeTakeFirst()).numDeletedRows>0}function wa(n){return async(e,t)=>{const r=await n.selectFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",t).selectAll().executeTakeFirst();return r?A(r):null}}function ka(n){return async(e,t,r)=>{const s={...r,updated_at:new Date().toISOString()};return await n.updateTable("connections").set(s).where("connections.id","=",t).where("connections.tenant_id","=",e).execute(),!0}}function xa(n){return{create:ga(n),get:wa(n),list:ya(n),remove:va(n),update:ka(n)}}function cn(n){return n!=null&&n.length?n.split(",").map(e=>e.trim()):[]}function ba(n){return{get:async e=>{const t=await n.selectFrom("applications").selectAll().where("id","=",e).executeTakeFirst();if(!t)return null;const r=await n.selectFrom("tenants").selectAll().where("id","=",t.tenant_id).executeTakeFirst();if(!r)throw new Q(404,{message:"Tenant not found"});const s=await n.selectFrom("connections").where("tenant_id","=",t.tenant_id).selectAll().execute(),a=await n.selectFrom("domains").where("tenant_id","=",t.tenant_id).selectAll().execute();return{id:t.id,name:t.name,connections:s.map(c=>sn.parse(A(c))),domains:a,tenant_id:r.id,allowed_callback_urls:cn(t.allowed_callback_urls),allowed_logout_urls:cn(t.allowed_logout_urls),allowed_web_origins:cn(t.allowed_web_origins),email_validation:t.email_validation,client_secret:t.client_secret,tenant:A(r),disable_sign_ups:!!t.disable_sign_ups}}}}function Ta(n){return async()=>await n.selectFrom("keys").where("revoked_at","is",null).selectAll().execute()}function Oa(n){return async e=>{await n.insertInto("keys").values(e).execute()}}function Sa(n){return async(e,t)=>!!(await n.updateTable("keys").set({revoked_at:t.toISOString()}).where("kid","=",e).execute()).length}function Za(n){return{create:Oa(n),list:Ta(n),revoke:Sa(n)}}function ja(n){return async(e,t)=>{const r={created_at:new Date().toISOString(),updated_at:new Date().toISOString(),tenant_id:e,id:Fe(),...t};return await n.insertInto("domains").values(r).execute(),r}}function Ia(n){return async(e,t)=>{let r=n.selectFrom("domains").where("domains.tenant_id","=",e);t.q&&(r=Ie(n,r,t.q,["user_id","ip"]));const a=await r.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await r.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{domains:a,start:t.page*t.per_page,limit:t.per_page,length:_e(o)}}}function Ca(n){return{create:ja(n),list:Ia(n)}}function Na(n){return async e=>{const[t]=await n.selectFrom("branding").where("branding.tenant_id","=",e).selectAll().execute();if(!t)return null;const{tenant_id:r,colors_primary:s,colors_page_background_type:a,colors_page_background_start:o,colors_page_background_end:c,colors_page_background_angle_dev:d,font_url:u,...l}=t;return A({...l,colors:{primary:s,page_background:{type:a,start:o,end:c,angle_deg:d}},font:u?{url:u}:void 0})}}function Ea(n){return async(e,t)=>{var o,c,d,u,l,T,R,L,te,de,xe,be,Te,Je,He,ne,re,se;const{colors:r,font:s,...a}=t;try{await n.insertInto("branding").values({...a,colors_primary:r==null?void 0:r.primary,colors_page_background_type:(c=(o=t.colors)==null?void 0:o.page_background)==null?void 0:c.type,colors_page_background_start:(u=(d=t.colors)==null?void 0:d.page_background)==null?void 0:u.start,colors_page_background_end:(T=(l=t.colors)==null?void 0:l.page_background)==null?void 0:T.end,colors_page_background_angle_dev:(L=(R=t.colors)==null?void 0:R.page_background)==null?void 0:L.angle_deg,font_url:(te=t.font)==null?void 0:te.url,tenant_id:e}).execute()}catch{await n.updateTable("branding").set({...a,colors_primary:r==null?void 0:r.primary,colors_page_background_type:(xe=(de=t.colors)==null?void 0:de.page_background)==null?void 0:xe.type,colors_page_background_start:(Te=(be=t.colors)==null?void 0:be.page_background)==null?void 0:Te.start,colors_page_background_end:(He=(Je=t.colors)==null?void 0:Je.page_background)==null?void 0:He.end,colors_page_background_angle_dev:(re=(ne=t.colors)==null?void 0:ne.page_background)==null?void 0:re.angle_deg,font_url:(se=t.font)==null?void 0:se.url}).where("tenant_id","=",e).execute()}}}function Aa(n){return{get:Na(n),set:Ea(n)}}function Ra(n){return async(e,t)=>{const r=await n.selectFrom("authentication_codes").where("tenant_id","=",e).where("code","=",t).selectAll().executeTakeFirst();if(!r)throw new Q(403,{message:"Code not found or expired"});const{state:s,nonce:a,scope:o,client_id:c,response_type:d,response_mode:u,...l}=r;return{...l,authParams:{state:s,nonce:a,scope:o,client_id:c,response_type:d,response_mode:u}}}}function $a(n){return async(e,t)=>{const{authParams:r,...s}=t;await n.insertInto("authentication_codes").values({...s,...r,tenant_id:e}).execute()}}function Pa(n){return{create:$a(n),get:Ra(n)}}function Da(n){return async(e,t)=>{let r=n.selectFrom("hooks").where("hooks.tenant_id","=",e);t.q&&(r=Ie(n,r,t.q,["url"]));const a=await r.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await r.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow();return{hooks:a.map(d=>{const{tenant_id:u,enabled:l,...T}=d;return A({...T,enabled:!!l})}),start:t.page*t.per_page,limit:t.per_page,length:_e(o)}}}function Ma(n){return async(e,t)=>{const r=await n.selectFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",t).selectAll().executeTakeFirst();return r?(r.enabled=!!r.enabled,A(r)):null}}function La(n){return async(e,t)=>(await n.deleteFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",t).executeTakeFirst()).numDeletedRows>0}function Va(n){return async(e,t)=>{const r={hook_id:Fe(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("hooks").values({...r,tenant_id:e}).execute(),r}}function Ua(n){return async(e,t,r)=>{const s={...r,updated_at:new Date().toISOString()};return await n.updateTable("hooks").set(s).where("hooks.hook_id","=",t).where("hooks.tenant_id","=",e).execute(),!0}}function Fa(n){return{create:Va(n),get:Ma(n),list:Da(n),update:Ua(n),remove:La(n)}}function za(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t}typeof SuppressedError=="function"&&SuppressedError;function Ba(n,e){var t;return((t=n==null?void 0:n._def)===null||t===void 0?void 0:t.typeName)===e}function mt(n,e){const t=n.ZodType.prototype[e];n.ZodType.prototype[e]=function(...r){const s=t.apply(this,r);return s._def.openapi=this._def.openapi,s}}function qa(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(s,a){var o,c,d,u,l,T;const R=typeof s=="string"?a:s,L=R??{},{param:te}=L,de=za(L,["param"]),xe=Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o._internal),typeof s=="string"?{refId:s}:void 0),be=Object.assign(Object.assign(Object.assign({},(c=this._def.openapi)===null||c===void 0?void 0:c.metadata),de),!((u=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||u===void 0)&&u.param||te?{param:Object.assign(Object.assign({},(T=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||T===void 0?void 0:T.param),te)}:void 0),Te=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(xe).length>0?{_internal:xe}:void 0),Object.keys(be).length>0?{metadata:be}:void 0)}));if(Ba(this,"ZodObject")){const Je=this.extend;Te.extend=function(...He){var ne,re,se,Oe,Ae,Re;const $e=Je.apply(this,He);return $e._def.openapi={_internal:{extendedFrom:!((re=(ne=this._def.openapi)===null||ne===void 0?void 0:ne._internal)===null||re===void 0)&&re.refId?{refId:(Oe=(se=this._def.openapi)===null||se===void 0?void 0:se._internal)===null||Oe===void 0?void 0:Oe.refId,schema:this}:(Ae=this._def.openapi)===null||Ae===void 0?void 0:Ae._internal.extendedFrom},metadata:(Re=$e._def.openapi)===null||Re===void 0?void 0:Re.metadata},$e}}return Te},mt(n,"optional"),mt(n,"nullable"),mt(n,"default"),mt(n,"transform"),mt(n,"refine");const e=n.ZodObject.prototype.deepPartial;n.ZodObject.prototype.deepPartial=function(){const s=this._def.shape(),a=e.apply(this),o=a._def.shape();return Object.entries(o).forEach(([c,d])=>{var u,l;d._def.openapi=(l=(u=s[c])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.openapi}),a._def.openapi=void 0,a};const t=n.ZodObject.prototype.pick;n.ZodObject.prototype.pick=function(...s){const a=t.apply(this,s);return a._def.openapi=void 0,a};const r=n.ZodObject.prototype.omit;n.ZodObject.prototype.omit=function(...s){const a=r.apply(this,s);return a._def.openapi=void 0,a}}new Set(".\\+*[^]$()");var C;(function(n){n.assertEqual=s=>s;function e(s){}n.assertIs=e;function t(s){throw new Error}n.assertNever=t,n.arrayToEnum=s=>{const a={};for(const o of s)a[o]=o;return a},n.getValidEnumValues=s=>{const a=n.objectKeys(s).filter(c=>typeof s[s[c]]!="number"),o={};for(const c of a)o[c]=s[c];return n.objectValues(o)},n.objectValues=s=>n.objectKeys(s).map(function(a){return s[a]}),n.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&a.push(o);return a},n.find=(s,a)=>{for(const o of s)if(a(o))return o},n.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function r(s,a=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}n.joinValues=r,n.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(C||(C={}));var dn;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(dn||(dn={}));const g=C.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ge=n=>{switch(typeof n){case"undefined":return g.undefined;case"string":return g.string;case"number":return isNaN(n)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(n)?g.array:n===null?g.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?g.promise:typeof Map<"u"&&n instanceof Map?g.map:typeof Set<"u"&&n instanceof Set?g.set:typeof Date<"u"&&n instanceof Date?g.date:g.object;default:return g.unknown}},h=C.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"]),Wa=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class U extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const 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){const t=e||function(a){return a.message},r={_errors:[]},s=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(t(o));else{let c=r,d=0;for(;d<o.path.length;){const u=o.path[d];d===o.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(o))):c[u]=c[u]||{_errors:[]},c=c[u],d++}}};return s(this),r}static assert(e){if(!(e instanceof U))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,C.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):r.push(e(s));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}U.create=n=>new U(n);const ze=(n,e)=>{let t;switch(n.code){case h.invalid_type:n.received===g.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case h.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,C.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:t=`Unrecognized key(s) in object: ${C.joinValues(n.keys,", ")}`;break;case h.invalid_union:t="Invalid input";break;case h.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${C.joinValues(n.options)}`;break;case h.invalid_enum_value:t=`Invalid enum value. Expected ${C.joinValues(n.options)}, received '${n.received}'`;break;case h.invalid_arguments:t="Invalid function arguments";break;case h.invalid_return_type:t="Invalid function return type";break;case h.invalid_date:t="Invalid date";break;case h.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:C.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case h.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case h.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case h.custom:t="Invalid input";break;case h.invalid_intersection_types:t="Intersection results could not be merged";break;case h.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case h.not_finite:t="Number must be finite";break;default:t=e.defaultError,C.assertNever(n)}return{message:t}};let Ln=ze;function Ka(n){Ln=n}function zt(){return Ln}const Bt=n=>{const{data:e,path:t,errorMaps:r,issueData:s}=n,a=[...t,...s.path||[]],o={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let c="";const d=r.filter(u=>!!u).slice().reverse();for(const u of d)c=u(o,{data:e,defaultError:c}).message;return{...s,path:a,message:c}},Qa=[];function m(n,e){const t=zt(),r=Bt({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===ze?void 0:ze].filter(s=>!!s)});n.common.issues.push(r)}class P{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const s of t){if(s.status==="aborted")return x;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const s of t){const a=await s.key,o=await s.value;r.push({key:a,value:o})}return P.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const s of t){const{key:a,value:o}=s;if(a.status==="aborted"||o.status==="aborted")return x;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[a.value]=o.value)}return{status:e.value,value:r}}}const x=Object.freeze({status:"aborted"}),Be=n=>({status:"dirty",value:n}),M=n=>({status:"valid",value:n}),un=n=>n.status==="aborted",ln=n=>n.status==="dirty",_t=n=>n.status==="valid",gt=n=>typeof Promise<"u"&&n instanceof Promise;function qt(n,e,t,r){if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Vn(n,e,t,r,s){if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}typeof SuppressedError=="function"&&SuppressedError;var v;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(v||(v={}));var yt,vt;class G{constructor(e,t,r,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Un=(n,e)=>{if(_t(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new U(n.common.issues);return this._error=t,this._error}}};function S(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:s}=n;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,c)=>{var d,u;const{message:l}=n;return o.code==="invalid_enum_value"?{message:l??c.defaultError}:typeof c.data>"u"?{message:(d=l??r)!==null&&d!==void 0?d:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(u=l??t)!==null&&u!==void 0?u:c.defaultError}},description:s}}class j{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 ge(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ge(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new P,ctx:{common:e.parent.common,data:e.data,parsedType:ge(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(gt(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const s={common:{issues:[],async:(r=t==null?void 0:t.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ge(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Un(s,a)}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ge(e)},s=this._parse({data:e,path:r.path,parent:r}),a=await(gt(s)?s:Promise.resolve(s));return Un(r,a)}refine(e,t){const r=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const o=e(s),c=()=>a.addIssue({code:h.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof t=="function"?t(r,s):t),!1))}_refinement(e){return new K({schema:this,typeName:k.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ee.create(this,this._def)}nullable(){return ke.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return W.create(this,this._def)}promise(){return Qe.create(this,this._def)}or(e){return bt.create([this,e],this._def)}and(e){return Tt.create(this,e,this._def)}transform(e){return new K({...S(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new It({...S(this._def),innerType:this,defaultValue:t,typeName:k.ZodDefault})}brand(){return new fn({typeName:k.ZodBranded,type:this,...S(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ct({...S(this._def),innerType:this,catchValue:t,typeName:k.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Nt.create(this,e)}readonly(){return Et.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ja=/^c[^\s-]{8,}$/i,Ha=/^[0-9a-z]+$/,Ya=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ga=/^[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,Xa=/^[a-z0-9_-]{21}$/i,ei=/^[-+]?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)?)??$/,ti=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ni="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let pn;const ri=/^(?:(?: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])$/,si=/^(([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})))$/,ai=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Fn="((\\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])))",ii=new RegExp(`^${Fn}$`);function zn(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function oi(n){return new RegExp(`^${zn(n)}$`)}function Bn(n){let e=`${Fn}T${zn(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function ci(n,e){return!!((e==="v4"||!e)&&ri.test(n)||(e==="v6"||!e)&&si.test(n))}class q extends j{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_type,expected:g.string,received:a.parsedType}),x}const r=new P;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const o=e.data.length>a.value,c=e.data.length<a.value;(o||c)&&(s=this._getOrReturnCtx(e,s),o?m(s,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):c&&m(s,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")ti.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"email",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")pn||(pn=new RegExp(ni,"u")),pn.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"emoji",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")Ga.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"uuid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")Xa.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"nanoid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")Ja.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")Ha.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid2",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")Ya.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ulid",code:h.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),m(s,{validation:"url",code:h.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"regex",code:h.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),m(s,{code:h.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:h.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:h.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?Bn(a).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:h.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?ii.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:h.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?oi(a).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:h.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?ei.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"duration",code:h.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?ci(e.data,a.version)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ip",code:h.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?ai.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"base64",code:h.invalid_string,message:a.message}),r.dirty()):C.assertNever(a);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(s=>e.test(s),{validation:t,code:h.invalid_string,...v.errToObj(r)})}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...v.errToObj(e)})}url(e){return this._addCheck({kind:"url",...v.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...v.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...v.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...v.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...v.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...v.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...v.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...v.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...v.errToObj(e)})}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...v.errToObj(e==null?void 0: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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...v.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...v.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...v.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...v.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...v.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...v.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...v.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...v.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...v.errToObj(t)})}nonempty(e){return this.min(1,v.errToObj(e))}trim(){return new q({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new q({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new q({...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(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}q.create=n=>{var e;return new q({checks:[],typeName:k.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...S(n)})};function di(n,e){const t=(n.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=t>r?t:r,a=parseInt(n.toFixed(s).replace(".","")),o=parseInt(e.toFixed(s).replace(".",""));return a%o/Math.pow(10,s)}class ye extends j{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)!==g.number){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_type,expected:g.number,received:a.parsedType}),x}let r;const s=new P;for(const a of this._def.checks)a.kind==="int"?C.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?di(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.not_finite,message:a.message}),s.dirty()):C.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,t,r,s){return new ye({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:v.toString(s)}]})}_addCheck(e){return new ye({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:v.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:v.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:v.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:v.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const 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"&&C.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ye.create=n=>new ye({checks:[],typeName:k.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...S(n)});class ve extends j{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)!==g.bigint){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_type,expected:g.bigint,received:a.parsedType}),x}let r;const s=new P;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):C.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,t,r,s){return new ve({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:v.toString(s)}]})}_addCheck(e){return new ve({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ve.create=n=>{var e;return new ve({checks:[],typeName:k.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...S(n)})};class wt extends j{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){const r=this._getOrReturnCtx(e);return m(r,{code:h.invalid_type,expected:g.boolean,received:r.parsedType}),x}return M(e.data)}}wt.create=n=>new wt({typeName:k.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...S(n)});class Ce extends j{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_type,expected:g.date,received:a.parsedType}),x}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_date}),x}const r=new P;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):C.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ce({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:v.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:v.toString(t)})}get minDate(){let e=null;for(const 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(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Ce.create=n=>new Ce({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:k.ZodDate,...S(n)});class Wt extends j{_parse(e){if(this._getType(e)!==g.symbol){const r=this._getOrReturnCtx(e);return m(r,{code:h.invalid_type,expected:g.symbol,received:r.parsedType}),x}return M(e.data)}}Wt.create=n=>new Wt({typeName:k.ZodSymbol,...S(n)});class kt extends j{_parse(e){if(this._getType(e)!==g.undefined){const r=this._getOrReturnCtx(e);return m(r,{code:h.invalid_type,expected:g.undefined,received:r.parsedType}),x}return M(e.data)}}kt.create=n=>new kt({typeName:k.ZodUndefined,...S(n)});class xt extends j{_parse(e){if(this._getType(e)!==g.null){const r=this._getOrReturnCtx(e);return m(r,{code:h.invalid_type,expected:g.null,received:r.parsedType}),x}return M(e.data)}}xt.create=n=>new xt({typeName:k.ZodNull,...S(n)});class qe extends j{constructor(){super(...arguments),this._any=!0}_parse(e){return M(e.data)}}qe.create=n=>new qe({typeName:k.ZodAny,...S(n)});class Ne extends j{constructor(){super(...arguments),this._unknown=!0}_parse(e){return M(e.data)}}Ne.create=n=>new Ne({typeName:k.ZodUnknown,...S(n)});class oe extends j{_parse(e){const t=this._getOrReturnCtx(e);return m(t,{code:h.invalid_type,expected:g.never,received:t.parsedType}),x}}oe.create=n=>new oe({typeName:k.ZodNever,...S(n)});class Kt extends j{_parse(e){if(this._getType(e)!==g.undefined){const r=this._getOrReturnCtx(e);return m(r,{code:h.invalid_type,expected:g.void,received:r.parsedType}),x}return M(e.data)}}Kt.create=n=>new Kt({typeName:k.ZodVoid,...S(n)});class W extends j{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==g.array)return m(t,{code:h.invalid_type,expected:g.array,received:t.parsedType}),x;if(s.exactLength!==null){const o=t.data.length>s.exactLength.value,c=t.data.length<s.exactLength.value;(o||c)&&(m(t,{code:o?h.too_big:h.too_small,minimum:c?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(m(t,{code:h.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(m(t,{code:h.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>s.type._parseAsync(new G(t,o,t.path,c)))).then(o=>P.mergeArray(r,o));const a=[...t.data].map((o,c)=>s.type._parseSync(new G(t,o,t.path,c)));return P.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new W({...this._def,minLength:{value:e,message:v.toString(t)}})}max(e,t){return new W({...this._def,maxLength:{value:e,message:v.toString(t)}})}length(e,t){return new W({...this._def,exactLength:{value:e,message:v.toString(t)}})}nonempty(e){return this.min(1,e)}}W.create=(n,e)=>new W({type:n,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...S(e)});function We(n){if(n instanceof E){const e={};for(const t in n.shape){const r=n.shape[t];e[t]=ee.create(We(r))}return new E({...n._def,shape:()=>e})}else return n instanceof W?new W({...n._def,type:We(n.element)}):n instanceof ee?ee.create(We(n.unwrap())):n instanceof ke?ke.create(We(n.unwrap())):n instanceof X?X.create(n.items.map(e=>We(e))):n}class E extends j{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=C.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==g.object){const u=this._getOrReturnCtx(e);return m(u,{code:h.invalid_type,expected:g.object,received:u.parsedType}),x}const{status:r,ctx:s}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof oe&&this._def.unknownKeys==="strip"))for(const u in s.data)o.includes(u)||c.push(u);const d=[];for(const u of o){const l=a[u],T=s.data[u];d.push({key:{status:"valid",value:u},value:l._parse(new G(s,T,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof oe){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of c)d.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")c.length>0&&(m(s,{code:h.unrecognized_keys,keys:c}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of c){const T=s.data[l];d.push({key:{status:"valid",value:l},value:u._parse(new G(s,T,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of d){const T=await l.key,R=await l.value;u.push({key:T,value:R,alwaysSet:l.alwaysSet})}return u}).then(u=>P.mergeObjectSync(r,u)):P.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return v.errToObj,new E({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var s,a,o,c;const d=(o=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,r).message)!==null&&o!==void 0?o:r.defaultError;return t.code==="unrecognized_keys"?{message:(c=v.errToObj(e).message)!==null&&c!==void 0?c:d}:{message:d}}}:{}})}strip(){return new E({...this._def,unknownKeys:"strip"})}passthrough(){return new E({...this._def,unknownKeys:"passthrough"})}extend(e){return new E({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new E({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:k.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new E({...this._def,catchall:e})}pick(e){const t={};return C.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new E({...this._def,shape:()=>t})}omit(e){const t={};return C.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new E({...this._def,shape:()=>t})}deepPartial(){return We(this)}partial(e){const t={};return C.objectKeys(this.shape).forEach(r=>{const s=this.shape[r];e&&!e[r]?t[r]=s:t[r]=s.optional()}),new E({...this._def,shape:()=>t})}required(e){const t={};return C.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof ee;)a=a._def.innerType;t[r]=a}}),new E({...this._def,shape:()=>t})}keyof(){return qn(C.objectKeys(this.shape))}}E.create=(n,e)=>new E({shape:()=>n,unknownKeys:"strip",catchall:oe.create(),typeName:k.ZodObject,...S(e)}),E.strictCreate=(n,e)=>new E({shape:()=>n,unknownKeys:"strict",catchall:oe.create(),typeName:k.ZodObject,...S(e)}),E.lazycreate=(n,e)=>new E({shape:n,unknownKeys:"strip",catchall:oe.create(),typeName:k.ZodObject,...S(e)});class bt extends j{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function s(a){for(const c of a)if(c.result.status==="valid")return c.result;for(const c of a)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=a.map(c=>new U(c.ctx.common.issues));return m(t,{code:h.invalid_union,unionErrors:o}),x}if(t.common.async)return Promise.all(r.map(async a=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(s);{let a;const o=[];for(const d of r){const u={...t,common:{...t.common,issues:[]},parent:null},l=d._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const c=o.map(d=>new U(d));return m(t,{code:h.invalid_union,unionErrors:c}),x}}get options(){return this._def.options}}bt.create=(n,e)=>new bt({options:n,typeName:k.ZodUnion,...S(e)});const ce=n=>n instanceof St?ce(n.schema):n instanceof K?ce(n.innerType()):n instanceof Zt?[n.value]:n instanceof we?n.options:n instanceof jt?C.objectValues(n.enum):n instanceof It?ce(n._def.innerType):n instanceof kt?[void 0]:n instanceof xt?[null]:n instanceof ee?[void 0,...ce(n.unwrap())]:n instanceof ke?[null,...ce(n.unwrap())]:n instanceof fn||n instanceof Et?ce(n.unwrap()):n instanceof Ct?ce(n._def.innerType):[];class Qt extends j{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.object)return m(t,{code:h.invalid_type,expected:g.object,received:t.parsedType}),x;const r=this.discriminator,s=t.data[r],a=this.optionsMap.get(s);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}):(m(t,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const s=new Map;for(const a of t){const o=ce(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(s.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);s.set(c,a)}}return new Qt({typeName:k.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...S(r)})}}function hn(n,e){const t=ge(n),r=ge(e);if(n===e)return{valid:!0,data:n};if(t===g.object&&r===g.object){const s=C.objectKeys(e),a=C.objectKeys(n).filter(c=>s.indexOf(c)!==-1),o={...n,...e};for(const c of a){const d=hn(n[c],e[c]);if(!d.valid)return{valid:!1};o[c]=d.data}return{valid:!0,data:o}}else if(t===g.array&&r===g.array){if(n.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<n.length;a++){const o=n[a],c=e[a],d=hn(o,c);if(!d.valid)return{valid:!1};s.push(d.data)}return{valid:!0,data:s}}else return t===g.date&&r===g.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Tt extends j{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=(a,o)=>{if(un(a)||un(o))return x;const c=hn(a.value,o.value);return c.valid?((ln(a)||ln(o))&&t.dirty(),{status:t.value,value:c.data}):(m(r,{code:h.invalid_intersection_types}),x)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,o])=>s(a,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Tt.create=(n,e,t)=>new Tt({left:n,right:e,typeName:k.ZodIntersection,...S(t)});class X extends j{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.array)return m(r,{code:h.invalid_type,expected:g.array,received:r.parsedType}),x;if(r.data.length<this._def.items.length)return m(r,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&r.data.length>this._def.items.length&&(m(r,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...r.data].map((o,c)=>{const d=this._def.items[c]||this._def.rest;return d?d._parse(new G(r,o,r.path,c)):null}).filter(o=>!!o);return r.common.async?Promise.all(a).then(o=>P.mergeArray(t,o)):P.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new X({...this._def,rest:e})}}X.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new X({items:n,typeName:k.ZodTuple,rest:null,...S(e)})};class Ot extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.object)return m(r,{code:h.invalid_type,expected:g.object,received:r.parsedType}),x;const s=[],a=this._def.keyType,o=this._def.valueType;for(const c in r.data)s.push({key:a._parse(new G(r,c,r.path,c)),value:o._parse(new G(r,r.data[c],r.path,c)),alwaysSet:c in r.data});return r.common.async?P.mergeObjectAsync(t,s):P.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof j?new Ot({keyType:e,valueType:t,typeName:k.ZodRecord,...S(r)}):new Ot({keyType:q.create(),valueType:e,typeName:k.ZodRecord,...S(t)})}}class Jt extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.map)return m(r,{code:h.invalid_type,expected:g.map,received:r.parsedType}),x;const s=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([c,d],u)=>({key:s._parse(new G(r,c,r.path,[u,"key"])),value:a._parse(new G(r,d,r.path,[u,"value"]))}));if(r.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const d of o){const u=await d.key,l=await d.value;if(u.status==="aborted"||l.status==="aborted")return x;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),c.set(u.value,l.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const d of o){const u=d.key,l=d.value;if(u.status==="aborted"||l.status==="aborted")return x;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),c.set(u.value,l.value)}return{status:t.value,value:c}}}}Jt.create=(n,e,t)=>new Jt({valueType:e,keyType:n,typeName:k.ZodMap,...S(t)});class Ee extends j{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.set)return m(r,{code:h.invalid_type,expected:g.set,received:r.parsedType}),x;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(m(r,{code:h.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(m(r,{code:h.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function o(d){const u=new Set;for(const l of d){if(l.status==="aborted")return x;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const c=[...r.data.values()].map((d,u)=>a._parse(new G(r,d,r.path,u)));return r.common.async?Promise.all(c).then(d=>o(d)):o(c)}min(e,t){return new Ee({...this._def,minSize:{value:e,message:v.toString(t)}})}max(e,t){return new Ee({...this._def,maxSize:{value:e,message:v.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ee.create=(n,e)=>new Ee({valueType:n,minSize:null,maxSize:null,typeName:k.ZodSet,...S(e)});class Ke extends j{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.function)return m(t,{code:h.invalid_type,expected:g.function,received:t.parsedType}),x;function r(c,d){return Bt({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,zt(),ze].filter(u=>!!u),issueData:{code:h.invalid_arguments,argumentsError:d}})}function s(c,d){return Bt({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,zt(),ze].filter(u=>!!u),issueData:{code:h.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Qe){const c=this;return M(async function(...d){const u=new U([]),l=await c._def.args.parseAsync(d,a).catch(L=>{throw u.addIssue(r(d,L)),u}),T=await Reflect.apply(o,this,l);return await c._def.returns._def.type.parseAsync(T,a).catch(L=>{throw u.addIssue(s(T,L)),u})})}else{const c=this;return M(function(...d){const u=c._def.args.safeParse(d,a);if(!u.success)throw new U([r(d,u.error)]);const l=Reflect.apply(o,this,u.data),T=c._def.returns.safeParse(l,a);if(!T.success)throw new U([s(l,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ke({...this._def,args:X.create(e).rest(Ne.create())})}returns(e){return new Ke({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new Ke({args:e||X.create([]).rest(Ne.create()),returns:t||Ne.create(),typeName:k.ZodFunction,...S(r)})}}class St extends j{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}St.create=(n,e)=>new St({getter:n,typeName:k.ZodLazy,...S(e)});class Zt extends j{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return m(t,{received:t.data,code:h.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}}Zt.create=(n,e)=>new Zt({value:n,typeName:k.ZodLiteral,...S(e)});function qn(n,e){return new we({values:n,typeName:k.ZodEnum,...S(e)})}class we extends j{constructor(){super(...arguments),yt.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return m(t,{expected:C.joinValues(r),received:t.parsedType,code:h.invalid_type}),x}if(qt(this,yt)||Vn(this,yt,new Set(this._def.values)),!qt(this,yt).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return m(t,{received:t.data,code:h.invalid_enum_value,options:r}),x}return M(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return we.create(e,{...this._def,...t})}exclude(e,t=this._def){return we.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}yt=new WeakMap,we.create=qn;class jt extends j{constructor(){super(...arguments),vt.set(this,void 0)}_parse(e){const t=C.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==g.string&&r.parsedType!==g.number){const s=C.objectValues(t);return m(r,{expected:C.joinValues(s),received:r.parsedType,code:h.invalid_type}),x}if(qt(this,vt)||Vn(this,vt,new Set(C.getValidEnumValues(this._def.values))),!qt(this,vt).has(e.data)){const s=C.objectValues(t);return m(r,{received:r.data,code:h.invalid_enum_value,options:s}),x}return M(e.data)}get enum(){return this._def.values}}vt=new WeakMap,jt.create=(n,e)=>new jt({values:n,typeName:k.ZodNativeEnum,...S(e)});class Qe extends j{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.promise&&t.common.async===!1)return m(t,{code:h.invalid_type,expected:g.promise,received:t.parsedType}),x;const r=t.parsedType===g.promise?t.data:Promise.resolve(t.data);return M(r.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Qe.create=(n,e)=>new Qe({type:n,typeName:k.ZodPromise,...S(e)});class K extends j{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===k.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:o=>{m(r,o),o.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const o=s.transform(r.data,a);if(r.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return x;const d=await this._def.schema._parseAsync({data:c,path:r.path,parent:r});return d.status==="aborted"?x:d.status==="dirty"||t.value==="dirty"?Be(d.value):d});{if(t.value==="aborted")return x;const c=this._def.schema._parseSync({data:o,path:r.path,parent:r});return c.status==="aborted"?x:c.status==="dirty"||t.value==="dirty"?Be(c.value):c}}if(s.type==="refinement"){const o=c=>{const d=s.refinement(c,a);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(r.common.async===!1){const c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return c.status==="aborted"?x:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>c.status==="aborted"?x:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!_t(o))return o;const c=s.transform(o.value,a);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>_t(o)?Promise.resolve(s.transform(o.value,a)).then(c=>({status:t.value,value:c})):o);C.assertNever(s)}}K.create=(n,e,t)=>new K({schema:n,typeName:k.ZodEffects,effect:e,...S(t)}),K.createWithPreprocess=(n,e,t)=>new K({schema:e,effect:{type:"preprocess",transform:n},typeName:k.ZodEffects,...S(t)});class ee extends j{_parse(e){return this._getType(e)===g.undefined?M(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ee.create=(n,e)=>new ee({innerType:n,typeName:k.ZodOptional,...S(e)});class ke extends j{_parse(e){return this._getType(e)===g.null?M(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ke.create=(n,e)=>new ke({innerType:n,typeName:k.ZodNullable,...S(e)});class It extends j{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===g.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}It.create=(n,e)=>new It({innerType:n,typeName:k.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...S(e)});class Ct extends j{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return gt(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new U(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new U(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Ct.create=(n,e)=>new Ct({innerType:n,typeName:k.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...S(e)});class Ht extends j{_parse(e){if(this._getType(e)!==g.nan){const r=this._getOrReturnCtx(e);return m(r,{code:h.invalid_type,expected:g.nan,received:r.parsedType}),x}return{status:"valid",value:e.data}}}Ht.create=n=>new Ht({typeName:k.ZodNaN,...S(n)});const ui=Symbol("zod_brand");class fn extends j{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class Nt extends j{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?x:a.status==="dirty"?(t.dirty(),Be(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?x:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,t){return new Nt({in:e,out:t,typeName:k.ZodPipeline})}}class Et extends j{_parse(e){const t=this._def.innerType._parse(e),r=s=>(_t(s)&&(s.value=Object.freeze(s.value)),s);return gt(t)?t.then(s=>r(s)):r(t)}unwrap(){return this._def.innerType}}Et.create=(n,e)=>new Et({innerType:n,typeName:k.ZodReadonly,...S(e)});function Wn(n,e={},t){return n?qe.create().superRefine((r,s)=>{var a,o;if(!n(r)){const c=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,d=(o=(a=c.fatal)!==null&&a!==void 0?a:t)!==null&&o!==void 0?o:!0,u=typeof c=="string"?{message:c}:c;s.addIssue({code:"custom",...u,fatal:d})}}):qe.create()}const li={object:E.lazycreate};var k;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(k||(k={}));const pi=(n,e={message:`Input not instance of ${n.name}`})=>Wn(t=>t instanceof n,e),Kn=q.create,Qn=ye.create,hi=Ht.create,fi=ve.create,Jn=wt.create,mi=Ce.create,_i=Wt.create,gi=kt.create,yi=xt.create,vi=qe.create,wi=Ne.create,ki=oe.create,xi=Kt.create,bi=W.create,Ti=E.create,Oi=E.strictCreate,Si=bt.create,Zi=Qt.create,ji=Tt.create,Ii=X.create,Ci=Ot.create,Ni=Jt.create,Ei=Ee.create,Ai=Ke.create,Ri=St.create,$i=Zt.create,Pi=we.create,Di=jt.create,Mi=Qe.create,Hn=K.create,Li=ee.create,Vi=ke.create,Ui=K.createWithPreprocess,Fi=Nt.create;var zi=Object.freeze({__proto__:null,defaultErrorMap:ze,setErrorMap:Ka,getErrorMap:zt,makeIssue:Bt,EMPTY_PATH:Qa,addIssueToContext:m,ParseStatus:P,INVALID:x,DIRTY:Be,OK:M,isAborted:un,isDirty:ln,isValid:_t,isAsync:gt,get util(){return C},get objectUtil(){return dn},ZodParsedType:g,getParsedType:ge,ZodType:j,datetimeRegex:Bn,ZodString:q,ZodNumber:ye,ZodBigInt:ve,ZodBoolean:wt,ZodDate:Ce,ZodSymbol:Wt,ZodUndefined:kt,ZodNull:xt,ZodAny:qe,ZodUnknown:Ne,ZodNever:oe,ZodVoid:Kt,ZodArray:W,ZodObject:E,ZodUnion:bt,ZodDiscriminatedUnion:Qt,ZodIntersection:Tt,ZodTuple:X,ZodRecord:Ot,ZodMap:Jt,ZodSet:Ee,ZodFunction:Ke,ZodLazy:St,ZodLiteral:Zt,ZodEnum:we,ZodNativeEnum:jt,ZodPromise:Qe,ZodEffects:K,ZodTransformer:K,ZodOptional:ee,ZodNullable:ke,ZodDefault:It,ZodCatch:Ct,ZodNaN:Ht,BRAND:ui,ZodBranded:fn,ZodPipeline:Nt,ZodReadonly:Et,custom:Wn,Schema:j,ZodSchema:j,late:li,get ZodFirstPartyTypeKind(){return k},coerce:{string:n=>q.create({...n,coerce:!0}),number:n=>ye.create({...n,coerce:!0}),boolean:n=>wt.create({...n,coerce:!0}),bigint:n=>ve.create({...n,coerce:!0}),date:n=>Ce.create({...n,coerce:!0})},any:vi,array:bi,bigint:fi,boolean:Jn,date:mi,discriminatedUnion:Zi,effect:Hn,enum:Pi,function:Ai,instanceof:pi,intersection:ji,lazy:Ri,literal:$i,map:Ni,nan:hi,nativeEnum:Di,never:ki,null:yi,nullable:Vi,number:Qn,object:Ti,oboolean:()=>Jn().optional(),onumber:()=>Qn().optional(),optional:Li,ostring:()=>Kn().optional(),pipeline:Fi,preprocess:Ui,promise:Mi,record:Ci,set:Ei,strictObject:Oi,string:Kn,symbol:_i,transformer:Hn,tuple:Ii,undefined:gi,union:Si,unknown:wi,void:xi,NEVER:x,ZodIssueCode:h,quotelessJson:Wa,ZodError:U});qa(zi);function mn(n,e="",t={}){for(let r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const s=e?`${e}_${r}`:r;typeof n[r]=="object"&&n[r]!==null&&!Array.isArray(n[r])?mn(n[r],s,t):t[s]=n[r]}return t}function Bi(n){return async(e,t)=>{const r={themeId:Fe(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("themes").values({...mn(r),tenant_id:e}).execute(),r}}function qi(n){return async(e,t)=>(await n.deleteFrom("themes").where("themes.tenant_id","=",e).where("themes.theme_id","=",t).executeTakeFirst()).numDeletedRows>0}function Wi(n){return async(e,t)=>{const r=await n.selectFrom("themes").where("themes.tenant_id","=",e).where("themes.theme_id","=",t).selectAll().executeTakeFirst();return r?A(r):null}}function Ki(n){return async(e,t,r)=>{const s=mn({...r,updated_at:new Date().toISOString()});return await n.updateTable("themes").set(s).where("themes.id","=",t).where("themes.tenant_id","=",e).execute(),!0}}function Qi(n){return{create:Bi(n),get:Wi(n),remove:qi(n),update:Ki(n)}}function Ji(n){return{applications:_a(n),authenticationCodes:Pa(n),branding:Aa(n),clients:ba(n),codes:ia(n),connections:xa(n),domains:Ca(n),hooks:Fa(n),keys:Za(n),logs:Ds(n),OTP:Ys(n),passwords:ta(n),users:Os(n),sessions:zs(n),tenants:Es(n),themes:Qi(n),tickets:Ks(n),universalLoginSessions:ua(n)}}return Ji}();
|