@authhero/kysely-adapter 0.3.0 → 0.4.1
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 -5
- package/dist/kysely-adapter.d.ts +226 -206
- package/dist/kysely-adapter.iife.js +1 -5
- package/dist/kysely-adapter.mjs +1972 -3543
- package/package.json +2 -3
|
@@ -1,5 +1 @@
|
|
|
1
|
-
var kyselyAdapter=function(){"use strict";var Er=Object.defineProperty;var Ar=(z,X,$)=>X in z?Er(z,X,{enumerable:!0,configurable:!0,writable:!0,value:$}):z[X]=$;var _t=(z,X,$)=>Ar(z,typeof X!="symbol"?X+"":X,$);var z=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});_t(this,"res");_t(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 X(n){return async(e,t)=>{const{identities:a,...r}=t,i={...r,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(i).execute()}catch(o){throw o.code==="SQLITE_CONSTRAINT_UNIQUE"||o.message.includes("AlreadyExists")?new z(409,{message:"User already exists"}):(console.log(o.message),new z(500,{message:`${o.code}, ${o.message}`}))}return{...i,email:i.email||"",email_verified:i.email_verified===1,is_social:i.is_social===1}}}function $(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($):e[t]=$(e[t]));return e}function Mt(n,e){var t={};for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&e.indexOf(a)<0&&(t[a]=n[a]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,a=Object.getOwnPropertySymbols(n);r<a.length;r++)e.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(n,a[r])&&(t[a[r]]=n[a[r]]);return t}function Lt(n,e){var t;return((t=n==null?void 0:n._def)===null||t===void 0?void 0:t.typeName)===e}function Ze(n,e){const t=n.ZodType.prototype[e];n.ZodType.prototype[e]=function(...a){const r=t.apply(this,a);return r._def.openapi=this._def.openapi,r}}function qt(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(r,i){var o,c,f,_,y,C;const D=typeof r=="string"?i:r,te=D??{},{param:L}=te,Q=Mt(te,["param"]),xe=Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o._internal),typeof r=="string"?{refId:r}:void 0),he=Object.assign(Object.assign(Object.assign({},(c=this._def.openapi)===null||c===void 0?void 0:c.metadata),Q),!((_=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||_===void 0)&&_.param||L?{param:Object.assign(Object.assign({},(C=(y=this._def.openapi)===null||y===void 0?void 0:y.metadata)===null||C===void 0?void 0:C.param),L)}:void 0),de=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(he).length>0?{metadata:he}:void 0)}));if(Lt(this,"ZodObject")){const _e=this.extend;de.extend=function(...ge){var B,q,ne,Oe,Ie,me;const x=_e.apply(this,ge);return x._def.openapi={_internal:{extendedFrom:!((q=(B=this._def.openapi)===null||B===void 0?void 0:B._internal)===null||q===void 0)&&q.refId?{refId:(Oe=(ne=this._def.openapi)===null||ne===void 0?void 0:ne._internal)===null||Oe===void 0?void 0:Oe.refId,schema:this}:(Ie=this._def.openapi)===null||Ie===void 0?void 0:Ie._internal.extendedFrom},metadata:(me=x._def.openapi)===null||me===void 0?void 0:me.metadata},x}}return de},Ze(n,"optional"),Ze(n,"nullable"),Ze(n,"default"),Ze(n,"transform"),Ze(n,"refine");const e=n.ZodObject.prototype.deepPartial;n.ZodObject.prototype.deepPartial=function(){const r=this._def.shape(),i=e.apply(this),o=i._def.shape();return Object.entries(o).forEach(([c,f])=>{var _,y;f._def.openapi=(y=(_=r[c])===null||_===void 0?void 0:_._def)===null||y===void 0?void 0:y.openapi}),i._def.openapi=void 0,i};const t=n.ZodObject.prototype.pick;n.ZodObject.prototype.pick=function(...r){const i=t.apply(this,r);return i._def.openapi=void 0,i};const a=n.ZodObject.prototype.omit;n.ZodObject.prototype.omit=function(...r){const i=a.apply(this,r);return i._def.openapi=void 0,i}}new Set(".\\+*[^]$()");var E;(function(n){n.assertEqual=r=>r;function e(r){}n.assertIs=e;function t(r){throw new Error}n.assertNever=t,n.arrayToEnum=r=>{const i={};for(const o of r)i[o]=o;return i},n.getValidEnumValues=r=>{const i=n.objectKeys(r).filter(c=>typeof r[r[c]]!="number"),o={};for(const c of i)o[c]=r[c];return n.objectValues(o)},n.objectValues=r=>n.objectKeys(r).map(function(i){return r[i]}),n.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const i=[];for(const o in r)Object.prototype.hasOwnProperty.call(r,o)&&i.push(o);return i},n.find=(r,i)=>{for(const o of r)if(i(o))return o},n.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function a(r,i=" | "){return r.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}n.joinValues=a,n.jsonStringifyReplacer=(r,i)=>typeof i=="bigint"?i.toString():i})(E||(E={}));var at;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(at||(at={}));const v=E.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ae=n=>{switch(typeof n){case"undefined":return v.undefined;case"string":return v.string;case"number":return isNaN(n)?v.nan:v.number;case"boolean":return v.boolean;case"function":return v.function;case"bigint":return v.bigint;case"symbol":return v.symbol;case"object":return Array.isArray(n)?v.array:n===null?v.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?v.promise:typeof Map<"u"&&n instanceof Map?v.map:typeof Set<"u"&&n instanceof Set?v.set:typeof Date<"u"&&n instanceof Date?v.date:v.object;default:return v.unknown}},g=E.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"]),Bt=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class M extends Error{constructor(e){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};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(i){return i.message},a={_errors:[]},r=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(r);else if(o.code==="invalid_return_type")r(o.returnTypeError);else if(o.code==="invalid_arguments")r(o.argumentsError);else if(o.path.length===0)a._errors.push(t(o));else{let c=a,f=0;for(;f<o.path.length;){const _=o.path[f];f===o.path.length-1?(c[_]=c[_]||{_errors:[]},c[_]._errors.push(t(o))):c[_]=c[_]||{_errors:[]},c=c[_],f++}}};return r(this),a}static assert(e){if(!(e instanceof M))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,E.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},a=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):a.push(e(r));return{formErrors:a,fieldErrors:t}}get formErrors(){return this.flatten()}}M.create=n=>new M(n);const ye=(n,e)=>{let t;switch(n.code){case g.invalid_type:n.received===v.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case g.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,E.jsonStringifyReplacer)}`;break;case g.unrecognized_keys:t=`Unrecognized key(s) in object: ${E.joinValues(n.keys,", ")}`;break;case g.invalid_union:t="Invalid input";break;case g.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${E.joinValues(n.options)}`;break;case g.invalid_enum_value:t=`Invalid enum value. Expected ${E.joinValues(n.options)}, received '${n.received}'`;break;case g.invalid_arguments:t="Invalid function arguments";break;case g.invalid_return_type:t="Invalid function return type";break;case g.invalid_date:t="Invalid date";break;case g.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}"`:E.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case g.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 g.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 g.custom:t="Invalid input";break;case g.invalid_intersection_types:t="Intersection results could not be merged";break;case g.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case g.not_finite:t="Number must be finite";break;default:t=e.defaultError,E.assertNever(n)}return{message:t}};let gt=ye;function zt(n){gt=n}function Qe(){return gt}const He=n=>{const{data:e,path:t,errorMaps:a,issueData:r}=n,i=[...t,...r.path||[]],o={...r,path:i};if(r.message!==void 0)return{...r,path:i,message:r.message};let c="";const f=a.filter(_=>!!_).slice().reverse();for(const _ of f)c=_(o,{data:e,defaultError:c}).message;return{...r,path:i,message:c}},Vt=[];function b(n,e){const t=Qe(),a=He({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===ye?void 0:ye].filter(r=>!!r)});n.common.issues.push(a)}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 a=[];for(const r of t){if(r.status==="aborted")return O;r.status==="dirty"&&e.dirty(),a.push(r.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,t){const a=[];for(const r of t){const i=await r.key,o=await r.value;a.push({key:i,value:o})}return P.mergeObjectSync(e,a)}static mergeObjectSync(e,t){const a={};for(const r of t){const{key:i,value:o}=r;if(i.status==="aborted"||o.status==="aborted")return O;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||r.alwaysSet)&&(a[i.value]=o.value)}return{status:e.value,value:a}}}const O=Object.freeze({status:"aborted"}),Ge=n=>({status:"dirty",value:n}),U=n=>({status:"valid",value:n}),rt=n=>n.status==="aborted",st=n=>n.status==="dirty",Ee=n=>n.status==="valid",Ae=n=>typeof Promise<"u"&&n instanceof Promise;function Je(n,e,t,a){if(typeof e=="function"?n!==e||!a:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function mt(n,e,t,a,r){if(typeof e=="function"?n!==e||!r:!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 w;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(w||(w={}));var Ce,Se;class G{constructor(e,t,a,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=a,this._key=r}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 yt=(n,e)=>{if(Ee(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 M(n.common.issues);return this._error=t,this._error}}};function I(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:a,description:r}=n;if(e&&(t||a))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(i,o)=>{var c,f;const{message:_}=n;return i.code==="invalid_enum_value"?{message:_??o.defaultError}:typeof o.data>"u"?{message:(c=_??a)!==null&&c!==void 0?c:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(f=_??t)!==null&&f!==void 0?f:o.defaultError}},description:r}}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 ae(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ae(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:ae(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ae(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 a=this.safeParse(e,t);if(a.success)return a.data;throw a.error}safeParse(e,t){var a;const r={common:{issues:[],async:(a=t==null?void 0:t.async)!==null&&a!==void 0?a:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ae(e)},i=this._parseSync({data:e,path:r.path,parent:r});return yt(r,i)}async parseAsync(e,t){const a=await this.safeParseAsync(e,t);if(a.success)return a.data;throw a.error}async safeParseAsync(e,t){const a={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:ae(e)},r=this._parse({data:e,path:a.path,parent:a}),i=await(Ae(r)?r:Promise.resolve(r));return yt(a,i)}refine(e,t){const a=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,i)=>{const o=e(r),c=()=>i.addIssue({code:g.custom,...a(r)});return typeof Promise<"u"&&o instanceof Promise?o.then(f=>f?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((a,r)=>e(a)?!0:(r.addIssue(typeof t=="function"?t(a,r):t),!1))}_refinement(e){return new W({schema:this,typeName:T.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Y.create(this,this._def)}nullable(){return ce.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return K.create(this,this._def)}promise(){return ke.create(this,this._def)}or(e){return Re.create([this,e],this._def)}and(e){return De.create(this,e,this._def)}transform(e){return new W({...I(this._def),schema:this,typeName:T.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new qe({...I(this._def),innerType:this,defaultValue:t,typeName:T.ZodDefault})}brand(){return new ct({typeName:T.ZodBranded,type:this,...I(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Be({...I(this._def),innerType:this,catchValue:t,typeName:T.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ze.create(this,e)}readonly(){return Ve.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Kt=/^c[^\s-]{8,}$/i,Wt=/^[0-9a-z]+$/,Qt=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ht=/^[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,Gt=/^[a-z0-9_-]{21}$/i,Jt=/^[-+]?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)?)??$/,Yt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Xt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let it;const en=/^(?:(?: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])$/,tn=/^(([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})))$/,nn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,bt="((\\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])))",an=new RegExp(`^${bt}$`);function vt(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 rn(n){return new RegExp(`^${vt(n)}$`)}function wt(n){let e=`${bt}T${vt(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 sn(n,e){return!!((e==="v4"||!e)&&en.test(n)||(e==="v6"||!e)&&tn.test(n))}class V extends j{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==v.string){const r=this._getOrReturnCtx(e);return b(r,{code:g.invalid_type,expected:v.string,received:r.parsedType}),O}const t=new P;let a;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(a=this._getOrReturnCtx(e,a),b(a,{code:g.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="max")e.data.length>r.value&&(a=this._getOrReturnCtx(e,a),b(a,{code:g.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="length"){const i=e.data.length>r.value,o=e.data.length<r.value;(i||o)&&(a=this._getOrReturnCtx(e,a),i?b(a,{code:g.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):o&&b(a,{code:g.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind==="email")Yt.test(e.data)||(a=this._getOrReturnCtx(e,a),b(a,{validation:"email",code:g.invalid_string,message:r.message}),t.dirty());else if(r.kind==="emoji")it||(it=new RegExp(Xt,"u")),it.test(e.data)||(a=this._getOrReturnCtx(e,a),b(a,{validation:"emoji",code:g.invalid_string,message:r.message}),t.dirty());else if(r.kind==="uuid")Ht.test(e.data)||(a=this._getOrReturnCtx(e,a),b(a,{validation:"uuid",code:g.invalid_string,message:r.message}),t.dirty());else if(r.kind==="nanoid")Gt.test(e.data)||(a=this._getOrReturnCtx(e,a),b(a,{validation:"nanoid",code:g.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid")Kt.test(e.data)||(a=this._getOrReturnCtx(e,a),b(a,{validation:"cuid",code:g.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid2")Wt.test(e.data)||(a=this._getOrReturnCtx(e,a),b(a,{validation:"cuid2",code:g.invalid_string,message:r.message}),t.dirty());else if(r.kind==="ulid")Qt.test(e.data)||(a=this._getOrReturnCtx(e,a),b(a,{validation:"ulid",code:g.invalid_string,message:r.message}),t.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),b(a,{validation:"url",code:g.invalid_string,message:r.message}),t.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),b(a,{validation:"regex",code:g.invalid_string,message:r.message}),t.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(a=this._getOrReturnCtx(e,a),b(a,{code:g.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(a=this._getOrReturnCtx(e,a),b(a,{code:g.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(a=this._getOrReturnCtx(e,a),b(a,{code:g.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind==="datetime"?wt(r).test(e.data)||(a=this._getOrReturnCtx(e,a),b(a,{code:g.invalid_string,validation:"datetime",message:r.message}),t.dirty()):r.kind==="date"?an.test(e.data)||(a=this._getOrReturnCtx(e,a),b(a,{code:g.invalid_string,validation:"date",message:r.message}),t.dirty()):r.kind==="time"?rn(r).test(e.data)||(a=this._getOrReturnCtx(e,a),b(a,{code:g.invalid_string,validation:"time",message:r.message}),t.dirty()):r.kind==="duration"?Jt.test(e.data)||(a=this._getOrReturnCtx(e,a),b(a,{validation:"duration",code:g.invalid_string,message:r.message}),t.dirty()):r.kind==="ip"?sn(e.data,r.version)||(a=this._getOrReturnCtx(e,a),b(a,{validation:"ip",code:g.invalid_string,message:r.message}),t.dirty()):r.kind==="base64"?nn.test(e.data)||(a=this._getOrReturnCtx(e,a),b(a,{validation:"base64",code:g.invalid_string,message:r.message}),t.dirty()):E.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,a){return this.refinement(r=>e.test(r),{validation:t,code:g.invalid_string,...w.errToObj(a)})}_addCheck(e){return new V({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...w.errToObj(e)})}url(e){return this._addCheck({kind:"url",...w.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...w.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...w.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...w.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...w.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...w.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...w.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...w.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...w.errToObj(e)})}datetime(e){var t,a;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:(a=e==null?void 0:e.local)!==null&&a!==void 0?a:!1,...w.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,...w.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...w.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...w.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...w.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...w.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...w.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...w.errToObj(t)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new V({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new V({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new V({...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}}V.create=n=>{var e;return new V({checks:[],typeName:T.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...I(n)})};function on(n,e){const t=(n.toString().split(".")[1]||"").length,a=(e.toString().split(".")[1]||"").length,r=t>a?t:a,i=parseInt(n.toFixed(r).replace(".","")),o=parseInt(e.toFixed(r).replace(".",""));return i%o/Math.pow(10,r)}class re 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)!==v.number){const r=this._getOrReturnCtx(e);return b(r,{code:g.invalid_type,expected:v.number,received:r.parsedType}),O}let t;const a=new P;for(const r of this._def.checks)r.kind==="int"?E.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),b(t,{code:g.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),b(t,{code:g.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),b(t,{code:g.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="multipleOf"?on(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),b(t,{code:g.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),b(t,{code:g.not_finite,message:r.message}),a.dirty()):E.assertNever(r);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,a,r){return new re({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:w.toString(r)}]})}_addCheck(e){return new re({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(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"&&E.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(t===null||a.value>t)&&(t=a.value):a.kind==="max"&&(e===null||a.value<e)&&(e=a.value)}return Number.isFinite(t)&&Number.isFinite(e)}}re.create=n=>new re({checks:[],typeName:T.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...I(n)});class se 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)!==v.bigint){const r=this._getOrReturnCtx(e);return b(r,{code:g.invalid_type,expected:v.bigint,received:r.parsedType}),O}let t;const a=new P;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),b(t,{code:g.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),b(t,{code:g.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),b(t,{code:g.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):E.assertNever(r);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,a,r){return new se({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:w.toString(r)}]})}_addCheck(e){return new se({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.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}}se.create=n=>{var e;return new se({checks:[],typeName:T.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...I(n)})};class Fe extends j{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==v.boolean){const t=this._getOrReturnCtx(e);return b(t,{code:g.invalid_type,expected:v.boolean,received:t.parsedType}),O}return U(e.data)}}Fe.create=n=>new Fe({typeName:T.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...I(n)});class ue extends j{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==v.date){const r=this._getOrReturnCtx(e);return b(r,{code:g.invalid_type,expected:v.date,received:r.parsedType}),O}if(isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return b(r,{code:g.invalid_date}),O}const t=new P;let a;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(a=this._getOrReturnCtx(e,a),b(a,{code:g.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(a=this._getOrReturnCtx(e,a),b(a,{code:g.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):E.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ue({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:w.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}}ue.create=n=>new ue({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:T.ZodDate,...I(n)});class Ye extends j{_parse(e){if(this._getType(e)!==v.symbol){const t=this._getOrReturnCtx(e);return b(t,{code:g.invalid_type,expected:v.symbol,received:t.parsedType}),O}return U(e.data)}}Ye.create=n=>new Ye({typeName:T.ZodSymbol,...I(n)});class Ne extends j{_parse(e){if(this._getType(e)!==v.undefined){const t=this._getOrReturnCtx(e);return b(t,{code:g.invalid_type,expected:v.undefined,received:t.parsedType}),O}return U(e.data)}}Ne.create=n=>new Ne({typeName:T.ZodUndefined,...I(n)});class $e extends j{_parse(e){if(this._getType(e)!==v.null){const t=this._getOrReturnCtx(e);return b(t,{code:g.invalid_type,expected:v.null,received:t.parsedType}),O}return U(e.data)}}$e.create=n=>new $e({typeName:T.ZodNull,...I(n)});class be extends j{constructor(){super(...arguments),this._any=!0}_parse(e){return U(e.data)}}be.create=n=>new be({typeName:T.ZodAny,...I(n)});class le extends j{constructor(){super(...arguments),this._unknown=!0}_parse(e){return U(e.data)}}le.create=n=>new le({typeName:T.ZodUnknown,...I(n)});class ee extends j{_parse(e){const t=this._getOrReturnCtx(e);return b(t,{code:g.invalid_type,expected:v.never,received:t.parsedType}),O}}ee.create=n=>new ee({typeName:T.ZodNever,...I(n)});class Xe extends j{_parse(e){if(this._getType(e)!==v.undefined){const t=this._getOrReturnCtx(e);return b(t,{code:g.invalid_type,expected:v.void,received:t.parsedType}),O}return U(e.data)}}Xe.create=n=>new Xe({typeName:T.ZodVoid,...I(n)});class K extends j{_parse(e){const{ctx:t,status:a}=this._processInputParams(e),r=this._def;if(t.parsedType!==v.array)return b(t,{code:g.invalid_type,expected:v.array,received:t.parsedType}),O;if(r.exactLength!==null){const o=t.data.length>r.exactLength.value,c=t.data.length<r.exactLength.value;(o||c)&&(b(t,{code:o?g.too_big:g.too_small,minimum:c?r.exactLength.value:void 0,maximum:o?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),a.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(b(t,{code:g.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),a.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(b(t,{code:g.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>r.type._parseAsync(new G(t,o,t.path,c)))).then(o=>P.mergeArray(a,o));const i=[...t.data].map((o,c)=>r.type._parseSync(new G(t,o,t.path,c)));return P.mergeArray(a,i)}get element(){return this._def.type}min(e,t){return new K({...this._def,minLength:{value:e,message:w.toString(t)}})}max(e,t){return new K({...this._def,maxLength:{value:e,message:w.toString(t)}})}length(e,t){return new K({...this._def,exactLength:{value:e,message:w.toString(t)}})}nonempty(e){return this.min(1,e)}}K.create=(n,e)=>new K({type:n,minLength:null,maxLength:null,exactLength:null,typeName:T.ZodArray,...I(e)});function ve(n){if(n instanceof F){const e={};for(const t in n.shape){const a=n.shape[t];e[t]=Y.create(ve(a))}return new F({...n._def,shape:()=>e})}else return n instanceof K?new K({...n._def,type:ve(n.element)}):n instanceof Y?Y.create(ve(n.unwrap())):n instanceof ce?ce.create(ve(n.unwrap())):n instanceof J?J.create(n.items.map(e=>ve(e))):n}class F 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=E.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==v.object){const f=this._getOrReturnCtx(e);return b(f,{code:g.invalid_type,expected:v.object,received:f.parsedType}),O}const{status:t,ctx:a}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof ee&&this._def.unknownKeys==="strip"))for(const f in a.data)i.includes(f)||o.push(f);const c=[];for(const f of i){const _=r[f],y=a.data[f];c.push({key:{status:"valid",value:f},value:_._parse(new G(a,y,a.path,f)),alwaysSet:f in a.data})}if(this._def.catchall instanceof ee){const f=this._def.unknownKeys;if(f==="passthrough")for(const _ of o)c.push({key:{status:"valid",value:_},value:{status:"valid",value:a.data[_]}});else if(f==="strict")o.length>0&&(b(a,{code:g.unrecognized_keys,keys:o}),t.dirty());else if(f!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const f=this._def.catchall;for(const _ of o){const y=a.data[_];c.push({key:{status:"valid",value:_},value:f._parse(new G(a,y,a.path,_)),alwaysSet:_ in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const f=[];for(const _ of c){const y=await _.key,C=await _.value;f.push({key:y,value:C,alwaysSet:_.alwaysSet})}return f}).then(f=>P.mergeObjectSync(t,f)):P.mergeObjectSync(t,c)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new F({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,a)=>{var r,i,o,c;const f=(o=(i=(r=this._def).errorMap)===null||i===void 0?void 0:i.call(r,t,a).message)!==null&&o!==void 0?o:a.defaultError;return t.code==="unrecognized_keys"?{message:(c=w.errToObj(e).message)!==null&&c!==void 0?c:f}:{message:f}}}:{}})}strip(){return new F({...this._def,unknownKeys:"strip"})}passthrough(){return new F({...this._def,unknownKeys:"passthrough"})}extend(e){return new F({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new F({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:T.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new F({...this._def,catchall:e})}pick(e){const t={};return E.objectKeys(e).forEach(a=>{e[a]&&this.shape[a]&&(t[a]=this.shape[a])}),new F({...this._def,shape:()=>t})}omit(e){const t={};return E.objectKeys(this.shape).forEach(a=>{e[a]||(t[a]=this.shape[a])}),new F({...this._def,shape:()=>t})}deepPartial(){return ve(this)}partial(e){const t={};return E.objectKeys(this.shape).forEach(a=>{const r=this.shape[a];e&&!e[a]?t[a]=r:t[a]=r.optional()}),new F({...this._def,shape:()=>t})}required(e){const t={};return E.objectKeys(this.shape).forEach(a=>{if(e&&!e[a])t[a]=this.shape[a];else{let r=this.shape[a];for(;r instanceof Y;)r=r._def.innerType;t[a]=r}}),new F({...this._def,shape:()=>t})}keyof(){return kt(E.objectKeys(this.shape))}}F.create=(n,e)=>new F({shape:()=>n,unknownKeys:"strip",catchall:ee.create(),typeName:T.ZodObject,...I(e)}),F.strictCreate=(n,e)=>new F({shape:()=>n,unknownKeys:"strict",catchall:ee.create(),typeName:T.ZodObject,...I(e)}),F.lazycreate=(n,e)=>new F({shape:n,unknownKeys:"strip",catchall:ee.create(),typeName:T.ZodObject,...I(e)});class Re extends j{_parse(e){const{ctx:t}=this._processInputParams(e),a=this._def.options;function r(i){for(const c of i)if(c.result.status==="valid")return c.result;for(const c of i)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=i.map(c=>new M(c.ctx.common.issues));return b(t,{code:g.invalid_union,unionErrors:o}),O}if(t.common.async)return Promise.all(a.map(async i=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await i._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(r);{let i;const o=[];for(const f of a){const _={...t,common:{...t.common,issues:[]},parent:null},y=f._parseSync({data:t.data,path:t.path,parent:_});if(y.status==="valid")return y;y.status==="dirty"&&!i&&(i={result:y,ctx:_}),_.common.issues.length&&o.push(_.common.issues)}if(i)return t.common.issues.push(...i.ctx.common.issues),i.result;const c=o.map(f=>new M(f));return b(t,{code:g.invalid_union,unionErrors:c}),O}}get options(){return this._def.options}}Re.create=(n,e)=>new Re({options:n,typeName:T.ZodUnion,...I(e)});const ie=n=>n instanceof Ue?ie(n.schema):n instanceof W?ie(n.innerType()):n instanceof Me?[n.value]:n instanceof oe?n.options:n instanceof Le?E.objectValues(n.enum):n instanceof qe?ie(n._def.innerType):n instanceof Ne?[void 0]:n instanceof $e?[null]:n instanceof Y?[void 0,...ie(n.unwrap())]:n instanceof ce?[null,...ie(n.unwrap())]:n instanceof ct||n instanceof Ve?ie(n.unwrap()):n instanceof Be?ie(n._def.innerType):[];class et extends j{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.object)return b(t,{code:g.invalid_type,expected:v.object,received:t.parsedType}),O;const a=this.discriminator,r=t.data[a],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(b(t,{code:g.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),O)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,a){const r=new Map;for(const i of t){const o=ie(i.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(r.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);r.set(c,i)}}return new et({typeName:T.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...I(a)})}}function ot(n,e){const t=ae(n),a=ae(e);if(n===e)return{valid:!0,data:n};if(t===v.object&&a===v.object){const r=E.objectKeys(e),i=E.objectKeys(n).filter(c=>r.indexOf(c)!==-1),o={...n,...e};for(const c of i){const f=ot(n[c],e[c]);if(!f.valid)return{valid:!1};o[c]=f.data}return{valid:!0,data:o}}else if(t===v.array&&a===v.array){if(n.length!==e.length)return{valid:!1};const r=[];for(let i=0;i<n.length;i++){const o=n[i],c=e[i],f=ot(o,c);if(!f.valid)return{valid:!1};r.push(f.data)}return{valid:!0,data:r}}else return t===v.date&&a===v.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class De extends j{_parse(e){const{status:t,ctx:a}=this._processInputParams(e),r=(i,o)=>{if(rt(i)||rt(o))return O;const c=ot(i.value,o.value);return c.valid?((st(i)||st(o))&&t.dirty(),{status:t.value,value:c.data}):(b(a,{code:g.invalid_intersection_types}),O)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([i,o])=>r(i,o)):r(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}De.create=(n,e,t)=>new De({left:n,right:e,typeName:T.ZodIntersection,...I(t)});class J extends j{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==v.array)return b(a,{code:g.invalid_type,expected:v.array,received:a.parsedType}),O;if(a.data.length<this._def.items.length)return b(a,{code:g.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),O;!this._def.rest&&a.data.length>this._def.items.length&&(b(a,{code:g.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...a.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new G(a,i,a.path,o)):null}).filter(i=>!!i);return a.common.async?Promise.all(r).then(i=>P.mergeArray(t,i)):P.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new J({...this._def,rest:e})}}J.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new J({items:n,typeName:T.ZodTuple,rest:null,...I(e)})};class Pe extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==v.object)return b(a,{code:g.invalid_type,expected:v.object,received:a.parsedType}),O;const r=[],i=this._def.keyType,o=this._def.valueType;for(const c in a.data)r.push({key:i._parse(new G(a,c,a.path,c)),value:o._parse(new G(a,a.data[c],a.path,c)),alwaysSet:c in a.data});return a.common.async?P.mergeObjectAsync(t,r):P.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,a){return t instanceof j?new Pe({keyType:e,valueType:t,typeName:T.ZodRecord,...I(a)}):new Pe({keyType:V.create(),valueType:e,typeName:T.ZodRecord,...I(t)})}}class tt extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==v.map)return b(a,{code:g.invalid_type,expected:v.map,received:a.parsedType}),O;const r=this._def.keyType,i=this._def.valueType,o=[...a.data.entries()].map(([c,f],_)=>({key:r._parse(new G(a,c,a.path,[_,"key"])),value:i._parse(new G(a,f,a.path,[_,"value"]))}));if(a.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const f of o){const _=await f.key,y=await f.value;if(_.status==="aborted"||y.status==="aborted")return O;(_.status==="dirty"||y.status==="dirty")&&t.dirty(),c.set(_.value,y.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const f of o){const _=f.key,y=f.value;if(_.status==="aborted"||y.status==="aborted")return O;(_.status==="dirty"||y.status==="dirty")&&t.dirty(),c.set(_.value,y.value)}return{status:t.value,value:c}}}}tt.create=(n,e,t)=>new tt({valueType:e,keyType:n,typeName:T.ZodMap,...I(t)});class fe extends j{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==v.set)return b(a,{code:g.invalid_type,expected:v.set,received:a.parsedType}),O;const r=this._def;r.minSize!==null&&a.data.size<r.minSize.value&&(b(a,{code:g.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&a.data.size>r.maxSize.value&&(b(a,{code:g.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const i=this._def.valueType;function o(f){const _=new Set;for(const y of f){if(y.status==="aborted")return O;y.status==="dirty"&&t.dirty(),_.add(y.value)}return{status:t.value,value:_}}const c=[...a.data.values()].map((f,_)=>i._parse(new G(a,f,a.path,_)));return a.common.async?Promise.all(c).then(f=>o(f)):o(c)}min(e,t){return new fe({...this._def,minSize:{value:e,message:w.toString(t)}})}max(e,t){return new fe({...this._def,maxSize:{value:e,message:w.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}fe.create=(n,e)=>new fe({valueType:n,minSize:null,maxSize:null,typeName:T.ZodSet,...I(e)});class we extends j{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.function)return b(t,{code:g.invalid_type,expected:v.function,received:t.parsedType}),O;function a(c,f){return He({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Qe(),ye].filter(_=>!!_),issueData:{code:g.invalid_arguments,argumentsError:f}})}function r(c,f){return He({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Qe(),ye].filter(_=>!!_),issueData:{code:g.invalid_return_type,returnTypeError:f}})}const i={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof ke){const c=this;return U(async function(...f){const _=new M([]),y=await c._def.args.parseAsync(f,i).catch(D=>{throw _.addIssue(a(f,D)),_}),C=await Reflect.apply(o,this,y);return await c._def.returns._def.type.parseAsync(C,i).catch(D=>{throw _.addIssue(r(C,D)),_})})}else{const c=this;return U(function(...f){const _=c._def.args.safeParse(f,i);if(!_.success)throw new M([a(f,_.error)]);const y=Reflect.apply(o,this,_.data),C=c._def.returns.safeParse(y,i);if(!C.success)throw new M([r(y,C.error)]);return C.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new we({...this._def,args:J.create(e).rest(le.create())})}returns(e){return new we({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,a){return new we({args:e||J.create([]).rest(le.create()),returns:t||le.create(),typeName:T.ZodFunction,...I(a)})}}class Ue 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})}}Ue.create=(n,e)=>new Ue({getter:n,typeName:T.ZodLazy,...I(e)});class Me extends j{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return b(t,{received:t.data,code:g.invalid_literal,expected:this._def.value}),O}return{status:"valid",value:e.data}}get value(){return this._def.value}}Me.create=(n,e)=>new Me({value:n,typeName:T.ZodLiteral,...I(e)});function kt(n,e){return new oe({values:n,typeName:T.ZodEnum,...I(e)})}class oe extends j{constructor(){super(...arguments),Ce.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),a=this._def.values;return b(t,{expected:E.joinValues(a),received:t.parsedType,code:g.invalid_type}),O}if(Je(this,Ce)||mt(this,Ce,new Set(this._def.values)),!Je(this,Ce).has(e.data)){const t=this._getOrReturnCtx(e),a=this._def.values;return b(t,{received:t.data,code:g.invalid_enum_value,options:a}),O}return U(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 oe.create(e,{...this._def,...t})}exclude(e,t=this._def){return oe.create(this.options.filter(a=>!e.includes(a)),{...this._def,...t})}}Ce=new WeakMap,oe.create=kt;class Le extends j{constructor(){super(...arguments),Se.set(this,void 0)}_parse(e){const t=E.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==v.string&&a.parsedType!==v.number){const r=E.objectValues(t);return b(a,{expected:E.joinValues(r),received:a.parsedType,code:g.invalid_type}),O}if(Je(this,Se)||mt(this,Se,new Set(E.getValidEnumValues(this._def.values))),!Je(this,Se).has(e.data)){const r=E.objectValues(t);return b(a,{received:a.data,code:g.invalid_enum_value,options:r}),O}return U(e.data)}get enum(){return this._def.values}}Se=new WeakMap,Le.create=(n,e)=>new Le({values:n,typeName:T.ZodNativeEnum,...I(e)});class ke extends j{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.promise&&t.common.async===!1)return b(t,{code:g.invalid_type,expected:v.promise,received:t.parsedType}),O;const a=t.parsedType===v.promise?t.data:Promise.resolve(t.data);return U(a.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ke.create=(n,e)=>new ke({type:n,typeName:T.ZodPromise,...I(e)});class W extends j{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===T.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:a}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:o=>{b(a,o),o.fatal?t.abort():t.dirty()},get path(){return a.path}};if(i.addIssue=i.addIssue.bind(i),r.type==="preprocess"){const o=r.transform(a.data,i);if(a.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return O;const f=await this._def.schema._parseAsync({data:c,path:a.path,parent:a});return f.status==="aborted"?O:f.status==="dirty"||t.value==="dirty"?Ge(f.value):f});{if(t.value==="aborted")return O;const c=this._def.schema._parseSync({data:o,path:a.path,parent:a});return c.status==="aborted"?O:c.status==="dirty"||t.value==="dirty"?Ge(c.value):c}}if(r.type==="refinement"){const o=c=>{const f=r.refinement(c,i);if(a.common.async)return Promise.resolve(f);if(f instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(a.common.async===!1){const c=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return c.status==="aborted"?O:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(c=>c.status==="aborted"?O:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(r.type==="transform")if(a.common.async===!1){const o=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Ee(o))return o;const c=r.transform(o.value,i);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:a.data,path:a.path,parent:a}).then(o=>Ee(o)?Promise.resolve(r.transform(o.value,i)).then(c=>({status:t.value,value:c})):o);E.assertNever(r)}}W.create=(n,e,t)=>new W({schema:n,typeName:T.ZodEffects,effect:e,...I(t)}),W.createWithPreprocess=(n,e,t)=>new W({schema:e,effect:{type:"preprocess",transform:n},typeName:T.ZodEffects,...I(t)});class Y extends j{_parse(e){return this._getType(e)===v.undefined?U(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Y.create=(n,e)=>new Y({innerType:n,typeName:T.ZodOptional,...I(e)});class ce extends j{_parse(e){return this._getType(e)===v.null?U(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ce.create=(n,e)=>new ce({innerType:n,typeName:T.ZodNullable,...I(e)});class qe extends j{_parse(e){const{ctx:t}=this._processInputParams(e);let a=t.data;return t.parsedType===v.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}qe.create=(n,e)=>new qe({innerType:n,typeName:T.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...I(e)});class Be extends j{_parse(e){const{ctx:t}=this._processInputParams(e),a={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return Ae(r)?r.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new M(a.common.issues)},input:a.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new M(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}Be.create=(n,e)=>new Be({innerType:n,typeName:T.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...I(e)});class nt extends j{_parse(e){if(this._getType(e)!==v.nan){const t=this._getOrReturnCtx(e);return b(t,{code:g.invalid_type,expected:v.nan,received:t.parsedType}),O}return{status:"valid",value:e.data}}}nt.create=n=>new nt({typeName:T.ZodNaN,...I(n)});const cn=Symbol("zod_brand");class ct extends j{_parse(e){const{ctx:t}=this._processInputParams(e),a=t.data;return this._def.type._parse({data:a,path:t.path,parent:t})}unwrap(){return this._def.type}}class ze extends j{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return r.status==="aborted"?O:r.status==="dirty"?(t.dirty(),Ge(r.value)):this._def.out._parseAsync({data:r.value,path:a.path,parent:a})})();{const r=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return r.status==="aborted"?O:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:a.path,parent:a})}}static create(e,t){return new ze({in:e,out:t,typeName:T.ZodPipeline})}}class Ve extends j{_parse(e){const t=this._def.innerType._parse(e),a=r=>(Ee(r)&&(r.value=Object.freeze(r.value)),r);return Ae(t)?t.then(r=>a(r)):a(t)}unwrap(){return this._def.innerType}}Ve.create=(n,e)=>new Ve({innerType:n,typeName:T.ZodReadonly,...I(e)});function Tt(n,e={},t){return n?be.create().superRefine((a,r)=>{var i,o;if(!n(a)){const c=typeof e=="function"?e(a):typeof e=="string"?{message:e}:e,f=(o=(i=c.fatal)!==null&&i!==void 0?i:t)!==null&&o!==void 0?o:!0,_=typeof c=="string"?{message:c}:c;r.addIssue({code:"custom",..._,fatal:f})}}):be.create()}const dn={object:F.lazycreate};var T;(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"})(T||(T={}));const un=(n,e={message:`Input not instance of ${n.name}`})=>Tt(t=>t instanceof n,e),Ot=V.create,It=re.create,ln=nt.create,fn=se.create,jt=Fe.create,pn=ue.create,xn=Ye.create,hn=Ne.create,_n=$e.create,gn=be.create,mn=le.create,yn=ee.create,bn=Xe.create,vn=K.create,wn=F.create,kn=F.strictCreate,Tn=Re.create,On=et.create,In=De.create,jn=J.create,Zn=Pe.create,En=tt.create,An=fe.create,Cn=we.create,Sn=Ue.create,Fn=Me.create,Nn=oe.create,$n=Le.create,Rn=ke.create,Zt=W.create,Dn=Y.create,Pn=ce.create,Un=W.createWithPreprocess,Mn=ze.create;var s=Object.freeze({__proto__:null,defaultErrorMap:ye,setErrorMap:zt,getErrorMap:Qe,makeIssue:He,EMPTY_PATH:Vt,addIssueToContext:b,ParseStatus:P,INVALID:O,DIRTY:Ge,OK:U,isAborted:rt,isDirty:st,isValid:Ee,isAsync:Ae,get util(){return E},get objectUtil(){return at},ZodParsedType:v,getParsedType:ae,ZodType:j,datetimeRegex:wt,ZodString:V,ZodNumber:re,ZodBigInt:se,ZodBoolean:Fe,ZodDate:ue,ZodSymbol:Ye,ZodUndefined:Ne,ZodNull:$e,ZodAny:be,ZodUnknown:le,ZodNever:ee,ZodVoid:Xe,ZodArray:K,ZodObject:F,ZodUnion:Re,ZodDiscriminatedUnion:et,ZodIntersection:De,ZodTuple:J,ZodRecord:Pe,ZodMap:tt,ZodSet:fe,ZodFunction:we,ZodLazy:Ue,ZodLiteral:Me,ZodEnum:oe,ZodNativeEnum:Le,ZodPromise:ke,ZodEffects:W,ZodTransformer:W,ZodOptional:Y,ZodNullable:ce,ZodDefault:qe,ZodCatch:Be,ZodNaN:nt,BRAND:cn,ZodBranded:ct,ZodPipeline:ze,ZodReadonly:Ve,custom:Tt,Schema:j,ZodSchema:j,late:dn,get ZodFirstPartyTypeKind(){return T},coerce:{string:n=>V.create({...n,coerce:!0}),number:n=>re.create({...n,coerce:!0}),boolean:n=>Fe.create({...n,coerce:!0}),bigint:n=>se.create({...n,coerce:!0}),date:n=>ue.create({...n,coerce:!0})},any:gn,array:vn,bigint:fn,boolean:jt,date:pn,discriminatedUnion:On,effect:Zt,enum:Nn,function:Cn,instanceof:un,intersection:In,lazy:Sn,literal:Fn,map:En,nan:ln,nativeEnum:$n,never:yn,null:_n,nullable:Pn,number:It,object:wn,oboolean:()=>jt().optional(),onumber:()=>It().optional(),optional:Dn,ostring:()=>Ot().optional(),pipeline:Mn,preprocess:Un,promise:Rn,record:Zn,set:An,strictObject:kn,string:Ot,symbol:xn,transformer:Zt,tuple:jn,undefined:hn,union:Tn,unknown:mn,void:bn,NEVER:O,ZodIssueCode:g,quotelessJson:Bt,ZodError:M});qt(s),s.object({start:s.number(),limit:s.number(),length:s.number()});const dt=s.object({created_at:s.string(),updated_at:s.string()}),Ln=s.object({email:s.string().optional(),email_verified:s.boolean().optional(),name:s.string().optional(),username:s.string().optional(),given_name:s.string().optional(),phone_number:s.string().optional(),phone_verified:s.boolean().optional(),family_name:s.string().optional()}).catchall(s.any()),qn=s.object({connection:s.string(),user_id:s.string(),provider:s.string(),isSocial:s.boolean(),access_token:s.string().optional(),access_token_secret:s.string().optional(),refresh_token:s.string().optional(),profileData:Ln.optional()}),Et=s.object({email:s.string().optional(),username:s.string().optional(),given_name:s.string().optional(),family_name:s.string().optional(),nickname:s.string().optional(),name:s.string().optional(),picture:s.string().optional(),locale:s.string().optional(),linked_to:s.string().optional(),profileData:s.string().optional(),user_id:s.string().optional()});Et.extend({email_verified:s.boolean().default(!1),verify_email:s.boolean().optional(),last_ip:s.string().optional(),last_login:s.string().optional(),user_id:s.string().optional(),provider:s.string().default("email"),connection:s.string().default("email")}).extend(dt.shape).extend({user_id:s.string(),email:s.string(),is_social:s.boolean(),login_count:s.number(),identities:s.array(qn).optional()}),Et.extend({email:s.string(),login_count:s.number(),multifactor:s.array(s.string()).optional(),last_ip:s.string().optional(),last_login:s.string().optional(),user_id:s.string()}).catchall(s.any());const Bn=s.enum(["sapi","ssa","fsa","ss","ssa","fs","s","f","fp","slo","scoa","fcoa","seccft","cls","seacft","serft"]),zn=s.object({name:s.string(),version:s.string(),env:s.object({node:s.string().optional()}).optional()});s.object({type:Bn,date:s.string(),description:s.string().optional(),log_id:s.string().optional(),_id:s.string().optional(),ip:s.string(),user_agent:s.string(),details:s.any().optional(),isMobile:s.boolean(),user_id:s.string().optional(),user_name:s.string().optional(),connection:s.string().optional(),connection_id:s.string().optional(),client_id:s.string().optional(),client_name:s.string().optional(),audience:s.string().optional(),scope:s.array(s.string()).optional(),strategy:s.string().optional(),strategy_type:s.string().optional(),hostname:s.string().optional(),auth0_client:zn.optional()});const Vn=s.object({id:s.string(),name:s.string(),allowed_web_origins:s.string().transform(n=>n===null?"":n).default(""),allowed_callback_urls:s.string().transform(n=>n===null?"":n).default(""),allowed_logout_urls:s.string().transform(n=>n===null?"":n).default(""),email_validation:s.enum(["enabled","disabled","enforced"]).default("enforced"),client_secret:s.string().default(""),disable_sign_ups:s.boolean().default(!1)});s.object({created_at:s.string().transform(n=>n===null?"":n),updated_at:s.string().transform(n=>n===null?"":n)}).extend(Vn.shape);var At=(n=>(n.TOKEN="token",n.TOKEN_ID_TOKEN="token id_token",n.CODE="code",n))(At||{}),Ct=(n=>(n.QUERY="query",n.FRAGMENT="fragment",n.FORM_POST="form_post",n.WEB_MESSAGE="web_message",n))(Ct||{}),St=(n=>(n.S265="S256",n.plain="plain",n))(St||{});const ut=s.object({client_id:s.string(),vendor_id:s.string().optional(),response_type:s.nativeEnum(At).optional(),response_mode:s.nativeEnum(Ct).optional(),redirect_uri:s.string().optional(),audience:s.string().optional(),state:s.string().optional(),nonce:s.string().optional(),scope:s.string().optional(),code_challenge_method:s.nativeEnum(St).optional(),code_challenge:s.string().optional(),username:s.string().optional()}),Kn=s.object({authParams:ut,code:s.string(),user_id:s.string(),created_at:s.string(),expires_at:s.string(),used_at:s.string().optional()});s.object({...Kn.shape,created_at:s.string()}),s.object({colors:s.object({primary:s.string(),page_background:s.object({type:s.string().optional(),start:s.string().optional(),end:s.string().optional(),angle_deg:s.number().optional()}).optional()}).optional(),logo_url:s.string().optional(),favicon_url:s.string().optional(),font:s.object({url:s.string()}).optional()});const Wn=s.object({id:s.string().optional(),name:s.string(),client_id:s.string().optional(),client_secret:s.string().optional(),authorization_endpoint:s.string().optional(),response_type:s.custom().optional(),response_mode:s.custom().optional(),private_key:s.string().optional(),kid:s.string().optional(),team_id:s.string().optional(),token_endpoint:s.string().optional(),token_exchange_basic_auth:s.boolean().optional(),userinfo_endpoint:s.string().optional(),scope:s.string().optional()}),lt=s.object({id:s.string(),created_at:s.string().transform(n=>n===null?"":n),updated_at:s.string().transform(n=>n===null?"":n)}).extend(Wn.shape),Qn=s.object({domain:s.string(),dkim_private_key:s.string().optional(),dkim_public_key:s.string().optional(),email_api_key:s.string().optional(),email_service:s.union([s.literal("mailgun"),s.literal("mailchannels")]).optional()}),Ft=s.object({id:s.string(),name:s.string(),domains:s.array(Qn),allowed_callback_urls:s.array(s.string()),allowed_logout_urls:s.array(s.string()),allowed_web_origins:s.array(s.string()),email_validation:s.union([s.literal("enabled"),s.literal("disabled"),s.literal("enforced")]),tenant_id:s.string(),client_secret:s.string(),disable_sign_ups:s.boolean(),tenant:s.object({name:s.string(),audience:s.string().optional(),logo:s.string().optional(),primary_color:s.string().optional(),secondary_color:s.string().optional(),sender_email:s.string(),sender_name:s.string(),support_url:s.string().optional(),language:s.string().length(2).optional()})});Ft.extend({connections:s.array(lt)}),Ft.extend({connections:s.array(lt.partial())});const Hn=s.object({domain:s.string(),dkim_private_key:s.string().optional(),dkim_public_key:s.string().optional(),email_api_key:s.string().optional(),email_service:s.enum(["mailgun","mailchannels"])});dt.extend({...Hn.shape,id:s.string()}),s.object({trigger_id:s.enum(["post-user-registration","post-user-login"]),enabled:s.boolean().default(!1),url:s.string(),hook_id:s.string().optional()}).extend({...dt.shape,hook_id:s.string()});const Gn=s.object({alg:s.string(),e:s.string(),kid:s.string(),kty:s.string(),n:s.string(),use:s.string().optional()});s.object({keys:s.array(Gn)}),s.object({issuer:s.string(),authorization_endpoint:s.string(),token_endpoint:s.string(),device_authorization_endpoint:s.string(),userinfo_endpoint:s.string(),mfa_challenge_endpoint:s.string(),jwks_uri:s.string(),registration_endpoint:s.string(),revocation_endpoint:s.string(),scopes_supported:s.array(s.string()),response_types_supported:s.array(s.string()),code_challenge_methods_supported:s.array(s.string()),response_modes_supported:s.array(s.string()),subject_types_supported:s.array(s.string()),id_token_signing_alg_values_supported:s.array(s.string()),token_endpoint_auth_methods_supported:s.array(s.string()),claims_supported:s.array(s.string()),request_uri_parameter_supported:s.boolean(),request_parameter_supported:s.boolean(),token_endpoint_auth_signing_alg_values_supported:s.array(s.string())});const Jn=s.object({id:s.string(),email:s.string(),code:s.string(),ip:s.string().optional(),send:s.enum(["code","link"]),authParams:ut,expires_at:s.string(),used_at:s.string().optional(),user_id:s.string().optional()});s.object({created_at:s.string(),...Jn.shape});const Yn=s.object({session_id:s.string(),client_id:s.string(),expires_at:s.string(),used_at:s.string(),deleted_at:s.string().optional(),user_id:s.string()});s.object({created_at:s.string(),...Yn.shape}),s.object({private_key:s.string(),public_key:s.string(),kid:s.string(),created_at:s.string(),revoked_at:s.string().optional()}),s.object({kid:s.string().openapi({description:"The key id of the signing key"}),cert:s.string().openapi({description:"The public certificate of the signing key"}),fingerprint:s.string().openapi({description:"The cert fingerprint"}),thumbprint:s.string().openapi({description:"The cert thumbprint"}),pkcs7:s.string().optional().openapi({description:"The public certificate of the signing key in pkcs7 format"}),current:s.boolean().optional().openapi({description:"True if the key is the current key"}),next:s.boolean().optional().openapi({description:"True if the key is the next key"}),previous:s.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:s.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:s.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:s.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:s.string().optional().openapi({description:"The date and time when the key was revoked"})}),s.object({name:s.string(),audience:s.string(),sender_email:s.string().email(),sender_name:s.string(),support_url:s.string().url().optional(),logo:s.string().url().optional(),primary_color:s.string().optional(),secondary_color:s.string().optional(),language:s.string().optional()}).extend({created_at:s.string().transform(n=>n===null?"":n),updated_at:s.string().transform(n=>n===null?"":n)}),s.object({logoUrl:s.string(),loginBackgroundImage:s.string().nullish(),style:s.object({primaryColor:s.string(),buttonTextColor:s.string(),primaryHoverColor:s.string()}),supportEmail:s.string().nullable(),supportUrl:s.string().nullable(),name:s.string(),showGreyishBackground:s.boolean().optional(),termsAndConditionsUrl:s.string().nullable(),companyName:s.string().optional(),checkoutHideSocial:s.boolean().optional(),siteUrl:s.string().nullable(),manageSubscriptionsUrl:s.string().optional()});var Nt=(n=>(n.RefreshToken="refresh_token",n.AuthorizationCode="authorization_code",n.ClientCredential="client_credentials",n.Passwordless="passwordless",n.Password="password",n))(Nt||{});const ft=s.nativeEnum(Nt);s.object({grant_type:ft.refine(n=>n==="authorization_code"),code:s.string(),client_secret:s.string(),client_id:s.string()}),s.object({grant_type:ft.refine(n=>n==="authorization_code"),code:s.string(),code_verifier:s.string(),client_id:s.string().optional(),redirect_uri:s.string()}),s.object({grant_type:ft.refine(n=>n==="client_credentials"),scope:s.string().optional(),client_secret:s.string(),client_id:s.string(),audience:s.string().optional()}),s.object({access_token:s.string(),id_token:s.string().optional(),scope:s.string().optional(),state:s.string().optional(),refresh_token:s.string().optional(),token_type:s.string(),expires_in:s.number()}),s.object({code:s.string(),state:s.string().optional()});const Xn=s.object({id:s.string(),expires_at:s.string(),auth0Client:s.string().optional(),authParams:ut});s.object({...Xn.shape,created_at:s.string(),updated_at:s.string()});function pt(n){const[e,t]=n.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${n}`);return{connection:e,id:t}}function $t(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:pt(n.user_id).id,isSocial:!!n.is_social,profileData:{email:n.email,email_verified:!!n.email_verified,...e}}}function ea(n){return async(e,t)=>{const[a,r]=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(!a)return null;const{tenant_id:i,...o}=a,c={...o,email:a.email||"",email_verified:a.email_verified===1,is_social:a.is_social===1,identities:[{connection:a.connection,provider:a.provider,user_id:pt(a.user_id).id,isSocial:!!a.is_social},...r.map($t)]};return $(c)}}function Te(n,e,t,a){return t.split(/\s+/).map(i=>i.replace("=",":")).map(i=>{let o=i.startsWith("-"),c,f,_;return i.startsWith("-_exists_:")?(c=i.substring(10),_=!0,o=!0):i.startsWith("_exists_:")?(c=i.substring(9),_=!0,o=!1):i.includes(":")?(o=i.startsWith("-"),[c,f]=o?i.substring(1).split(":"):i.split(":"),_=!1):(c=null,f=i,_=!1),{key:c,value:f,isNegation:o,isExistsQuery:_}}).forEach(({key:i,value:o,isNegation:c,isExistsQuery:f})=>{if(i)f?c?e=e.where(i,"is",null):e=e.where(i,"is not",null):c?e=e.where(i,"!=",o):e=e.where(i,"=",o);else{const{ref:_}=n.dynamic;e=e.where(y=>y.or(a.map(C=>y(_(C),"like",`%${o}%`))))}}),e}function pe(n){return typeof n=="string"?parseInt(n,10):typeof n=="bigint"?Number(n):n}function ta(n){return async(e,t)=>{let a=n.selectFrom("users").where("users.tenant_id","=",e);if(t.q&&(a=Te(n,a,t.q,["email","name"])),t.sort&&t.sort.sort_by){const{ref:y}=n.dynamic;a=a.orderBy(y(t.sort.sort_by),t.sort.sort_order)}const i=await a.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),o=i.map(y=>y.user_id),c=o.length?await n.selectFrom("users").selectAll().where("users.tenant_id","=",e).where("users.linked_to","in",o).execute():[],f=i.map(y=>{const C=c.filter(D=>D.linked_to===y.user_id);return $({...y,email_verified:y.email_verified===1,is_social:y.is_social===1,identities:[{connection:y.connection,provider:y.provider,user_id:pt(y.user_id).id,isSocial:!!y.is_social},...C.map($t)]})}),{count:_}=await a.select(y=>y.fn.countAll().as("count")).executeTakeFirstOrThrow();return{users:f,start:t.page*t.per_page,limit:t.per_page,length:pe(_)}}}function na(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 aa(n){if(n.email_verified!==void 0)return n.email_verified?1:0}function ra(n){return async(e,t,a)=>{const r={...a,email_verified:aa(a),updated_at:new Date().toISOString()};return(await n.updateTable("users").set(r).where("users.tenant_id","=",e).where("users.user_id","=",t).execute()).length===1}}function sa(n){return async(e,t,a,r)=>{const i={linked_to:null};return(await n.updateTable("users").set(i).where("users.tenant_id","=",e).where("users.user_id","=",`${a}|${r}`).where("users.linked_to","=",`${t}`).execute()).length===1}}function ia(n){return{create:X(n),remove:na(n),get:ea(n),list:ta(n),update:ra(n),unlink:sa(n)}}const oa="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ke=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n));for(;n--;)e+=oa[t[n]&63];return e};function ca(n){return async e=>{const t={id:e.id||Ke(),created_at:new Date().toISOString(),updated_at:new Date().toISOString(),...e};return await n.insertInto("tenants").values(t).execute(),t}}function da(n){return async e=>{const t=await n.selectFrom("tenants").where("tenants.id","=",e).selectAll().executeTakeFirst();return t?$(t):null}}function ua(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 r=await t.offset(e.page*e.per_page).limit(e.per_page).selectAll().execute();if(!e.include_totals)return{tenants:r};const{count:i}=await t.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow(),o=pe(i);return{tenants:r.map($),start:(e.page-1)*e.per_page,limit:e.per_page,length:o}}}function la(n){return async(e,t)=>{const a={...t,id:e,updated_at:new Date().toISOString()};await n.updateTable("tenants").set(a).where("id","=",e).execute()}}function fa(n){return async e=>(await n.deleteFrom("tenants").where("tenants.id","=",e).execute()).length===1}function pa(n){return{create:ca(n),get:da(n),list:ua(n),update:la(n),remove:fa(n)}}function Rt(n){return n?JSON.stringify(n):void 0}const xa=1024;function ha(n){return async(e,t)=>{var r,i;const a={id:Ke(),...t,user_agent:t.user_agent.slice(0,xa)};return await n.insertInto("logs").values({...a,isMobile:t.isMobile?1:0,tenant_id:e,scope:(r=t.scope)==null?void 0:r.join(","),auth0_client:Rt(t.auth0_client),details:(i=Rt(t.details))==null?void 0:i.substring(0,8192)}).execute(),a}}function Dt(n){if(!n)return"";try{return JSON.parse(n)}catch{return n}}function Pt(n){return{...n,client_id:n.client_id,client_name:"",auth0_client:Dt(n.auth0_client),details:Dt(n.details),isMobile:!!n.isMobile,scope:n.scope?n.scope.split(","):void 0,log_id:n.id,_id:n.id}}function _a(n){return async(e,t)=>{let a=n.selectFrom("logs").where("logs.tenant_id","=",e);t.q&&(a=Te(n,a,t.q,["user_id","ip"]));let r=a;if(t.sort&&t.sort.sort_by){const{ref:c}=n.dynamic;r=r.orderBy(c(t.sort.sort_by),t.sort.sort_order)}r=r.offset(t.page*t.per_page).limit(t.per_page);const i=await r.selectAll().execute(),{count:o}=await a.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{logs:i.map(Pt),start:t.page*t.per_page,limit:t.per_page,length:pe(o)}}}function ga(n){return async(e,t)=>{const a=await n.selectFrom("logs").where("logs.tenant_id","=",e).where("logs.id","=",t).selectAll().executeTakeFirst();return a?Pt(a):null}}function ma(n){return{create:ha(n),list:_a(n),get:ga(n)}}function ya(n){return async(e,t)=>{const a=await n.selectFrom("sessions").where("sessions.tenant_id","=",e).where("sessions.id","=",t).where("sessions.deleted_at","is",null).selectAll().executeTakeFirst();return a?{session_id:a.id,user_id:a.user_id,client_id:a.client_id,created_at:a.created_at,expires_at:a.expires_at,used_at:a.used_at}:null}}function ba(n){return async(e,t)=>{const a={user_id:t.user_id,client_id:t.client_id,created_at:new Date().toISOString(),expires_at:new Date().toISOString(),used_at:t.used_at};return await n.insertInto("sessions").values({...a,tenant_id:e,id:t.session_id}).execute(),{...t,...a}}}function va(n){return async(e,t)=>!!(await n.updateTable("sessions").set({deleted_at:new Date().toISOString()}).where("tenant_id","=",e).where("sessions.id","=",t).where("sessions.deleted_at","is",null).execute()).length}function wa(n){return async(e,t,a)=>!!(await n.updateTable("sessions").set(a).where("tenant_id","=",e).where("sessions.id","=",t).where("sessions.deleted_at","is",null).execute()).length}function ka(n){return async(e,t)=>{let a=n.selectFrom("sessions").where("sessions.tenant_id","=",e);t.q&&(a=Te(n,a,t.q,["user_id","id"]));let r=a;if(t.sort&&t.sort.sort_by){const{ref:f}=n.dynamic;r=r.orderBy(f(t.sort.sort_by),t.sort.sort_order)}r=r.offset(t.page*t.per_page).limit(t.per_page);const i=await r.selectAll().execute(),{count:o}=await a.select(f=>f.fn.countAll().as("count")).executeTakeFirstOrThrow(),c=pe(o);return{sessions:i.map(f=>{const{id:_,...y}=f;return{session_id:_,...y}}),start:t.page*t.per_page,limit:t.per_page,length:c}}}function Ta(n){return{create:ba(n),get:ya(n),list:ka(n),remove:va(n),update:wa(n)}}function Oa(n){return async(e,t)=>{const a=await n.selectFrom("tickets").where("tickets.tenant_id","=",e).where("tickets.id","=",t).where("tickets.used_at","is",null).selectAll().executeTakeFirst();if(!a)return null;const{nonce:r,state:i,scope:o,response_type:c,response_mode:f,redirect_uri:_,...y}=a;return{...y,authParams:{nonce:r,state:i,scope:o,response_type:c,response_mode:f,redirect_uri:_},created_at:new Date(a.created_at),expires_at:new Date(a.expires_at),used_at:a.used_at?new Date(a.used_at):void 0}}}function Ia(n){return async e=>{const{authParams:t,...a}=e,r={...a,...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(r).execute()}}function ja(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 Za(n){return{create:Ia(n),get:Oa(n),remove:ja(n)}}function Ea(n){return async(e,t)=>{const a=new Date().toISOString();return(await n.selectFrom("otps").where("otps.tenant_id","=",e).where("otps.email","=",t).where("otps.expires_at",">",a).where("otps.used_at","is",null).selectAll().execute()).map(i=>{const{nonce:o,state:c,scope:f,response_type:_,redirect_uri:y,client_id:C,...D}=i;return{...D,client_id:C,authParams:{client_id:C,nonce:o,state:c,scope:f,response_type:_,redirect_uri:y},created_at:i.created_at,expires_at:i.expires_at}})}}function Aa(n){return async(e,t)=>{const{authParams:a,...r}=t;await n.insertInto("otps").values({...r,...a,created_at:new Date().toISOString(),tenant_id:e,send:t.send==="code"?"code":"link"}).execute()}}function Ca(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 Sa(n){return{create:Aa(n),list:Ea(n),remove:Ca(n)}}var Fa=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Na(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function $a(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function a(){return this instanceof a?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(a){var r=Object.getOwnPropertyDescriptor(n,a);Object.defineProperty(t,a,r.get?r:{enumerable:!0,get:function(){return n[a]}})}),t}function Ra(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ut={exports:{}};const Da=$a(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(n){/**
|
|
2
|
-
* @license bcrypt.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
|
|
3
|
-
* Released under the Apache License, Version 2.0
|
|
4
|
-
* see: https://github.com/dcodeIO/bcrypt.js for details
|
|
5
|
-
*/(function(e,t){typeof Ra=="function"&&n&&n.exports?n.exports=t():(e.dcodeIO=e.dcodeIO||{}).bcrypt=t()})(Fa,function(){var e={},t=null;function a(x){if(n&&n.exports)try{return Da.randomBytes(x)}catch{}try{var p;return(self.crypto||self.msCrypto).getRandomValues(p=new Uint32Array(x)),Array.prototype.slice.call(p)}catch{}if(!t)throw Error("Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative");return t(x)}var r=!1;try{a(1),r=!0}catch{}t=null,e.setRandomFallback=function(x){t=x},e.genSaltSync=function(x,p){if(x=x||Q,typeof x!="number")throw Error("Illegal arguments: "+typeof x+", "+typeof p);x<4?x=4:x>31&&(x=31);var l=[];return l.push("$2a$"),x<10&&l.push("0"),l.push(x.toString()),l.push("$"),l.push(C(a(L),L)),l.join("")},e.genSalt=function(x,p,l){if(typeof p=="function"&&(l=p,p=void 0),typeof x=="function"&&(l=x,x=void 0),typeof x>"u")x=Q;else if(typeof x!="number")throw Error("illegal arguments: "+typeof x);function u(d){o(function(){try{d(null,e.genSaltSync(x))}catch(h){d(h)}})}if(l){if(typeof l!="function")throw Error("Illegal callback: "+typeof l);u(l)}else return new Promise(function(d,h){u(function(m,Z){if(m){h(m);return}d(Z)})})},e.hashSync=function(x,p){if(typeof p>"u"&&(p=Q),typeof p=="number"&&(p=e.genSaltSync(p)),typeof x!="string"||typeof p!="string")throw Error("Illegal arguments: "+typeof x+", "+typeof p);return me(x,p)},e.hash=function(x,p,l,u){function d(h){typeof x=="string"&&typeof p=="number"?e.genSalt(p,function(m,Z){me(x,Z,h,u)}):typeof x=="string"&&typeof p=="string"?me(x,p,h,u):o(h.bind(this,Error("Illegal arguments: "+typeof x+", "+typeof p)))}if(l){if(typeof l!="function")throw Error("Illegal callback: "+typeof l);d(l)}else return new Promise(function(h,m){d(function(Z,k){if(Z){m(Z);return}h(k)})})};function i(x,p){for(var l=0,u=0,d=0,h=x.length;d<h;++d)x.charCodeAt(d)===p.charCodeAt(d)?++l:++u;return l<0?!1:u===0}e.compareSync=function(x,p){if(typeof x!="string"||typeof p!="string")throw Error("Illegal arguments: "+typeof x+", "+typeof p);return p.length!==60?!1:i(e.hashSync(x,p.substr(0,p.length-31)),p)},e.compare=function(x,p,l,u){function d(h){if(typeof x!="string"||typeof p!="string"){o(h.bind(this,Error("Illegal arguments: "+typeof x+", "+typeof p)));return}if(p.length!==60){o(h.bind(this,null,!1));return}e.hash(x,p.substr(0,29),function(m,Z){m?h(m):h(null,i(Z,p))},u)}if(l){if(typeof l!="function")throw Error("Illegal callback: "+typeof l);d(l)}else return new Promise(function(h,m){d(function(Z,k){if(Z){m(Z);return}h(k)})})},e.getRounds=function(x){if(typeof x!="string")throw Error("Illegal arguments: "+typeof x);return parseInt(x.split("$")[2],10)},e.getSalt=function(x){if(typeof x!="string")throw Error("Illegal arguments: "+typeof x);if(x.length!==60)throw Error("Illegal hash length: "+x.length+" != 60");return x.substring(0,29)};var o=typeof process<"u"&&process&&typeof process.nextTick=="function"?typeof setImmediate=="function"?setImmediate:process.nextTick:setTimeout;function c(x){var p=[],l=0;return te.encodeUTF16toUTF8(function(){return l>=x.length?null:x.charCodeAt(l++)},function(u){p.push(u)}),p}var f="./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),_=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,54,55,56,57,58,59,60,61,62,63,-1,-1,-1,-1,-1,-1,-1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,-1,-1,-1,-1,-1,-1,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,-1,-1,-1,-1,-1],y=String.fromCharCode;function C(x,p){var l=0,u=[],d,h;if(p<=0||p>x.length)throw Error("Illegal len: "+p);for(;l<p;){if(d=x[l++]&255,u.push(f[d>>2&63]),d=(d&3)<<4,l>=p){u.push(f[d&63]);break}if(h=x[l++]&255,d|=h>>4&15,u.push(f[d&63]),d=(h&15)<<2,l>=p){u.push(f[d&63]);break}h=x[l++]&255,d|=h>>6&3,u.push(f[d&63]),u.push(f[h&63])}return u.join("")}function D(x,p){var l=0,u=x.length,d=0,h=[],m,Z,k,A,S,N;if(p<=0)throw Error("Illegal len: "+p);for(;l<u-1&&d<p&&(N=x.charCodeAt(l++),m=N<_.length?_[N]:-1,N=x.charCodeAt(l++),Z=N<_.length?_[N]:-1,!(m==-1||Z==-1||(S=m<<2>>>0,S|=(Z&48)>>4,h.push(y(S)),++d>=p||l>=u)||(N=x.charCodeAt(l++),k=N<_.length?_[N]:-1,k==-1)||(S=(Z&15)<<4>>>0,S|=(k&60)>>2,h.push(y(S)),++d>=p||l>=u)));)N=x.charCodeAt(l++),A=N<_.length?_[N]:-1,S=(k&3)<<6>>>0,S|=A,h.push(y(S)),++d;var H=[];for(l=0;l<d;l++)H.push(h[l].charCodeAt(0));return H}var te=function(){var x={};return x.MAX_CODEPOINT=1114111,x.encodeUTF8=function(p,l){var u=null;for(typeof p=="number"&&(u=p,p=function(){return null});u!==null||(u=p())!==null;)u<128?l(u&127):u<2048?(l(u>>6&31|192),l(u&63|128)):u<65536?(l(u>>12&15|224),l(u>>6&63|128),l(u&63|128)):(l(u>>18&7|240),l(u>>12&63|128),l(u>>6&63|128),l(u&63|128)),u=null},x.decodeUTF8=function(p,l){for(var u,d,h,m,Z=function(k){k=k.slice(0,k.indexOf(null));var A=Error(k.toString());throw A.name="TruncatedError",A.bytes=k,A};(u=p())!==null;)if(!(u&128))l(u);else if((u&224)===192)(d=p())===null&&Z([u,d]),l((u&31)<<6|d&63);else if((u&240)===224)((d=p())===null||(h=p())===null)&&Z([u,d,h]),l((u&15)<<12|(d&63)<<6|h&63);else if((u&248)===240)((d=p())===null||(h=p())===null||(m=p())===null)&&Z([u,d,h,m]),l((u&7)<<18|(d&63)<<12|(h&63)<<6|m&63);else throw RangeError("Illegal starting byte: "+u)},x.UTF16toUTF8=function(p,l){for(var u,d=null;(u=d!==null?d:p())!==null;){if(u>=55296&&u<=57343&&(d=p())!==null&&d>=56320&&d<=57343){l((u-55296)*1024+d-56320+65536),d=null;continue}l(u)}d!==null&&l(d)},x.UTF8toUTF16=function(p,l){var u=null;for(typeof p=="number"&&(u=p,p=function(){return null});u!==null||(u=p())!==null;)u<=65535?l(u):(u-=65536,l((u>>10)+55296),l(u%1024+56320)),u=null},x.encodeUTF16toUTF8=function(p,l){x.UTF16toUTF8(p,function(u){x.encodeUTF8(u,l)})},x.decodeUTF8toUTF16=function(p,l){x.decodeUTF8(p,function(u){x.UTF8toUTF16(u,l)})},x.calculateCodePoint=function(p){return p<128?1:p<2048?2:p<65536?3:4},x.calculateUTF8=function(p){for(var l,u=0;(l=p())!==null;)u+=x.calculateCodePoint(l);return u},x.calculateUTF16asUTF8=function(p){var l=0,u=0;return x.UTF16toUTF8(p,function(d){++l,u+=x.calculateCodePoint(d)}),[l,u]},x}();Date.now=Date.now||function(){return+new Date};var L=16,Q=10,xe=16,he=100,de=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731],_e=[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110,2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150,2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882,3600875718,1076654713,1738483198,4213154764,2393238008,3677496056,1014306527,4251020053,793779912,2902807211,842905082,4246964064,1395751752,1040244610,2656851899,3396308128,445077038,3742853595,3577915638,679411651,2892444358,2354009459,1767581616,3150600392,3791627101,3102740896,284835224,4246832056,1258075500,768725851,2589189241,3069724005,3532540348,1274779536,3789419226,2764799539,1660621633,3471099624,4011903706,913787905,3497959166,737222580,2514213453,2928710040,3937242737,1804850592,3499020752,2949064160,2386320175,2390070455,2415321851,4061277028,2290661394,2416832540,1336762016,1754252060,3520065937,3014181293,791618072,3188594551,3933548030,2332172193,3852520463,3043980520,413987798,3465142937,3030929376,4245938359,2093235073,3534596313,375366246,2157278981,2479649556,555357303,3870105701,2008414854,3344188149,4221384143,3956125452,2067696032,3594591187,2921233993,2428461,544322398,577241275,1471733935,610547355,4027169054,1432588573,1507829418,2025931657,3646575487,545086370,48609733,2200306550,1653985193,298326376,1316178497,3007786442,2064951626,458293330,2589141269,3591329599,3164325604,727753846,2179363840,146436021,1461446943,4069977195,705550613,3059967265,3887724982,4281599278,3313849956,1404054877,2845806497,146425753,1854211946,1266315497,3048417604,3681880366,3289982499,290971e4,1235738493,2632868024,2414719590,3970600049,1771706367,1449415276,3266420449,422970021,1963543593,2690192192,3826793022,1062508698,1531092325,1804592342,2583117782,2714934279,4024971509,1294809318,4028980673,1289560198,2221992742,1669523910,35572830,157838143,1052438473,1016535060,1802137761,1753167236,1386275462,3080475397,2857371447,1040679964,2145300060,2390574316,1461121720,2956646967,4031777805,4028374788,33600511,2920084762,1018524850,629373528,3691585981,3515945977,2091462646,2486323059,586499841,988145025,935516892,3367335476,2599673255,2839830854,265290510,3972581182,2759138881,3795373465,1005194799,847297441,406762289,1314163512,1332590856,1866599683,4127851711,750260880,613907577,1450815602,3165620655,3734664991,3650291728,3012275730,3704569646,1427272223,778793252,1343938022,2676280711,2052605720,1946737175,3164576444,3914038668,3967478842,3682934266,1661551462,3294938066,4011595847,840292616,3712170807,616741398,312560963,711312465,1351876610,322626781,1910503582,271666773,2175563734,1594956187,70604529,3617834859,1007753275,1495573769,4069517037,2549218298,2663038764,504708206,2263041392,3941167025,2249088522,1514023603,1998579484,1312622330,694541497,2582060303,2151582166,1382467621,776784248,2618340202,3323268794,2497899128,2784771155,503983604,4076293799,907881277,423175695,432175456,1378068232,4145222326,3954048622,3938656102,3820766613,2793130115,2977904593,26017576,3274890735,3194772133,1700274565,1756076034,4006520079,3677328699,720338349,1533947780,354530856,688349552,3973924725,1637815568,332179504,3949051286,53804574,2852348879,3044236432,1282449977,3583942155,3416972820,4006381244,1617046695,2628476075,3002303598,1686838959,431878346,2686675385,1700445008,1080580658,1009431731,832498133,3223435511,2605976345,2271191193,2516031870,1648197032,4164389018,2548247927,300782431,375919233,238389289,3353747414,2531188641,2019080857,1475708069,455242339,2609103871,448939670,3451063019,1395535956,2413381860,1841049896,1491858159,885456874,4264095073,4001119347,1565136089,3898914787,1108368660,540939232,1173283510,2745871338,3681308437,4207628240,3343053890,4016749493,1699691293,1103962373,3625875870,2256883143,3830138730,1031889488,3479347698,1535977030,4236805024,3251091107,2132092099,1774941330,1199868427,1452454533,157007616,2904115357,342012276,595725824,1480756522,206960106,497939518,591360097,863170706,2375253569,3596610801,1814182875,2094937945,3421402208,1082520231,3463918190,2785509508,435703966,3908032597,1641649973,2842273706,3305899714,1510255612,2148256476,2655287854,3276092548,4258621189,236887753,3681803219,274041037,1734335097,3815195456,3317970021,1899903192,1026095262,4050517792,356393447,2410691914,3873677099,3682840055,3913112168,2491498743,4132185628,2489919796,1091903735,1979897079,3170134830,3567386728,3557303409,857797738,1136121015,1342202287,507115054,2535736646,337727348,3213592640,1301675037,2528481711,1895095763,1721773893,3216771564,62756741,2142006736,835421444,2531993523,1442658625,3659876326,2882144922,676362277,1392781812,170690266,3921047035,1759253602,3611846912,1745797284,664899054,1329594018,3901205900,3045908486,2062866102,2865634940,3543621612,3464012697,1080764994,553557557,3656615353,3996768171,991055499,499776247,1265440854,648242737,3940784050,980351604,3713745714,1749149687,3396870395,4211799374,3640570775,1161844396,3125318951,1431517754,545492359,4268468663,3499529547,1437099964,2702547544,3433638243,2581715763,2787789398,1060185593,1593081372,2418618748,4260947970,69676912,2159744348,86519011,2512459080,3838209314,1220612927,3339683548,133810670,1090789135,1078426020,1569222167,845107691,3583754449,4072456591,1091646820,628848692,1613405280,3757631651,526609435,236106946,48312990,2942717905,3402727701,1797494240,859738849,992217954,4005476642,2243076622,3870952857,3732016268,765654824,3490871365,2511836413,1685915746,3888969200,1414112111,2273134842,3281911079,4080962846,172450625,2569994100,980381355,4109958455,2819808352,2716589560,2568741196,3681446669,3329971472,1835478071,660984891,3704678404,4045999559,3422617507,3040415634,1762651403,1719377915,3470491036,2693910283,3642056355,3138596744,1364962596,2073328063,1983633131,926494387,3423689081,2150032023,4096667949,1749200295,3328846651,309677260,2016342300,1779581495,3079819751,111262694,1274766160,443224088,298511866,1025883608,3806446537,1145181785,168956806,3641502830,3584813610,1689216846,3666258015,3200248200,1692713982,2646376535,4042768518,1618508792,1610833997,3523052358,4130873264,2001055236,3610705100,2202168115,4028541809,2961195399,1006657119,2006996926,3186142756,1430667929,3210227297,1314452623,4074634658,4101304120,2273951170,1399257539,3367210612,3027628629,1190975929,2062231137,2333990788,2221543033,2438960610,1181637006,548689776,2362791313,3372408396,3104550113,3145860560,296247880,1970579870,3078560182,3769228297,1714227617,3291629107,3898220290,166772364,1251581989,493813264,448347421,195405023,2709975567,677966185,3703036547,1463355134,2715995803,1338867538,1343315457,2802222074,2684532164,233230375,2599980071,2000651841,3277868038,1638401717,4028070440,3237316320,6314154,819756386,300326615,590932579,1405279636,3267499572,3150704214,2428286686,3959192993,3461946742,1862657033,1266418056,963775037,2089974820,2263052895,1917689273,448879540,3550394620,3981727096,150775221,3627908307,1303187396,508620638,2975983352,2726630617,1817252668,1876281319,1457606340,908771278,3720792119,3617206836,2455994898,1729034894,1080033504,976866871,3556439503,2881648439,1522871579,1555064734,1336096578,3548522304,2579274686,3574697629,3205460757,3593280638,3338716283,3079412587,564236357,2993598910,1781952180,1464380207,3163844217,3332601554,1699332808,1393555694,1183702653,3581086237,1288719814,691649499,2847557200,2895455976,3193889540,2717570544,1781354906,1676643554,2592534050,3230253752,1126444790,2770207658,2633158820,2210423226,2615765581,2414155088,3127139286,673620729,2805611233,1269405062,4015350505,3341807571,4149409754,1057255273,2012875353,2162469141,2276492801,2601117357,993977747,3918593370,2654263191,753973209,36408145,2530585658,25011837,3520020182,2088578344,530523599,2918365339,1524020338,1518925132,3760827505,3759777254,1202760957,3985898139,3906192525,674977740,4174734889,2031300136,2019492241,3983892565,4153806404,3822280332,352677332,2297720250,60907813,90501309,3286998549,1016092578,2535922412,2839152426,457141659,509813237,4120667899,652014361,1966332200,2975202805,55981186,2327461051,676427537,3255491064,2882294119,3433927263,1307055953,942726286,933058658,2468411793,3933900994,4215176142,1361170020,2001714738,2830558078,3274259782,1222529897,1679025792,2729314320,3714953764,1770335741,151462246,3013232138,1682292957,1483529935,471910574,1539241949,458788160,3436315007,1807016891,3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409e3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588,3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493,1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462],ge=[1332899944,1700884034,1701343084,1684370003,1668446532,1869963892];function B(x,p,l,u){var d,h=x[p],m=x[p+1];return h^=l[0],d=u[h>>>24],d+=u[256|h>>16&255],d^=u[512|h>>8&255],d+=u[768|h&255],m^=d^l[1],d=u[m>>>24],d+=u[256|m>>16&255],d^=u[512|m>>8&255],d+=u[768|m&255],h^=d^l[2],d=u[h>>>24],d+=u[256|h>>16&255],d^=u[512|h>>8&255],d+=u[768|h&255],m^=d^l[3],d=u[m>>>24],d+=u[256|m>>16&255],d^=u[512|m>>8&255],d+=u[768|m&255],h^=d^l[4],d=u[h>>>24],d+=u[256|h>>16&255],d^=u[512|h>>8&255],d+=u[768|h&255],m^=d^l[5],d=u[m>>>24],d+=u[256|m>>16&255],d^=u[512|m>>8&255],d+=u[768|m&255],h^=d^l[6],d=u[h>>>24],d+=u[256|h>>16&255],d^=u[512|h>>8&255],d+=u[768|h&255],m^=d^l[7],d=u[m>>>24],d+=u[256|m>>16&255],d^=u[512|m>>8&255],d+=u[768|m&255],h^=d^l[8],d=u[h>>>24],d+=u[256|h>>16&255],d^=u[512|h>>8&255],d+=u[768|h&255],m^=d^l[9],d=u[m>>>24],d+=u[256|m>>16&255],d^=u[512|m>>8&255],d+=u[768|m&255],h^=d^l[10],d=u[h>>>24],d+=u[256|h>>16&255],d^=u[512|h>>8&255],d+=u[768|h&255],m^=d^l[11],d=u[m>>>24],d+=u[256|m>>16&255],d^=u[512|m>>8&255],d+=u[768|m&255],h^=d^l[12],d=u[h>>>24],d+=u[256|h>>16&255],d^=u[512|h>>8&255],d+=u[768|h&255],m^=d^l[13],d=u[m>>>24],d+=u[256|m>>16&255],d^=u[512|m>>8&255],d+=u[768|m&255],h^=d^l[14],d=u[h>>>24],d+=u[256|h>>16&255],d^=u[512|h>>8&255],d+=u[768|h&255],m^=d^l[15],d=u[m>>>24],d+=u[256|m>>16&255],d^=u[512|m>>8&255],d+=u[768|m&255],h^=d^l[16],x[p]=m^l[xe+1],x[p+1]=h,x}function q(x,p){for(var l=0,u=0;l<4;++l)u=u<<8|x[p]&255,p=(p+1)%x.length;return{key:u,offp:p}}function ne(x,p,l){for(var u=0,d=[0,0],h=p.length,m=l.length,Z,k=0;k<h;k++)Z=q(x,u),u=Z.offp,p[k]=p[k]^Z.key;for(k=0;k<h;k+=2)d=B(d,0,p,l),p[k]=d[0],p[k+1]=d[1];for(k=0;k<m;k+=2)d=B(d,0,p,l),l[k]=d[0],l[k+1]=d[1]}function Oe(x,p,l,u){for(var d=0,h=[0,0],m=l.length,Z=u.length,k,A=0;A<m;A++)k=q(p,d),d=k.offp,l[A]=l[A]^k.key;for(d=0,A=0;A<m;A+=2)k=q(x,d),d=k.offp,h[0]^=k.key,k=q(x,d),d=k.offp,h[1]^=k.key,h=B(h,0,l,u),l[A]=h[0],l[A+1]=h[1];for(A=0;A<Z;A+=2)k=q(x,d),d=k.offp,h[0]^=k.key,k=q(x,d),d=k.offp,h[1]^=k.key,h=B(h,0,l,u),u[A]=h[0],u[A+1]=h[1]}function Ie(x,p,l,u,d){var h=ge.slice(),m=h.length,Z;if(l<4||l>31)if(Z=Error("Illegal number of rounds (4-31): "+l),u){o(u.bind(this,Z));return}else throw Z;if(p.length!==L)if(Z=Error("Illegal salt length: "+p.length+" != "+L),u){o(u.bind(this,Z));return}else throw Z;l=1<<l>>>0;var k,A,S=0,N;Int32Array?(k=new Int32Array(de),A=new Int32Array(_e)):(k=de.slice(),A=_e.slice()),Oe(p,x,k,A);function H(){if(d&&d(S/l),S<l)for(var je=Date.now();S<l&&(S=S+1,ne(x,k,A),ne(p,k,A),!(Date.now()-je>he)););else{for(S=0;S<64;S++)for(N=0;N<m>>1;N++)B(h,N<<1,k,A);var R=[];for(S=0;S<m;S++)R.push((h[S]>>24&255)>>>0),R.push((h[S]>>16&255)>>>0),R.push((h[S]>>8&255)>>>0),R.push((h[S]&255)>>>0);if(u){u(null,R);return}else return R}u&&o(H)}if(typeof u<"u")H();else for(var We;;)if(typeof(We=H())<"u")return We||[]}function me(x,p,l,u){var d;if(typeof x!="string"||typeof p!="string")if(d=Error("Invalid string / salt: Not a string"),l){o(l.bind(this,d));return}else throw d;var h,m;if(p.charAt(0)!=="$"||p.charAt(1)!=="2")if(d=Error("Invalid salt version: "+p.substring(0,2)),l){o(l.bind(this,d));return}else throw d;if(p.charAt(2)==="$")h="\0",m=3;else{if(h=p.charAt(2),h!=="a"&&h!=="b"&&h!=="y"||p.charAt(3)!=="$")if(d=Error("Invalid salt revision: "+p.substring(2,4)),l){o(l.bind(this,d));return}else throw d;m=4}if(p.charAt(m+2)>"$")if(d=Error("Missing salt rounds"),l){o(l.bind(this,d));return}else throw d;var Z=parseInt(p.substring(m,m+1),10)*10,k=parseInt(p.substring(m+1,m+2),10),A=Z+k,S=p.substring(m+3,m+25);x+=h>="a"?"\0":"";var N=c(x),H=D(S,L);function We(je){var R=[];return R.push("$2"),h>="a"&&R.push(h),R.push("$"),A<10&&R.push("0"),R.push(A.toString()),R.push("$"),R.push(C(H,H.length)),R.push(C(je,ge.length*4-1)),R.join("")}if(typeof l>"u")return We(Ie(N,H,A));Ie(N,H,A,function(je,R){je?l(je,null):l(null,We(R))},u)}return e.encodeBase64=C,e.decodeBase64=D,e})})(Ut);var Pa=Ut.exports;const xt=Na(Pa);function Ua(n){return async(e,t)=>{const a=await n.selectFrom("passwords").where("passwords.tenant_id","=",e).where("passwords.user_id","=",t.user_id).selectAll().executeTakeFirst();return a?xt.compareSync(t.password,a.password)?{valid:!0,message:""}:{valid:!1,message:"Incorrect password"}:{valid:!1,message:"No password exists"}}}function Ma(n){return async(e,t)=>{const a=xt.hashSync(t.password,10);await n.insertInto("passwords").values({tenant_id:e,user_id:t.user_id,password:a,created_at:new Date().toISOString(),updated_at:new Date().toISOString()}).execute()}}function La(n){return async(e,t)=>{const a=xt.hashSync(t.password,10);return(await n.updateTable("passwords").set({password:a,updated_at:new Date().toISOString()}).where("tenant_id","=",e).where("user_id","=",t.user_id).execute()).length===1}}function qa(n){return{create:Ma(n),update:La(n),validate:Ua(n)}}function Ba(n){return async(e,t)=>{const a=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",">",a).selectAll().execute()).map(i=>{const{tenant_id:o,...c}=i;return c})}}function za(n){return async(e,t)=>{await n.insertInto("codes").values({...t,tenant_id:e}).execute()}}function Va(n){return{create:za(n),list:Ba(n)}}function Ka(n){return async e=>{const t=new Date().toISOString(),a=await n.selectFrom("universal_login_sessions").where("universal_login_sessions.expires_at",">",t).where("universal_login_sessions.id","=",e).selectAll().executeTakeFirst();if(!a)return null;const{response_type:r,response_mode:i,redirect_uri:o,audience:c,state:f,nonce:_,scope:y,code_challenge_method:C,code_challenge:D,username:te,vendor_id:L,...Q}=a;return{...Q,authParams:{client_id:Q.client_id,vendor_id:L,response_type:r,response_mode:i,redirect_uri:o,audience:c,state:f,nonce:_,scope:y,code_challenge_method:C,code_challenge:D,username:te}}}}function Wa(n){return async(e,t)=>{const{authParams:a,...r}=t,i={created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("universal_login_sessions").values({...a,...r,...i,tenant_id:e}).execute(),{...t,...i}}}function Qa(n){return async(e,t,a)=>{const{authParams:r,...i}=a;return(await n.updateTable("universal_login_sessions").set({...r,...i}).where("id","=",t).where("tenant_id","=",e).execute()).length===1}}function Ha(n){return{create:Wa(n),get:Ka(n),update:Qa(n)}}function Ga(n){return async(e,t)=>{const a={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({...a,tenant_id:e}).execute(),a}}function Ja(n){return async e=>({applications:await n.selectFrom("applications").where("applications.tenant_id","=",e).selectAll().execute()})}function Ya(n){return async(e,t)=>{const a=await n.selectFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",t).selectAll().executeTakeFirst();return a?(a.disable_sign_ups=!!a.disable_sign_ups,$(a)):null}}function Xa(n){return async(e,t)=>(await n.deleteFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",t).executeTakeFirst()).numDeletedRows>0}function er(n){return async(e,t,a)=>{const r={...a,updated_at:new Date().toISOString()};return await n.updateTable("connections").set(r).where("connections.id","=",t).where("connections.tenant_id","=",e).execute(),!0}}function tr(n){return{create:Ga(n),list:Ja(n),get:Ya(n),remove:Xa(n),update:er(n)}}function nr(n){return async(e,t)=>{const a={id:Ke(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("connections").values({...a,tenant_id:e}).execute(),a}}function ar(n){return async(e,t)=>{let a=n.selectFrom("connections").where("connections.tenant_id","=",e);t.q&&(a=Te(n,a,t.q,["user_id","ip"]));const i=await a.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await a.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{connections:i.map($),start:t.page*t.per_page,limit:t.per_page,length:pe(o)}}}function rr(n){return async(e,t)=>(await n.deleteFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",t).executeTakeFirst()).numDeletedRows>0}function sr(n){return async(e,t)=>{const a=await n.selectFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",t).selectAll().executeTakeFirst();return a?$(a):null}}function ir(n){return async(e,t,a)=>{const r={...a,updated_at:new Date().toISOString()};return await n.updateTable("connections").set(r).where("connections.id","=",t).where("connections.tenant_id","=",e).execute(),!0}}function or(n){return{create:nr(n),get:sr(n),list:ar(n),remove:rr(n),update:ir(n)}}function ht(n){return n!=null&&n.length?n.split(",").map(e=>e.trim()):[]}function cr(n){return{get:async e=>{const t=await n.selectFrom("applications").selectAll().where("id","=",e).executeTakeFirst();if(!t)throw new z(404,{message:"Client not found"});const a=await n.selectFrom("tenants").selectAll().where("id","=",t.tenant_id).executeTakeFirst();if(!a)throw new z(404,{message:"Tenant not found"});const r=await n.selectFrom("connections").where("tenant_id","=",t.tenant_id).selectAll().execute(),i=await n.selectFrom("domains").where("tenant_id","=",t.tenant_id).selectAll().execute();return{id:t.id,name:t.name,connections:r.map(c=>lt.parse($(c))),domains:i,tenant_id:a.id,allowed_callback_urls:ht(t.allowed_callback_urls),allowed_logout_urls:ht(t.allowed_logout_urls),allowed_web_origins:ht(t.allowed_web_origins),email_validation:t.email_validation,client_secret:t.client_secret,tenant:$(a),disable_sign_ups:!!t.disable_sign_ups}}}}function dr(n){return async()=>await n.selectFrom("keys").where("revoked_at","is",null).selectAll().execute()}function ur(n){return async e=>{await n.insertInto("keys").values(e).execute()}}function lr(n){return async(e,t)=>!!(await n.updateTable("keys").set({revoked_at:t.toISOString()}).where("kid","=",e).execute()).length}function fr(n){return{create:ur(n),list:dr(n),revoke:lr(n)}}function pr(n){return async(e,t)=>{const a={created_at:new Date().toISOString(),updated_at:new Date().toISOString(),tenant_id:e,id:Ke(),...t};return await n.insertInto("domains").values(a).execute(),a}}function xr(n){return async(e,t)=>{let a=n.selectFrom("domains").where("domains.tenant_id","=",e);t.q&&(a=Te(n,a,t.q,["user_id","ip"]));const i=await a.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await a.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{domains:i,start:t.page*t.per_page,limit:t.per_page,length:pe(o)}}}function hr(n){return{create:pr(n),list:xr(n)}}function _r(n){return async e=>{const[t]=await n.selectFrom("branding").where("branding.tenant_id","=",e).selectAll().execute();if(!t)return null;const{tenant_id:a,colors_primary:r,colors_page_background_type:i,colors_page_background_start:o,colors_page_background_end:c,colors_page_background_angle_dev:f,font_url:_,...y}=t;return $({...y,colors:{primary:r,page_background:{type:i,start:o,end:c,angle_deg:f}},font:_?{url:_}:void 0})}}function gr(n){return async(e,t)=>{var o,c,f,_,y,C,D,te,L,Q,xe,he,de,_e,ge,B,q,ne;const{colors:a,font:r,...i}=t;try{await n.insertInto("branding").values({...i,colors_primary:a==null?void 0:a.primary,colors_page_background_type:(c=(o=t.colors)==null?void 0:o.page_background)==null?void 0:c.type,colors_page_background_start:(_=(f=t.colors)==null?void 0:f.page_background)==null?void 0:_.start,colors_page_background_end:(C=(y=t.colors)==null?void 0:y.page_background)==null?void 0:C.end,colors_page_background_angle_dev:(te=(D=t.colors)==null?void 0:D.page_background)==null?void 0:te.angle_deg,font_url:(L=t.font)==null?void 0:L.url,tenant_id:e}).execute()}catch{await n.updateTable("branding").set({...i,colors_primary:a==null?void 0:a.primary,colors_page_background_type:(xe=(Q=t.colors)==null?void 0:Q.page_background)==null?void 0:xe.type,colors_page_background_start:(de=(he=t.colors)==null?void 0:he.page_background)==null?void 0:de.start,colors_page_background_end:(ge=(_e=t.colors)==null?void 0:_e.page_background)==null?void 0:ge.end,colors_page_background_angle_dev:(q=(B=t.colors)==null?void 0:B.page_background)==null?void 0:q.angle_deg,font_url:(ne=t.font)==null?void 0:ne.url}).where("tenant_id","=",e).execute()}}}function mr(n){return{get:_r(n),set:gr(n)}}function yr(n){return async(e,t)=>{const a=await n.selectFrom("authentication_codes").where("tenant_id","=",e).where("code","=",t).selectAll().executeTakeFirst();if(!a)throw new z(403,{message:"Code not found or expired"});const{state:r,nonce:i,scope:o,client_id:c,response_type:f,response_mode:_,...y}=a;return{...y,authParams:{state:r,nonce:i,scope:o,client_id:c,response_type:f,response_mode:_}}}}function br(n){return async(e,t)=>{const{authParams:a,...r}=t;await n.insertInto("authentication_codes").values({...r,...a,tenant_id:e}).execute()}}function vr(n){return{create:br(n),get:yr(n)}}function wr(n){return async(e,t)=>{let a=n.selectFrom("hooks").where("hooks.tenant_id","=",e);t.q&&(a=Te(n,a,t.q,["url"]));const i=await a.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await a.select(f=>f.fn.countAll().as("count")).executeTakeFirstOrThrow();return{hooks:i.map(f=>{const{tenant_id:_,enabled:y,...C}=f;return $({...C,enabled:!!y})}),start:t.page*t.per_page,limit:t.per_page,length:pe(o)}}}function kr(n){return async(e,t)=>{const a=await n.selectFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",t).selectAll().executeTakeFirst();return a?(a.enabled=!!a.enabled,$(a)):null}}function Tr(n){return async(e,t)=>(await n.deleteFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",t).executeTakeFirst()).numDeletedRows>0}function Or(n){return async(e,t)=>{const a={hook_id:Ke(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("hooks").values({...a,tenant_id:e}).execute(),a}}function Ir(n){return async(e,t,a)=>{const r={...a,updated_at:new Date().toISOString()};return await n.updateTable("hooks").set(r).where("hooks.hook_id","=",t).where("hooks.tenant_id","=",e).execute(),!0}}function jr(n){return{create:Or(n),get:kr(n),list:wr(n),update:Ir(n),remove:Tr(n)}}function Zr(n){return{applications:tr(n),authenticationCodes:vr(n),branding:mr(n),clients:cr(n),keys:fr(n),users:ia(n),sessions:Ta(n),tenants:pa(n),tickets:Za(n),universalLoginSessions:Ha(n),OTP:Sa(n),logs:ma(n),passwords:qa(n),codes:Va(n),connections:or(n),domains:hr(n),hooks:jr(n)}}return Zr}();
|
|
1
|
+
var kyselyAdapter=function(){"use strict";var or=Object.defineProperty;var cr=(C,P,b)=>P in C?or(C,P,{enumerable:!0,configurable:!0,writable:!0,value:b}):C[P]=b;var et=(C,P,b)=>cr(C,typeof P!="symbol"?P+"":P,b);var C=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});et(this,"res");et(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 P(n){return async(e,t)=>{const{identities:s,...r}=t,a={...r,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 C(409,{message:"User already exists"}):(console.log(o.message),new C(500,{message:`${o.code}, ${o.message}`}))}return{...a,email:a.email||"",email_verified:a.email_verified===1,is_social:a.is_social===1}}}function b(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(b):e[t]=b(e[t]));return e}function bt(n,e){var t={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(n);r<s.length;r++)e.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(n,s[r])&&(t[s[r]]=n[s[r]]);return t}function Tt(n,e){var t;return((t=n==null?void 0:n._def)===null||t===void 0?void 0:t.typeName)===e}function ie(n,e){const t=n.ZodType.prototype[e];n.ZodType.prototype[e]=function(...s){const r=t.apply(this,s);return r._def.openapi=this._def.openapi,r}}function Ot(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(r,a){var o,c,d,u,h,k;const S=typeof r=="string"?a:r,W=S??{},{param:Q}=W,H=bt(W,["param"]),Te=Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o._internal),typeof r=="string"?{refId:r}:void 0),Oe=Object.assign(Object.assign(Object.assign({},(c=this._def.openapi)===null||c===void 0?void 0:c.metadata),H),!((u=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||u===void 0)&&u.param||Q?{param:Object.assign(Object.assign({},(k=(h=this._def.openapi)===null||h===void 0?void 0:h.metadata)===null||k===void 0?void 0:k.param),Q)}:void 0),Se=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(Te).length>0?{_internal:Te}:void 0),Object.keys(Oe).length>0?{metadata:Oe}:void 0)}));if(Tt(this,"ZodObject")){const Re=this.extend;Se.extend=function(...De){var ne,se,re,Fe,Ye,Ge;const Xe=Re.apply(this,De);return Xe._def.openapi={_internal:{extendedFrom:!((se=(ne=this._def.openapi)===null||ne===void 0?void 0:ne._internal)===null||se===void 0)&&se.refId?{refId:(Fe=(re=this._def.openapi)===null||re===void 0?void 0:re._internal)===null||Fe===void 0?void 0:Fe.refId,schema:this}:(Ye=this._def.openapi)===null||Ye===void 0?void 0:Ye._internal.extendedFrom},metadata:(Ge=Xe._def.openapi)===null||Ge===void 0?void 0:Ge.metadata},Xe}}return Se},ie(n,"optional"),ie(n,"nullable"),ie(n,"default"),ie(n,"transform"),ie(n,"refine");const e=n.ZodObject.prototype.deepPartial;n.ZodObject.prototype.deepPartial=function(){const r=this._def.shape(),a=e.apply(this),o=a._def.shape();return Object.entries(o).forEach(([c,d])=>{var u,h;d._def.openapi=(h=(u=r[c])===null||u===void 0?void 0:u._def)===null||h===void 0?void 0:h.openapi}),a._def.openapi=void 0,a};const t=n.ZodObject.prototype.pick;n.ZodObject.prototype.pick=function(...r){const a=t.apply(this,r);return a._def.openapi=void 0,a};const s=n.ZodObject.prototype.omit;n.ZodObject.prototype.omit=function(...r){const a=s.apply(this,r);return a._def.openapi=void 0,a}}new Set(".\\+*[^]$()");var w;(function(n){n.assertEqual=r=>r;function e(r){}n.assertIs=e;function t(r){throw new Error}n.assertNever=t,n.arrayToEnum=r=>{const a={};for(const o of r)a[o]=o;return a},n.getValidEnumValues=r=>{const a=n.objectKeys(r).filter(c=>typeof r[r[c]]!="number"),o={};for(const c of a)o[c]=r[c];return n.objectValues(o)},n.objectValues=r=>n.objectKeys(r).map(function(a){return r[a]}),n.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const o in r)Object.prototype.hasOwnProperty.call(r,o)&&a.push(o);return a},n.find=(r,a)=>{for(const o of r)if(a(o))return o},n.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function s(r,a=" | "){return r.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}n.joinValues=s,n.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(w||(w={}));var Me;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Me||(Me={}));const _=w.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),D=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}},l=w.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"]),St=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class Z extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};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},s={_errors:[]},r=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(r);else if(o.code==="invalid_return_type")r(o.returnTypeError);else if(o.code==="invalid_arguments")r(o.argumentsError);else if(o.path.length===0)s._errors.push(t(o));else{let c=s,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 r(this),s}static assert(e){if(!(e instanceof Z))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,w.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):s.push(e(r));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}Z.create=n=>new Z(n);const J=(n,e)=>{let t;switch(n.code){case l.invalid_type:n.received===_.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case l.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,w.jsonStringifyReplacer)}`;break;case l.unrecognized_keys:t=`Unrecognized key(s) in object: ${w.joinValues(n.keys,", ")}`;break;case l.invalid_union:t="Invalid input";break;case l.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${w.joinValues(n.options)}`;break;case l.invalid_enum_value:t=`Invalid enum value. Expected ${w.joinValues(n.options)}, received '${n.received}'`;break;case l.invalid_arguments:t="Invalid function arguments";break;case l.invalid_return_type:t="Invalid function return type";break;case l.invalid_date:t="Invalid date";break;case l.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}"`:w.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case l.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 l.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 l.custom:t="Invalid input";break;case l.invalid_intersection_types:t="Intersection results could not be merged";break;case l.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case l.not_finite:t="Number must be finite";break;default:t=e.defaultError,w.assertNever(n)}return{message:t}};let tt=J;function Zt(n){tt=n}function Ze(){return tt}const je=n=>{const{data:e,path:t,errorMaps:s,issueData:r}=n,a=[...t,...r.path||[]],o={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let c="";const d=s.filter(u=>!!u).slice().reverse();for(const u of d)c=u(o,{data:e,defaultError:c}).message;return{...r,path:a,message:c}},jt=[];function p(n,e){const t=Ze(),s=je({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===J?void 0:J].filter(r=>!!r)});n.common.issues.push(s)}class T{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const r of t){if(r.status==="aborted")return f;r.status==="dirty"&&e.dirty(),s.push(r.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const r of t){const a=await r.key,o=await r.value;s.push({key:a,value:o})}return T.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const r of t){const{key:a,value:o}=r;if(a.status==="aborted"||o.status==="aborted")return f;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||r.alwaysSet)&&(s[a.value]=o.value)}return{status:e.value,value:s}}}const f=Object.freeze({status:"aborted"}),Ie=n=>({status:"dirty",value:n}),O=n=>({status:"valid",value:n}),Le=n=>n.status==="aborted",Ue=n=>n.status==="dirty",ae=n=>n.status==="valid",oe=n=>typeof Promise<"u"&&n instanceof Promise;function Ae(n,e,t,s){if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function nt(n,e,t,s,r){if(typeof e=="function"?n!==e||!r:!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 g;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(g||(g={}));var ce,de;class N{constructor(e,t,s,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=r}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 st=(n,e)=>{if(ae(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 Z(n.common.issues);return this._error=t,this._error}}};function y(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:r}=n;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{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??s)!==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:r}}class v{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 D(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:D(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new T,ctx:{common:e.parent.common,data:e.data,parsedType:D(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(oe(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 s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const r={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:D(e)},a=this._parseSync({data:e,path:r.path,parent:r});return st(r,a)}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={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:D(e)},r=this._parse({data:e,path:s.path,parent:s}),a=await(oe(r)?r:Promise.resolve(r));return st(s,a)}refine(e,t){const s=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,a)=>{const o=e(r),c=()=>a.addIssue({code:l.custom,...s(r)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((s,r)=>e(s)?!0:(r.addIssue(typeof t=="function"?t(s,r):t),!1))}_refinement(e){return new A({schema:this,typeName:m.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return $.create(this,this._def)}nullable(){return z.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return I.create(this,this._def)}promise(){return ee.create(this,this._def)}or(e){return he.create([this,e],this._def)}and(e){return _e.create(this,e,this._def)}transform(e){return new A({...y(this._def),schema:this,typeName:m.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ve({...y(this._def),innerType:this,defaultValue:t,typeName:m.ZodDefault})}brand(){return new Ve({typeName:m.ZodBranded,type:this,...y(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new we({...y(this._def),innerType:this,catchValue:t,typeName:m.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ke.create(this,e)}readonly(){return xe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const It=/^c[^\s-]{8,}$/i,At=/^[0-9a-z]+$/,Ct=/^[0-9A-HJKMNP-TV-Z]{26}$/,Nt=/^[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,Et=/^[a-z0-9_-]{21}$/i,$t=/^[-+]?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)?)??$/,Pt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Rt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ze;const Dt=/^(?:(?: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])$/,Ft=/^(([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})))$/,Mt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,rt="((\\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])))",Lt=new RegExp(`^${rt}$`);function it(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 Ut(n){return new RegExp(`^${it(n)}$`)}function at(n){let e=`${rt}T${it(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 zt(n,e){return!!((e==="v4"||!e)&&Dt.test(n)||(e==="v6"||!e)&&Ft.test(n))}class j extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){const r=this._getOrReturnCtx(e);return p(r,{code:l.invalid_type,expected:_.string,received:r.parsedType}),f}const t=new T;let s;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:l.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="max")e.data.length>r.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:l.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="length"){const a=e.data.length>r.value,o=e.data.length<r.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?p(s,{code:l.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):o&&p(s,{code:l.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind==="email")Pt.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"email",code:l.invalid_string,message:r.message}),t.dirty());else if(r.kind==="emoji")ze||(ze=new RegExp(Rt,"u")),ze.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"emoji",code:l.invalid_string,message:r.message}),t.dirty());else if(r.kind==="uuid")Nt.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"uuid",code:l.invalid_string,message:r.message}),t.dirty());else if(r.kind==="nanoid")Et.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"nanoid",code:l.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid")It.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid",code:l.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid2")At.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"cuid2",code:l.invalid_string,message:r.message}),t.dirty());else if(r.kind==="ulid")Ct.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"ulid",code:l.invalid_string,message:r.message}),t.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),p(s,{validation:"url",code:l.invalid_string,message:r.message}),t.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"regex",code:l.invalid_string,message:r.message}),t.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(s=this._getOrReturnCtx(e,s),p(s,{code:l.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:l.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(s=this._getOrReturnCtx(e,s),p(s,{code:l.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind==="datetime"?at(r).test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:l.invalid_string,validation:"datetime",message:r.message}),t.dirty()):r.kind==="date"?Lt.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:l.invalid_string,validation:"date",message:r.message}),t.dirty()):r.kind==="time"?Ut(r).test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{code:l.invalid_string,validation:"time",message:r.message}),t.dirty()):r.kind==="duration"?$t.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"duration",code:l.invalid_string,message:r.message}),t.dirty()):r.kind==="ip"?zt(e.data,r.version)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"ip",code:l.invalid_string,message:r.message}),t.dirty()):r.kind==="base64"?Mt.test(e.data)||(s=this._getOrReturnCtx(e,s),p(s,{validation:"base64",code:l.invalid_string,message:r.message}),t.dirty()):w.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement(r=>e.test(r),{validation:t,code:l.invalid_string,...g.errToObj(s)})}_addCheck(e){return new j({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...g.errToObj(e)})}url(e){return this._addCheck({kind:"url",...g.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...g.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...g.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...g.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...g.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...g.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...g.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...g.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...g.errToObj(e)})}datetime(e){var t,s;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==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:(s=e==null?void 0:e.local)!==null&&s!==void 0?s:!1,...g.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,...g.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...g.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...g.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...g.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...g.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...g.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...g.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...g.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...g.errToObj(t)})}nonempty(e){return this.min(1,g.errToObj(e))}trim(){return new j({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new j({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new j({...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}}j.create=n=>{var e;return new j({checks:[],typeName:m.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...y(n)})};function qt(n,e){const t=(n.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,r=t>s?t:s,a=parseInt(n.toFixed(r).replace(".","")),o=parseInt(e.toFixed(r).replace(".",""));return a%o/Math.pow(10,r)}class F extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==_.number){const r=this._getOrReturnCtx(e);return p(r,{code:l.invalid_type,expected:_.number,received:r.parsedType}),f}let t;const s=new T;for(const r of this._def.checks)r.kind==="int"?w.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),p(t,{code:l.invalid_type,expected:"integer",received:"float",message:r.message}),s.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:l.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),s.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:l.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),s.dirty()):r.kind==="multipleOf"?qt(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),p(t,{code:l.not_multiple_of,multipleOf:r.value,message:r.message}),s.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),p(t,{code:l.not_finite,message:r.message}),s.dirty()):w.assertNever(r);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,g.toString(t))}gt(e,t){return this.setLimit("min",e,!1,g.toString(t))}lte(e,t){return this.setLimit("max",e,!0,g.toString(t))}lt(e,t){return this.setLimit("max",e,!1,g.toString(t))}setLimit(e,t,s,r){return new F({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:g.toString(r)}]})}_addCheck(e){return new F({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:g.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:g.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:g.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:g.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"&&w.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}F.create=n=>new F({checks:[],typeName:m.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...y(n)});class M extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==_.bigint){const r=this._getOrReturnCtx(e);return p(r,{code:l.invalid_type,expected:_.bigint,received:r.parsedType}),f}let t;const s=new T;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:l.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),s.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),p(t,{code:l.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),s.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),p(t,{code:l.not_multiple_of,multipleOf:r.value,message:r.message}),s.dirty()):w.assertNever(r);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,g.toString(t))}gt(e,t){return this.setLimit("min",e,!1,g.toString(t))}lte(e,t){return this.setLimit("max",e,!0,g.toString(t))}lt(e,t){return this.setLimit("max",e,!1,g.toString(t))}setLimit(e,t,s,r){return new M({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:g.toString(r)}]})}_addCheck(e){return new M({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:g.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}}M.create=n=>{var e;return new M({checks:[],typeName:m.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...y(n)})};class ue extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){const t=this._getOrReturnCtx(e);return p(t,{code:l.invalid_type,expected:_.boolean,received:t.parsedType}),f}return O(e.data)}}ue.create=n=>new ue({typeName:m.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...y(n)});class q extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){const r=this._getOrReturnCtx(e);return p(r,{code:l.invalid_type,expected:_.date,received:r.parsedType}),f}if(isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return p(r,{code:l.invalid_date}),f}const t=new T;let s;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:l.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(s=this._getOrReturnCtx(e,s),p(s,{code:l.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):w.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:g.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:g.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}}q.create=n=>new q({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:m.ZodDate,...y(n)});class Ce extends v{_parse(e){if(this._getType(e)!==_.symbol){const t=this._getOrReturnCtx(e);return p(t,{code:l.invalid_type,expected:_.symbol,received:t.parsedType}),f}return O(e.data)}}Ce.create=n=>new Ce({typeName:m.ZodSymbol,...y(n)});class le extends v{_parse(e){if(this._getType(e)!==_.undefined){const t=this._getOrReturnCtx(e);return p(t,{code:l.invalid_type,expected:_.undefined,received:t.parsedType}),f}return O(e.data)}}le.create=n=>new le({typeName:m.ZodUndefined,...y(n)});class pe extends v{_parse(e){if(this._getType(e)!==_.null){const t=this._getOrReturnCtx(e);return p(t,{code:l.invalid_type,expected:_.null,received:t.parsedType}),f}return O(e.data)}}pe.create=n=>new pe({typeName:m.ZodNull,...y(n)});class Y extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return O(e.data)}}Y.create=n=>new Y({typeName:m.ZodAny,...y(n)});class V extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return O(e.data)}}V.create=n=>new V({typeName:m.ZodUnknown,...y(n)});class R extends v{_parse(e){const t=this._getOrReturnCtx(e);return p(t,{code:l.invalid_type,expected:_.never,received:t.parsedType}),f}}R.create=n=>new R({typeName:m.ZodNever,...y(n)});class Ne extends v{_parse(e){if(this._getType(e)!==_.undefined){const t=this._getOrReturnCtx(e);return p(t,{code:l.invalid_type,expected:_.void,received:t.parsedType}),f}return O(e.data)}}Ne.create=n=>new Ne({typeName:m.ZodVoid,...y(n)});class I extends v{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),r=this._def;if(t.parsedType!==_.array)return p(t,{code:l.invalid_type,expected:_.array,received:t.parsedType}),f;if(r.exactLength!==null){const o=t.data.length>r.exactLength.value,c=t.data.length<r.exactLength.value;(o||c)&&(p(t,{code:o?l.too_big:l.too_small,minimum:c?r.exactLength.value:void 0,maximum:o?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),s.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(p(t,{code:l.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),s.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(p(t,{code:l.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>r.type._parseAsync(new N(t,o,t.path,c)))).then(o=>T.mergeArray(s,o));const a=[...t.data].map((o,c)=>r.type._parseSync(new N(t,o,t.path,c)));return T.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new I({...this._def,minLength:{value:e,message:g.toString(t)}})}max(e,t){return new I({...this._def,maxLength:{value:e,message:g.toString(t)}})}length(e,t){return new I({...this._def,exactLength:{value:e,message:g.toString(t)}})}nonempty(e){return this.min(1,e)}}I.create=(n,e)=>new I({type:n,minLength:null,maxLength:null,exactLength:null,typeName:m.ZodArray,...y(e)});function G(n){if(n instanceof x){const e={};for(const t in n.shape){const s=n.shape[t];e[t]=$.create(G(s))}return new x({...n._def,shape:()=>e})}else return n instanceof I?new I({...n._def,type:G(n.element)}):n instanceof $?$.create(G(n.unwrap())):n instanceof z?z.create(G(n.unwrap())):n instanceof E?E.create(n.items.map(e=>G(e))):n}class x extends v{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=w.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==_.object){const d=this._getOrReturnCtx(e);return p(d,{code:l.invalid_type,expected:_.object,received:d.parsedType}),f}const{status:t,ctx:s}=this._processInputParams(e),{shape:r,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof R&&this._def.unknownKeys==="strip"))for(const d in s.data)a.includes(d)||o.push(d);const c=[];for(const d of a){const u=r[d],h=s.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new N(s,h,s.path,d)),alwaysSet:d in s.data})}if(this._def.catchall instanceof R){const d=this._def.unknownKeys;if(d==="passthrough")for(const u of o)c.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(d==="strict")o.length>0&&(p(s,{code:l.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 h=s.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new N(s,h,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const d=[];for(const u of c){const h=await u.key,k=await u.value;d.push({key:h,value:k,alwaysSet:u.alwaysSet})}return d}).then(d=>T.mergeObjectSync(t,d)):T.mergeObjectSync(t,c)}get shape(){return this._def.shape()}strict(e){return g.errToObj,new x({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var r,a,o,c;const d=(o=(a=(r=this._def).errorMap)===null||a===void 0?void 0:a.call(r,t,s).message)!==null&&o!==void 0?o:s.defaultError;return t.code==="unrecognized_keys"?{message:(c=g.errToObj(e).message)!==null&&c!==void 0?c:d}:{message:d}}}:{}})}strip(){return new x({...this._def,unknownKeys:"strip"})}passthrough(){return new x({...this._def,unknownKeys:"passthrough"})}extend(e){return new x({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new x({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:m.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new x({...this._def,catchall:e})}pick(e){const t={};return w.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new x({...this._def,shape:()=>t})}omit(e){const t={};return w.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new x({...this._def,shape:()=>t})}deepPartial(){return G(this)}partial(e){const t={};return w.objectKeys(this.shape).forEach(s=>{const r=this.shape[s];e&&!e[s]?t[s]=r:t[s]=r.optional()}),new x({...this._def,shape:()=>t})}required(e){const t={};return w.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let r=this.shape[s];for(;r instanceof $;)r=r._def.innerType;t[s]=r}}),new x({...this._def,shape:()=>t})}keyof(){return ot(w.objectKeys(this.shape))}}x.create=(n,e)=>new x({shape:()=>n,unknownKeys:"strip",catchall:R.create(),typeName:m.ZodObject,...y(e)}),x.strictCreate=(n,e)=>new x({shape:()=>n,unknownKeys:"strict",catchall:R.create(),typeName:m.ZodObject,...y(e)}),x.lazycreate=(n,e)=>new x({shape:n,unknownKeys:"strip",catchall:R.create(),typeName:m.ZodObject,...y(e)});class he extends v{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function r(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 Z(c.ctx.common.issues));return p(t,{code:l.invalid_union,unionErrors:o}),f}if(t.common.async)return Promise.all(s.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(r);{let a;const o=[];for(const d of s){const u={...t,common:{...t.common,issues:[]},parent:null},h=d._parseSync({data:t.data,path:t.path,parent:u});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,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 Z(d));return p(t,{code:l.invalid_union,unionErrors:c}),f}}get options(){return this._def.options}}he.create=(n,e)=>new he({options:n,typeName:m.ZodUnion,...y(e)});const L=n=>n instanceof me?L(n.schema):n instanceof A?L(n.innerType()):n instanceof fe?[n.value]:n instanceof U?n.options:n instanceof ye?w.objectValues(n.enum):n instanceof ve?L(n._def.innerType):n instanceof le?[void 0]:n instanceof pe?[null]:n instanceof $?[void 0,...L(n.unwrap())]:n instanceof z?[null,...L(n.unwrap())]:n instanceof Ve||n instanceof xe?L(n.unwrap()):n instanceof we?L(n._def.innerType):[];class Ee extends v{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.object)return p(t,{code:l.invalid_type,expected:_.object,received:t.parsedType}),f;const s=this.discriminator,r=t.data[s],a=this.optionsMap.get(r);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}):(p(t,{code:l.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),f)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const r=new Map;for(const a of t){const o=L(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(r.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);r.set(c,a)}}return new Ee({typeName:m.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...y(s)})}}function qe(n,e){const t=D(n),s=D(e);if(n===e)return{valid:!0,data:n};if(t===_.object&&s===_.object){const r=w.objectKeys(e),a=w.objectKeys(n).filter(c=>r.indexOf(c)!==-1),o={...n,...e};for(const c of a){const d=qe(n[c],e[c]);if(!d.valid)return{valid:!1};o[c]=d.data}return{valid:!0,data:o}}else if(t===_.array&&s===_.array){if(n.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<n.length;a++){const o=n[a],c=e[a],d=qe(o,c);if(!d.valid)return{valid:!1};r.push(d.data)}return{valid:!0,data:r}}else return t===_.date&&s===_.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class _e extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=(a,o)=>{if(Le(a)||Le(o))return f;const c=qe(a.value,o.value);return c.valid?((Ue(a)||Ue(o))&&t.dirty(),{status:t.value,value:c.data}):(p(s,{code:l.invalid_intersection_types}),f)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,o])=>r(a,o)):r(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}_e.create=(n,e,t)=>new _e({left:n,right:e,typeName:m.ZodIntersection,...y(t)});class E extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==_.array)return p(s,{code:l.invalid_type,expected:_.array,received:s.parsedType}),f;if(s.data.length<this._def.items.length)return p(s,{code:l.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),f;!this._def.rest&&s.data.length>this._def.items.length&&(p(s,{code:l.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...s.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new N(s,a,s.path,o)):null}).filter(a=>!!a);return s.common.async?Promise.all(r).then(a=>T.mergeArray(t,a)):T.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new E({...this._def,rest:e})}}E.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new E({items:n,typeName:m.ZodTuple,rest:null,...y(e)})};class ge extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==_.object)return p(s,{code:l.invalid_type,expected:_.object,received:s.parsedType}),f;const r=[],a=this._def.keyType,o=this._def.valueType;for(const c in s.data)r.push({key:a._parse(new N(s,c,s.path,c)),value:o._parse(new N(s,s.data[c],s.path,c)),alwaysSet:c in s.data});return s.common.async?T.mergeObjectAsync(t,r):T.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof v?new ge({keyType:e,valueType:t,typeName:m.ZodRecord,...y(s)}):new ge({keyType:j.create(),valueType:e,typeName:m.ZodRecord,...y(t)})}}class $e extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==_.map)return p(s,{code:l.invalid_type,expected:_.map,received:s.parsedType}),f;const r=this._def.keyType,a=this._def.valueType,o=[...s.data.entries()].map(([c,d],u)=>({key:r._parse(new N(s,c,s.path,[u,"key"])),value:a._parse(new N(s,d,s.path,[u,"value"]))}));if(s.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const d of o){const u=await d.key,h=await d.value;if(u.status==="aborted"||h.status==="aborted")return f;(u.status==="dirty"||h.status==="dirty")&&t.dirty(),c.set(u.value,h.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const d of o){const u=d.key,h=d.value;if(u.status==="aborted"||h.status==="aborted")return f;(u.status==="dirty"||h.status==="dirty")&&t.dirty(),c.set(u.value,h.value)}return{status:t.value,value:c}}}}$e.create=(n,e,t)=>new $e({valueType:e,keyType:n,typeName:m.ZodMap,...y(t)});class B extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==_.set)return p(s,{code:l.invalid_type,expected:_.set,received:s.parsedType}),f;const r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(p(s,{code:l.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&s.data.size>r.maxSize.value&&(p(s,{code:l.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const a=this._def.valueType;function o(d){const u=new Set;for(const h of d){if(h.status==="aborted")return f;h.status==="dirty"&&t.dirty(),u.add(h.value)}return{status:t.value,value:u}}const c=[...s.data.values()].map((d,u)=>a._parse(new N(s,d,s.path,u)));return s.common.async?Promise.all(c).then(d=>o(d)):o(c)}min(e,t){return new B({...this._def,minSize:{value:e,message:g.toString(t)}})}max(e,t){return new B({...this._def,maxSize:{value:e,message:g.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}B.create=(n,e)=>new B({valueType:n,minSize:null,maxSize:null,typeName:m.ZodSet,...y(e)});class X extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.function)return p(t,{code:l.invalid_type,expected:_.function,received:t.parsedType}),f;function s(c,d){return je({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ze(),J].filter(u=>!!u),issueData:{code:l.invalid_arguments,argumentsError:d}})}function r(c,d){return je({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ze(),J].filter(u=>!!u),issueData:{code:l.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof ee){const c=this;return O(async function(...d){const u=new Z([]),h=await c._def.args.parseAsync(d,a).catch(S=>{throw u.addIssue(s(d,S)),u}),k=await Reflect.apply(o,this,h);return await c._def.returns._def.type.parseAsync(k,a).catch(S=>{throw u.addIssue(r(k,S)),u})})}else{const c=this;return O(function(...d){const u=c._def.args.safeParse(d,a);if(!u.success)throw new Z([s(d,u.error)]);const h=Reflect.apply(o,this,u.data),k=c._def.returns.safeParse(h,a);if(!k.success)throw new Z([r(h,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new X({...this._def,args:E.create(e).rest(V.create())})}returns(e){return new X({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new X({args:e||E.create([]).rest(V.create()),returns:t||V.create(),typeName:m.ZodFunction,...y(s)})}}class me extends v{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})}}me.create=(n,e)=>new me({getter:n,typeName:m.ZodLazy,...y(e)});class fe extends v{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return p(t,{received:t.data,code:l.invalid_literal,expected:this._def.value}),f}return{status:"valid",value:e.data}}get value(){return this._def.value}}fe.create=(n,e)=>new fe({value:n,typeName:m.ZodLiteral,...y(e)});function ot(n,e){return new U({values:n,typeName:m.ZodEnum,...y(e)})}class U extends v{constructor(){super(...arguments),ce.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return p(t,{expected:w.joinValues(s),received:t.parsedType,code:l.invalid_type}),f}if(Ae(this,ce)||nt(this,ce,new Set(this._def.values)),!Ae(this,ce).has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return p(t,{received:t.data,code:l.invalid_enum_value,options:s}),f}return O(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 U.create(e,{...this._def,...t})}exclude(e,t=this._def){return U.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}ce=new WeakMap,U.create=ot;class ye extends v{constructor(){super(...arguments),de.set(this,void 0)}_parse(e){const t=w.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==_.string&&s.parsedType!==_.number){const r=w.objectValues(t);return p(s,{expected:w.joinValues(r),received:s.parsedType,code:l.invalid_type}),f}if(Ae(this,de)||nt(this,de,new Set(w.getValidEnumValues(this._def.values))),!Ae(this,de).has(e.data)){const r=w.objectValues(t);return p(s,{received:s.data,code:l.invalid_enum_value,options:r}),f}return O(e.data)}get enum(){return this._def.values}}de=new WeakMap,ye.create=(n,e)=>new ye({values:n,typeName:m.ZodNativeEnum,...y(e)});class ee extends v{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.promise&&t.common.async===!1)return p(t,{code:l.invalid_type,expected:_.promise,received:t.parsedType}),f;const s=t.parsedType===_.promise?t.data:Promise.resolve(t.data);return O(s.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ee.create=(n,e)=>new ee({type:n,typeName:m.ZodPromise,...y(e)});class A extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===m.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:o=>{p(s,o),o.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const o=r.transform(s.data,a);if(s.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return f;const d=await this._def.schema._parseAsync({data:c,path:s.path,parent:s});return d.status==="aborted"?f:d.status==="dirty"||t.value==="dirty"?Ie(d.value):d});{if(t.value==="aborted")return f;const c=this._def.schema._parseSync({data:o,path:s.path,parent:s});return c.status==="aborted"?f:c.status==="dirty"||t.value==="dirty"?Ie(c.value):c}}if(r.type==="refinement"){const o=c=>{const d=r.refinement(c,a);if(s.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(s.common.async===!1){const c=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return c.status==="aborted"?f:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(c=>c.status==="aborted"?f:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(r.type==="transform")if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!ae(o))return o;const c=r.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:s.data,path:s.path,parent:s}).then(o=>ae(o)?Promise.resolve(r.transform(o.value,a)).then(c=>({status:t.value,value:c})):o);w.assertNever(r)}}A.create=(n,e,t)=>new A({schema:n,typeName:m.ZodEffects,effect:e,...y(t)}),A.createWithPreprocess=(n,e,t)=>new A({schema:e,effect:{type:"preprocess",transform:n},typeName:m.ZodEffects,...y(t)});class $ extends v{_parse(e){return this._getType(e)===_.undefined?O(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}$.create=(n,e)=>new $({innerType:n,typeName:m.ZodOptional,...y(e)});class z extends v{_parse(e){return this._getType(e)===_.null?O(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}z.create=(n,e)=>new z({innerType:n,typeName:m.ZodNullable,...y(e)});class ve extends v{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===_.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ve.create=(n,e)=>new ve({innerType:n,typeName:m.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...y(e)});class we extends v{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return oe(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Z(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Z(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}we.create=(n,e)=>new we({innerType:n,typeName:m.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...y(e)});class Pe extends v{_parse(e){if(this._getType(e)!==_.nan){const t=this._getOrReturnCtx(e);return p(t,{code:l.invalid_type,expected:_.nan,received:t.parsedType}),f}return{status:"valid",value:e.data}}}Pe.create=n=>new Pe({typeName:m.ZodNaN,...y(n)});const Vt=Symbol("zod_brand");class Ve extends v{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class ke extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?f:r.status==="dirty"?(t.dirty(),Ie(r.value)):this._def.out._parseAsync({data:r.value,path:s.path,parent:s})})();{const r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?f:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(e,t){return new ke({in:e,out:t,typeName:m.ZodPipeline})}}class xe extends v{_parse(e){const t=this._def.innerType._parse(e),s=r=>(ae(r)&&(r.value=Object.freeze(r.value)),r);return oe(t)?t.then(r=>s(r)):s(t)}unwrap(){return this._def.innerType}}xe.create=(n,e)=>new xe({innerType:n,typeName:m.ZodReadonly,...y(e)});function ct(n,e={},t){return n?Y.create().superRefine((s,r)=>{var a,o;if(!n(s)){const c=typeof e=="function"?e(s):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;r.addIssue({code:"custom",...u,fatal:d})}}):Y.create()}const Bt={object:x.lazycreate};var m;(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"})(m||(m={}));const Kt=(n,e={message:`Input not instance of ${n.name}`})=>ct(t=>t instanceof n,e),dt=j.create,ut=F.create,Wt=Pe.create,Qt=M.create,lt=ue.create,Ht=q.create,Jt=Ce.create,Yt=le.create,Gt=pe.create,Xt=Y.create,en=V.create,tn=R.create,nn=Ne.create,sn=I.create,rn=x.create,an=x.strictCreate,on=he.create,cn=Ee.create,dn=_e.create,un=E.create,ln=ge.create,pn=$e.create,hn=B.create,_n=X.create,gn=me.create,mn=fe.create,fn=U.create,yn=ye.create,vn=ee.create,pt=A.create,wn=$.create,kn=z.create,xn=A.createWithPreprocess,bn=ke.create;var i=Object.freeze({__proto__:null,defaultErrorMap:J,setErrorMap:Zt,getErrorMap:Ze,makeIssue:je,EMPTY_PATH:jt,addIssueToContext:p,ParseStatus:T,INVALID:f,DIRTY:Ie,OK:O,isAborted:Le,isDirty:Ue,isValid:ae,isAsync:oe,get util(){return w},get objectUtil(){return Me},ZodParsedType:_,getParsedType:D,ZodType:v,datetimeRegex:at,ZodString:j,ZodNumber:F,ZodBigInt:M,ZodBoolean:ue,ZodDate:q,ZodSymbol:Ce,ZodUndefined:le,ZodNull:pe,ZodAny:Y,ZodUnknown:V,ZodNever:R,ZodVoid:Ne,ZodArray:I,ZodObject:x,ZodUnion:he,ZodDiscriminatedUnion:Ee,ZodIntersection:_e,ZodTuple:E,ZodRecord:ge,ZodMap:$e,ZodSet:B,ZodFunction:X,ZodLazy:me,ZodLiteral:fe,ZodEnum:U,ZodNativeEnum:ye,ZodPromise:ee,ZodEffects:A,ZodTransformer:A,ZodOptional:$,ZodNullable:z,ZodDefault:ve,ZodCatch:we,ZodNaN:Pe,BRAND:Vt,ZodBranded:Ve,ZodPipeline:ke,ZodReadonly:xe,custom:ct,Schema:v,ZodSchema:v,late:Bt,get ZodFirstPartyTypeKind(){return m},coerce:{string:n=>j.create({...n,coerce:!0}),number:n=>F.create({...n,coerce:!0}),boolean:n=>ue.create({...n,coerce:!0}),bigint:n=>M.create({...n,coerce:!0}),date:n=>q.create({...n,coerce:!0})},any:Xt,array:sn,bigint:Qt,boolean:lt,date:Ht,discriminatedUnion:cn,effect:pt,enum:fn,function:_n,instanceof:Kt,intersection:dn,lazy:gn,literal:mn,map:pn,nan:Wt,nativeEnum:yn,never:tn,null:Gt,nullable:kn,number:ut,object:rn,oboolean:()=>lt().optional(),onumber:()=>ut().optional(),optional:wn,ostring:()=>dt().optional(),pipeline:bn,preprocess:xn,promise:vn,record:ln,set:hn,strictObject:an,string:dt,symbol:Jt,transformer:pt,tuple:un,undefined:Yt,union:on,unknown:en,void:nn,NEVER:f,ZodIssueCode:l,quotelessJson:St,ZodError:Z});Ot(i),i.object({start:i.number(),limit:i.number(),length:i.number()});const Be=i.object({created_at:i.string(),updated_at:i.string()}),Tn=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()),On=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:Tn.optional()}),ht=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()});ht.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(Be.shape).extend({user_id:i.string(),email:i.string(),is_social:i.boolean(),login_count:i.number(),identities:i.array(On).optional()}),ht.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 Sn=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(Sn.shape);var _t=(n=>(n.TOKEN="token",n.TOKEN_ID_TOKEN="token id_token",n.CODE="code",n))(_t||{}),gt=(n=>(n.QUERY="query",n.FRAGMENT="fragment",n.FORM_POST="form_post",n.WEB_MESSAGE="web_message",n))(gt||{}),mt=(n=>(n.S265="S256",n.plain="plain",n))(mt||{});const Ke=i.object({client_id:i.string(),vendor_id:i.string().optional(),response_type:i.nativeEnum(_t).optional(),response_mode:i.nativeEnum(gt).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(mt).optional(),code_challenge:i.string().optional(),username:i.string().optional()}),Zn=i.object({authParams:Ke,code:i.string(),user_id:i.string(),created_at:i.string(),expires_at:i.string(),used_at:i.string().optional()});i.object({...Zn.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 jn=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()}),We=i.object({id:i.string(),created_at:i.string().transform(n=>n===null?"":n),updated_at:i.string().transform(n=>n===null?"":n)}).extend(jn.shape),In=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()}),ft=i.object({id:i.string(),name:i.string(),domains:i.array(In),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()})});ft.extend({connections:i.array(We)}),ft.extend({connections:i.array(We.partial())});const An=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"])});Be.extend({...An.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({...Be.shape,hook_id:i.string()});const Cn=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(Cn)}),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 Nn=i.object({id:i.string(),email:i.string(),code:i.string(),ip:i.string().optional(),send:i.enum(["code","link"]),authParams:Ke,expires_at:i.string(),used_at:i.string().optional(),user_id:i.string().optional()});i.object({created_at:i.string(),...Nn.shape});const En=i.object({user_id:i.string(),password:i.string()});i.object({...En.shape,created_at:i.string(),updated_at:i.string()});const $n=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(),...$n.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 yt=(n=>(n.RefreshToken="refresh_token",n.AuthorizationCode="authorization_code",n.ClientCredential="client_credentials",n.Passwordless="passwordless",n.Password="password",n))(yt||{});const Qe=i.nativeEnum(yt);i.object({grant_type:Qe.refine(n=>n==="authorization_code"),code:i.string(),client_secret:i.string(),client_id:i.string()}),i.object({grant_type:Qe.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:Qe.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 Pn=i.object({id:i.string(),expires_at:i.string(),auth0Client:i.string().optional(),authParams:Ke});i.object({...Pn.shape,created_at:i.string(),updated_at:i.string()});const Rn=i.enum(["sapi","ssa","fsa","ss","ssa","fs","s","f","fp","slo","scoa","fcoa","seccft","cls","seacft","serft"]),Dn=i.object({name:i.string(),version:i.string(),env:i.object({node:i.string().optional()}).optional()});i.object({type:Rn,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:Dn.optional()});function He(n){const[e,t]=n.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${n}`);return{connection:e,id:t}}function vt(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:He(n.user_id).id,isSocial:!!n.is_social,profileData:{email:n.email,email_verified:!!n.email_verified,...e}}}function Fn(n){return async(e,t)=>{const[s,r]=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(!s)return null;const{tenant_id:a,...o}=s,c={...o,email:s.email||"",email_verified:s.email_verified===1,is_social:s.is_social===1,identities:[{connection:s.connection,provider:s.provider,user_id:He(s.user_id).id,isSocial:!!s.is_social},...r.map(vt)]};return b(c)}}function te(n,e,t,s){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(h=>h.or(s.map(k=>h(u(k),"like",`%${o}%`))))}}),e}function K(n){return typeof n=="string"?parseInt(n,10):typeof n=="bigint"?Number(n):n}function Mn(n){return async(e,t)=>{let s=n.selectFrom("users").where("users.tenant_id","=",e);if(t.q&&(s=te(n,s,t.q,["email","name"])),t.sort&&t.sort.sort_by){const{ref:h}=n.dynamic;s=s.orderBy(h(t.sort.sort_by),t.sort.sort_order)}const a=await s.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),o=a.map(h=>h.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(h=>{const k=c.filter(S=>S.linked_to===h.user_id);return b({...h,email_verified:h.email_verified===1,is_social:h.is_social===1,identities:[{connection:h.connection,provider:h.provider,user_id:He(h.user_id).id,isSocial:!!h.is_social},...k.map(vt)]})}),{count:u}=await s.select(h=>h.fn.countAll().as("count")).executeTakeFirstOrThrow();return{users:d,start:t.page*t.per_page,limit:t.per_page,length:K(u)}}}function Ln(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 Un(n){if(n.email_verified!==void 0)return n.email_verified?1:0}function zn(n){return async(e,t,s)=>{const r={...s,email_verified:Un(s),updated_at:new Date().toISOString()};return(await n.updateTable("users").set(r).where("users.tenant_id","=",e).where("users.user_id","=",t).execute()).length===1}}function qn(n){return async(e,t,s,r)=>{const a={linked_to:null};return(await n.updateTable("users").set(a).where("users.tenant_id","=",e).where("users.user_id","=",`${s}|${r}`).where("users.linked_to","=",`${t}`).execute()).length===1}}function Vn(n){return{create:P(n),remove:Ln(n),get:Fn(n),list:Mn(n),update:zn(n),unlink:qn(n)}}const Bn="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let be=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n));for(;n--;)e+=Bn[t[n]&63];return e};function Kn(n){return async e=>{const t={id:e.id||be(),created_at:new Date().toISOString(),updated_at:new Date().toISOString(),...e};return await n.insertInto("tenants").values(t).execute(),t}}function Wn(n){return async e=>{const t=await n.selectFrom("tenants").where("tenants.id","=",e).selectAll().executeTakeFirst();return t?b(t):null}}function Qn(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 r=await t.offset(e.page*e.per_page).limit(e.per_page).selectAll().execute();if(!e.include_totals)return{tenants:r};const{count:a}=await t.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow(),o=K(a);return{tenants:r.map(b),start:(e.page-1)*e.per_page,limit:e.per_page,length:o}}}function Hn(n){return async(e,t)=>{const s={...t,id:e,updated_at:new Date().toISOString()};await n.updateTable("tenants").set(s).where("id","=",e).execute()}}function Jn(n){return async e=>(await n.deleteFrom("tenants").where("tenants.id","=",e).execute()).length===1}function Yn(n){return{create:Kn(n),get:Wn(n),list:Qn(n),update:Hn(n),remove:Jn(n)}}function wt(n){return n?JSON.stringify(n):void 0}const Gn=1024;function Xn(n){return async(e,t)=>{var r,a;const s={id:be(),...t,user_agent:t.user_agent.slice(0,Gn)};return await n.insertInto("logs").values({...s,isMobile:t.isMobile?1:0,tenant_id:e,scope:(r=t.scope)==null?void 0:r.join(","),auth0_client:wt(t.auth0_client),details:(a=wt(t.details))==null?void 0:a.substring(0,8192)}).execute(),s}}function kt(n){if(!n)return"";try{return JSON.parse(n)}catch{return n}}function xt(n){return{...n,client_id:n.client_id,client_name:"",auth0_client:kt(n.auth0_client),details:kt(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 s=n.selectFrom("logs").where("logs.tenant_id","=",e);t.q&&(s=te(n,s,t.q,["user_id","ip"]));let r=s;if(t.sort&&t.sort.sort_by){const{ref:c}=n.dynamic;r=r.orderBy(c(t.sort.sort_by),t.sort.sort_order)}r=r.offset(t.page*t.per_page).limit(t.per_page);const a=await r.selectAll().execute(),{count:o}=await s.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{logs:a.map(xt),start:t.page*t.per_page,limit:t.per_page,length:K(o)}}}function ts(n){return async(e,t)=>{const s=await n.selectFrom("logs").where("logs.tenant_id","=",e).where("logs.id","=",t).selectAll().executeTakeFirst();return s?xt(s):null}}function ns(n){return{create:Xn(n),list:es(n),get:ts(n)}}function ss(n){return async(e,t)=>{const s=await n.selectFrom("sessions").where("sessions.tenant_id","=",e).where("sessions.id","=",t).where("sessions.deleted_at","is",null).selectAll().executeTakeFirst();return s?{session_id:s.id,user_id:s.user_id,client_id:s.client_id,created_at:s.created_at,expires_at:s.expires_at,used_at:s.used_at}:null}}function rs(n){return async(e,t)=>{const s={user_id:t.user_id,client_id:t.client_id,created_at:new Date().toISOString(),expires_at:new Date().toISOString(),used_at:t.used_at};return await n.insertInto("sessions").values({...s,tenant_id:e,id:t.session_id}).execute(),{...t,...s}}}function is(n){return async(e,t)=>!!(await n.updateTable("sessions").set({deleted_at:new Date().toISOString()}).where("tenant_id","=",e).where("sessions.id","=",t).where("sessions.deleted_at","is",null).execute()).length}function as(n){return async(e,t,s)=>!!(await n.updateTable("sessions").set(s).where("tenant_id","=",e).where("sessions.id","=",t).where("sessions.deleted_at","is",null).execute()).length}function os(n){return async(e,t)=>{let s=n.selectFrom("sessions").where("sessions.tenant_id","=",e);t.q&&(s=te(n,s,t.q,["user_id","id"]));let r=s;if(t.sort&&t.sort.sort_by){const{ref:d}=n.dynamic;r=r.orderBy(d(t.sort.sort_by),t.sort.sort_order)}r=r.offset(t.page*t.per_page).limit(t.per_page);const a=await r.selectAll().execute(),{count:o}=await s.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow(),c=K(o);return{sessions:a.map(d=>{const{id:u,...h}=d;return{session_id:u,...h}}),start:t.page*t.per_page,limit:t.per_page,length:c}}}function cs(n){return{create:rs(n),get:ss(n),list:os(n),remove:is(n),update:as(n)}}function ds(n){return async(e,t)=>{const s=await n.selectFrom("tickets").where("tickets.tenant_id","=",e).where("tickets.id","=",t).where("tickets.used_at","is",null).selectAll().executeTakeFirst();if(!s)return null;const{nonce:r,state:a,scope:o,response_type:c,response_mode:d,redirect_uri:u,...h}=s;return{...h,authParams:{nonce:r,state:a,scope:o,response_type:c,response_mode:d,redirect_uri:u},created_at:new Date(s.created_at),expires_at:new Date(s.expires_at),used_at:s.used_at?new Date(s.used_at):void 0}}}function us(n){return async e=>{const{authParams:t,...s}=e,r={...s,...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(r).execute()}}function ls(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 ps(n){return{create:us(n),get:ds(n),remove:ls(n)}}function hs(n){return async(e,t)=>{const s=new Date().toISOString();return(await n.selectFrom("otps").where("otps.tenant_id","=",e).where("otps.email","=",t).where("otps.expires_at",">",s).where("otps.used_at","is",null).selectAll().execute()).map(a=>{const{nonce:o,state:c,scope:d,response_type:u,redirect_uri:h,client_id:k,...S}=a;return{...S,client_id:k,authParams:{client_id:k,nonce:o,state:c,scope:d,response_type:u,redirect_uri:h},created_at:a.created_at,expires_at:a.expires_at}})}}function _s(n){return async(e,t)=>{const{authParams:s,...r}=t;await n.insertInto("otps").values({...r,...s,created_at:new Date().toISOString(),tenant_id:e,send:t.send==="code"?"code":"link"}).execute()}}function gs(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 ms(n){return{create:_s(n),list:hs(n),remove:gs(n)}}function fs(n){return async(e,t)=>{const s=await n.selectFrom("passwords").where("passwords.tenant_id","=",e).where("passwords.user_id","=",t).selectAll().executeTakeFirstOrThrow(),{tenant_id:r,...a}=s;return a}}function ys(n){return async(e,t)=>{const s={...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("passwords").values({...s,tenant_id:e}).execute(),s}}function vs(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 ws(n){return{create:ys(n),update:vs(n),get:fs(n)}}function ks(n){return async(e,t)=>{const s=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",">",s).selectAll().execute()).map(a=>{const{tenant_id:o,...c}=a;return c})}}function xs(n){return async(e,t)=>{await n.insertInto("codes").values({...t,tenant_id:e}).execute()}}function bs(n){return{create:xs(n),list:ks(n)}}function Ts(n){return async e=>{const t=new Date().toISOString(),s=await n.selectFrom("universal_login_sessions").where("universal_login_sessions.expires_at",">",t).where("universal_login_sessions.id","=",e).selectAll().executeTakeFirst();if(!s)return null;const{response_type:r,response_mode:a,redirect_uri:o,audience:c,state:d,nonce:u,scope:h,code_challenge_method:k,code_challenge:S,username:W,vendor_id:Q,...H}=s;return{...H,authParams:{client_id:H.client_id,vendor_id:Q,response_type:r,response_mode:a,redirect_uri:o,audience:c,state:d,nonce:u,scope:h,code_challenge_method:k,code_challenge:S,username:W}}}}function Os(n){return async(e,t)=>{const{authParams:s,...r}=t,a={created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("universal_login_sessions").values({...s,...r,...a,tenant_id:e}).execute(),{...t,...a}}}function Ss(n){return async(e,t,s)=>{const{authParams:r,...a}=s;return(await n.updateTable("universal_login_sessions").set({...r,...a}).where("id","=",t).where("tenant_id","=",e).execute()).length===1}}function Zs(n){return{create:Os(n),get:Ts(n),update:Ss(n)}}function js(n){return async(e,t)=>{const s={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({...s,tenant_id:e}).execute(),s}}function Is(n){return async e=>({applications:await n.selectFrom("applications").where("applications.tenant_id","=",e).selectAll().execute()})}function As(n){return async(e,t)=>{const s=await n.selectFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",t).selectAll().executeTakeFirst();return s?(s.disable_sign_ups=!!s.disable_sign_ups,b(s)):null}}function Cs(n){return async(e,t)=>(await n.deleteFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",t).executeTakeFirst()).numDeletedRows>0}function Ns(n){return async(e,t,s)=>{const r={...s,updated_at:new Date().toISOString()};return await n.updateTable("connections").set(r).where("connections.id","=",t).where("connections.tenant_id","=",e).execute(),!0}}function Es(n){return{create:js(n),list:Is(n),get:As(n),remove:Cs(n),update:Ns(n)}}function $s(n){return async(e,t)=>{const s={id:be(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("connections").values({...s,tenant_id:e}).execute(),s}}function Ps(n){return async(e,t)=>{let s=n.selectFrom("connections").where("connections.tenant_id","=",e);t.q&&(s=te(n,s,t.q,["user_id","ip"]));const a=await s.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await s.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{connections:a.map(b),start:t.page*t.per_page,limit:t.per_page,length:K(o)}}}function Rs(n){return async(e,t)=>(await n.deleteFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",t).executeTakeFirst()).numDeletedRows>0}function Ds(n){return async(e,t)=>{const s=await n.selectFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",t).selectAll().executeTakeFirst();return s?b(s):null}}function Fs(n){return async(e,t,s)=>{const r={...s,updated_at:new Date().toISOString()};return await n.updateTable("connections").set(r).where("connections.id","=",t).where("connections.tenant_id","=",e).execute(),!0}}function Ms(n){return{create:$s(n),get:Ds(n),list:Ps(n),remove:Rs(n),update:Fs(n)}}function Je(n){return n!=null&&n.length?n.split(",").map(e=>e.trim()):[]}function Ls(n){return{get:async e=>{const t=await n.selectFrom("applications").selectAll().where("id","=",e).executeTakeFirst();if(!t)return null;const s=await n.selectFrom("tenants").selectAll().where("id","=",t.tenant_id).executeTakeFirst();if(!s)throw new C(404,{message:"Tenant not found"});const r=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:r.map(c=>We.parse(b(c))),domains:a,tenant_id:s.id,allowed_callback_urls:Je(t.allowed_callback_urls),allowed_logout_urls:Je(t.allowed_logout_urls),allowed_web_origins:Je(t.allowed_web_origins),email_validation:t.email_validation,client_secret:t.client_secret,tenant:b(s),disable_sign_ups:!!t.disable_sign_ups}}}}function Us(n){return async()=>await n.selectFrom("keys").where("revoked_at","is",null).selectAll().execute()}function zs(n){return async e=>{await n.insertInto("keys").values(e).execute()}}function qs(n){return async(e,t)=>!!(await n.updateTable("keys").set({revoked_at:t.toISOString()}).where("kid","=",e).execute()).length}function Vs(n){return{create:zs(n),list:Us(n),revoke:qs(n)}}function Bs(n){return async(e,t)=>{const s={created_at:new Date().toISOString(),updated_at:new Date().toISOString(),tenant_id:e,id:be(),...t};return await n.insertInto("domains").values(s).execute(),s}}function Ks(n){return async(e,t)=>{let s=n.selectFrom("domains").where("domains.tenant_id","=",e);t.q&&(s=te(n,s,t.q,["user_id","ip"]));const a=await s.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await s.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{domains:a,start:t.page*t.per_page,limit:t.per_page,length:K(o)}}}function Ws(n){return{create:Bs(n),list:Ks(n)}}function Qs(n){return async e=>{const[t]=await n.selectFrom("branding").where("branding.tenant_id","=",e).selectAll().execute();if(!t)return null;const{tenant_id:s,colors_primary:r,colors_page_background_type:a,colors_page_background_start:o,colors_page_background_end:c,colors_page_background_angle_dev:d,font_url:u,...h}=t;return b({...h,colors:{primary:r,page_background:{type:a,start:o,end:c,angle_deg:d}},font:u?{url:u}:void 0})}}function Hs(n){return async(e,t)=>{var o,c,d,u,h,k,S,W,Q,H,Te,Oe,Se,Re,De,ne,se,re;const{colors:s,font:r,...a}=t;try{await n.insertInto("branding").values({...a,colors_primary:s==null?void 0:s.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:(k=(h=t.colors)==null?void 0:h.page_background)==null?void 0:k.end,colors_page_background_angle_dev:(W=(S=t.colors)==null?void 0:S.page_background)==null?void 0:W.angle_deg,font_url:(Q=t.font)==null?void 0:Q.url,tenant_id:e}).execute()}catch{await n.updateTable("branding").set({...a,colors_primary:s==null?void 0:s.primary,colors_page_background_type:(Te=(H=t.colors)==null?void 0:H.page_background)==null?void 0:Te.type,colors_page_background_start:(Se=(Oe=t.colors)==null?void 0:Oe.page_background)==null?void 0:Se.start,colors_page_background_end:(De=(Re=t.colors)==null?void 0:Re.page_background)==null?void 0:De.end,colors_page_background_angle_dev:(se=(ne=t.colors)==null?void 0:ne.page_background)==null?void 0:se.angle_deg,font_url:(re=t.font)==null?void 0:re.url}).where("tenant_id","=",e).execute()}}}function Js(n){return{get:Qs(n),set:Hs(n)}}function Ys(n){return async(e,t)=>{const s=await n.selectFrom("authentication_codes").where("tenant_id","=",e).where("code","=",t).selectAll().executeTakeFirst();if(!s)throw new C(403,{message:"Code not found or expired"});const{state:r,nonce:a,scope:o,client_id:c,response_type:d,response_mode:u,...h}=s;return{...h,authParams:{state:r,nonce:a,scope:o,client_id:c,response_type:d,response_mode:u}}}}function Gs(n){return async(e,t)=>{const{authParams:s,...r}=t;await n.insertInto("authentication_codes").values({...r,...s,tenant_id:e}).execute()}}function Xs(n){return{create:Gs(n),get:Ys(n)}}function er(n){return async(e,t)=>{let s=n.selectFrom("hooks").where("hooks.tenant_id","=",e);t.q&&(s=te(n,s,t.q,["url"]));const a=await s.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await s.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow();return{hooks:a.map(d=>{const{tenant_id:u,enabled:h,...k}=d;return b({...k,enabled:!!h})}),start:t.page*t.per_page,limit:t.per_page,length:K(o)}}}function tr(n){return async(e,t)=>{const s=await n.selectFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",t).selectAll().executeTakeFirst();return s?(s.enabled=!!s.enabled,b(s)):null}}function nr(n){return async(e,t)=>(await n.deleteFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",t).executeTakeFirst()).numDeletedRows>0}function sr(n){return async(e,t)=>{const s={hook_id:be(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("hooks").values({...s,tenant_id:e}).execute(),s}}function rr(n){return async(e,t,s)=>{const r={...s,updated_at:new Date().toISOString()};return await n.updateTable("hooks").set(r).where("hooks.hook_id","=",t).where("hooks.tenant_id","=",e).execute(),!0}}function ir(n){return{create:sr(n),get:tr(n),list:er(n),update:rr(n),remove:nr(n)}}function ar(n){return{applications:Es(n),authenticationCodes:Xs(n),branding:Js(n),clients:Ls(n),keys:Vs(n),users:Vn(n),sessions:cs(n),tenants:Yn(n),tickets:ps(n),universalLoginSessions:Zs(n),OTP:ms(n),logs:ns(n),passwords:ws(n),codes:bs(n),connections:Ms(n),domains:Ws(n),hooks:ir(n)}}return ar}();
|