@authhero/kysely-adapter 0.16.0 → 0.17.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
var kyselyAdapter=function(A){"use strict";var Uu=Object.defineProperty;var $r=A=>{throw TypeError(A)};var Fu=(A,P,U)=>P in A?Uu(A,P,{enumerable:!0,configurable:!0,writable:!0,value:U}):A[P]=U;var Xt=(A,P,U)=>Fu(A,typeof P!="symbol"?P+"":P,U),Fn=(A,P,U)=>P.has(A)||$r("Cannot "+U);var v=(A,P,U)=>(Fn(A,P,"read from private field"),U?U.call(A):P.get(A)),he=(A,P,U)=>P.has(A)?$r("Cannot add the same private member more than once"):P instanceof WeakSet?P.add(A):P.set(A,U),en=(A,P,U,R)=>(Fn(A,P,"write to private field"),R?R.call(A,U):P.set(A,U),U),C=(A,P,U)=>(Fn(A,P,"access private method"),U);var xn,ot,Be,Ke,V,Ar,Pr,Dr,ut,Vn,Rr,Gt,D,m,tn,_e,ge,ht,Mr,ye,Lr,zr,Ur,Fr,Vr,Bn,pt,Kn,Br,Kr,Wr,Wn,Jr,qr,Qr,Hr,Gr,nn,Yt;var P=class extends Error{constructor(e=500,n){super(n==null?void 0:n.message,{cause:n==null?void 0:n.cause});Xt(this,"res");Xt(this,"status");this.res=n==null?void 0:n.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 U(t){return async(e,n)=>{const{identities:r,...a}=n,s={...a,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),tenant_id:e,email_verified:n.email_verified?1:0,is_social:n.is_social?1:0,app_metadata:JSON.stringify(n.app_metadata),user_metadata:JSON.stringify(n.user_metadata)};try{await t.insertInto("users").values(s).execute()}catch(o){throw o.code==="SQLITE_CONSTRAINT_UNIQUE"||o.message.includes("AlreadyExists")?new P(409,{message:"User already exists"}):(console.log(o.message),new P(500,{message:`${o.code}, ${o.message}`}))}return{...s,email:s.email||"",email_verified:s.email_verified===1,is_social:s.is_social===1}}}function R(t){const e={...t};for(const n in e)e[n]===null?delete e[n]:typeof e[n]=="object"&&(Array.isArray(e[n])?e[n]=e[n].map(R):e[n]=R(e[n]));return e}function Yr(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(t);a<r.length;a++)e.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(t,r[a])&&(n[r[a]]=t[r[a]]);return n}function Xr(t,e){var n;return((n=t==null?void 0:t._def)===null||n===void 0?void 0:n.typeName)===e}function mt(t,e){const n=t.ZodType.prototype[e];t.ZodType.prototype[e]=function(...r){const a=n.apply(this,r);return a._def.openapi=this._def.openapi,a}}function ea(t){if(typeof t.ZodType.prototype.openapi<"u")return;t.ZodType.prototype.openapi=function(a,s){var o,d,c,l,u,Z;const z=typeof a=="string"?s:a,H=z??{},{param:Ze}=H,dt=Yr(H,["param"]),Ee=Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o._internal),typeof a=="string"?{refId:a}:void 0),$e=Object.assign(Object.assign(Object.assign({},(d=this._def.openapi)===null||d===void 0?void 0:d.metadata),dt),!((l=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||l===void 0)&&l.param||Ze?{param:Object.assign(Object.assign({},(Z=(u=this._def.openapi)===null||u===void 0?void 0:u.metadata)===null||Z===void 0?void 0:Z.param),Ze)}:void 0),Ae=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(Ee).length>0?{_internal:Ee}:void 0),Object.keys($e).length>0?{metadata:$e}:void 0)}));if(Xr(this,"ZodObject")){const ct=this.extend;Ae.extend=function(...lt){var ce,le,ue,Pe,We,Je;const qe=ct.apply(this,lt);return qe._def.openapi={_internal:{extendedFrom:!((le=(ce=this._def.openapi)===null||ce===void 0?void 0:ce._internal)===null||le===void 0)&&le.refId?{refId:(Pe=(ue=this._def.openapi)===null||ue===void 0?void 0:ue._internal)===null||Pe===void 0?void 0:Pe.refId,schema:this}:(We=this._def.openapi)===null||We===void 0?void 0:We._internal.extendedFrom},metadata:(Je=qe._def.openapi)===null||Je===void 0?void 0:Je.metadata},qe}}return Ae},mt(t,"optional"),mt(t,"nullable"),mt(t,"default"),mt(t,"transform"),mt(t,"refine");const e=t.ZodObject.prototype.deepPartial;t.ZodObject.prototype.deepPartial=function(){const a=this._def.shape(),s=e.apply(this),o=s._def.shape();return Object.entries(o).forEach(([d,c])=>{var l,u;c._def.openapi=(u=(l=a[d])===null||l===void 0?void 0:l._def)===null||u===void 0?void 0:u.openapi}),s._def.openapi=void 0,s};const n=t.ZodObject.prototype.pick;t.ZodObject.prototype.pick=function(...a){const s=n.apply(this,a);return s._def.openapi=void 0,s};const r=t.ZodObject.prototype.omit;t.ZodObject.prototype.omit=function(...a){const s=r.apply(this,a);return s._def.openapi=void 0,s}}new Set(".\\+*[^]$()");var E;(function(t){t.assertEqual=a=>a;function e(a){}t.assertIs=e;function n(a){throw new Error}t.assertNever=n,t.arrayToEnum=a=>{const s={};for(const o of a)s[o]=o;return s},t.getValidEnumValues=a=>{const s=t.objectKeys(a).filter(d=>typeof a[a[d]]!="number"),o={};for(const d of s)o[d]=a[d];return t.objectValues(o)},t.objectValues=a=>t.objectKeys(a).map(function(s){return a[s]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const s=[];for(const o in a)Object.prototype.hasOwnProperty.call(a,o)&&s.push(o);return s},t.find=(a,s)=>{for(const o of a)if(s(o))return o},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&isFinite(a)&&Math.floor(a)===a;function r(a,s=" | "){return a.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}t.joinValues=r,t.jsonStringifyReplacer=(a,s)=>typeof s=="bigint"?s.toString():s})(E||(E={}));var Nn;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Nn||(Nn={}));const g=E.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ve=t=>{switch(typeof t){case"undefined":return g.undefined;case"string":return g.string;case"number":return isNaN(t)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(t)?g.array:t===null?g.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?g.promise:typeof Map<"u"&&t instanceof Map?g.map:typeof Set<"u"&&t instanceof Set?g.set:typeof Date<"u"&&t instanceof Date?g.date:g.object;default:return g.unknown}},h=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"]),ta=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class q extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const n=e||function(s){return s.message},r={_errors:[]},a=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(a);else if(o.code==="invalid_return_type")a(o.returnTypeError);else if(o.code==="invalid_arguments")a(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let d=r,c=0;for(;c<o.path.length;){const l=o.path[c];c===o.path.length-1?(d[l]=d[l]||{_errors:[]},d[l]._errors.push(n(o))):d[l]=d[l]||{_errors:[]},d=d[l],c++}}};return a(this),r}static assert(e){if(!(e instanceof q))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=n=>n.message){const n={},r=[];for(const a of this.issues)a.path.length>0?(n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(e(a))):r.push(e(a));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}q.create=t=>new q(t);const Qe=(t,e)=>{let n;switch(t.code){case h.invalid_type:t.received===g.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case h.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,E.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:n=`Unrecognized key(s) in object: ${E.joinValues(t.keys,", ")}`;break;case h.invalid_union:n="Invalid input";break;case h.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${E.joinValues(t.options)}`;break;case h.invalid_enum_value:n=`Invalid enum value. Expected ${E.joinValues(t.options)}, received '${t.received}'`;break;case h.invalid_arguments:n="Invalid function arguments";break;case h.invalid_return_type:n="Invalid function return type";break;case h.invalid_date:n="Invalid date";break;case h.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:E.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case h.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case h.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case h.custom:n="Invalid input";break;case h.invalid_intersection_types:n="Intersection results could not be merged";break;case h.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case h.not_finite:n="Number must be finite";break;default:n=e.defaultError,E.assertNever(t)}return{message:n}};let Jn=Qe;function na(t){Jn=t}function rn(){return Jn}const an=t=>{const{data:e,path:n,errorMaps:r,issueData:a}=t,s=[...n,...a.path||[]],o={...a,path:s};if(a.message!==void 0)return{...a,path:s,message:a.message};let d="";const c=r.filter(l=>!!l).slice().reverse();for(const l of c)d=l(o,{data:e,defaultError:d}).message;return{...a,path:s,message:d}},ra=[];function f(t,e){const n=rn(),r=an({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Qe?void 0:Qe].filter(a=>!!a)});t.common.issues.push(r)}class B{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const a of n){if(a.status==="aborted")return T;a.status==="dirty"&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const a of n){const s=await a.key,o=await a.value;r.push({key:s,value:o})}return B.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const a of n){const{key:s,value:o}=a;if(s.status==="aborted"||o.status==="aborted")return T;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||a.alwaysSet)&&(r[s.value]=o.value)}return{status:e.value,value:r}}}const T=Object.freeze({status:"aborted"}),sn=t=>({status:"dirty",value:t}),W=t=>({status:"valid",value:t}),kn=t=>t.status==="aborted",Tn=t=>t.status==="dirty",ft=t=>t.status==="valid",_t=t=>typeof Promise<"u"&&t instanceof Promise;function on(t,e,n,r){if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function qn(t,e,n,r,a){if(typeof e=="function"?t!==e||!a:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}var b;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(b||(b={}));var gt,yt;class re{constructor(e,n,r,a){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=a}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 Qn=(t,e)=>{if(ft(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new q(t.common.issues);return this._error=n,this._error}}};function O(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:a}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(s,o)=>{var d,c;const{message:l}=t;return s.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:(d=l??r)!==null&&d!==void 0?d:o.defaultError}:s.code!=="invalid_type"?{message:o.defaultError}:{message:(c=l??n)!==null&&c!==void 0?c:o.defaultError}},description:a}}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 ve(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:ve(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new B,ctx:{common:e.parent.common,data:e.data,parsedType:ve(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(_t(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){var r;const a={common:{issues:[],async:(r=n==null?void 0:n.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ve(e)},s=this._parseSync({data:e,path:a.path,parent:a});return Qn(a,s)}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ve(e)},a=this._parse({data:e,path:r.path,parent:r}),s=await(_t(a)?a:Promise.resolve(a));return Qn(r,s)}refine(e,n){const r=a=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(a):n;return this._refinement((a,s)=>{const o=e(a),d=()=>s.addIssue({code:h.custom,...r(a)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(d(),!1)):o?!0:(d(),!1)})}refinement(e,n){return this._refinement((r,a)=>e(r)?!0:(a.addIssue(typeof n=="function"?n(r,a):n),!1))}_refinement(e){return new X({schema:this,typeName:x.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return se.create(this,this._def)}nullable(){return ke.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Y.create(this,this._def)}promise(){return Xe.create(this,this._def)}or(e){return xt.create([this,e],this._def)}and(e){return Nt.create(this,e,this._def)}transform(e){return new X({...O(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new St({...O(this._def),innerType:this,defaultValue:n,typeName:x.ZodDefault})}brand(){return new Sn({typeName:x.ZodBranded,type:this,...O(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new jt({...O(this._def),innerType:this,catchValue:n,typeName:x.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return It.create(this,e)}readonly(){return Zt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const aa=/^c[^\s-]{8,}$/i,sa=/^[0-9a-z]+$/,ia=/^[0-9A-HJKMNP-TV-Z]{26}$/,oa=/^[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,da=/^[a-z0-9_-]{21}$/i,ca=/^[-+]?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)?)??$/,la=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ua="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Cn;const ha=/^(?:(?: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])$/,pa=/^(([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})))$/,ma=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Hn="((\\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])))",fa=new RegExp(`^${Hn}$`);function Gn(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`),e}function _a(t){return new RegExp(`^${Gn(t)}$`)}function Yn(t){let e=`${Hn}T${Gn(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function ga(t,e){return!!((e==="v4"||!e)&&ha.test(t)||(e==="v6"||!e)&&pa.test(t))}class G extends j{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){const a=this._getOrReturnCtx(e);return f(a,{code:h.invalid_type,expected:g.string,received:a.parsedType}),T}const n=new B;let r;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const s=e.data.length>a.value,o=e.data.length<a.value;(s||o)&&(r=this._getOrReturnCtx(e,r),s?f(r,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&f(r,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")la.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"email",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Cn||(Cn=new RegExp(ua,"u")),Cn.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"emoji",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")oa.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"uuid",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")da.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"nanoid",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")aa.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"cuid",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")sa.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"cuid2",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")ia.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"ulid",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),f(r,{validation:"url",code:h.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"regex",code:h.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(e,r),f(r,{code:h.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(r=this._getOrReturnCtx(e,r),f(r,{code:h.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(r=this._getOrReturnCtx(e,r),f(r,{code:h.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Yn(a).test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:h.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?fa.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:h.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?_a(a).test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:h.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?ca.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"duration",code:h.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?ga(e.data,a.version)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"ip",code:h.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?ma.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"base64",code:h.invalid_string,message:a.message}),n.dirty()):E.assertNever(a);return{status:n.value,value:e.data}}_regex(e,n,r){return this.refinement(a=>e.test(a),{validation:n,code:h.invalid_string,...b.errToObj(r)})}_addCheck(e){return new G({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...b.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...b.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...b.errToObj(e)})}datetime(e){var n,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(n=e==null?void 0:e.offset)!==null&&n!==void 0?n:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...b.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,...b.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...b.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...b.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...b.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...b.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...b.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...b.errToObj(n)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new G({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new G({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new G({...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 n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}G.create=t=>{var e;return new G({checks:[],typeName:x.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...O(t)})};function ya(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,a=n>r?n:r,s=parseInt(t.toFixed(a).replace(".","")),o=parseInt(e.toFixed(a).replace(".",""));return s%o/Math.pow(10,a)}class be extends j{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==g.number){const a=this._getOrReturnCtx(e);return f(a,{code:h.invalid_type,expected:g.number,received:a.parsedType}),T}let n;const r=new B;for(const a of this._def.checks)a.kind==="int"?E.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:h.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:h.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:h.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?ya(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),f(n,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:h.not_finite,message:a.message}),r.dirty()):E.assertNever(a);return{status:r.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,r,a){return new be({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(a)}]})}_addCheck(e){return new be({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.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,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}}be.create=t=>new be({checks:[],typeName:x.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...O(t)});class we extends j{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==g.bigint){const a=this._getOrReturnCtx(e);return f(a,{code:h.invalid_type,expected:g.bigint,received:a.parsedType}),T}let n;const r=new B;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:h.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:h.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),f(n,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):E.assertNever(a);return{status:r.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,r,a){return new we({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(a)}]})}_addCheck(e){return new we({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}we.create=t=>{var e;return new we({checks:[],typeName:x.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...O(t)})};class vt extends j{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.boolean,received:n.parsedType}),T}return W(e.data)}}vt.create=t=>new vt({typeName:x.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...O(t)});class De extends j{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){const a=this._getOrReturnCtx(e);return f(a,{code:h.invalid_type,expected:g.date,received:a.parsedType}),T}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return f(a,{code:h.invalid_date}),T}const n=new B;let r;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:h.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:h.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):E.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new De({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:b.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}De.create=t=>new De({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:x.ZodDate,...O(t)});class dn extends j{_parse(e){if(this._getType(e)!==g.symbol){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.symbol,received:n.parsedType}),T}return W(e.data)}}dn.create=t=>new dn({typeName:x.ZodSymbol,...O(t)});class bt extends j{_parse(e){if(this._getType(e)!==g.undefined){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.undefined,received:n.parsedType}),T}return W(e.data)}}bt.create=t=>new bt({typeName:x.ZodUndefined,...O(t)});class wt extends j{_parse(e){if(this._getType(e)!==g.null){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.null,received:n.parsedType}),T}return W(e.data)}}wt.create=t=>new wt({typeName:x.ZodNull,...O(t)});class He extends j{constructor(){super(...arguments),this._any=!0}_parse(e){return W(e.data)}}He.create=t=>new He({typeName:x.ZodAny,...O(t)});class Re extends j{constructor(){super(...arguments),this._unknown=!0}_parse(e){return W(e.data)}}Re.create=t=>new Re({typeName:x.ZodUnknown,...O(t)});class pe extends j{_parse(e){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.never,received:n.parsedType}),T}}pe.create=t=>new pe({typeName:x.ZodNever,...O(t)});class cn extends j{_parse(e){if(this._getType(e)!==g.undefined){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.void,received:n.parsedType}),T}return W(e.data)}}cn.create=t=>new cn({typeName:x.ZodVoid,...O(t)});class Y extends j{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),a=this._def;if(n.parsedType!==g.array)return f(n,{code:h.invalid_type,expected:g.array,received:n.parsedType}),T;if(a.exactLength!==null){const o=n.data.length>a.exactLength.value,d=n.data.length<a.exactLength.value;(o||d)&&(f(n,{code:o?h.too_big:h.too_small,minimum:d?a.exactLength.value:void 0,maximum:o?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&n.data.length<a.minLength.value&&(f(n,{code:h.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&n.data.length>a.maxLength.value&&(f(n,{code:h.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,d)=>a.type._parseAsync(new re(n,o,n.path,d)))).then(o=>B.mergeArray(r,o));const s=[...n.data].map((o,d)=>a.type._parseSync(new re(n,o,n.path,d)));return B.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new Y({...this._def,minLength:{value:e,message:b.toString(n)}})}max(e,n){return new Y({...this._def,maxLength:{value:e,message:b.toString(n)}})}length(e,n){return new Y({...this._def,exactLength:{value:e,message:b.toString(n)}})}nonempty(e){return this.min(1,e)}}Y.create=(t,e)=>new Y({type:t,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...O(e)});function Ge(t){if(t instanceof M){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=se.create(Ge(r))}return new M({...t._def,shape:()=>e})}else return t instanceof Y?new Y({...t._def,type:Ge(t.element)}):t instanceof se?se.create(Ge(t.unwrap())):t instanceof ke?ke.create(Ge(t.unwrap())):t instanceof ae?ae.create(t.items.map(e=>Ge(e))):t}class M 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(),n=E.objectKeys(e);return this._cached={shape:e,keys:n}}_parse(e){if(this._getType(e)!==g.object){const c=this._getOrReturnCtx(e);return f(c,{code:h.invalid_type,expected:g.object,received:c.parsedType}),T}const{status:n,ctx:r}=this._processInputParams(e),{shape:a,keys:s}=this._getCached(),o=[];if(!(this._def.catchall instanceof pe&&this._def.unknownKeys==="strip"))for(const c in r.data)s.includes(c)||o.push(c);const d=[];for(const c of s){const l=a[c],u=r.data[c];d.push({key:{status:"valid",value:c},value:l._parse(new re(r,u,r.path,c)),alwaysSet:c in r.data})}if(this._def.catchall instanceof pe){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of o)d.push({key:{status:"valid",value:l},value:{status:"valid",value:r.data[l]}});else if(c==="strict")o.length>0&&(f(r,{code:h.unrecognized_keys,keys:o}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of o){const u=r.data[l];d.push({key:{status:"valid",value:l},value:c._parse(new re(r,u,r.path,l)),alwaysSet:l in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of d){const u=await l.key,Z=await l.value;c.push({key:u,value:Z,alwaysSet:l.alwaysSet})}return c}).then(c=>B.mergeObjectSync(n,c)):B.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new M({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{var a,s,o,d;const c=(o=(s=(a=this._def).errorMap)===null||s===void 0?void 0:s.call(a,n,r).message)!==null&&o!==void 0?o:r.defaultError;return n.code==="unrecognized_keys"?{message:(d=b.errToObj(e).message)!==null&&d!==void 0?d:c}:{message:c}}}:{}})}strip(){return new M({...this._def,unknownKeys:"strip"})}passthrough(){return new M({...this._def,unknownKeys:"passthrough"})}extend(e){return new M({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new M({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new M({...this._def,catchall:e})}pick(e){const n={};return E.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new M({...this._def,shape:()=>n})}omit(e){const n={};return E.objectKeys(this.shape).forEach(r=>{e[r]||(n[r]=this.shape[r])}),new M({...this._def,shape:()=>n})}deepPartial(){return Ge(this)}partial(e){const n={};return E.objectKeys(this.shape).forEach(r=>{const a=this.shape[r];e&&!e[r]?n[r]=a:n[r]=a.optional()}),new M({...this._def,shape:()=>n})}required(e){const n={};return E.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])n[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof se;)a=a._def.innerType;n[r]=a}}),new M({...this._def,shape:()=>n})}keyof(){return Xn(E.objectKeys(this.shape))}}M.create=(t,e)=>new M({shape:()=>t,unknownKeys:"strip",catchall:pe.create(),typeName:x.ZodObject,...O(e)}),M.strictCreate=(t,e)=>new M({shape:()=>t,unknownKeys:"strict",catchall:pe.create(),typeName:x.ZodObject,...O(e)}),M.lazycreate=(t,e)=>new M({shape:t,unknownKeys:"strip",catchall:pe.create(),typeName:x.ZodObject,...O(e)});class xt extends j{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function a(s){for(const d of s)if(d.result.status==="valid")return d.result;for(const d of s)if(d.result.status==="dirty")return n.common.issues.push(...d.ctx.common.issues),d.result;const o=s.map(d=>new q(d.ctx.common.issues));return f(n,{code:h.invalid_union,unionErrors:o}),T}if(n.common.async)return Promise.all(r.map(async s=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(a);{let s;const o=[];for(const c of r){const l={...n,common:{...n.common,issues:[]},parent:null},u=c._parseSync({data:n.data,path:n.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!s&&(s={result:u,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const d=o.map(c=>new q(c));return f(n,{code:h.invalid_union,unionErrors:d}),T}}get options(){return this._def.options}}xt.create=(t,e)=>new xt({options:t,typeName:x.ZodUnion,...O(e)});const xe=t=>t instanceof Tt?xe(t.schema):t instanceof X?xe(t.innerType()):t instanceof Ct?[t.value]:t instanceof Ne?t.options:t instanceof Ot?E.objectValues(t.enum):t instanceof St?xe(t._def.innerType):t instanceof bt?[void 0]:t instanceof wt?[null]:t instanceof se?[void 0,...xe(t.unwrap())]:t instanceof ke?[null,...xe(t.unwrap())]:t instanceof Sn||t instanceof Zt?xe(t.unwrap()):t instanceof jt?xe(t._def.innerType):[];class ln extends j{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.object)return f(n,{code:h.invalid_type,expected:g.object,received:n.parsedType}),T;const r=this.discriminator,a=n.data[r],s=this.optionsMap.get(a);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(f(n,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),T)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){const a=new Map;for(const s of n){const o=xe(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const d of o){if(a.has(d))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(d)}`);a.set(d,s)}}return new ln({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:a,...O(r)})}}function On(t,e){const n=ve(t),r=ve(e);if(t===e)return{valid:!0,data:t};if(n===g.object&&r===g.object){const a=E.objectKeys(e),s=E.objectKeys(t).filter(d=>a.indexOf(d)!==-1),o={...t,...e};for(const d of s){const c=On(t[d],e[d]);if(!c.valid)return{valid:!1};o[d]=c.data}return{valid:!0,data:o}}else if(n===g.array&&r===g.array){if(t.length!==e.length)return{valid:!1};const a=[];for(let s=0;s<t.length;s++){const o=t[s],d=e[s],c=On(o,d);if(!c.valid)return{valid:!1};a.push(c.data)}return{valid:!0,data:a}}else return n===g.date&&r===g.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Nt extends j{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),a=(s,o)=>{if(kn(s)||kn(o))return T;const d=On(s.value,o.value);return d.valid?((Tn(s)||Tn(o))&&n.dirty(),{status:n.value,value:d.data}):(f(r,{code:h.invalid_intersection_types}),T)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>a(s,o)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Nt.create=(t,e,n)=>new Nt({left:t,right:e,typeName:x.ZodIntersection,...O(n)});class ae extends j{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.array)return f(r,{code:h.invalid_type,expected:g.array,received:r.parsedType}),T;if(r.data.length<this._def.items.length)return f(r,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),T;!this._def.rest&&r.data.length>this._def.items.length&&(f(r,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const a=[...r.data].map((s,o)=>{const d=this._def.items[o]||this._def.rest;return d?d._parse(new re(r,s,r.path,o)):null}).filter(s=>!!s);return r.common.async?Promise.all(a).then(s=>B.mergeArray(n,s)):B.mergeArray(n,a)}get items(){return this._def.items}rest(e){return new ae({...this._def,rest:e})}}ae.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ae({items:t,typeName:x.ZodTuple,rest:null,...O(e)})};class kt extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.object)return f(r,{code:h.invalid_type,expected:g.object,received:r.parsedType}),T;const a=[],s=this._def.keyType,o=this._def.valueType;for(const d in r.data)a.push({key:s._parse(new re(r,d,r.path,d)),value:o._parse(new re(r,r.data[d],r.path,d)),alwaysSet:d in r.data});return r.common.async?B.mergeObjectAsync(n,a):B.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof j?new kt({keyType:e,valueType:n,typeName:x.ZodRecord,...O(r)}):new kt({keyType:G.create(),valueType:e,typeName:x.ZodRecord,...O(n)})}}class un extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.map)return f(r,{code:h.invalid_type,expected:g.map,received:r.parsedType}),T;const a=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([d,c],l)=>({key:a._parse(new re(r,d,r.path,[l,"key"])),value:s._parse(new re(r,c,r.path,[l,"value"]))}));if(r.common.async){const d=new Map;return Promise.resolve().then(async()=>{for(const c of o){const l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return T;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),d.set(l.value,u.value)}return{status:n.value,value:d}})}else{const d=new Map;for(const c of o){const l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return T;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),d.set(l.value,u.value)}return{status:n.value,value:d}}}}un.create=(t,e,n)=>new un({valueType:e,keyType:t,typeName:x.ZodMap,...O(n)});class Me extends j{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.set)return f(r,{code:h.invalid_type,expected:g.set,received:r.parsedType}),T;const a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(f(r,{code:h.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(f(r,{code:h.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty());const s=this._def.valueType;function o(c){const l=new Set;for(const u of c){if(u.status==="aborted")return T;u.status==="dirty"&&n.dirty(),l.add(u.value)}return{status:n.value,value:l}}const d=[...r.data.values()].map((c,l)=>s._parse(new re(r,c,r.path,l)));return r.common.async?Promise.all(d).then(c=>o(c)):o(d)}min(e,n){return new Me({...this._def,minSize:{value:e,message:b.toString(n)}})}max(e,n){return new Me({...this._def,maxSize:{value:e,message:b.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}Me.create=(t,e)=>new Me({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...O(e)});class Ye extends j{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.function)return f(n,{code:h.invalid_type,expected:g.function,received:n.parsedType}),T;function r(d,c){return an({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,rn(),Qe].filter(l=>!!l),issueData:{code:h.invalid_arguments,argumentsError:c}})}function a(d,c){return an({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,rn(),Qe].filter(l=>!!l),issueData:{code:h.invalid_return_type,returnTypeError:c}})}const s={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof Xe){const d=this;return W(async function(...c){const l=new q([]),u=await d._def.args.parseAsync(c,s).catch(z=>{throw l.addIssue(r(c,z)),l}),Z=await Reflect.apply(o,this,u);return await d._def.returns._def.type.parseAsync(Z,s).catch(z=>{throw l.addIssue(a(Z,z)),l})})}else{const d=this;return W(function(...c){const l=d._def.args.safeParse(c,s);if(!l.success)throw new q([r(c,l.error)]);const u=Reflect.apply(o,this,l.data),Z=d._def.returns.safeParse(u,s);if(!Z.success)throw new q([a(u,Z.error)]);return Z.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ye({...this._def,args:ae.create(e).rest(Re.create())})}returns(e){return new Ye({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new Ye({args:e||ae.create([]).rest(Re.create()),returns:n||Re.create(),typeName:x.ZodFunction,...O(r)})}}class Tt extends j{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Tt.create=(t,e)=>new Tt({getter:t,typeName:x.ZodLazy,...O(e)});class Ct extends j{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return f(n,{received:n.data,code:h.invalid_literal,expected:this._def.value}),T}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ct.create=(t,e)=>new Ct({value:t,typeName:x.ZodLiteral,...O(e)});function Xn(t,e){return new Ne({values:t,typeName:x.ZodEnum,...O(e)})}class Ne extends j{constructor(){super(...arguments),gt.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return f(n,{expected:E.joinValues(r),received:n.parsedType,code:h.invalid_type}),T}if(on(this,gt)||qn(this,gt,new Set(this._def.values)),!on(this,gt).has(e.data)){const n=this._getOrReturnCtx(e),r=this._def.values;return f(n,{received:n.data,code:h.invalid_enum_value,options:r}),T}return W(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return Ne.create(e,{...this._def,...n})}exclude(e,n=this._def){return Ne.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}gt=new WeakMap,Ne.create=Xn;class Ot extends j{constructor(){super(...arguments),yt.set(this,void 0)}_parse(e){const n=E.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==g.string&&r.parsedType!==g.number){const a=E.objectValues(n);return f(r,{expected:E.joinValues(a),received:r.parsedType,code:h.invalid_type}),T}if(on(this,yt)||qn(this,yt,new Set(E.getValidEnumValues(this._def.values))),!on(this,yt).has(e.data)){const a=E.objectValues(n);return f(r,{received:r.data,code:h.invalid_enum_value,options:a}),T}return W(e.data)}get enum(){return this._def.values}}yt=new WeakMap,Ot.create=(t,e)=>new Ot({values:t,typeName:x.ZodNativeEnum,...O(e)});class Xe extends j{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.promise&&n.common.async===!1)return f(n,{code:h.invalid_type,expected:g.promise,received:n.parsedType}),T;const r=n.parsedType===g.promise?n.data:Promise.resolve(n.data);return W(r.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Xe.create=(t,e)=>new Xe({type:t,typeName:x.ZodPromise,...O(e)});class X extends j{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),a=this._def.effect||null,s={addIssue:o=>{f(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),a.type==="preprocess"){const o=a.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async d=>{if(n.value==="aborted")return T;const c=await this._def.schema._parseAsync({data:d,path:r.path,parent:r});return c.status==="aborted"?T:c.status==="dirty"||n.value==="dirty"?sn(c.value):c});{if(n.value==="aborted")return T;const d=this._def.schema._parseSync({data:o,path:r.path,parent:r});return d.status==="aborted"?T:d.status==="dirty"||n.value==="dirty"?sn(d.value):d}}if(a.type==="refinement"){const o=d=>{const c=a.refinement(d,s);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return d};if(r.common.async===!1){const d=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return d.status==="aborted"?T:(d.status==="dirty"&&n.dirty(),o(d.value),{status:n.value,value:d.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(d=>d.status==="aborted"?T:(d.status==="dirty"&&n.dirty(),o(d.value).then(()=>({status:n.value,value:d.value}))))}if(a.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ft(o))return o;const d=a.transform(o.value,s);if(d instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:d}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>ft(o)?Promise.resolve(a.transform(o.value,s)).then(d=>({status:n.value,value:d})):o);E.assertNever(a)}}X.create=(t,e,n)=>new X({schema:t,typeName:x.ZodEffects,effect:e,...O(n)}),X.createWithPreprocess=(t,e,n)=>new X({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...O(n)});class se extends j{_parse(e){return this._getType(e)===g.undefined?W(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}se.create=(t,e)=>new se({innerType:t,typeName:x.ZodOptional,...O(e)});class ke extends j{_parse(e){return this._getType(e)===g.null?W(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ke.create=(t,e)=>new ke({innerType:t,typeName:x.ZodNullable,...O(e)});class St extends j{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===g.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}St.create=(t,e)=>new St({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...O(e)});class jt extends j{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return _t(a)?a.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new q(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new q(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}jt.create=(t,e)=>new jt({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...O(e)});class hn extends j{_parse(e){if(this._getType(e)!==g.nan){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.nan,received:n.parsedType}),T}return{status:"valid",value:e.data}}}hn.create=t=>new hn({typeName:x.ZodNaN,...O(t)});const va=Symbol("zod_brand");class Sn extends j{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class It extends j{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?T:a.status==="dirty"?(n.dirty(),sn(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const a=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?T:a.status==="dirty"?(n.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:r.path,parent:r})}}static create(e,n){return new It({in:e,out:n,typeName:x.ZodPipeline})}}class Zt extends j{_parse(e){const n=this._def.innerType._parse(e),r=a=>(ft(a)&&(a.value=Object.freeze(a.value)),a);return _t(n)?n.then(a=>r(a)):r(n)}unwrap(){return this._def.innerType}}Zt.create=(t,e)=>new Zt({innerType:t,typeName:x.ZodReadonly,...O(e)});function er(t,e={},n){return t?He.create().superRefine((r,a)=>{var s,o;if(!t(r)){const d=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,c=(o=(s=d.fatal)!==null&&s!==void 0?s:n)!==null&&o!==void 0?o:!0,l=typeof d=="string"?{message:d}:d;a.addIssue({code:"custom",...l,fatal:c})}}):He.create()}const ba={object:M.lazycreate};var x;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(x||(x={}));const wa=(t,e={message:`Input not instance of ${t.name}`})=>er(n=>n instanceof t,e),tr=G.create,nr=be.create,xa=hn.create,Na=we.create,rr=vt.create,ka=De.create,Ta=dn.create,Ca=bt.create,Oa=wt.create,Sa=He.create,ja=Re.create,Ia=pe.create,Za=cn.create,Ea=Y.create,$a=M.create,Aa=M.strictCreate,Pa=xt.create,Da=ln.create,Ra=Nt.create,Ma=ae.create,La=kt.create,za=un.create,Ua=Me.create,Fa=Ye.create,Va=Tt.create,Ba=Ct.create,Ka=Ne.create,Wa=Ot.create,Ja=Xe.create,ar=X.create,qa=se.create,Qa=ke.create,Ha=X.createWithPreprocess,Ga=It.create;var i=Object.freeze({__proto__:null,defaultErrorMap:Qe,setErrorMap:na,getErrorMap:rn,makeIssue:an,EMPTY_PATH:ra,addIssueToContext:f,ParseStatus:B,INVALID:T,DIRTY:sn,OK:W,isAborted:kn,isDirty:Tn,isValid:ft,isAsync:_t,get util(){return E},get objectUtil(){return Nn},ZodParsedType:g,getParsedType:ve,ZodType:j,datetimeRegex:Yn,ZodString:G,ZodNumber:be,ZodBigInt:we,ZodBoolean:vt,ZodDate:De,ZodSymbol:dn,ZodUndefined:bt,ZodNull:wt,ZodAny:He,ZodUnknown:Re,ZodNever:pe,ZodVoid:cn,ZodArray:Y,ZodObject:M,ZodUnion:xt,ZodDiscriminatedUnion:ln,ZodIntersection:Nt,ZodTuple:ae,ZodRecord:kt,ZodMap:un,ZodSet:Me,ZodFunction:Ye,ZodLazy:Tt,ZodLiteral:Ct,ZodEnum:Ne,ZodNativeEnum:Ot,ZodPromise:Xe,ZodEffects:X,ZodTransformer:X,ZodOptional:se,ZodNullable:ke,ZodDefault:St,ZodCatch:jt,ZodNaN:hn,BRAND:va,ZodBranded:Sn,ZodPipeline:It,ZodReadonly:Zt,custom:er,Schema:j,ZodSchema:j,late:ba,get ZodFirstPartyTypeKind(){return x},coerce:{string:t=>G.create({...t,coerce:!0}),number:t=>be.create({...t,coerce:!0}),boolean:t=>vt.create({...t,coerce:!0}),bigint:t=>we.create({...t,coerce:!0}),date:t=>De.create({...t,coerce:!0})},any:Sa,array:Ea,bigint:Na,boolean:rr,date:ka,discriminatedUnion:Da,effect:ar,enum:Ka,function:Fa,instanceof:wa,intersection:Ra,lazy:Va,literal:Ba,map:za,nan:xa,nativeEnum:Wa,never:Ia,null:Oa,nullable:Qa,number:nr,object:$a,oboolean:()=>rr().optional(),onumber:()=>nr().optional(),optional:qa,ostring:()=>tr().optional(),pipeline:Ga,preprocess:Ha,promise:Ja,record:La,set:Ua,strictObject:Aa,string:tr,symbol:Ta,transformer:ar,tuple:Ma,undefined:Ca,union:Pa,unknown:ja,void:Za,NEVER:T,ZodIssueCode:h,quotelessJson:ta,ZodError:q});ea(i),i.object({start:i.number(),limit:i.number(),length:i.number()});const jn=i.object({created_at:i.string(),updated_at:i.string()}),Ya=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()),Xa=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:Ya.optional()}),sr=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(),app_metadata:i.any().default({}).optional(),user_metadata:i.any().default({}).optional()}),es=sr.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")});i.object({...es.shape,...jn.shape,user_id:i.string(),email:i.string(),is_social:i.boolean(),login_count:i.number(),identities:i.array(Xa).optional()}),sr.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 ts="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ns=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=ts[n[t]&63];return e};const rs=i.object({audience:i.string().optional(),recipient:i.string().optional(),createUpnClaim:i.boolean().optional(),mapUnknownClaimsAsIs:i.boolean().optional(),passthroughClaimsWithNoMapping:i.boolean().optional(),mapIdentities:i.boolean().optional(),signatureAlgorithm:i.string().optional(),digestAlgorithm:i.string().optional(),issuer:i.string().optional(),destination:i.string().optional(),lifetimeInSeconds:i.number().optional(),signResponse:i.boolean().optional(),nameIdentifierFormat:i.string().optional(),nameIdentifierProbes:i.array(i.string()).optional(),authnContextClassRef:i.string().optional(),mappings:i.record(i.string()).optional()}),as=i.object({id:i.string(),name:i.string(),callbacks:i.array(i.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:i.array(i.string()).default([]).optional().openapi({description:"Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level. Query strings and hash information are not taken into account when validating these URLs."}),web_origins:i.array(i.string()).default([]).optional().openapi({description:"Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode."}),allowed_logout_urls:i.array(i.string()).default([]).optional().openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),allowed_clients:i.array(i.string()).default([]).optional().openapi({description:"Ids of clients that will be allowed to perform delegation requests. Clients that will be allowed to make delegation request. By default, all your clients will be allowed. This field allows you to specify specific clients"}),addons:i.object({samlp:rs.optional()}).default({}).optional().openapi({description:"Addons associated with the client. The key is the addon's package name and the value is an object with the configuration for the addon."}),email_validation:i.enum(["enabled","disabled","enforced"]).default("enforced").optional().openapi({description:"Defines if it possible to sign in with an unverified email and if verification emails will be sent. This is not available in auth0"}),client_secret:i.string().default(()=>ns()).optional(),disable_sign_ups:i.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),ss=i.object({created_at:i.string().transform(t=>t===null?"":t),updated_at:i.string().transform(t=>t===null?"":t),...as.shape});var ir=(t=>(t.TOKEN="token",t.TOKEN_ID_TOKEN="token id_token",t.CODE="code",t))(ir||{}),or=(t=>(t.QUERY="query",t.FRAGMENT="fragment",t.FORM_POST="form_post",t.WEB_MESSAGE="web_message",t.SAML_POST="saml_post",t))(or||{}),dr=(t=>(t.S265="S256",t.plain="plain",t))(dr||{});const is=i.object({client_id:i.string(),vendor_id:i.string().optional(),response_type:i.nativeEnum(ir).optional(),response_mode:i.nativeEnum(or).optional(),redirect_uri:i.string().optional(),audience:i.string().optional(),state:i.string().optional(),nonce:i.string().optional(),scope:i.string().optional(),prompt:i.string().optional(),code_challenge_method:i.nativeEnum(dr).optional(),code_challenge:i.string().optional(),username:i.string().optional(),ui_locales:i.string().optional()});i.object({colors:i.object({primary:i.string(),page_background:i.object({type:i.string().optional(),start:i.string().optional(),end:i.string().optional(),angle_deg:i.number().optional()}).optional()}).optional(),logo_url:i.string().optional(),favicon_url:i.string().optional(),font:i.object({url:i.string()}).optional()});const os=i.object({id:i.string().optional(),name:i.string(),strategy:i.enum(["google-oauth2","facebook","vipps","freja","apple","email","Username-Password-Authentication","oidc","oauth2","custom"]).optional(),options:i.object({kid:i.string().optional(),team_id:i.string().optional(),realms:i.string().optional(),client_id:i.string().optional(),client_secret:i.string().optional(),app_secret:i.string().optional(),scope:i.string().optional(),authorization_endpoint:i.string().default("").optional(),token_endpoint:i.string().default("").optional(),userinfo_endpoint:i.string().default("").optional(),jwks_uri:i.string().default("").optional(),discovery_url:i.string().default("").optional(),issuer:i.string().default("").optional()}).default({}).optional(),enabled_clients:i.array(i.string()).default([]).optional(),response_type:i.custom().optional(),response_mode:i.custom().optional()}),cr=i.object({id:i.string(),created_at:i.string().transform(t=>t===null?"":t),updated_at:i.string().transform(t=>t===null?"":t)}).extend(os.shape),ds=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()}),cs=i.object({created_at:i.string().transform(t=>t===null?"":t),updated_at:i.string().transform(t=>t===null?"":t),id:i.string(),...ds.shape});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()});const ls=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()});i.object({...ss.shape,domains:i.array(ls),tenant:cs,connections:i.array(cr)});const us=i.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),hs=i.object({code_id:i.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:i.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:i.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:us,expires_at:i.string(),used_at:i.string().optional(),user_id:i.string().optional()}),ps=i.object({...hs.shape,created_at:i.string()}),ms=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"])});jn.extend({...ms.shape,id:i.string()}),i.object({trigger_id:i.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:i.boolean().default(!1),url:i.string(),hook_id:i.string().optional(),synchronous:i.boolean().default(!1),priority:i.number().optional()}).extend({...jn.shape,hook_id:i.string()});const fs=i.object({alg:i.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:i.string(),kid:i.string(),kty:i.enum(["RSA","EC","oct"]),n:i.string(),x5t:i.string().optional(),x5c:i.array(i.string()).optional(),use:i.enum(["sig","enc"]).optional()});i.object({keys:i.array(fs)}),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 _s=i.object({auth0Client:i.string().optional(),authParams:is,expires_at:i.string(),deleted_at:i.string().optional(),ip:i.string().optional()}).openapi({description:"This represents a login sesion"}),gs=i.object({..._s.shape,login_id:i.string().openapi({description:"This is is used as the state in the universal login"}),created_at:i.string(),updated_at:i.string()}),ys=i.enum(["cls","fsa","fs","f","fc","fcoa","fcp","fh","fp","fs","fu","s","sapi","scoa","scp","scpr","scu","seacft","serft","slo","ss","ssa","sv","svr"]),vs=i.object({name:i.string(),version:i.string(),env:i.object({node:i.string().optional()}).optional()});i.object({type:ys,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:vs.optional()});const bs=i.object({user_id:i.string(),password:i.string(),algorithm:i.enum(["bcrypt","argon2id"]).default("argon2id")});i.object({...bs.shape,created_at:i.string(),updated_at:i.string()});const ws=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(),...ws.shape}),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 private 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"})});var lr=(t=>(t.RefreshToken="refresh_token",t.AuthorizationCode="authorization_code",t.ClientCredential="client_credentials",t.Passwordless="passwordless",t.Password="password",t))(lr||{});const In=i.nativeEnum(lr);i.object({grant_type:In.refine(t=>t==="authorization_code"),code:i.string(),client_secret:i.string(),client_id:i.string()}),i.object({grant_type:In.refine(t=>t==="authorization_code"),code:i.string(),code_verifier:i.string(),client_id:i.string().optional(),redirect_uri:i.string()}),i.object({grant_type:In.refine(t=>t==="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 xs=i.object({button_border_radius:i.number(),button_border_weight:i.number(),buttons_style:i.enum(["pill"]),input_border_radius:i.number(),input_border_weight:i.number(),inputs_style:i.enum(["pill"]),show_widget_shadow:i.boolean(),widget_border_weight:i.number(),widget_corner_radius:i.number()}),Ns=i.object({base_focus_color:i.string(),base_hover_color:i.string(),body_text:i.string(),captcha_widget_theme:i.enum(["auto"]),error:i.string(),header:i.string(),icons:i.string(),input_background:i.string(),input_border:i.string(),input_filled_text:i.string(),input_labels_placeholders:i.string(),links_focused_components:i.string(),primary_button:i.string(),primary_button_label:i.string(),secondary_button_border:i.string(),secondary_button_label:i.string(),success:i.string(),widget_background:i.string(),widget_border:i.string()}),et=i.object({bold:i.boolean(),size:i.number()}),ks=i.object({body_text:et,buttons_text:et,font_url:i.string(),input_labels:et,links:et,links_style:i.enum(["normal"]),reference_text_size:i.number(),subtitle:et,title:et}),Ts=i.object({background_color:i.string(),background_image_url:i.string(),page_layout:i.enum(["center"])}),Cs=i.object({header_text_alignment:i.enum(["center"]),logo_height:i.number(),logo_position:i.enum(["center"]),logo_url:i.string(),social_buttons_layout:i.enum(["bottom"])});i.object({borders:xs,colors:Ns,displayName:i.string(),fonts:ks,page_background:Ts,widget:Cs}).extend({themeId:i.string()});const Os=i.object({universal_login_experience:i.enum(["new","classic"]).default("new"),identifier_first:i.boolean().default(!0),password_first:i.boolean().default(!1),webauthn_platform_first_factor:i.boolean()});function Zn(t){const[e,n]=t.split("|");if(!e||!n)throw new Error(`Invalid user_id: ${t}`);return{connection:e,id:n}}function ur(t){let e={};try{e=JSON.parse(t.profileData||"{}")}catch(n){console.error("Error parsing profileData",n)}return{connection:t.connection,provider:t.provider,user_id:Zn(t.user_id).id,isSocial:!!t.is_social,profileData:{email:t.email,email_verified:!!t.email_verified,...e}}}function Ss(t){return async(e,n)=>{const[r,a]=await Promise.all([t.selectFrom("users").where("users.tenant_id","=",e).where("users.user_id","=",n).selectAll().executeTakeFirst(),t.selectFrom("users").where("users.tenant_id","=",e).where("users.linked_to","=",n).selectAll().execute()]);if(!r)return null;const{tenant_id:s,...o}=r,d={...o,email:r.email||"",email_verified:r.email_verified===1,is_social:r.is_social===1,app_metadata:JSON.parse(r.app_metadata),user_metadata:JSON.parse(r.user_metadata),identities:[{connection:r.connection,provider:r.provider,user_id:Zn(r.user_id).id,isSocial:!!r.is_social},...a.map(ur)]};return R(d)}}function Le(t,e,n,r){return n.split(/\s+/).map(s=>s.replace(/^([^:]+)=/g,"$1:")).map(s=>{let o=s.startsWith("-"),d,c,l,u;return s.startsWith("-_exists_:")?(d=s.substring(10),l=!0,o=!0):s.startsWith("_exists_:")?(d=s.substring(9),l=!0,o=!1):s.includes(":")?(o=s.startsWith("-"),[d,c]=o?s.substring(1).split(":"):s.split(":"),l=!1,c.startsWith(">=")?(u=">=",c=c.substring(2)):c.startsWith(">")?(u=">",c=c.substring(1)):c.startsWith("<=")?(console.log("value",c),u="<=",c=c.substring(2)):c.startsWith("<")?(u="<",c=c.substring(1)):u="="):(d=null,c=s,l=!1),{key:d,value:c,isNegation:o,isExistsQuery:l,operator:u}}).forEach(({key:s,value:o,isNegation:d,isExistsQuery:c,operator:l})=>{if(s)if(c)d?e=e.where(s,"is",null):e=e.where(s,"is not",null);else if(d)switch(l){case">":e=e.where(s,"<=",o);break;case">=":e=e.where(s,"<",o);break;case"<":e=e.where(s,">=",o);break;case"<=":e=e.where(s,">",o);break;default:e=e.where(s,"!=",o)}else e=e.where(s,l,o);else{const{ref:u}=t.dynamic;e=e.where(Z=>Z.or(r.map(z=>Z(u(z),"like",`%${o}%`))))}}),e}function Te(t){return typeof t=="string"?parseInt(t,10):typeof t=="bigint"?Number(t):t}function js(t){return async(e,n)=>{let r=t.selectFrom("users").where("users.tenant_id","=",e);if(n.q&&(r=Le(t,r,n.q,["email","name"])),n.sort&&n.sort.sort_by){const{ref:u}=t.dynamic;r=r.orderBy(u(n.sort.sort_by),n.sort.sort_order)}const s=await r.offset(n.page*n.per_page).limit(n.per_page).selectAll().execute(),o=s.map(u=>u.user_id),d=o.length?await t.selectFrom("users").selectAll().where("users.tenant_id","=",e).where("users.linked_to","in",o).execute():[],c=s.map(u=>{const Z=d.filter(z=>z.linked_to===u.user_id);return R({...u,email_verified:u.email_verified===1,is_social:u.is_social===1,app_metadata:JSON.parse(u.app_metadata),user_metadata:JSON.parse(u.user_metadata),identities:[{connection:u.connection,provider:u.provider,user_id:Zn(u.user_id).id,isSocial:!!u.is_social},...Z.map(ur)]})}),{count:l}=await r.select(u=>u.fn.countAll().as("count")).executeTakeFirstOrThrow();return{users:c,start:n.page*n.per_page,limit:n.per_page,length:Te(l)}}}function Is(t){return async(e,n)=>(await t.deleteFrom("users").where("users.tenant_id","=",e).where("users.linked_to","=",n).execute(),(await t.deleteFrom("users").where("users.tenant_id","=",e).where("users.user_id","=",n).execute()).length===1)}function Zs(t){if(t.email_verified!==void 0)return t.email_verified?1:0}function Es(t){return async(e,n,r)=>{const a={...r,email_verified:Zs(r),updated_at:new Date().toISOString()};return r.app_metadata&&(a.app_metadata=JSON.stringify(r.app_metadata)),r.user_metadata&&(a.user_metadata=JSON.stringify(r.user_metadata)),(await t.updateTable("users").set(a).where("users.tenant_id","=",e).where("users.user_id","=",n).execute()).length===1}}function $s(t){return async(e,n,r,a)=>{const s={linked_to:null};return(await t.updateTable("users").set(s).where("users.tenant_id","=",e).where("users.user_id","=",`${r}|${a}`).where("users.linked_to","=",`${n}`).execute()).length===1}}function As(t){return{create:U(t),remove:Is(t),get:Ss(t),list:js(t),update:Es(t),unlink:$s(t)}}const Ps="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ze=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=Ps[n[t]&63];return e};function Ds(t){return async e=>{const n={id:e.id||ze(),created_at:new Date().toISOString(),updated_at:new Date().toISOString(),...e};return await t.insertInto("tenants").values(n).execute(),n}}function Rs(t){return async e=>{const n=await t.selectFrom("tenants").where("tenants.id","=",e).selectAll().executeTakeFirst();return n?R(n):null}}function Ms(t){return async e=>{let n=t.selectFrom("tenants");if(e.sort&&e.sort.sort_by){const{ref:d}=t.dynamic;n=n.orderBy(d(e.sort.sort_by),e.sort.sort_order)}e.q&&(n=n.where(d=>d.or([d("name","like",`%${e.q}%`)])));const a=await n.offset(e.page*e.per_page).limit(e.per_page).selectAll().execute();if(!e.include_totals)return{tenants:a};const{count:s}=await n.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow(),o=Te(s);return{tenants:a.map(R),start:(e.page-1)*e.per_page,limit:e.per_page,length:o}}}function Ls(t){return async(e,n)=>{const r={...n,id:e,updated_at:new Date().toISOString()};await t.updateTable("tenants").set(r).where("id","=",e).execute()}}function zs(t){return async e=>(await t.deleteFrom("tenants").where("tenants.id","=",e).execute()).length===1}function Us(t){return{create:Ds(t),get:Rs(t),list:Ms(t),update:Ls(t),remove:zs(t)}}function hr(t){return t?JSON.stringify(t):void 0}const Fs=1024;function Vs(t){return async(e,n)=>{var a,s,o;const r={id:ze(),...n,user_agent:n.user_agent.slice(0,Fs)};return await t.insertInto("logs").values({...r,description:(a=r.description)==null?void 0:a.substring(0,256),isMobile:n.isMobile?1:0,tenant_id:e,scope:(s=n.scope)==null?void 0:s.join(","),auth0_client:hr(n.auth0_client),details:(o=hr(n.details))==null?void 0:o.substring(0,8192)}).execute(),r}}function pr(t){if(!t)return"";try{return JSON.parse(t)}catch{return t}}function mr(t){return{...t,client_id:t.client_id,client_name:"",auth0_client:pr(t.auth0_client),details:pr(t.details),isMobile:!!t.isMobile,scope:t.scope?t.scope.split(","):void 0,log_id:t.id,_id:t.id}}function Bs(t){return async(e,n)=>{let r=t.selectFrom("logs").where("logs.tenant_id","=",e);n.q&&(r=Le(t,r,n.q,["user_id","ip"]));let a=r;if(n.sort&&n.sort.sort_by){const{ref:d}=t.dynamic;a=a.orderBy(d(n.sort.sort_by),n.sort.sort_order)}a=a.offset(n.page*n.per_page).limit(n.per_page);const s=await a.selectAll().execute(),{count:o}=await r.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow();return{logs:s.map(mr),start:n.page*n.per_page,limit:n.per_page,length:Te(o)}}}function Ks(t){return async(e,n)=>{const r=await t.selectFrom("logs").where("logs.tenant_id","=",e).where("logs.id","=",n).selectAll().executeTakeFirst();return r?mr(r):null}}function Ws(t){return{create:Vs(t),list:Bs(t),get:Ks(t)}}function Js(t){return async(e,n)=>await t.selectFrom("sessions").where("sessions.tenant_id","=",e).where("sessions.session_id","=",n).where("sessions.deleted_at","is",null).selectAll().executeTakeFirst()??null}function qs(t){return async(e,n)=>{const r={...n,created_at:new Date().toISOString(),expires_at:new Date().toISOString()};return await t.insertInto("sessions").values({...r,tenant_id:e}).execute(),{...n,...r}}}function Qs(t){return async(e,n)=>!!(await t.updateTable("sessions").set({deleted_at:new Date().toISOString()}).where("tenant_id","=",e).where("sessions.session_id","=",n).where("sessions.deleted_at","is",null).execute()).length}function Hs(t){return async(e,n,r)=>!!(await t.updateTable("sessions").set(r).where("tenant_id","=",e).where("sessions.session_id","=",n).where("sessions.deleted_at","is",null).execute()).length}function Gs(t){return async(e,n)=>{let r=t.selectFrom("sessions").where("sessions.tenant_id","=",e);n.q&&(r=Le(t,r,n.q,["user_id","session_id"]));let a=r;if(n.sort&&n.sort.sort_by){const{ref:c}=t.dynamic;a=a.orderBy(c(n.sort.sort_by),n.sort.sort_order)}a=a.offset(n.page*n.per_page).limit(n.per_page);const s=await a.selectAll().execute(),{count:o}=await r.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow(),d=Te(o);return{sessions:s,start:n.page*n.per_page,limit:n.per_page,length:d}}}function Ys(t){return{create:qs(t),get:Js(t),list:Gs(t),remove:Qs(t),update:Hs(t)}}function Xs(t){return async(e,n)=>{const r=await t.selectFrom("tickets").where("tickets.tenant_id","=",e).where("tickets.id","=",n).where("tickets.used_at","is",null).selectAll().executeTakeFirst();if(!r)return null;const{nonce:a,state:s,scope:o,response_type:d,response_mode:c,redirect_uri:l,...u}=r;return{...u,authParams:{nonce:a,state:s,scope:o,response_type:d,response_mode:c,redirect_uri:l},created_at:new Date(r.created_at),expires_at:new Date(r.expires_at),used_at:r.used_at?new Date(r.used_at):void 0}}}function ei(t){return async e=>{const{authParams:n,...r}=e,a={...r,...n,created_at:e.created_at.toISOString(),expires_at:e.expires_at.toISOString(),used_at:e.used_at?e.used_at.toISOString():void 0};await t.insertInto("tickets").values(a).execute()}}function ti(t){return async(e,n)=>{await t.updateTable("tickets").set({used_at:new Date().toISOString()}).where("tickets.tenant_id","=",e).where("tickets.id","=",n).execute()}}function ni(t){return{create:ei(t),get:Xs(t),remove:ti(t)}}function ri(t){return async(e,n)=>{const r=await t.selectFrom("passwords").where("passwords.tenant_id","=",e).where("passwords.user_id","=",n).selectAll().executeTakeFirstOrThrow(),{tenant_id:a,...s}=r;return s}}function ai(t){return async(e,n)=>{const r={...n,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await t.insertInto("passwords").values({...r,tenant_id:e}).execute(),r}}function si(t){return async(e,n)=>(await t.updateTable("passwords").set({password:n.password,updated_at:new Date().toISOString()}).where("tenant_id","=",e).where("user_id","=",n.user_id).execute()).length===1}function ii(t){return{create:ai(t),update:si(t),get:ri(t)}}function oi(t){return async(e,n)=>{let r=t.selectFrom("codes").where("codes.tenant_id","=",e);n.q&&(r=Le(t,r,n.q,["code","login_id"]));const s=await r.offset(n.page*n.per_page).limit(n.per_page).selectAll().execute(),{count:o}=await r.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{codes:s.map(c=>{const{tenant_id:l,...u}=c;return ps.parse(R(u))}),start:n.page*n.per_page,limit:n.per_page,length:Te(o)}}}function di(t){return async(e,n)=>{const r={...n,created_at:new Date().toISOString()};return await t.insertInto("codes").values({...r,tenant_id:e}).execute(),r}}function ci(t){return async(e,n)=>(await t.deleteFrom("codes").where("codes.tenant_id","=",e).where("codes.code_id","=",n).executeTakeFirst()).numDeletedRows>0}function li(t){return async(e,n,r)=>{let a=t.selectFrom("codes").where("codes.code_id","=",n).where("codes.code_type","=",r).where("codes.expires_at",">",new Date().toISOString());e.length&&(a=a.where("codes.tenant_id","=",e));const s=await a.selectAll().executeTakeFirst();return s?R(s):null}}function ui(t){return{create:di(t),list:oi(t),remove:ci(t),get:li(t)}}function hi(t){return async(e,n)=>{const r={created_at:new Date().toISOString(),updated_at:new Date().toISOString(),...n},a=JSON.stringify(n.allowed_origins),s=JSON.stringify(n.callbacks),o=JSON.stringify(n.web_origins),d=JSON.stringify(n.allowed_logout_urls),c=JSON.stringify(n.allowed_clients);return await t.insertInto("applications").values({...r,tenant_id:e,disable_sign_ups:n.disable_sign_ups?1:0,addons:n.addons?JSON.stringify(n.addons):"{}",callbacks:s,allowed_origins:a,web_origins:o,allowed_logout_urls:d,allowed_clients:c}).execute(),r}}function pi(t){return async e=>({applications:(await t.selectFrom("applications").where("applications.tenant_id","=",e).selectAll().execute()).map(s=>({...s,disable_sign_ups:!!s.disable_sign_ups,addons:s.addons?JSON.parse(s.addons):{},callbacks:s.callbacks?JSON.parse(s.callbacks):[],allowed_origins:s.allowed_origins?JSON.parse(s.allowed_origins):[],web_origins:s.web_origins?JSON.parse(s.web_origins):[],allowed_logout_urls:s.allowed_logout_urls?JSON.parse(s.allowed_logout_urls):[],allowed_clients:s.allowed_logout_urls?JSON.parse(s.allowed_logout_urls):[]}))})}function mi(t){return async(e,n)=>{const r=await t.selectFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",n).selectAll().executeTakeFirst();return r?R({...r,disable_sign_ups:!!r.disable_sign_ups,addons:JSON.parse(r.addons),callbacks:JSON.parse(r.callbacks),allowed_origins:JSON.parse(r.allowed_origins),web_origins:JSON.parse(r.web_origins),allowed_logout_urls:JSON.parse(r.allowed_logout_urls)}):null}}function fi(t){return async(e,n)=>(await t.deleteFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",n).executeTakeFirst()).numDeletedRows>0}function _i(t){return async(e,n,r)=>{const a={...r,updated_at:new Date().toISOString(),allowed_origins:r.allowed_origins?JSON.stringify(r.allowed_origins):void 0,callbacks:r.callbacks?JSON.stringify(r.callbacks):void 0,web_origins:r.web_origins?JSON.stringify(r.web_origins):void 0,allowed_logout_urls:r.allowed_logout_urls?JSON.stringify(r.allowed_logout_urls):void 0,allowed_clients:r.allowed_clients?JSON.stringify(r.allowed_clients):void 0,addons:r.addons?JSON.stringify(r.addons):"{}",disable_sign_ups:r.disable_sign_ups?1:0};return await t.updateTable("applications").set(a).where("applications.id","=",n).where("applications.tenant_id","=",e).execute(),!0}}function gi(t){return{create:hi(t),list:pi(t),get:mi(t),remove:fi(t),update:_i(t)}}function yi(t){return async(e,n)=>{const r={id:ze(),...n,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await t.insertInto("connections").values({...r,options:JSON.stringify(r.options||{}),tenant_id:e}).execute(),r}}function vi(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(t);a<r.length;a++)e.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(t,r[a])&&(n[r[a]]=t[r[a]]);return n}typeof SuppressedError=="function"&&SuppressedError;function bi(t,e){var n;return((n=t==null?void 0:t._def)===null||n===void 0?void 0:n.typeName)===e}function Et(t,e){const n=t.ZodType.prototype[e];t.ZodType.prototype[e]=function(...r){const a=n.apply(this,r);return a._def.openapi=this._def.openapi,a}}function wi(t){if(typeof t.ZodType.prototype.openapi<"u")return;t.ZodType.prototype.openapi=function(a,s){var o,d,c,l,u,Z;const z=typeof a=="string"?s:a,H=z??{},{param:Ze}=H,dt=vi(H,["param"]),Ee=Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o._internal),typeof a=="string"?{refId:a}:void 0),$e=Object.assign(Object.assign(Object.assign({},(d=this._def.openapi)===null||d===void 0?void 0:d.metadata),dt),!((l=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||l===void 0)&&l.param||Ze?{param:Object.assign(Object.assign({},(Z=(u=this._def.openapi)===null||u===void 0?void 0:u.metadata)===null||Z===void 0?void 0:Z.param),Ze)}:void 0),Ae=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(Ee).length>0?{_internal:Ee}:void 0),Object.keys($e).length>0?{metadata:$e}:void 0)}));if(bi(this,"ZodObject")){const ct=this.extend;Ae.extend=function(...lt){var ce,le,ue,Pe,We,Je;const qe=ct.apply(this,lt);return qe._def.openapi={_internal:{extendedFrom:!((le=(ce=this._def.openapi)===null||ce===void 0?void 0:ce._internal)===null||le===void 0)&&le.refId?{refId:(Pe=(ue=this._def.openapi)===null||ue===void 0?void 0:ue._internal)===null||Pe===void 0?void 0:Pe.refId,schema:this}:(We=this._def.openapi)===null||We===void 0?void 0:We._internal.extendedFrom},metadata:(Je=qe._def.openapi)===null||Je===void 0?void 0:Je.metadata},qe}}return Ae},Et(t,"optional"),Et(t,"nullable"),Et(t,"default"),Et(t,"transform"),Et(t,"refine");const e=t.ZodObject.prototype.deepPartial;t.ZodObject.prototype.deepPartial=function(){const a=this._def.shape(),s=e.apply(this),o=s._def.shape();return Object.entries(o).forEach(([d,c])=>{var l,u;c._def.openapi=(u=(l=a[d])===null||l===void 0?void 0:l._def)===null||u===void 0?void 0:u.openapi}),s._def.openapi=void 0,s};const n=t.ZodObject.prototype.pick;t.ZodObject.prototype.pick=function(...a){const s=n.apply(this,a);return s._def.openapi=void 0,s};const r=t.ZodObject.prototype.omit;t.ZodObject.prototype.omit=function(...a){const s=r.apply(this,a);return s._def.openapi=void 0,s}}new Set(".\\+*[^]$()");var $;(function(t){t.assertEqual=a=>a;function e(a){}t.assertIs=e;function n(a){throw new Error}t.assertNever=n,t.arrayToEnum=a=>{const s={};for(const o of a)s[o]=o;return s},t.getValidEnumValues=a=>{const s=t.objectKeys(a).filter(d=>typeof a[a[d]]!="number"),o={};for(const d of s)o[d]=a[d];return t.objectValues(o)},t.objectValues=a=>t.objectKeys(a).map(function(s){return a[s]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const s=[];for(const o in a)Object.prototype.hasOwnProperty.call(a,o)&&s.push(o);return s},t.find=(a,s)=>{for(const o of a)if(s(o))return o},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&isFinite(a)&&Math.floor(a)===a;function r(a,s=" | "){return a.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}t.joinValues=r,t.jsonStringifyReplacer=(a,s)=>typeof s=="bigint"?s.toString():s})($||($={}));var En;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(En||(En={}));const y=$.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ce=t=>{switch(typeof t){case"undefined":return y.undefined;case"string":return y.string;case"number":return isNaN(t)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(t)?y.array:t===null?y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?y.promise:typeof Map<"u"&&t instanceof Map?y.map:typeof Set<"u"&&t instanceof Set?y.set:typeof Date<"u"&&t instanceof Date?y.date:y.object;default:return y.unknown}},p=$.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"]),xi=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class Q extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const n=e||function(s){return s.message},r={_errors:[]},a=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(a);else if(o.code==="invalid_return_type")a(o.returnTypeError);else if(o.code==="invalid_arguments")a(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let d=r,c=0;for(;c<o.path.length;){const l=o.path[c];c===o.path.length-1?(d[l]=d[l]||{_errors:[]},d[l]._errors.push(n(o))):d[l]=d[l]||{_errors:[]},d=d[l],c++}}};return a(this),r}static assert(e){if(!(e instanceof Q))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,$.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},r=[];for(const a of this.issues)a.path.length>0?(n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(e(a))):r.push(e(a));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Q.create=t=>new Q(t);const tt=(t,e)=>{let n;switch(t.code){case p.invalid_type:t.received===y.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case p.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,$.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:n=`Unrecognized key(s) in object: ${$.joinValues(t.keys,", ")}`;break;case p.invalid_union:n="Invalid input";break;case p.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${$.joinValues(t.options)}`;break;case p.invalid_enum_value:n=`Invalid enum value. Expected ${$.joinValues(t.options)}, received '${t.received}'`;break;case p.invalid_arguments:n="Invalid function arguments";break;case p.invalid_return_type:n="Invalid function return type";break;case p.invalid_date:n="Invalid date";break;case p.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:$.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case p.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case p.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case p.custom:n="Invalid input";break;case p.invalid_intersection_types:n="Intersection results could not be merged";break;case p.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case p.not_finite:n="Number must be finite";break;default:n=e.defaultError,$.assertNever(t)}return{message:n}};let fr=tt;function Ni(t){fr=t}function pn(){return fr}const mn=t=>{const{data:e,path:n,errorMaps:r,issueData:a}=t,s=[...n,...a.path||[]],o={...a,path:s};if(a.message!==void 0)return{...a,path:s,message:a.message};let d="";const c=r.filter(l=>!!l).slice().reverse();for(const l of c)d=l(o,{data:e,defaultError:d}).message;return{...a,path:s,message:d}},ki=[];function _(t,e){const n=pn(),r=mn({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===tt?void 0:tt].filter(a=>!!a)});t.common.issues.push(r)}class K{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const a of n){if(a.status==="aborted")return k;a.status==="dirty"&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const a of n){const s=await a.key,o=await a.value;r.push({key:s,value:o})}return K.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const a of n){const{key:s,value:o}=a;if(s.status==="aborted"||o.status==="aborted")return k;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||a.alwaysSet)&&(r[s.value]=o.value)}return{status:e.value,value:r}}}const k=Object.freeze({status:"aborted"}),nt=t=>({status:"dirty",value:t}),J=t=>({status:"valid",value:t}),$n=t=>t.status==="aborted",An=t=>t.status==="dirty",$t=t=>t.status==="valid",At=t=>typeof Promise<"u"&&t instanceof Promise;function fn(t,e,n,r){if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function _r(t,e,n,r,a){if(typeof e=="function"?t!==e||!a:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}typeof SuppressedError=="function"&&SuppressedError;var w;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(w||(w={}));var Pt,Dt;class ie{constructor(e,n,r,a){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=a}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 gr=(t,e)=>{if($t(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Q(t.common.issues);return this._error=n,this._error}}};function S(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:a}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(o,d)=>{var c,l;const{message:u}=t;return o.code==="invalid_enum_value"?{message:u??d.defaultError}:typeof d.data>"u"?{message:(c=u??r)!==null&&c!==void 0?c:d.defaultError}:o.code!=="invalid_type"?{message:d.defaultError}:{message:(l=u??n)!==null&&l!==void 0?l:d.defaultError}},description:a}}class I{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 Ce(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:Ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new K,ctx:{common:e.parent.common,data:e.data,parsedType:Ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(At(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){var r;const a={common:{issues:[],async:(r=n==null?void 0:n.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ce(e)},s=this._parseSync({data:e,path:a.path,parent:a});return gr(a,s)}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ce(e)},a=this._parse({data:e,path:r.path,parent:r}),s=await(At(a)?a:Promise.resolve(a));return gr(r,s)}refine(e,n){const r=a=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(a):n;return this._refinement((a,s)=>{const o=e(a),d=()=>s.addIssue({code:p.custom,...r(a)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(d(),!1)):o?!0:(d(),!1)})}refinement(e,n){return this._refinement((r,a)=>e(r)?!0:(a.addIssue(typeof n=="function"?n(r,a):n),!1))}_refinement(e){return new ne({schema:this,typeName:N.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return de.create(this,this._def)}nullable(){return Ie.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return te.create(this,this._def)}promise(){return it.create(this,this._def)}or(e){return zt.create([this,e],this._def)}and(e){return Ut.create(this,e,this._def)}transform(e){return new ne({...S(this._def),schema:this,typeName:N.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new Wt({...S(this._def),innerType:this,defaultValue:n,typeName:N.ZodDefault})}brand(){return new Rn({typeName:N.ZodBranded,type:this,...S(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new Jt({...S(this._def),innerType:this,catchValue:n,typeName:N.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return qt.create(this,e)}readonly(){return Qt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ti=/^c[^\s-]{8,}$/i,Ci=/^[0-9a-z]+$/,Oi=/^[0-9A-HJKMNP-TV-Z]{26}$/,Si=/^[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,ji=/^[a-z0-9_-]{21}$/i,Ii=/^[-+]?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)?)??$/,Zi=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ei="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Pn;const $i=/^(?:(?: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])$/,Ai=/^(([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})))$/,Pi=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,yr="((\\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])))",Di=new RegExp(`^${yr}$`);function vr(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Ri(t){return new RegExp(`^${vr(t)}$`)}function br(t){let e=`${yr}T${vr(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Mi(t,e){return!!((e==="v4"||!e)&&$i.test(t)||(e==="v6"||!e)&&Ai.test(t))}class ee extends I{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){const s=this._getOrReturnCtx(e);return _(s,{code:p.invalid_type,expected:y.string,received:s.parsedType}),k}const r=new K;let a;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(a=this._getOrReturnCtx(e,a),_(a,{code:p.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(a=this._getOrReturnCtx(e,a),_(a,{code:p.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=e.data.length>s.value,d=e.data.length<s.value;(o||d)&&(a=this._getOrReturnCtx(e,a),o?_(a,{code:p.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):d&&_(a,{code:p.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")Zi.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"email",code:p.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Pn||(Pn=new RegExp(Ei,"u")),Pn.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"emoji",code:p.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")Si.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"uuid",code:p.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")ji.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"nanoid",code:p.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")Ti.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"cuid",code:p.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")Ci.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"cuid2",code:p.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")Oi.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"ulid",code:p.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),_(a,{validation:"url",code:p.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"regex",code:p.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(a=this._getOrReturnCtx(e,a),_(a,{code:p.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(a=this._getOrReturnCtx(e,a),_(a,{code:p.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(a=this._getOrReturnCtx(e,a),_(a,{code:p.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?br(s).test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{code:p.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?Di.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{code:p.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?Ri(s).test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{code:p.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?Ii.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"duration",code:p.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?Mi(e.data,s.version)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"ip",code:p.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?Pi.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"base64",code:p.invalid_string,message:s.message}),r.dirty()):$.assertNever(s);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(a=>e.test(a),{validation:n,code:p.invalid_string,...w.errToObj(r)})}_addCheck(e){return new ee({...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 n,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(n=e==null?void 0:e.offset)!==null&&n!==void 0?n:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!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,n){return this._addCheck({kind:"regex",regex:e,...w.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...w.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...w.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...w.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...w.errToObj(n)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new ee({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ee({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ee({...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 n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}ee.create=t=>{var e;return new ee({checks:[],typeName:N.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...S(t)})};function Li(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,a=n>r?n:r,s=parseInt(t.toFixed(a).replace(".","")),o=parseInt(e.toFixed(a).replace(".",""));return s%o/Math.pow(10,a)}class Oe extends I{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)!==y.number){const s=this._getOrReturnCtx(e);return _(s,{code:p.invalid_type,expected:y.number,received:s.parsedType}),k}let r;const a=new K;for(const s of this._def.checks)s.kind==="int"?$.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{code:p.invalid_type,expected:"integer",received:"float",message:s.message}),a.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),_(r,{code:p.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),a.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),_(r,{code:p.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),a.dirty()):s.kind==="multipleOf"?Li(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),_(r,{code:p.not_multiple_of,multipleOf:s.value,message:s.message}),a.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{code:p.not_finite,message:s.message}),a.dirty()):$.assertNever(s);return{status:a.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,w.toString(n))}gt(e,n){return this.setLimit("min",e,!1,w.toString(n))}lte(e,n){return this.setLimit("max",e,!0,w.toString(n))}lt(e,n){return this.setLimit("max",e,!1,w.toString(n))}setLimit(e,n,r,a){return new Oe({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:w.toString(a)}]})}_addCheck(e){return new Oe({...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,n){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(n)})}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 n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&$.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}}Oe.create=t=>new Oe({checks:[],typeName:N.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...S(t)});class Se extends I{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)!==y.bigint){const s=this._getOrReturnCtx(e);return _(s,{code:p.invalid_type,expected:y.bigint,received:s.parsedType}),k}let r;const a=new K;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),_(r,{code:p.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),a.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),_(r,{code:p.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),a.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),_(r,{code:p.not_multiple_of,multipleOf:s.value,message:s.message}),a.dirty()):$.assertNever(s);return{status:a.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,w.toString(n))}gt(e,n){return this.setLimit("min",e,!1,w.toString(n))}lte(e,n){return this.setLimit("max",e,!0,w.toString(n))}lt(e,n){return this.setLimit("max",e,!1,w.toString(n))}setLimit(e,n,r,a){return new Se({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:w.toString(a)}]})}_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,n){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}Se.create=t=>{var e;return new Se({checks:[],typeName:N.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...S(t)})};class Rt extends I{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){const r=this._getOrReturnCtx(e);return _(r,{code:p.invalid_type,expected:y.boolean,received:r.parsedType}),k}return J(e.data)}}Rt.create=t=>new Rt({typeName:N.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...S(t)});class Ue extends I{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){const s=this._getOrReturnCtx(e);return _(s,{code:p.invalid_type,expected:y.date,received:s.parsedType}),k}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return _(s,{code:p.invalid_date}),k}const r=new K;let a;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(a=this._getOrReturnCtx(e,a),_(a,{code:p.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(a=this._getOrReturnCtx(e,a),_(a,{code:p.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):$.assertNever(s);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ue({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}Ue.create=t=>new Ue({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:N.ZodDate,...S(t)});class _n extends I{_parse(e){if(this._getType(e)!==y.symbol){const r=this._getOrReturnCtx(e);return _(r,{code:p.invalid_type,expected:y.symbol,received:r.parsedType}),k}return J(e.data)}}_n.create=t=>new _n({typeName:N.ZodSymbol,...S(t)});class Mt extends I{_parse(e){if(this._getType(e)!==y.undefined){const r=this._getOrReturnCtx(e);return _(r,{code:p.invalid_type,expected:y.undefined,received:r.parsedType}),k}return J(e.data)}}Mt.create=t=>new Mt({typeName:N.ZodUndefined,...S(t)});class Lt extends I{_parse(e){if(this._getType(e)!==y.null){const r=this._getOrReturnCtx(e);return _(r,{code:p.invalid_type,expected:y.null,received:r.parsedType}),k}return J(e.data)}}Lt.create=t=>new Lt({typeName:N.ZodNull,...S(t)});class rt extends I{constructor(){super(...arguments),this._any=!0}_parse(e){return J(e.data)}}rt.create=t=>new rt({typeName:N.ZodAny,...S(t)});class Fe extends I{constructor(){super(...arguments),this._unknown=!0}_parse(e){return J(e.data)}}Fe.create=t=>new Fe({typeName:N.ZodUnknown,...S(t)});class me extends I{_parse(e){const n=this._getOrReturnCtx(e);return _(n,{code:p.invalid_type,expected:y.never,received:n.parsedType}),k}}me.create=t=>new me({typeName:N.ZodNever,...S(t)});class gn extends I{_parse(e){if(this._getType(e)!==y.undefined){const r=this._getOrReturnCtx(e);return _(r,{code:p.invalid_type,expected:y.void,received:r.parsedType}),k}return J(e.data)}}gn.create=t=>new gn({typeName:N.ZodVoid,...S(t)});class te extends I{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),a=this._def;if(n.parsedType!==y.array)return _(n,{code:p.invalid_type,expected:y.array,received:n.parsedType}),k;if(a.exactLength!==null){const o=n.data.length>a.exactLength.value,d=n.data.length<a.exactLength.value;(o||d)&&(_(n,{code:o?p.too_big:p.too_small,minimum:d?a.exactLength.value:void 0,maximum:o?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&n.data.length<a.minLength.value&&(_(n,{code:p.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&n.data.length>a.maxLength.value&&(_(n,{code:p.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,d)=>a.type._parseAsync(new ie(n,o,n.path,d)))).then(o=>K.mergeArray(r,o));const s=[...n.data].map((o,d)=>a.type._parseSync(new ie(n,o,n.path,d)));return K.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new te({...this._def,minLength:{value:e,message:w.toString(n)}})}max(e,n){return new te({...this._def,maxLength:{value:e,message:w.toString(n)}})}length(e,n){return new te({...this._def,exactLength:{value:e,message:w.toString(n)}})}nonempty(e){return this.min(1,e)}}te.create=(t,e)=>new te({type:t,minLength:null,maxLength:null,exactLength:null,typeName:N.ZodArray,...S(e)});function at(t){if(t instanceof L){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=de.create(at(r))}return new L({...t._def,shape:()=>e})}else return t instanceof te?new te({...t._def,type:at(t.element)}):t instanceof de?de.create(at(t.unwrap())):t instanceof Ie?Ie.create(at(t.unwrap())):t instanceof oe?oe.create(t.items.map(e=>at(e))):t}class L extends I{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(),n=$.objectKeys(e);return this._cached={shape:e,keys:n}}_parse(e){if(this._getType(e)!==y.object){const l=this._getOrReturnCtx(e);return _(l,{code:p.invalid_type,expected:y.object,received:l.parsedType}),k}const{status:r,ctx:a}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),d=[];if(!(this._def.catchall instanceof me&&this._def.unknownKeys==="strip"))for(const l in a.data)o.includes(l)||d.push(l);const c=[];for(const l of o){const u=s[l],Z=a.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new ie(a,Z,a.path,l)),alwaysSet:l in a.data})}if(this._def.catchall instanceof me){const l=this._def.unknownKeys;if(l==="passthrough")for(const u of d)c.push({key:{status:"valid",value:u},value:{status:"valid",value:a.data[u]}});else if(l==="strict")d.length>0&&(_(a,{code:p.unrecognized_keys,keys:d}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const u of d){const Z=a.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new ie(a,Z,a.path,u)),alwaysSet:u in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const l=[];for(const u of c){const Z=await u.key,z=await u.value;l.push({key:Z,value:z,alwaysSet:u.alwaysSet})}return l}).then(l=>K.mergeObjectSync(r,l)):K.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new L({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{var a,s,o,d;const c=(o=(s=(a=this._def).errorMap)===null||s===void 0?void 0:s.call(a,n,r).message)!==null&&o!==void 0?o:r.defaultError;return n.code==="unrecognized_keys"?{message:(d=w.errToObj(e).message)!==null&&d!==void 0?d:c}:{message:c}}}:{}})}strip(){return new L({...this._def,unknownKeys:"strip"})}passthrough(){return new L({...this._def,unknownKeys:"passthrough"})}extend(e){return new L({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new L({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:N.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new L({...this._def,catchall:e})}pick(e){const n={};return $.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new L({...this._def,shape:()=>n})}omit(e){const n={};return $.objectKeys(this.shape).forEach(r=>{e[r]||(n[r]=this.shape[r])}),new L({...this._def,shape:()=>n})}deepPartial(){return at(this)}partial(e){const n={};return $.objectKeys(this.shape).forEach(r=>{const a=this.shape[r];e&&!e[r]?n[r]=a:n[r]=a.optional()}),new L({...this._def,shape:()=>n})}required(e){const n={};return $.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof de;)s=s._def.innerType;n[r]=s}}),new L({...this._def,shape:()=>n})}keyof(){return wr($.objectKeys(this.shape))}}L.create=(t,e)=>new L({shape:()=>t,unknownKeys:"strip",catchall:me.create(),typeName:N.ZodObject,...S(e)}),L.strictCreate=(t,e)=>new L({shape:()=>t,unknownKeys:"strict",catchall:me.create(),typeName:N.ZodObject,...S(e)}),L.lazycreate=(t,e)=>new L({shape:t,unknownKeys:"strip",catchall:me.create(),typeName:N.ZodObject,...S(e)});class zt extends I{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function a(s){for(const d of s)if(d.result.status==="valid")return d.result;for(const d of s)if(d.result.status==="dirty")return n.common.issues.push(...d.ctx.common.issues),d.result;const o=s.map(d=>new Q(d.ctx.common.issues));return _(n,{code:p.invalid_union,unionErrors:o}),k}if(n.common.async)return Promise.all(r.map(async s=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(a);{let s;const o=[];for(const c of r){const l={...n,common:{...n.common,issues:[]},parent:null},u=c._parseSync({data:n.data,path:n.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!s&&(s={result:u,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const d=o.map(c=>new Q(c));return _(n,{code:p.invalid_union,unionErrors:d}),k}}get options(){return this._def.options}}zt.create=(t,e)=>new zt({options:t,typeName:N.ZodUnion,...S(e)});const fe=t=>t instanceof Vt?fe(t.schema):t instanceof ne?fe(t.innerType()):t instanceof Bt?[t.value]:t instanceof je?t.options:t instanceof Kt?$.objectValues(t.enum):t instanceof Wt?fe(t._def.innerType):t instanceof Mt?[void 0]:t instanceof Lt?[null]:t instanceof de?[void 0,...fe(t.unwrap())]:t instanceof Ie?[null,...fe(t.unwrap())]:t instanceof Rn||t instanceof Qt?fe(t.unwrap()):t instanceof Jt?fe(t._def.innerType):[];class yn extends I{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.object)return _(n,{code:p.invalid_type,expected:y.object,received:n.parsedType}),k;const r=this.discriminator,a=n.data[r],s=this.optionsMap.get(a);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(_(n,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),k)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){const a=new Map;for(const s of n){const o=fe(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const d of o){if(a.has(d))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(d)}`);a.set(d,s)}}return new yn({typeName:N.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:a,...S(r)})}}function Dn(t,e){const n=Ce(t),r=Ce(e);if(t===e)return{valid:!0,data:t};if(n===y.object&&r===y.object){const a=$.objectKeys(e),s=$.objectKeys(t).filter(d=>a.indexOf(d)!==-1),o={...t,...e};for(const d of s){const c=Dn(t[d],e[d]);if(!c.valid)return{valid:!1};o[d]=c.data}return{valid:!0,data:o}}else if(n===y.array&&r===y.array){if(t.length!==e.length)return{valid:!1};const a=[];for(let s=0;s<t.length;s++){const o=t[s],d=e[s],c=Dn(o,d);if(!c.valid)return{valid:!1};a.push(c.data)}return{valid:!0,data:a}}else return n===y.date&&r===y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Ut extends I{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),a=(s,o)=>{if($n(s)||$n(o))return k;const d=Dn(s.value,o.value);return d.valid?((An(s)||An(o))&&n.dirty(),{status:n.value,value:d.data}):(_(r,{code:p.invalid_intersection_types}),k)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>a(s,o)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Ut.create=(t,e,n)=>new Ut({left:t,right:e,typeName:N.ZodIntersection,...S(n)});class oe extends I{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.array)return _(r,{code:p.invalid_type,expected:y.array,received:r.parsedType}),k;if(r.data.length<this._def.items.length)return _(r,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),k;!this._def.rest&&r.data.length>this._def.items.length&&(_(r,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const s=[...r.data].map((o,d)=>{const c=this._def.items[d]||this._def.rest;return c?c._parse(new ie(r,o,r.path,d)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>K.mergeArray(n,o)):K.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new oe({...this._def,rest:e})}}oe.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new oe({items:t,typeName:N.ZodTuple,rest:null,...S(e)})};class Ft extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.object)return _(r,{code:p.invalid_type,expected:y.object,received:r.parsedType}),k;const a=[],s=this._def.keyType,o=this._def.valueType;for(const d in r.data)a.push({key:s._parse(new ie(r,d,r.path,d)),value:o._parse(new ie(r,r.data[d],r.path,d)),alwaysSet:d in r.data});return r.common.async?K.mergeObjectAsync(n,a):K.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof I?new Ft({keyType:e,valueType:n,typeName:N.ZodRecord,...S(r)}):new Ft({keyType:ee.create(),valueType:e,typeName:N.ZodRecord,...S(n)})}}class vn extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.map)return _(r,{code:p.invalid_type,expected:y.map,received:r.parsedType}),k;const a=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([d,c],l)=>({key:a._parse(new ie(r,d,r.path,[l,"key"])),value:s._parse(new ie(r,c,r.path,[l,"value"]))}));if(r.common.async){const d=new Map;return Promise.resolve().then(async()=>{for(const c of o){const l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return k;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),d.set(l.value,u.value)}return{status:n.value,value:d}})}else{const d=new Map;for(const c of o){const l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return k;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),d.set(l.value,u.value)}return{status:n.value,value:d}}}}vn.create=(t,e,n)=>new vn({valueType:e,keyType:t,typeName:N.ZodMap,...S(n)});class Ve extends I{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.set)return _(r,{code:p.invalid_type,expected:y.set,received:r.parsedType}),k;const a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(_(r,{code:p.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(_(r,{code:p.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty());const s=this._def.valueType;function o(c){const l=new Set;for(const u of c){if(u.status==="aborted")return k;u.status==="dirty"&&n.dirty(),l.add(u.value)}return{status:n.value,value:l}}const d=[...r.data.values()].map((c,l)=>s._parse(new ie(r,c,r.path,l)));return r.common.async?Promise.all(d).then(c=>o(c)):o(d)}min(e,n){return new Ve({...this._def,minSize:{value:e,message:w.toString(n)}})}max(e,n){return new Ve({...this._def,maxSize:{value:e,message:w.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}Ve.create=(t,e)=>new Ve({valueType:t,minSize:null,maxSize:null,typeName:N.ZodSet,...S(e)});class st extends I{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.function)return _(n,{code:p.invalid_type,expected:y.function,received:n.parsedType}),k;function r(d,c){return mn({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,pn(),tt].filter(l=>!!l),issueData:{code:p.invalid_arguments,argumentsError:c}})}function a(d,c){return mn({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,pn(),tt].filter(l=>!!l),issueData:{code:p.invalid_return_type,returnTypeError:c}})}const s={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof it){const d=this;return J(async function(...c){const l=new Q([]),u=await d._def.args.parseAsync(c,s).catch(H=>{throw l.addIssue(r(c,H)),l}),Z=await Reflect.apply(o,this,u);return await d._def.returns._def.type.parseAsync(Z,s).catch(H=>{throw l.addIssue(a(Z,H)),l})})}else{const d=this;return J(function(...c){const l=d._def.args.safeParse(c,s);if(!l.success)throw new Q([r(c,l.error)]);const u=Reflect.apply(o,this,l.data),Z=d._def.returns.safeParse(u,s);if(!Z.success)throw new Q([a(u,Z.error)]);return Z.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new st({...this._def,args:oe.create(e).rest(Fe.create())})}returns(e){return new st({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new st({args:e||oe.create([]).rest(Fe.create()),returns:n||Fe.create(),typeName:N.ZodFunction,...S(r)})}}class Vt extends I{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Vt.create=(t,e)=>new Vt({getter:t,typeName:N.ZodLazy,...S(e)});class Bt extends I{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return _(n,{received:n.data,code:p.invalid_literal,expected:this._def.value}),k}return{status:"valid",value:e.data}}get value(){return this._def.value}}Bt.create=(t,e)=>new Bt({value:t,typeName:N.ZodLiteral,...S(e)});function wr(t,e){return new je({values:t,typeName:N.ZodEnum,...S(e)})}class je extends I{constructor(){super(...arguments),Pt.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return _(n,{expected:$.joinValues(r),received:n.parsedType,code:p.invalid_type}),k}if(fn(this,Pt)||_r(this,Pt,new Set(this._def.values)),!fn(this,Pt).has(e.data)){const n=this._getOrReturnCtx(e),r=this._def.values;return _(n,{received:n.data,code:p.invalid_enum_value,options:r}),k}return J(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return je.create(e,{...this._def,...n})}exclude(e,n=this._def){return je.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}Pt=new WeakMap,je.create=wr;class Kt extends I{constructor(){super(...arguments),Dt.set(this,void 0)}_parse(e){const n=$.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){const a=$.objectValues(n);return _(r,{expected:$.joinValues(a),received:r.parsedType,code:p.invalid_type}),k}if(fn(this,Dt)||_r(this,Dt,new Set($.getValidEnumValues(this._def.values))),!fn(this,Dt).has(e.data)){const a=$.objectValues(n);return _(r,{received:r.data,code:p.invalid_enum_value,options:a}),k}return J(e.data)}get enum(){return this._def.values}}Dt=new WeakMap,Kt.create=(t,e)=>new Kt({values:t,typeName:N.ZodNativeEnum,...S(e)});class it extends I{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.promise&&n.common.async===!1)return _(n,{code:p.invalid_type,expected:y.promise,received:n.parsedType}),k;const r=n.parsedType===y.promise?n.data:Promise.resolve(n.data);return J(r.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}}it.create=(t,e)=>new it({type:t,typeName:N.ZodPromise,...S(e)});class ne extends I{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===N.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),a=this._def.effect||null,s={addIssue:o=>{_(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),a.type==="preprocess"){const o=a.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async d=>{if(n.value==="aborted")return k;const c=await this._def.schema._parseAsync({data:d,path:r.path,parent:r});return c.status==="aborted"?k:c.status==="dirty"||n.value==="dirty"?nt(c.value):c});{if(n.value==="aborted")return k;const d=this._def.schema._parseSync({data:o,path:r.path,parent:r});return d.status==="aborted"?k:d.status==="dirty"||n.value==="dirty"?nt(d.value):d}}if(a.type==="refinement"){const o=d=>{const c=a.refinement(d,s);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return d};if(r.common.async===!1){const d=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return d.status==="aborted"?k:(d.status==="dirty"&&n.dirty(),o(d.value),{status:n.value,value:d.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(d=>d.status==="aborted"?k:(d.status==="dirty"&&n.dirty(),o(d.value).then(()=>({status:n.value,value:d.value}))))}if(a.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!$t(o))return o;const d=a.transform(o.value,s);if(d instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:d}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>$t(o)?Promise.resolve(a.transform(o.value,s)).then(d=>({status:n.value,value:d})):o);$.assertNever(a)}}ne.create=(t,e,n)=>new ne({schema:t,typeName:N.ZodEffects,effect:e,...S(n)}),ne.createWithPreprocess=(t,e,n)=>new ne({schema:e,effect:{type:"preprocess",transform:t},typeName:N.ZodEffects,...S(n)});class de extends I{_parse(e){return this._getType(e)===y.undefined?J(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}de.create=(t,e)=>new de({innerType:t,typeName:N.ZodOptional,...S(e)});class Ie extends I{_parse(e){return this._getType(e)===y.null?J(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ie.create=(t,e)=>new Ie({innerType:t,typeName:N.ZodNullable,...S(e)});class Wt extends I{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Wt.create=(t,e)=>new Wt({innerType:t,typeName:N.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...S(e)});class Jt extends I{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return At(a)?a.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Q(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Q(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Jt.create=(t,e)=>new Jt({innerType:t,typeName:N.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...S(e)});class bn extends I{_parse(e){if(this._getType(e)!==y.nan){const r=this._getOrReturnCtx(e);return _(r,{code:p.invalid_type,expected:y.nan,received:r.parsedType}),k}return{status:"valid",value:e.data}}}bn.create=t=>new bn({typeName:N.ZodNaN,...S(t)});const zi=Symbol("zod_brand");class Rn extends I{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class qt extends I{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?k:s.status==="dirty"?(n.dirty(),nt(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const a=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?k:a.status==="dirty"?(n.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:r.path,parent:r})}}static create(e,n){return new qt({in:e,out:n,typeName:N.ZodPipeline})}}class Qt extends I{_parse(e){const n=this._def.innerType._parse(e),r=a=>($t(a)&&(a.value=Object.freeze(a.value)),a);return At(n)?n.then(a=>r(a)):r(n)}unwrap(){return this._def.innerType}}Qt.create=(t,e)=>new Qt({innerType:t,typeName:N.ZodReadonly,...S(e)});function xr(t,e={},n){return t?rt.create().superRefine((r,a)=>{var s,o;if(!t(r)){const d=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,c=(o=(s=d.fatal)!==null&&s!==void 0?s:n)!==null&&o!==void 0?o:!0,l=typeof d=="string"?{message:d}:d;a.addIssue({code:"custom",...l,fatal:c})}}):rt.create()}const Ui={object:L.lazycreate};var N;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(N||(N={}));const Fi=(t,e={message:`Input not instance of ${t.name}`})=>xr(n=>n instanceof t,e),Nr=ee.create,kr=Oe.create,Vi=bn.create,Bi=Se.create,Tr=Rt.create,Ki=Ue.create,Wi=_n.create,Ji=Mt.create,qi=Lt.create,Qi=rt.create,Hi=Fe.create,Gi=me.create,Yi=gn.create,Xi=te.create,eo=L.create,to=L.strictCreate,no=zt.create,ro=yn.create,ao=Ut.create,so=oe.create,io=Ft.create,oo=vn.create,co=Ve.create,lo=st.create,uo=Vt.create,ho=Bt.create,po=je.create,mo=Kt.create,fo=it.create,Cr=ne.create,_o=de.create,go=Ie.create,yo=ne.createWithPreprocess,vo=qt.create;var bo=Object.freeze({__proto__:null,defaultErrorMap:tt,setErrorMap:Ni,getErrorMap:pn,makeIssue:mn,EMPTY_PATH:ki,addIssueToContext:_,ParseStatus:K,INVALID:k,DIRTY:nt,OK:J,isAborted:$n,isDirty:An,isValid:$t,isAsync:At,get util(){return $},get objectUtil(){return En},ZodParsedType:y,getParsedType:Ce,ZodType:I,datetimeRegex:br,ZodString:ee,ZodNumber:Oe,ZodBigInt:Se,ZodBoolean:Rt,ZodDate:Ue,ZodSymbol:_n,ZodUndefined:Mt,ZodNull:Lt,ZodAny:rt,ZodUnknown:Fe,ZodNever:me,ZodVoid:gn,ZodArray:te,ZodObject:L,ZodUnion:zt,ZodDiscriminatedUnion:yn,ZodIntersection:Ut,ZodTuple:oe,ZodRecord:Ft,ZodMap:vn,ZodSet:Ve,ZodFunction:st,ZodLazy:Vt,ZodLiteral:Bt,ZodEnum:je,ZodNativeEnum:Kt,ZodPromise:it,ZodEffects:ne,ZodTransformer:ne,ZodOptional:de,ZodNullable:Ie,ZodDefault:Wt,ZodCatch:Jt,ZodNaN:bn,BRAND:zi,ZodBranded:Rn,ZodPipeline:qt,ZodReadonly:Qt,custom:xr,Schema:I,ZodSchema:I,late:Ui,get ZodFirstPartyTypeKind(){return N},coerce:{string:t=>ee.create({...t,coerce:!0}),number:t=>Oe.create({...t,coerce:!0}),boolean:t=>Rt.create({...t,coerce:!0}),bigint:t=>Se.create({...t,coerce:!0}),date:t=>Ue.create({...t,coerce:!0})},any:Qi,array:Xi,bigint:Bi,boolean:Tr,date:Ki,discriminatedUnion:ro,effect:Cr,enum:po,function:lo,instanceof:Fi,intersection:ao,lazy:uo,literal:ho,map:oo,nan:Vi,nativeEnum:mo,never:Gi,null:qi,nullable:go,number:kr,object:eo,oboolean:()=>Tr().optional(),onumber:()=>kr().optional(),optional:_o,ostring:()=>Nr().optional(),pipeline:vo,preprocess:yo,promise:fo,record:io,set:co,strictObject:to,string:Nr,symbol:Wi,transformer:Cr,tuple:so,undefined:Ji,union:no,unknown:Hi,void:Yi,NEVER:k,ZodIssueCode:p,quotelessJson:xi,ZodError:Q});wi(bo);function Ht(t,e="",n={}){for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const a=e?`${e}_${r}`:r;typeof t[r]=="object"&&t[r]!==null&&!Array.isArray(t[r])?Ht(t[r],a,n):n[a]=t[r]}return n}function Or(t,e){const n={};for(const[r,a]of Object.entries(t)){const s=e.find(o=>r.startsWith(`${o}_`));if(!s)n[r]=a;else{const o=r.slice(s.length+1);n[s]={...n[s],[o]:a}}}return n}function wo(t){return async(e,n)=>{let r=t.selectFrom("connections").where("connections.tenant_id","=",e);n.q&&(r=Le(t,r,n.q,["user_id","ip"]));const o=(await r.offset(n.page*n.per_page).limit(n.per_page).selectAll().execute()).map(c=>R(Or(c,["options"]))),{count:d}=await r.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{connections:o,start:n.page*n.per_page,limit:n.per_page,length:Te(d)}}}function xo(t){return async(e,n)=>(await t.deleteFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",n).executeTakeFirst()).numDeletedRows>0}function No(t){return async(e,n)=>{const r=await t.selectFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",n).selectAll().executeTakeFirst();return r?R({...r,options:JSON.parse(r.options)}):null}}function ko(t){return async(e,n,r)=>{const a={...r,updated_at:new Date().toISOString()};return await t.updateTable("connections").set({...a,options:a.options?JSON.stringify(a.options):void 0}).where("connections.id","=",n).where("connections.tenant_id","=",e).execute(),!0}}function To(t){return{create:yi(t),get:No(t),list:wo(t),remove:xo(t),update:ko(t)}}function Co(t){return{get:async e=>{const n=await t.selectFrom("applications").selectAll().where("id","=",e).executeTakeFirst();if(!n)return null;const r=await t.selectFrom("tenants").selectAll().where("id","=",n.tenant_id).executeTakeFirst();if(!r)throw new P(404,{message:"Tenant not found"});const a=await t.selectFrom("connections").where("tenant_id","=",n.tenant_id).selectAll().execute(),s=await t.selectFrom("domains").where("tenant_id","=",n.tenant_id).selectAll().execute();return{...n,connections:a.map(d=>cr.parse(R({...d,options:d.options?JSON.parse(d.options):{}}))),domains:s,addons:n.addons?JSON.parse(n.addons):{},callbacks:n.callbacks?JSON.parse(n.callbacks):[],allowed_origins:n.allowed_origins?JSON.parse(n.allowed_origins):[],web_origins:n.web_origins?JSON.parse(n.web_origins):[],allowed_logout_urls:n.allowed_logout_urls?JSON.parse(n.allowed_logout_urls):[],allowed_clients:n.allowed_clients?JSON.parse(n.allowed_clients):[],tenant:R(r),disable_sign_ups:!!n.disable_sign_ups}}}}function Oo(t){return async()=>await t.selectFrom("keys").where("revoked_at","is",null).selectAll().execute()}function So(t){return async e=>{await t.insertInto("keys").values({...e,created_at:new Date().toDateString()}).execute()}}function jo(t){return async(e,n)=>!!(await t.updateTable("keys").set(n).where("kid","=",e).execute()).length}function Io(t){return{create:So(t),list:Oo(t),update:jo(t)}}function Zo(t){return async(e,n)=>{const r={created_at:new Date().toISOString(),updated_at:new Date().toISOString(),tenant_id:e,id:ze(),...n};return await t.insertInto("domains").values(r).execute(),r}}function Eo(t){return async(e,n)=>{let r=t.selectFrom("domains").where("domains.tenant_id","=",e);n.q&&(r=Le(t,r,n.q,["user_id","ip"]));const s=await r.offset(n.page*n.per_page).limit(n.per_page).selectAll().execute(),{count:o}=await r.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow();return{domains:s,start:n.page*n.per_page,limit:n.per_page,length:Te(o)}}}function $o(t){return{create:Zo(t),list:Eo(t)}}function Ao(t){return async e=>{const[n]=await t.selectFrom("branding").where("branding.tenant_id","=",e).selectAll().execute();if(!n)return null;const{tenant_id:r,colors_primary:a,colors_page_background_type:s,colors_page_background_start:o,colors_page_background_end:d,colors_page_background_angle_dev:c,font_url:l,...u}=n;return R({...u,colors:{primary:a,page_background:{type:s,start:o,end:d,angle_deg:c}},font:l?{url:l}:void 0})}}function Po(t){return async(e,n)=>{var o,d,c,l,u,Z,z,H,Ze,dt,Ee,$e,Ae,ct,lt,ce,le,ue;const{colors:r,font:a,...s}=n;try{await t.insertInto("branding").values({...s,colors_primary:r==null?void 0:r.primary,colors_page_background_type:(d=(o=n.colors)==null?void 0:o.page_background)==null?void 0:d.type,colors_page_background_start:(l=(c=n.colors)==null?void 0:c.page_background)==null?void 0:l.start,colors_page_background_end:(Z=(u=n.colors)==null?void 0:u.page_background)==null?void 0:Z.end,colors_page_background_angle_dev:(H=(z=n.colors)==null?void 0:z.page_background)==null?void 0:H.angle_deg,font_url:(Ze=n.font)==null?void 0:Ze.url,tenant_id:e}).execute()}catch{await t.updateTable("branding").set({...s,colors_primary:r==null?void 0:r.primary,colors_page_background_type:(Ee=(dt=n.colors)==null?void 0:dt.page_background)==null?void 0:Ee.type,colors_page_background_start:(Ae=($e=n.colors)==null?void 0:$e.page_background)==null?void 0:Ae.start,colors_page_background_end:(lt=(ct=n.colors)==null?void 0:ct.page_background)==null?void 0:lt.end,colors_page_background_angle_dev:(le=(ce=n.colors)==null?void 0:ce.page_background)==null?void 0:le.angle_deg,font_url:(ue=n.font)==null?void 0:ue.url}).where("tenant_id","=",e).execute()}}}function Do(t){return{get:Ao(t),set:Po(t)}}function Ro(t){return async(e,n)=>{let r=t.selectFrom("hooks").where("hooks.tenant_id","=",e);n.q&&(r=Le(t,r,n.q,["url"]));const s=await r.offset(n.page*n.per_page).limit(n.per_page).selectAll().execute(),{count:o}=await r.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{hooks:s.map(c=>{const{tenant_id:l,enabled:u,synchronous:Z,...z}=c;return R({...z,enabled:!!u,synchronous:!!Z})}),start:n.page*n.per_page,limit:n.per_page,length:Te(o)}}}function Mo(t){return async(e,n)=>{const r=await t.selectFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",n).selectAll().executeTakeFirst();return r?R({...r,enabled:!!r.enabled,synchronous:!!r.synchronous}):null}}function Lo(t){return async(e,n)=>(await t.deleteFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",n).executeTakeFirst()).numDeletedRows>0}function zo(t){return async(e,n)=>{const r={hook_id:ze(),...n,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await t.insertInto("hooks").values({...r,tenant_id:e,enabled:n.enabled?1:0,synchronous:n.synchronous?1:0}).execute(),r}}function Uo(t){return async(e,n,r)=>{const a={...r,updated_at:new Date().toISOString(),enabled:r.enabled!==void 0?r.enabled?1:0:void 0,synchronous:r.enabled!==void 0?r.synchronous?1:0:void 0};return await t.updateTable("hooks").set(a).where("hooks.hook_id","=",n).where("hooks.tenant_id","=",e).execute(),!0}}function Fo(t){return{create:zo(t),get:Mo(t),list:Ro(t),update:Uo(t),remove:Lo(t)}}function Vo(t){return async(e,n)=>{const r={themeId:ze(),...n,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await t.insertInto("themes").values({...Ht(r),tenant_id:e}).execute(),r}}function Bo(t){return async(e,n)=>(await t.deleteFrom("themes").where("themes.tenant_id","=",e).where("themes.theme_id","=",n).executeTakeFirst()).numDeletedRows>0}function Ko(t){return async(e,n)=>{const r=await t.selectFrom("themes").where("themes.tenant_id","=",e).where("themes.theme_id","=",n).selectAll().executeTakeFirst();return r?R(r):null}}function Wo(t){return async(e,n,r)=>{const a=Ht({...r,updated_at:new Date().toISOString()});return await t.updateTable("themes").set(a).where("themes.id","=",n).where("themes.tenant_id","=",e).execute(),!0}}function Jo(t){return{create:Vo(t),get:Ko(t),remove:Bo(t),update:Wo(t)}}function qo(t){return async(e,n)=>{const r=new Date().toISOString(),a=await t.selectFrom("logins").where("logins.expires_at",">",r).where("logins.login_id","=",n).selectAll().executeTakeFirst();return a?gs.parse(Or(R(a),["authParams"])):null}}function Qo(t){return async(e,n)=>{const r={login_id:ze(),...n,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await t.insertInto("logins").values({...Ht(r),tenant_id:e}).execute(),r}}function Ho(t){return async(e,n,r)=>(await t.updateTable("logins").set(Ht(r)).where("logins.login_id","=",n).where("logins.tenant_id","=",e).execute()).length===1}function Go(t){return async(e,n)=>(await t.deleteFrom("logins").where("logins.tenant_id","=",e).where("logins.login_id","=",n).execute()).length>0}function Yo(t){return{create:Qo(t),get:qo(t),update:Ho(t),remove:Go(t)}}function Xo(t){return async e=>{const[n]=await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id","=",e).selectAll().execute();return R({identifier_first:!!(n!=null&&n.identifier_first),password_first:!!(n!=null&&n.password_first),webauthn_platform_first_factor:!!(n!=null&&n.webauthn_platform_first_factor),universal_login_experience:(n==null?void 0:n.universal_login_experience)||"new"})}}function Sr(t){return R({...t,webauthn_platform_first_factor:t.webauthn_platform_first_factor?!!t.webauthn_platform_first_factor:void 0,identifier_first:t.identifier_first?!!t.identifier_first:void 0,password_first:t.password_first?!!t.password_first:void 0,universal_login_experience:t.universal_login_experience})}function ed(t){return async(e,n)=>{try{const r=Os.parse(n);await t.insertInto("prompt_settings").values({...Sr(r),tenant_id:e}).execute()}catch{await t.updateTable("prompt_settings").set(Sr(n)).where("tenant_id","=",e).execute()}}}function td(t){return{get:Xo(t),set:ed(t)}}function nd(t){return t[t.length-1]}function F(t){return Object.freeze(t)}const wn=F({is(t){return t.kind==="IdentifierNode"},create(t){return F({kind:"IdentifierNode",name:t})}}),Mn=F({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return F({kind:"SchemableIdentifierNode",identifier:wn.create(t)})},createWithSchema(t,e){return F({kind:"SchemableIdentifierNode",schema:wn.create(t),identifier:wn.create(e)})}}),rd=F({is(t){return t.kind==="AliasNode"},create(t,e){return F({kind:"AliasNode",node:t,alias:e})}}),Ln=F({is(t){return t.kind==="TableNode"},create(t){return F({kind:"TableNode",table:Mn.create(t)})},createWithSchema(t,e){return F({kind:"TableNode",table:Mn.createWithSchema(t,e)})}});function th(t){return t}class ad{constructor(){Xt(this,"nodeStack",[]);he(this,xn,F({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this)}))}transformNode(e){if(!e)return e;this.nodeStack.push(e);const n=this.transformNodeImpl(e);return this.nodeStack.pop(),F(n)}transformNodeImpl(e){return v(this,xn)[e.kind](e)}transformNodeList(e){return e&&F(e.map(n=>this.transformNode(n)))}transformSelectQuery(e){return{kind:"SelectQueryNode",from:this.transformNode(e.from),selections:this.transformNodeList(e.selections),distinctOn:this.transformNodeList(e.distinctOn),joins:this.transformNodeList(e.joins),groupBy:this.transformNode(e.groupBy),orderBy:this.transformNode(e.orderBy),where:this.transformNode(e.where),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),limit:this.transformNode(e.limit),offset:this.transformNode(e.offset),with:this.transformNode(e.with),having:this.transformNode(e.having),explain:this.transformNode(e.explain),setOperations:this.transformNodeList(e.setOperations),fetch:this.transformNode(e.fetch),top:this.transformNode(e.top)}}transformSelection(e){return{kind:"SelectionNode",selection:this.transformNode(e.selection)}}transformColumn(e){return{kind:"ColumnNode",column:this.transformNode(e.column)}}transformAlias(e){return{kind:"AliasNode",node:this.transformNode(e.node),alias:this.transformNode(e.alias)}}transformTable(e){return{kind:"TableNode",table:this.transformNode(e.table)}}transformFrom(e){return{kind:"FromNode",froms:this.transformNodeList(e.froms)}}transformReference(e){return{kind:"ReferenceNode",column:this.transformNode(e.column),table:this.transformNode(e.table)}}transformAnd(e){return{kind:"AndNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformOr(e){return{kind:"OrNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformValueList(e){return{kind:"ValueListNode",values:this.transformNodeList(e.values)}}transformParens(e){return{kind:"ParensNode",node:this.transformNode(e.node)}}transformJoin(e){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table),on:this.transformNode(e.on)}}transformRaw(e){return{kind:"RawNode",sqlFragments:F([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters)}}transformWhere(e){return{kind:"WhereNode",where:this.transformNode(e.where)}}transformInsertQuery(e){return{kind:"InsertQueryNode",into:this.transformNode(e.into),columns:this.transformNodeList(e.columns),values:this.transformNode(e.values),returning:this.transformNode(e.returning),onConflict:this.transformNode(e.onConflict),onDuplicateKey:this.transformNode(e.onDuplicateKey),with:this.transformNode(e.with),ignore:e.ignore,replace:e.replace,explain:this.transformNode(e.explain),defaultValues:e.defaultValues,top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformValues(e){return{kind:"ValuesNode",values:this.transformNodeList(e.values)}}transformDeleteQuery(e){return{kind:"DeleteQueryNode",from:this.transformNode(e.from),using:this.transformNode(e.using),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),returning:this.transformNode(e.returning),with:this.transformNode(e.with),orderBy:this.transformNode(e.orderBy),limit:this.transformNode(e.limit),explain:this.transformNode(e.explain),top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformReturning(e){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections)}}transformCreateTable(e){return{kind:"CreateTableNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),constraints:this.transformNodeList(e.constraints),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),selectQuery:this.transformNode(e.selectQuery)}}transformColumnDefinition(e){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),references:this.transformNode(e.references),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo),check:this.transformNode(e.check),generated:this.transformNode(e.generated),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists}}transformAddColumn(e){return{kind:"AddColumnNode",column:this.transformNode(e.column)}}transformDropTable(e){return{kind:"DropTableNode",table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e){return{kind:"OrderByNode",items:this.transformNodeList(e.items)}}transformOrderByItem(e){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy),direction:this.transformNode(e.direction)}}transformGroupBy(e){return{kind:"GroupByNode",items:this.transformNodeList(e.items)}}transformGroupByItem(e){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy)}}transformUpdateQuery(e){return{kind:"UpdateQueryNode",table:this.transformNode(e.table),from:this.transformNode(e.from),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),updates:this.transformNodeList(e.updates),returning:this.transformNode(e.returning),with:this.transformNode(e.with),explain:this.transformNode(e.explain),limit:this.transformNode(e.limit),top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformColumnUpdate(e){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column),value:this.transformNode(e.value)}}transformLimit(e){return{kind:"LimitNode",limit:this.transformNode(e.limit)}}transformOffset(e){return{kind:"OffsetNode",offset:this.transformNode(e.offset)}}transformOnConflict(e){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns),constraint:this.transformNode(e.constraint),indexExpression:this.transformNode(e.indexExpression),indexWhere:this.transformNode(e.indexWhere),updates:this.transformNodeList(e.updates),updateWhere:this.transformNode(e.updateWhere),doNothing:e.doNothing}}transformOnDuplicateKey(e){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates)}}transformCreateIndex(e){return{kind:"CreateIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists,where:this.transformNode(e.where),nullsNotDistinct:e.nullsNotDistinct}}transformList(e){return{kind:"ListNode",items:this.transformNodeList(e.items)}}transformDropIndex(e){return{kind:"DropIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformUniqueConstraint(e){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name),nullsNotDistinct:e.nullsNotDistinct}}transformForeignKeyConstraint(e){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns),references:this.transformNode(e.references),name:this.transformNode(e.name),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformSetOperation(e){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression),all:e.all}}transformReferences(e){return{kind:"ReferencesNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression),name:this.transformNode(e.name)}}transformWith(e){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions),recursive:e.recursive}}transformCommonTableExpression(e){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name),materialized:e.materialized,expression:this.transformNode(e.expression)}}transformCommonTableExpressionName(e){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns)}}transformHaving(e){return{kind:"HavingNode",having:this.transformNode(e.having)}}transformCreateSchema(e){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema),ifNotExists:e.ifNotExists}}transformDropSchema(e){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e){return{kind:"AlterTableNode",table:this.transformNode(e.table),renameTo:this.transformNode(e.renameTo),setSchema:this.transformNode(e.setSchema),columnAlterations:this.transformNodeList(e.columnAlterations),addConstraint:this.transformNode(e.addConstraint),dropConstraint:this.transformNode(e.dropConstraint),addIndex:this.transformNode(e.addIndex),dropIndex:this.transformNode(e.dropIndex)}}transformDropColumn(e){return{kind:"DropColumnNode",column:this.transformNode(e.column)}}transformRenameColumn(e){return{kind:"RenameColumnNode",column:this.transformNode(e.column),renameTo:this.transformNode(e.renameTo)}}transformAlterColumn(e){return{kind:"AlterColumnNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),dataTypeExpression:this.transformNode(e.dataTypeExpression),setDefault:this.transformNode(e.setDefault),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e){return{kind:"ModifyColumnNode",column:this.transformNode(e.column)}}transformAddConstraint(e){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint)}}transformDropConstraint(e){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName),ifExists:e.ifExists,modifier:e.modifier}}transformCreateView(e){return{kind:"CreateViewNode",name:this.transformNode(e.name),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns),as:this.transformNode(e.as)}}transformDropView(e){return{kind:"DropViewNode",name:this.transformNode(e.name),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression)}}transformDefaultValue(e){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue)}}transformOn(e){return{kind:"OnNode",on:this.transformNode(e.on)}}transformSelectModifier(e){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier),of:this.transformNodeList(e.of)}}transformCreateType(e){return{kind:"CreateTypeNode",name:this.transformNode(e.name),enum:this.transformNode(e.enum)}}transformDropType(e){return{kind:"DropTypeNode",name:this.transformNode(e.name),ifExists:e.ifExists}}transformExplain(e){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options)}}transformSchemableIdentifier(e){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema),identifier:this.transformNode(e.identifier)}}transformAggregateFunction(e){return{kind:"AggregateFunctionNode",aggregated:this.transformNodeList(e.aggregated),distinct:e.distinct,filter:this.transformNode(e.filter),func:e.func,over:this.transformNode(e.over)}}transformOver(e){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy),partitionBy:this.transformNode(e.partitionBy)}}transformPartitionBy(e){return{kind:"PartitionByNode",items:this.transformNodeList(e.items)}}transformPartitionByItem(e){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy)}}transformBinaryOperation(e){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand),operator:this.transformNode(e.operator),rightOperand:this.transformNode(e.rightOperand)}}transformUnaryOperation(e){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator),operand:this.transformNode(e.operand)}}transformUsing(e){return{kind:"UsingNode",tables:this.transformNodeList(e.tables)}}transformFunction(e){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments)}}transformCase(e){return{kind:"CaseNode",value:this.transformNode(e.value),when:this.transformNodeList(e.when),else:this.transformNode(e.else),isStatement:e.isStatement}}transformWhen(e){return{kind:"WhenNode",condition:this.transformNode(e.condition),result:this.transformNode(e.result)}}transformJSONReference(e){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference),traversal:this.transformNode(e.traversal)}}transformJSONPath(e){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator),pathLegs:this.transformNodeList(e.pathLegs)}}transformJSONPathLeg(e){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator),values:this.transformNodeList(e.values)}}transformTuple(e){return{kind:"TupleNode",values:this.transformNodeList(e.values)}}transformMergeQuery(e){return{kind:"MergeQueryNode",into:this.transformNode(e.into),using:this.transformNode(e.using),whens:this.transformNodeList(e.whens),with:this.transformNode(e.with),top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformMatched(e){return{kind:"MatchedNode",not:e.not,bySource:e.bySource}}transformAddIndex(e){return{kind:"AddIndexNode",name:this.transformNode(e.name),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists}}transformCast(e){return{kind:"CastNode",expression:this.transformNode(e.expression),dataType:this.transformNode(e.dataType)}}transformFetch(e){return{kind:"FetchNode",rowCount:this.transformNode(e.rowCount),modifier:e.modifier}}transformTop(e){return{kind:"TopNode",expression:e.expression,modifiers:e.modifiers}}transformOutput(e){return{kind:"OutputNode",selections:this.transformNodeList(e.selections)}}transformDataType(e){return e}transformSelectAll(e){return e}transformIdentifier(e){return e}transformValue(e){return e}transformPrimitiveValueList(e){return e}transformOperator(e){return e}transformDefaultInsertValue(e){return e}}xn=new WeakMap;const sd=F({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0});class id extends ad{constructor(n){super();he(this,V);he(this,ot);he(this,Be,new Set);he(this,Ke,new Set);en(this,ot,n)}transformNodeImpl(n){if(!C(this,V,Ar).call(this,n))return super.transformNodeImpl(n);const r=C(this,V,Dr).call(this,n);for(const o of r)v(this,Ke).add(o);const a=C(this,V,Pr).call(this,n);for(const o of a)v(this,Be).add(o);const s=super.transformNodeImpl(n);for(const o of a)v(this,Be).delete(o);for(const o of r)v(this,Ke).delete(o);return s}transformSchemableIdentifier(n){const r=super.transformSchemableIdentifier(n);return r.schema||!v(this,Be).has(n.identifier.name)?r:{...r,schema:wn.create(v(this,ot))}}transformReferences(n){const r=super.transformReferences(n);return r.table.table.schema?r:{...r,table:Ln.createWithSchema(v(this,ot),r.table.table.identifier.name)}}}ot=new WeakMap,Be=new WeakMap,Ke=new WeakMap,V=new WeakSet,Ar=function(n){return n.kind in sd},Pr=function(n){const r=new Set;if("name"in n&&n.name&&Mn.is(n.name)&&C(this,V,Vn).call(this,n.name,r),"from"in n&&n.from)for(const a of n.from.froms)C(this,V,ut).call(this,a,r);if("into"in n&&n.into&&C(this,V,ut).call(this,n.into,r),"table"in n&&n.table&&C(this,V,ut).call(this,n.table,r),"joins"in n&&n.joins)for(const a of n.joins)C(this,V,ut).call(this,a.table,r);return"using"in n&&n.using&&C(this,V,ut).call(this,n.using,r),r},Dr=function(n){const r=new Set;return"with"in n&&n.with&&C(this,V,Rr).call(this,n.with,r),r},ut=function(n,r){const a=Ln.is(n)?n:rd.is(n)&&Ln.is(n.node)?n.node:null;a&&C(this,V,Vn).call(this,a.table,r)},Vn=function(n,r){const a=n.identifier.name;!v(this,Be).has(a)&&!v(this,Ke).has(a)&&r.add(a)},Rr=function(n,r){for(const a of n.expressions){const s=a.name.table.table.identifier.name;v(this,Ke).has(s)||r.add(s)}};class od{constructor(e){he(this,Gt);en(this,Gt,new id(e))}transformQuery(e){return v(this,Gt).transformNode(e.node)}async transformResult(e){return e.result}}Gt=new WeakMap;class dd{transformQuery(e){return e.node}async transformResult(e){return e.result}}const cd="kysely_migration",jr="kysely_migration_lock",ld=!1,zn="migration_lock",ud=F({__noMigrations__:!0});class Ir{constructor(e){he(this,m);he(this,D);en(this,D,F(e))}async getMigrations(){const e=await C(this,m,pt).call(this,v(this,m,ge))?await v(this,D).db.withPlugin(v(this,m,ye)).selectFrom(v(this,m,ge)).select(["name","timestamp"]).execute():[];return(await C(this,m,Wn).call(this)).map(({name:r,...a})=>{const s=e.find(o=>o.name===r);return{name:r,migration:a,executedAt:s?new Date(s.timestamp):void 0}})}async migrateToLatest(){return C(this,m,tn).call(this,()=>({direction:"Up",step:1/0}))}async migrateTo(e){return C(this,m,tn).call(this,({migrations:n,executedMigrations:r,pendingMigrations:a})=>{if(e===ud)return{direction:"Down",step:1/0};if(!n.find(d=>d.name===e))throw new Error(`migration "${e}" doesn't exist`);const s=r.indexOf(e),o=a.findIndex(d=>d.name===e);if(s!==-1)return{direction:"Down",step:r.length-s-1};if(o!==-1)return{direction:"Up",step:o+1};throw new Error(`migration "${e}" isn't executed or pending`)})}async migrateUp(){return C(this,m,tn).call(this,()=>({direction:"Up",step:1}))}async migrateDown(){return C(this,m,tn).call(this,()=>({direction:"Down",step:1}))}}D=new WeakMap,m=new WeakSet,tn=async function(e){try{return await C(this,m,Lr).call(this),await C(this,m,Br).call(this,e)}catch(n){return n instanceof Un?n.resultSet:{error:n}}},_e=function(){return v(this,D).migrationTableSchema},ge=function(){return v(this,D).migrationTableName??cd},ht=function(){return v(this,D).migrationLockTableName??jr},Mr=function(){return v(this,D).allowUnorderedMigrations??ld},ye=function(){return v(this,m,_e)?new od(v(this,m,_e)):new dd},Lr=async function(){await C(this,m,zr).call(this),await C(this,m,Ur).call(this),await C(this,m,Fr).call(this),await C(this,m,Vr).call(this)},zr=async function(){if(v(this,m,_e)&&!await C(this,m,Bn).call(this))try{await C(this,m,nn).call(this,v(this,D).db.schema.createSchema(v(this,m,_e)))}catch(e){if(!await C(this,m,Bn).call(this))throw e}},Ur=async function(){if(!await C(this,m,pt).call(this,v(this,m,ge)))try{v(this,m,_e)&&await C(this,m,nn).call(this,v(this,D).db.schema.createSchema(v(this,m,_e))),await C(this,m,nn).call(this,v(this,D).db.schema.withPlugin(v(this,m,ye)).createTable(v(this,m,ge)).addColumn("name","varchar(255)",e=>e.notNull().primaryKey()).addColumn("timestamp","varchar(255)",e=>e.notNull()))}catch(e){if(!await C(this,m,pt).call(this,v(this,m,ge)))throw e}},Fr=async function(){if(!await C(this,m,pt).call(this,v(this,m,ht)))try{await C(this,m,nn).call(this,v(this,D).db.schema.withPlugin(v(this,m,ye)).createTable(v(this,m,ht)).addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("is_locked","integer",e=>e.notNull().defaultTo(0)))}catch(e){if(!await C(this,m,pt).call(this,v(this,m,ht)))throw e}},Vr=async function(){if(!await C(this,m,Kn).call(this))try{await v(this,D).db.withPlugin(v(this,m,ye)).insertInto(v(this,m,ht)).values({id:zn,is_locked:0}).execute()}catch(e){if(!await C(this,m,Kn).call(this))throw e}},Bn=async function(){return(await v(this,D).db.introspection.getSchemas()).some(n=>n.name===v(this,m,_e))},pt=async function(e){const n=v(this,m,_e);return(await v(this,D).db.introspection.getTables({withInternalKyselyTables:!0})).some(a=>a.name===e&&(!n||a.schema===n))},Kn=async function(){return!!await v(this,D).db.withPlugin(v(this,m,ye)).selectFrom(v(this,m,ht)).where("id","=",zn).select("id").executeTakeFirst()},Br=async function(e){const n=v(this,D).db.getExecutor().adapter,r=F({lockTable:v(this,D).migrationLockTableName??jr,lockRowId:zn,lockTableSchema:v(this,D).migrationTableSchema}),a=async s=>{try{await n.acquireMigrationLock(s,r);const o=await C(this,m,Kr).call(this,s);if(o.migrations.length===0)return{results:[]};const{direction:d,step:c}=e(o);return c<=0?{results:[]}:d==="Down"?await C(this,m,Hr).call(this,s,o,c):d==="Up"?await C(this,m,Gr).call(this,s,o,c):{results:[]}}finally{await n.releaseMigrationLock(s,r)}};return n.supportsTransactionalDdl?v(this,D).db.transaction().execute(a):v(this,D).db.connection().execute(a)},Kr=async function(e){const n=await C(this,m,Wn).call(this),r=await C(this,m,Jr).call(this,e);C(this,m,qr).call(this,n,r),v(this,m,Mr)||C(this,m,Qr).call(this,n,r);const a=C(this,m,Wr).call(this,n,r);return F({migrations:n,executedMigrations:r,lastMigration:nd(r),pendingMigrations:a})},Wr=function(e,n){return e.filter(r=>!n.includes(r.name))},Wn=async function(){const e=await v(this,D).provider.getMigrations();return Object.keys(e).sort().map(n=>({...e[n],name:n}))},Jr=async function(e){return(await e.withPlugin(v(this,m,ye)).selectFrom(v(this,m,ge)).select("name").orderBy(["timestamp","name"]).execute()).map(r=>r.name)},qr=function(e,n){for(const r of n)if(!e.some(a=>a.name===r))throw new Error(`corrupted migrations: previously executed migration ${r} is missing`)},Qr=function(e,n){for(let r=0;r<n.length;++r)if(e[r].name!==n[r])throw new Error(`corrupted migrations: expected previously executed migration ${n[r]} to be at index ${r} but ${e[r].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`)},Hr=async function(e,n,r){const a=n.executedMigrations.slice().reverse().slice(0,r).map(o=>n.migrations.find(d=>d.name===o)),s=a.map(o=>({migrationName:o.name,direction:"Down",status:"NotExecuted"}));for(let o=0;o<s.length;++o){const d=a[o];try{d.down&&(await d.down(e),await e.withPlugin(v(this,m,ye)).deleteFrom(v(this,m,ge)).where("name","=",d.name).execute(),s[o]={migrationName:d.name,direction:"Down",status:"Success"})}catch(c){throw s[o]={migrationName:d.name,direction:"Down",status:"Error"},new Un({error:c,results:s})}}return{results:s}},Gr=async function(e,n,r){const s=n.pendingMigrations.slice(0,r).map(o=>({migrationName:o.name,direction:"Up",status:"NotExecuted"}));for(let o=0;o<s.length;o++){const d=n.pendingMigrations[o];try{await d.up(e),await e.withPlugin(v(this,m,ye)).insertInto(v(this,m,ge)).values({name:d.name,timestamp:new Date().toISOString()}).execute(),s[o]={migrationName:d.name,direction:"Up",status:"Success"}}catch(c){throw s[o]={migrationName:d.name,direction:"Up",status:"Error"},new Un({error:c,results:s})}}return{results:s}},nn=async function(e){v(this,D).db.getExecutor().adapter.supportsCreateIfNotExists&&(e=e.ifNotExists()),await e.execute()};class Un extends Error{constructor(n){super();he(this,Yt);en(this,Yt,n)}get resultSet(){return v(this,Yt)}}Yt=new WeakMap;class Zr{constructor(e){Xt(this,"migrations");this.migrations=e}async getMigrations(){return this.migrations}}async function hd(t){await t.schema.createTable("tenants").addColumn("id","varchar(255)",e=>e.primaryKey()).addColumn("name","varchar(255)").addColumn("audience","varchar(255)").addColumn("sender_email","varchar(255)").addColumn("sender_name","varchar(255)").addColumn("language","varchar(255)").addColumn("logo","varchar(255)").addColumn("primary_color","varchar(255)").addColumn("secondary_color","varchar(255)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).execute(),await t.schema.createTable("users").addColumn("user_id","varchar(255)",e=>e.notNull()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("email","varchar(255)",e=>e.notNull()).addColumn("given_name","varchar(255)").addColumn("family_name","varchar(255)").addColumn("nickname","varchar(255)").addColumn("name","varchar(255)").addColumn("picture","varchar(2083)").addColumn("tags","varchar(255)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).addPrimaryKeyConstraint("users_tenants",["user_id","tenant_id"]).addColumn("linked_to","varchar(255)").addForeignKeyConstraint("linked_to_constraint",["linked_to","tenant_id"],"users",["user_id","tenant_id"]).addColumn("last_ip","varchar(255)").addColumn("login_count","integer",e=>e.notNull()).addColumn("last_login","varchar(255)").addColumn("provider","varchar(255)",e=>e.notNull()).addColumn("connection","varchar(255)").addColumn("email_verified","boolean",e=>e.notNull()).addColumn("is_social","boolean",e=>e.notNull()).addColumn("app_metadata","varchar(4096)",e=>e.defaultTo("{}").notNull()).addColumn("user_metadata","varchar(4096)",e=>e.defaultTo("{}").notNull()).addUniqueConstraint("unique_email_provider",["email","provider","tenant_id"]).execute(),await t.schema.createTable("members").addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("sub","varchar(255)").addColumn("email","varchar(255)").addColumn("name","varchar(255)").addColumn("status","varchar(255)").addColumn("role","varchar(255)").addColumn("picture","varchar(2083)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).execute(),await t.schema.createTable("applications").addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("name","varchar(255)",e=>e.notNull()).addColumn("client_secret","varchar(255)").addColumn("allowed_logout_urls","varchar(255)").addColumn("authentication_settings","varchar(255)").addColumn("addons","varchar(4096)",e=>e.notNull().defaultTo("{}")).addColumn("callbacks","varchar(1024)",e=>e.notNull().defaultTo("[]")).addColumn("allowed_origins","varchar(1024)",e=>e.notNull().defaultTo("[]")).addColumn("web_origins","varchar(1024)",e=>e.notNull().defaultTo("[]")).addColumn("allowed_clients","varchar(1024)",e=>e.defaultTo("[]").notNull()).addColumn("options_kid","varchar(32)").addColumn("options_team_id","varchar(32)").addColumn("options_client_id","varchar(128)").addColumn("options_client_secret","varchar(255)").addColumn("options_scope","varchar(255)").addColumn("options_realms","varchar(255)").addColumn("options_app_secret","varchar(1024)").addColumn("email_validation","varchar(255)").addColumn("disable_sign_ups","boolean",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).execute(),await t.schema.createTable("connections").addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("name","varchar(255)",e=>e.notNull()).addColumn("response_type","varchar(255)").addColumn("response_mode","varchar(255)").addColumn("strategy","varchar(64)").addColumn("options","varchar(2048)",e=>e.defaultTo("{}").notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).execute(),await t.schema.createTable("migrations").addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("provider","varchar(255)").addColumn("client_id","varchar(255)").addColumn("origin","varchar(255)").addColumn("domain","varchar(255)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).execute(),await t.schema.createTable("domains").addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("domain","varchar(255)",e=>e.notNull()).addColumn("email_service","varchar(255)").addColumn("email_api_key","varchar(255)").addColumn("dkim_private_key","varchar(2048)").addColumn("dkim_public_key","varchar(2048)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).execute()}async function pd(t){await t.schema.dropTable("domains").execute(),await t.schema.dropTable("members").execute(),await t.schema.dropTable("users").execute(),await t.schema.dropTable("connections").execute(),await t.schema.dropTable("applications").execute(),await t.schema.dropTable("migrations").execute(),await t.schema.dropTable("tenants").execute()}const md=Object.freeze(Object.defineProperty({__proto__:null,down:pd,up:hd},Symbol.toStringTag,{value:"Module"}));async function fd(t){await t.schema.alterTable("tenants").addColumn("support_url","varchar(255)").execute()}async function _d(t){await t.schema.alterTable("tenants").dropColumn("support_url").execute()}const gd=Object.freeze(Object.defineProperty({__proto__:null,down:_d,up:fd},Symbol.toStringTag,{value:"Module"}));async function yd(t){}async function vd(t){}const bd=Object.freeze(Object.defineProperty({__proto__:null,down:vd,up:yd},Symbol.toStringTag,{value:"Module"}));async function wd(t){await t.schema.createTable("logs").addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("category","varchar(255)",e=>e.notNull()).addColumn("tenant_id","varchar(64)").addColumn("user_id","varchar(64)").addForeignKeyConstraint("tenant_id_constraint",["tenant_id"],"tenants",["id"],e=>e.onDelete("cascade")).addColumn("ip","varchar(255)").addColumn("type","varchar(8)",e=>e.notNull()).addColumn("date","varchar(25)",e=>e.notNull()).addColumn("client_id","varchar(255)").addColumn("client_name","varchar(255)").addColumn("user_agent","varchar(255)").addColumn("description","varchar(255)").addColumn("details","varchar(2048)").execute()}async function xd(t){await t.schema.dropTable("logs").execute()}const Nd=Object.freeze(Object.defineProperty({__proto__:null,down:xd,up:wd},Symbol.toStringTag,{value:"Module"}));async function kd(t){}async function Td(t){}const Cd=Object.freeze(Object.defineProperty({__proto__:null,down:Td,up:kd},Symbol.toStringTag,{value:"Module"}));async function Od(t){await t.schema.createTable("sessions").addColumn("session_id","varchar(255)",e=>e.primaryKey()).addColumn("client_id","varchar(255)",e=>e.references("applications.id").onDelete("cascade").notNull()).addColumn("tenant_id","varchar(255)").addColumn("user_id","varchar(255)").addForeignKeyConstraint("user_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").addColumn("deleted_at","varchar(255)").execute(),await t.schema.createTable("tickets").addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("id","varchar(255)",e=>e.primaryKey()).addColumn("client_id","varchar(255)",e=>e.references("applications.id").onDelete("cascade").notNull()).addColumn("email","varchar(255)",e=>e.notNull()).addColumn("nonce","varchar(255)").addColumn("state","varchar(1024)").addColumn("scope","varchar(1024)").addColumn("response_type","varchar(256)").addColumn("response_mode","varchar(256)").addColumn("redirect_uri","varchar(1024)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute(),await t.schema.createTable("otps").addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("id","varchar(255)",e=>e.primaryKey()).addColumn("client_id","varchar(255)",e=>e.references("applications.id").onDelete("cascade").notNull()).addColumn("code","varchar(255)",e=>e.notNull()).addColumn("email","varchar(255)",e=>e.notNull()).addColumn("user_id","varchar(255)").addColumn("send","varchar(255)").addColumn("nonce","varchar(255)").addColumn("state","varchar(1024)").addColumn("scope","varchar(1024)").addColumn("response_type","varchar(256)").addColumn("response_mode","varchar(256)").addColumn("redirect_uri","varchar(1024)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute(),await t.schema.createIndex("otps_email_index").on("otps").column("email").execute(),await t.schema.createIndex("otps_expires_at_index").on("otps").column("expires_at").execute()}async function Sd(t){await t.schema.dropTable("sessions").execute(),await t.schema.dropTable("tickets").execute(),await t.schema.dropTable("otps").execute()}const jd=Object.freeze(Object.defineProperty({__proto__:null,down:Sd,up:Od},Symbol.toStringTag,{value:"Module"}));async function Id(t){await t.schema.createTable("passwords").addColumn("tenant_id","varchar(255)").addColumn("user_id","varchar(255)").addForeignKeyConstraint("user_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("created_at","varchar(255)").addColumn("updated_at","varchar(255)").execute(),await t.schema.createTable("codes").addColumn("id","varchar(255)",e=>e.primaryKey()).addColumn("user_id","varchar(255)").addColumn("tenant_id","varchar(255)").addForeignKeyConstraint("user_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("type","varchar(255)",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute(),await t.schema.createIndex("codes_expires_at_index").on("codes").column("expires_at").execute()}async function Zd(t){await t.schema.dropTable("passwords").execute(),await t.schema.dropTable("codes").execute()}const Ed=Object.freeze(Object.defineProperty({__proto__:null,down:Zd,up:Id},Symbol.toStringTag,{value:"Module"}));async function $d(t){}async function Ad(t){}const Pd=Object.freeze(Object.defineProperty({__proto__:null,down:Ad,up:$d},Symbol.toStringTag,{value:"Module"}));async function Dd(t){await t.schema.alterTable("passwords").addColumn("password","varchar(255)",e=>e.notNull()).execute()}async function Rd(t){await t.schema.alterTable("passwords").dropColumn("password").execute()}const Md=Object.freeze(Object.defineProperty({__proto__:null,down:Rd,up:Dd},Symbol.toStringTag,{value:"Module"}));async function Ld(t){}async function zd(t){}const Ud=Object.freeze(Object.defineProperty({__proto__:null,down:zd,up:Ld},Symbol.toStringTag,{value:"Module"}));async function Fd(t){}async function Vd(t){}const Bd=Object.freeze(Object.defineProperty({__proto__:null,down:Vd,up:Fd},Symbol.toStringTag,{value:"Module"}));async function Kd(t){}async function Wd(t){}const Jd=Object.freeze(Object.defineProperty({__proto__:null,down:Wd,up:Kd},Symbol.toStringTag,{value:"Module"}));async function qd(t){await t.schema.createIndex("users_email_index").on("users").column("email").execute()}async function Qd(t){await t.schema.dropIndex("users_email_index").execute()}const Hd=Object.freeze(Object.defineProperty({__proto__:null,down:Qd,up:qd},Symbol.toStringTag,{value:"Module"}));async function Gd(t){await t.schema.alterTable("users").addColumn("profileData","varchar(2048)").execute()}async function Yd(t){await t.schema.alterTable("users").dropColumn("profileData").execute()}const Xd=Object.freeze(Object.defineProperty({__proto__:null,down:Yd,up:Gd},Symbol.toStringTag,{value:"Module"}));async function ec(t){await t.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute()}async function tc(t){await t.schema.dropIndex("users_linked_to_index")}const nc=Object.freeze(Object.defineProperty({__proto__:null,down:tc,up:ec},Symbol.toStringTag,{value:"Module"}));async function rc(t){await t.schema.alterTable("users").addColumn("locale","varchar(255)").execute()}async function ac(t){await t.schema.alterTable("users").dropColumn("locale").execute()}const sc=Object.freeze(Object.defineProperty({__proto__:null,down:ac,up:rc},Symbol.toStringTag,{value:"Module"}));async function ic(t){await t.schema.createTable("keys").addColumn("kid","varchar(255)",e=>e.primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade")).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("revoked_at","varchar(255)").addColumn("cert","varchar(2048)").addColumn("pkcs7","varchar(2048)").addColumn("fingerprint","varchar(256)").addColumn("thumbprint","varchar(256)").addColumn("current_since","varchar(256)").addColumn("current_until","varchar(256)").execute()}async function oc(t){await t.schema.dropTable("keys").execute()}const dc=Object.freeze(Object.defineProperty({__proto__:null,down:oc,up:ic},Symbol.toStringTag,{value:"Module"}));async function cc(t){}async function lc(t){}const uc=Object.freeze(Object.defineProperty({__proto__:null,down:lc,up:cc},Symbol.toStringTag,{value:"Module"}));async function hc(t){}async function pc(t){}const mc=Object.freeze(Object.defineProperty({__proto__:null,down:pc,up:hc},Symbol.toStringTag,{value:"Module"}));async function fc(t){await t.schema.alterTable("otps").addColumn("audience","varchar(255)").execute()}async function _c(t){await t.schema.alterTable("otps").dropColumn("audience").execute()}const gc=Object.freeze(Object.defineProperty({__proto__:null,down:_c,up:fc},Symbol.toStringTag,{value:"Module"}));async function yc(t){}async function vc(t){}const bc=Object.freeze(Object.defineProperty({__proto__:null,down:vc,up:yc},Symbol.toStringTag,{value:"Module"}));async function wc(t){await t.schema.alterTable("logs").dropColumn("category").execute()}async function xc(t){await t.schema.alterTable("logs").addColumn("category","varchar(255)",e=>e.notNull()).execute()}const Nc=Object.freeze(Object.defineProperty({__proto__:null,down:xc,up:wc},Symbol.toStringTag,{value:"Module"}));async function kc(t){await t.schema.alterTable("users").dropColumn("tags").execute()}async function Tc(t){await t.schema.alterTable("users").addColumn("tags","varchar(255)").execute()}const Cc=Object.freeze(Object.defineProperty({__proto__:null,down:Tc,up:kc},Symbol.toStringTag,{value:"Module"}));async function Oc(t){await t.schema.createIndex("logs_user_id").on("logs").column("user_id").execute(),await t.schema.createIndex("logs_tenant_id").on("logs").column("tenant_id").execute(),await t.schema.createIndex("logs_date").on("logs").column("date").execute()}async function Sc(t){await t.schema.dropIndex("logs_user_id"),await t.schema.dropIndex("logs_tenant_id"),await t.schema.dropIndex("logs_date")}const jc=Object.freeze(Object.defineProperty({__proto__:null,down:Sc,up:Oc},Symbol.toStringTag,{value:"Module"}));async function Ic(t){await t.schema.alterTable("logs").dropColumn("details").execute(),await t.schema.alterTable("logs").addColumn("details","varchar(8192)").execute()}async function Zc(t){await t.schema.alterTable("logs").dropColumn("details").execute(),await t.schema.alterTable("logs").addColumn("details","varchar(2048)").execute()}const Ec=Object.freeze(Object.defineProperty({__proto__:null,down:Zc,up:Ic},Symbol.toStringTag,{value:"Module"}));async function $c(t){await t.schema.alterTable("logs").addColumn("user_name","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("auth0_client","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("isMobile","boolean").execute(),await t.schema.alterTable("logs").addColumn("connection","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("connection_id","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("audience","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("scope","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("strategy","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("strategy_type","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("hostname","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("session_connection","varchar(255)").execute()}async function Ac(t){await t.schema.alterTable("logs").dropColumn("user_name").execute(),await t.schema.alterTable("logs").dropColumn("auth0_client").execute(),await t.schema.alterTable("logs").dropColumn("isMobile").execute(),await t.schema.alterTable("logs").dropColumn("connection").execute(),await t.schema.alterTable("logs").dropColumn("connection_id").execute(),await t.schema.alterTable("logs").dropColumn("audience").execute(),await t.schema.alterTable("logs").dropColumn("scope").execute(),await t.schema.alterTable("logs").dropColumn("strategy").execute(),await t.schema.alterTable("logs").dropColumn("strategy_type").execute(),await t.schema.alterTable("logs").dropColumn("hostname").execute(),await t.schema.alterTable("logs").dropColumn("session_connection").execute()}const Pc=Object.freeze(Object.defineProperty({__proto__:null,down:Ac,up:$c},Symbol.toStringTag,{value:"Module"}));async function Dc(t){await t.schema.createIndex("users_name_index").on("users").column("name").execute()}async function Rc(t){await t.schema.dropIndex("users_name_index").execute()}const Mc=Object.freeze(Object.defineProperty({__proto__:null,down:Rc,up:Dc},Symbol.toStringTag,{value:"Module"}));async function Lc(t){}async function zc(t){await t.schema.alterTable("users").dropConstraint("unique_email_provider").execute()}const Uc=Object.freeze(Object.defineProperty({__proto__:null,down:zc,up:Lc},Symbol.toStringTag,{value:"Module"}));async function Fc(t){await t.schema.alterTable("otps").dropColumn("state").execute(),await t.schema.alterTable("otps").addColumn("state","varchar(8192)").execute()}async function Vc(t){await t.schema.alterTable("otps").dropColumn("state").execute(),await t.schema.alterTable("otps").addColumn("state","varchar(1024)").execute()}const Bc=Object.freeze(Object.defineProperty({__proto__:null,down:Vc,up:Fc},Symbol.toStringTag,{value:"Module"}));async function Kc(t){await t.schema.alterTable("tickets").dropColumn("state").execute(),await t.schema.alterTable("tickets").addColumn("state","varchar(8192)").execute()}async function Wc(t){await t.schema.alterTable("tickets").dropColumn("state").execute(),await t.schema.alterTable("tickets").addColumn("state","varchar(1024)").execute()}const Jc=Object.freeze(Object.defineProperty({__proto__:null,down:Wc,up:Kc},Symbol.toStringTag,{value:"Module"}));async function qc(t){await t.schema.createTable("branding").addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull().primaryKey()).addColumn("logo_url","varchar(512)").addColumn("favicon_url","varchar(512)").addColumn("font_url","varchar(512)").addColumn("colors_primary","varchar(8)").addColumn("colors_page_background_type","varchar(32)").addColumn("colors_page_background_start","varchar(8)").addColumn("colors_page_background_end","varchar(8)").addColumn("colors_page_background_angle_dev","integer").execute()}async function Qc(t){await t.schema.dropTable("branding").execute()}const Hc=Object.freeze(Object.defineProperty({__proto__:null,down:Qc,up:qc},Symbol.toStringTag,{value:"Module"}));async function Gc(t){}async function Yc(t){}const Xc=Object.freeze(Object.defineProperty({__proto__:null,down:Yc,up:Gc},Symbol.toStringTag,{value:"Module"}));async function el(t){}async function tl(t){}const nl=Object.freeze(Object.defineProperty({__proto__:null,down:tl,up:el},Symbol.toStringTag,{value:"Module"}));async function rl(t){}async function al(t){}const sl=Object.freeze(Object.defineProperty({__proto__:null,down:al,up:rl},Symbol.toStringTag,{value:"Module"}));async function il(t){}async function ol(t){}const dl=Object.freeze(Object.defineProperty({__proto__:null,down:ol,up:il},Symbol.toStringTag,{value:"Module"}));async function cl(t){await t.schema.createTable("authentication_codes").addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("code","varchar(255)",e=>e.primaryKey()).addColumn("client_id","varchar(255)",e=>e.references("applications.id").onDelete("cascade").notNull()).addColumn("user_id","varchar(255)",e=>e.notNull()).addColumn("nonce","varchar(255)").addColumn("state","varchar(8192)").addColumn("scope","varchar(1024)").addColumn("response_type","varchar(256)").addColumn("response_mode","varchar(256)").addColumn("redirect_uri","varchar(1024)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute()}async function ll(t){await t.schema.dropTable("authentication_codes").execute()}const ul=Object.freeze(Object.defineProperty({__proto__:null,down:ll,up:cl},Symbol.toStringTag,{value:"Module"}));async function hl(t){}async function pl(t){}const ml=Object.freeze(Object.defineProperty({__proto__:null,down:pl,up:hl},Symbol.toStringTag,{value:"Module"}));async function fl(t){await t.schema.alterTable("otps").addColumn("ip","varchar(64)").execute()}async function _l(t){await t.schema.alterTable("otps").dropColumn("ip").execute()}const gl=Object.freeze(Object.defineProperty({__proto__:null,down:_l,up:fl},Symbol.toStringTag,{value:"Module"}));async function yl(t){await t.schema.alterTable("logs").dropColumn("user_agent").execute(),await t.schema.alterTable("logs").addColumn("user_agent","varchar(1024)").execute()}async function vl(t){await t.schema.alterTable("logs").dropColumn("user_agent").execute(),await t.schema.alterTable("logs").addColumn("user_agent","varchar(255)").execute()}const bl=Object.freeze(Object.defineProperty({__proto__:null,down:vl,up:yl},Symbol.toStringTag,{value:"Module"}));async function wl(t){}async function xl(t){}const Nl=Object.freeze(Object.defineProperty({__proto__:null,down:xl,up:wl},Symbol.toStringTag,{value:"Module"}));async function kl(t){await t.schema.createTable("hooks").addColumn("hook_id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("url","varchar(512)",e=>e.notNull()).addColumn("trigger_id","varchar(255)",e=>e.notNull()).addColumn("enabled","boolean",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).addColumn("synchronous","boolean",e=>e.defaultTo(!1).notNull()).addColumn("priority","integer").execute()}async function Tl(t){await t.schema.dropTable("hooks").execute()}const Cl=Object.freeze(Object.defineProperty({__proto__:null,down:Tl,up:kl},Symbol.toStringTag,{value:"Module"}));async function Ol(t){}async function Sl(t){}const jl=Object.freeze(Object.defineProperty({__proto__:null,down:Sl,up:Ol},Symbol.toStringTag,{value:"Module"}));async function Il(t){}async function Zl(t){}const El=Object.freeze(Object.defineProperty({__proto__:null,down:Zl,up:Il},Symbol.toStringTag,{value:"Module"}));async function $l(t){await t.schema.createTable("logins").addColumn("login_id","varchar(255)",e=>e.primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("authParams_client_id","varchar(255)",e=>e.notNull()).addColumn("authParams_vendor_id","varchar(255)").addColumn("authParams_username","varchar(255)").addColumn("authParams_response_type","varchar(255)").addColumn("authParams_response_mode","varchar(255)").addColumn("authParams_audience","varchar(255)").addColumn("authParams_scope","varchar(511)").addColumn("authParams_state","varchar(511)").addColumn("authParams_code_challenge_method","varchar(256)").addColumn("authParams_code_challenge","varchar(256)").addColumn("authParams_redirect_uri","varchar(256)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).execute(),await t.schema.alterTable("passwords").addColumn("algorithm","varchar(16)").execute(),await t.schema.dropTable("codes").execute(),await t.schema.createTable("codes").addColumn("code_id","varchar(255)",e=>e.primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("user_id","varchar(255)").addColumn("login_id","varchar(255)").addForeignKeyConstraint("codes_user_id_tenant_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("code_type","varchar(255)",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute()}async function Al(t){await t.schema.dropTable("logins").execute(),await t.schema.alterTable("passwords").dropColumn("algorithm").execute(),await t.schema.dropTable("codes").execute(),await t.schema.createTable("codes").addColumn("id","varchar(255)",e=>e.primaryKey()).addColumn("code","varchar(255)",e=>e.notNull()).addColumn("user_id","varchar(255)").addColumn("tenant_id","varchar(255)").addForeignKeyConstraint("codes_user_id_tenant_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("type","varchar(255)",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute()}const Pl=Object.freeze(Object.defineProperty({__proto__:null,down:Al,up:$l},Symbol.toStringTag,{value:"Module"}));async function Dl(t){}async function Rl(t){}const Ml=Object.freeze(Object.defineProperty({__proto__:null,down:Rl,up:Dl},Symbol.toStringTag,{value:"Module"}));async function Ll(t){await t.schema.alterTable("logins").addColumn("auth0Client","varchar(256)").execute()}async function zl(t){await t.schema.alterTable("logins").dropColumn("auth0Client").execute()}const Ul=Object.freeze(Object.defineProperty({__proto__:null,down:zl,up:Ll},Symbol.toStringTag,{value:"Module"}));async function Fl(t){await t.schema.alterTable("logins").dropColumn("authParams_state").execute(),await t.schema.alterTable("logins").addColumn("authParams_state","varchar(8192)").execute()}async function Vl(t){await t.schema.alterTable("logins").dropColumn("authParams_state").execute(),await t.schema.alterTable("logins").addColumn("authParams_state","varchar(511)").execute()}const Bl=Object.freeze(Object.defineProperty({__proto__:null,down:Vl,up:Fl},Symbol.toStringTag,{value:"Module"}));async function Kl(t){}async function Wl(t){}const Jl=Object.freeze(Object.defineProperty({__proto__:null,down:Wl,up:Kl},Symbol.toStringTag,{value:"Module"}));async function ql(t){}async function Ql(t){}const Hl=Object.freeze(Object.defineProperty({__proto__:null,down:Ql,up:ql},Symbol.toStringTag,{value:"Module"}));async function Gl(t){await t.schema.alterTable("logins").addColumn("authParams_nonce","varchar(255)").execute()}async function Yl(t){await t.schema.alterTable("logins").dropColumn("nonce").execute()}const Xl=Object.freeze(Object.defineProperty({__proto__:null,down:Yl,up:Gl},Symbol.toStringTag,{value:"Module"}));async function eu(t){}async function tu(t){}const nu=Object.freeze(Object.defineProperty({__proto__:null,down:tu,up:eu},Symbol.toStringTag,{value:"Module"}));async function ru(t){}async function au(t){}const su=Object.freeze(Object.defineProperty({__proto__:null,down:au,up:ru},Symbol.toStringTag,{value:"Module"}));async function iu(t){await t.schema.dropTable("codes").execute(),await t.schema.createTable("codes").addColumn("code_id","varchar(255)",e=>e.notNull()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("user_id","varchar(255)").addColumn("login_id","varchar(255)").addColumn("connection_id","varchar(255)").addForeignKeyConstraint("codes_user_id_tenant_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("code_type","varchar(255)",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").addPrimaryKeyConstraint("PK_codes_code_id_code_type",["code_id","code_type"]).execute()}async function ou(t){await t.schema.dropTable("codes").execute(),await t.schema.createTable("codes").addColumn("code_id","varchar(255)",e=>e.primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("user_id","varchar(255)").addColumn("connection_id","varchar(255)").addColumn("login_id","varchar(255)").addForeignKeyConstraint("codes_user_id_tenant_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("code_type","varchar(255)",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute()}const du=Object.freeze(Object.defineProperty({__proto__:null,down:ou,up:iu},Symbol.toStringTag,{value:"Module"}));async function cu(t){await t.schema.dropTable("otps").execute(),await t.schema.dropTable("authentication_codes").execute()}async function lu(t){await t.schema.alterTable("keys").addColumn("private_key","varchar(2048)").addColumn("public_key","varchar(2048)").execute(),await t.schema.createTable("otps").addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("id","varchar(255)",e=>e.primaryKey()).addColumn("client_id","varchar(255)",e=>e.references("applications.id").onDelete("cascade").notNull()).addColumn("code","varchar(255)",e=>e.notNull()).addColumn("email","varchar(255)",e=>e.notNull()).addColumn("user_id","varchar(255)").addColumn("send","varchar(255)").addColumn("nonce","varchar(255)").addColumn("state","varchar(1024)").addColumn("scope","varchar(1024)").addColumn("response_type","varchar(256)").addColumn("response_mode","varchar(256)").addColumn("redirect_uri","varchar(1024)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute(),await t.schema.createTable("authentication_codes").addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("code","varchar(255)",e=>e.primaryKey()).addColumn("client_id","varchar(255)",e=>e.references("applications.id").onDelete("cascade").notNull()).addColumn("user_id","varchar(255)",e=>e.notNull()).addColumn("nonce","varchar(255)").addColumn("state","varchar(8192)").addColumn("scope","varchar(1024)").addColumn("response_type","varchar(256)").addColumn("response_mode","varchar(256)").addColumn("redirect_uri","varchar(1024)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute()}const uu=Object.freeze(Object.defineProperty({__proto__:null,down:lu,up:cu},Symbol.toStringTag,{value:"Module"}));async function hu(t){await t.schema.createIndex("IDX_logs_tenant_date_type_user").on("logs").columns(["tenant_id","date","type","user_id"]).execute()}async function pu(t){await t.schema.dropIndex("IDX_logs_tenant_date_type_user").on("logs").execute()}const mu=Object.freeze(Object.defineProperty({__proto__:null,down:pu,up:hu},Symbol.toStringTag,{value:"Module"}));async function fu(t){}async function _u(t){}const gu=Object.freeze(Object.defineProperty({__proto__:null,down:_u,up:fu},Symbol.toStringTag,{value:"Module"}));async function yu(t){await t.schema.createTable("prompt_settings").addColumn("tenant_id","varchar(64)",e=>e.primaryKey()).addColumn("universal_login_experience","varchar(16)",e=>e.defaultTo("new").notNull()).addColumn("identifier_first","boolean",e=>e.defaultTo(!0).notNull()).addColumn("password_first","boolean",e=>e.defaultTo(!1).notNull()).addColumn("webauthn_platform_first_factor","boolean",e=>e.defaultTo(!1).notNull()).execute()}async function vu(t){await t.schema.dropTable("prompt_settings").execute()}const bu=Object.freeze(Object.defineProperty({__proto__:null,down:vu,up:yu},Symbol.toStringTag,{value:"Module"}));async function wu(t){}async function xu(t){}const Nu=Object.freeze(Object.defineProperty({__proto__:null,down:xu,up:wu},Symbol.toStringTag,{value:"Module"}));async function ku(t){}async function Tu(t){}const Cu=Object.freeze(Object.defineProperty({__proto__:null,down:Tu,up:ku},Symbol.toStringTag,{value:"Module"}));async function Ou(t){}async function Su(t){}const ju=Object.freeze(Object.defineProperty({__proto__:null,down:Su,up:Ou},Symbol.toStringTag,{value:"Module"}));async function Iu(t){await t.schema.alterTable("logins").addColumn("authParams_ui_locales","varchar(32)").execute()}async function Zu(t){await t.schema.alterTable("logins").dropColumn("authParams_ui_locales").execute()}const Eu=Object.freeze(Object.defineProperty({__proto__:null,down:Zu,up:Iu},Symbol.toStringTag,{value:"Module"}));async function $u(t){await t.schema.alterTable("logins").addColumn("authParams_prompt","varchar(16)").execute()}async function Au(t){await t.schema.alterTable("logins").dropColumn("authParams_prompt").execute()}const Pu=Object.freeze(Object.defineProperty({__proto__:null,down:Au,up:$u},Symbol.toStringTag,{value:"Module"}));async function Du(t){}async function Ru(t){}const Er={m1_init:md,m2_magicLink:gd,m3_updateAt:bd,m4_logTable:Nd,m5_userProfile:Cd,m6_sessions:jd,m7_passwords:Ed,m8_logsTableNewFields:Pd,m9_passwordTableNewField:Md,n01_codesTable:Ud,n11_universalLoginSession:Bd,n12_userFields:Jd,n13_userEmailIndex:Hd,n14_profileDataField:Xd,n15_userEmailIndex:nc,n16_userLocale:sc,n17_signingKeys:dc,n18_logsFields:uc,n19_connectionsUserinfo:mc,n20_missingFields:gc,n21_sessionDeletedAt:bc,n22_dropLogsFields:Nc,n23_dropUsersFields:Cc,n24_logsIndexes:jc,n25_logDescMaxLength:Ec,n26_logsTableExtraFields:Pc,n27_usersTableNameIndex:Mc,n28_usersEmailConstrain:Uc,n29_increaseOtpStateLength:Bc,n30_increaseTicketStateLength:Jc,n31_branding:Hc,n32_indexesAndNotNull:Xc,n33_vendorIdInUniversalLoginSession:nl,n34_auth0ClientInUniversalLoginSession:sl,n35_increaseUniversalSessionStateLength:dl,n36_authenticationCodes:ul,n37_disableSignUps:ml,n38_otpIpAddress:gl,n39_increaseUserAgentLength:bl,n40_userId:Nl,n41_hooks:Cl,n42_userIdIndexes:jl,n43_userIdIndexes:El,n44_codes:Pl,n45_hookProperties:Ml,n46_loginAuth0Client:Ul,n47_loginAuth0Client:Bl,n48_saml:Jl,n49_removeFields:Hl,n50_authParamsNonce:Xl,n51_connectionid:nu,n52_cert:su,n53_codes_primary_key:du,n54_cleanup_tables:uu,n55_logs_index:mu,n56_application_fields:gu,n57_prompt_settings:bu,n58_connection_client_id:Nu,n59_connection_options:Cu,n60_users_metadata:ju,n61_userLocales:Eu,n62_prompt:Pu,n63_connection_cleanup:Object.freeze(Object.defineProperty({__proto__:null,down:Ru,up:Du},Symbol.toStringTag,{value:"Module"}))};async function Mu(t,e=!1){e&&console.log("migrating...");const n=new Zr(Er),r=new Ir({db:t,provider:n}),{error:a,results:s}=await r.migrateToLatest();if(s==null||s.forEach(o=>{o.status==="Success"?e&&console.log(`migration "${o.migrationName}" was executed successfully`):o.status==="Error"&&console.error(`failed to execute migration "${o.migrationName}"`)}),a)throw console.error("failed to migrate"),console.error(a),a}async function Lu(t){console.log("migrating...");const e=new Zr(Er),n=new Ir({db:t,provider:e}),{error:r,results:a}=await n.migrateDown();if(a==null||a.forEach(s=>{s.status==="Success"?console.log(`migration "${s.migrationName}" was reverted successfully`):s.status==="Error"&&console.error(`failed to execute migration "${s.migrationName}"`)}),r)throw console.error("failed to migrate"),console.error(r),r}function zu(t){return{applications:gi(t),branding:Do(t),clients:Co(t),codes:ui(t),connections:To(t),domains:$o(t),hooks:Fo(t),keys:Io(t),logins:Yo(t),logs:Ws(t),passwords:ii(t),promptSettings:td(t),users:As(t),sessions:Ys(t),tenants:Us(t),themes:Jo(t),tickets:ni(t)}}return A.default=zu,A.migrateDown=Lu,A.migrateToLatest=Mu,Object.defineProperties(A,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),A}({});
|
|
1
|
+
var kyselyAdapter=function(A){"use strict";var Uu=Object.defineProperty;var $r=A=>{throw TypeError(A)};var Fu=(A,P,U)=>P in A?Uu(A,P,{enumerable:!0,configurable:!0,writable:!0,value:U}):A[P]=U;var Xt=(A,P,U)=>Fu(A,typeof P!="symbol"?P+"":P,U),Fn=(A,P,U)=>P.has(A)||$r("Cannot "+U);var v=(A,P,U)=>(Fn(A,P,"read from private field"),U?U.call(A):P.get(A)),he=(A,P,U)=>P.has(A)?$r("Cannot add the same private member more than once"):P instanceof WeakSet?P.add(A):P.set(A,U),en=(A,P,U,R)=>(Fn(A,P,"write to private field"),R?R.call(A,U):P.set(A,U),U),C=(A,P,U)=>(Fn(A,P,"access private method"),U);var xn,ot,Be,Ke,V,Ar,Pr,Dr,ut,Vn,Rr,Gt,D,m,tn,_e,ge,ht,Mr,ye,Lr,zr,Ur,Fr,Vr,Bn,pt,Kn,Br,Kr,Wr,Wn,Jr,qr,Qr,Hr,Gr,nn,Yt;var P=class extends Error{constructor(e=500,n){super(n==null?void 0:n.message,{cause:n==null?void 0:n.cause});Xt(this,"res");Xt(this,"status");this.res=n==null?void 0:n.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 U(t){return async(e,n)=>{const{identities:r,...a}=n,s={...a,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),tenant_id:e,email_verified:n.email_verified?1:0,is_social:n.is_social?1:0,app_metadata:JSON.stringify(n.app_metadata),user_metadata:JSON.stringify(n.user_metadata)};try{await t.insertInto("users").values(s).execute()}catch(o){throw o.code==="SQLITE_CONSTRAINT_UNIQUE"||o.message.includes("AlreadyExists")?new P(409,{message:"User already exists"}):(console.log(o.message),new P(500,{message:`${o.code}, ${o.message}`}))}return{...s,email:s.email||"",email_verified:s.email_verified===1,is_social:s.is_social===1}}}function R(t){const e={...t};for(const n in e)e[n]===null?delete e[n]:typeof e[n]=="object"&&(Array.isArray(e[n])?e[n]=e[n].map(R):e[n]=R(e[n]));return e}function Yr(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(t);a<r.length;a++)e.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(t,r[a])&&(n[r[a]]=t[r[a]]);return n}function Xr(t,e){var n;return((n=t==null?void 0:t._def)===null||n===void 0?void 0:n.typeName)===e}function mt(t,e){const n=t.ZodType.prototype[e];t.ZodType.prototype[e]=function(...r){const a=n.apply(this,r);return a._def.openapi=this._def.openapi,a}}function ea(t){if(typeof t.ZodType.prototype.openapi<"u")return;t.ZodType.prototype.openapi=function(a,s){var o,d,c,l,u,Z;const z=typeof a=="string"?s:a,H=z??{},{param:Ze}=H,dt=Yr(H,["param"]),Ee=Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o._internal),typeof a=="string"?{refId:a}:void 0),$e=Object.assign(Object.assign(Object.assign({},(d=this._def.openapi)===null||d===void 0?void 0:d.metadata),dt),!((l=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||l===void 0)&&l.param||Ze?{param:Object.assign(Object.assign({},(Z=(u=this._def.openapi)===null||u===void 0?void 0:u.metadata)===null||Z===void 0?void 0:Z.param),Ze)}:void 0),Ae=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(Ee).length>0?{_internal:Ee}:void 0),Object.keys($e).length>0?{metadata:$e}:void 0)}));if(Xr(this,"ZodObject")){const ct=this.extend;Ae.extend=function(...lt){var ce,le,ue,Pe,We,Je;const qe=ct.apply(this,lt);return qe._def.openapi={_internal:{extendedFrom:!((le=(ce=this._def.openapi)===null||ce===void 0?void 0:ce._internal)===null||le===void 0)&&le.refId?{refId:(Pe=(ue=this._def.openapi)===null||ue===void 0?void 0:ue._internal)===null||Pe===void 0?void 0:Pe.refId,schema:this}:(We=this._def.openapi)===null||We===void 0?void 0:We._internal.extendedFrom},metadata:(Je=qe._def.openapi)===null||Je===void 0?void 0:Je.metadata},qe}}return Ae},mt(t,"optional"),mt(t,"nullable"),mt(t,"default"),mt(t,"transform"),mt(t,"refine");const e=t.ZodObject.prototype.deepPartial;t.ZodObject.prototype.deepPartial=function(){const a=this._def.shape(),s=e.apply(this),o=s._def.shape();return Object.entries(o).forEach(([d,c])=>{var l,u;c._def.openapi=(u=(l=a[d])===null||l===void 0?void 0:l._def)===null||u===void 0?void 0:u.openapi}),s._def.openapi=void 0,s};const n=t.ZodObject.prototype.pick;t.ZodObject.prototype.pick=function(...a){const s=n.apply(this,a);return s._def.openapi=void 0,s};const r=t.ZodObject.prototype.omit;t.ZodObject.prototype.omit=function(...a){const s=r.apply(this,a);return s._def.openapi=void 0,s}}new Set(".\\+*[^]$()");var E;(function(t){t.assertEqual=a=>a;function e(a){}t.assertIs=e;function n(a){throw new Error}t.assertNever=n,t.arrayToEnum=a=>{const s={};for(const o of a)s[o]=o;return s},t.getValidEnumValues=a=>{const s=t.objectKeys(a).filter(d=>typeof a[a[d]]!="number"),o={};for(const d of s)o[d]=a[d];return t.objectValues(o)},t.objectValues=a=>t.objectKeys(a).map(function(s){return a[s]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const s=[];for(const o in a)Object.prototype.hasOwnProperty.call(a,o)&&s.push(o);return s},t.find=(a,s)=>{for(const o of a)if(s(o))return o},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&isFinite(a)&&Math.floor(a)===a;function r(a,s=" | "){return a.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}t.joinValues=r,t.jsonStringifyReplacer=(a,s)=>typeof s=="bigint"?s.toString():s})(E||(E={}));var Nn;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Nn||(Nn={}));const g=E.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ve=t=>{switch(typeof t){case"undefined":return g.undefined;case"string":return g.string;case"number":return isNaN(t)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(t)?g.array:t===null?g.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?g.promise:typeof Map<"u"&&t instanceof Map?g.map:typeof Set<"u"&&t instanceof Set?g.set:typeof Date<"u"&&t instanceof Date?g.date:g.object;default:return g.unknown}},h=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"]),ta=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class q extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const n=e||function(s){return s.message},r={_errors:[]},a=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(a);else if(o.code==="invalid_return_type")a(o.returnTypeError);else if(o.code==="invalid_arguments")a(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let d=r,c=0;for(;c<o.path.length;){const l=o.path[c];c===o.path.length-1?(d[l]=d[l]||{_errors:[]},d[l]._errors.push(n(o))):d[l]=d[l]||{_errors:[]},d=d[l],c++}}};return a(this),r}static assert(e){if(!(e instanceof q))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=n=>n.message){const n={},r=[];for(const a of this.issues)a.path.length>0?(n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(e(a))):r.push(e(a));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}q.create=t=>new q(t);const Qe=(t,e)=>{let n;switch(t.code){case h.invalid_type:t.received===g.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case h.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,E.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:n=`Unrecognized key(s) in object: ${E.joinValues(t.keys,", ")}`;break;case h.invalid_union:n="Invalid input";break;case h.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${E.joinValues(t.options)}`;break;case h.invalid_enum_value:n=`Invalid enum value. Expected ${E.joinValues(t.options)}, received '${t.received}'`;break;case h.invalid_arguments:n="Invalid function arguments";break;case h.invalid_return_type:n="Invalid function return type";break;case h.invalid_date:n="Invalid date";break;case h.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:E.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case h.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case h.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case h.custom:n="Invalid input";break;case h.invalid_intersection_types:n="Intersection results could not be merged";break;case h.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case h.not_finite:n="Number must be finite";break;default:n=e.defaultError,E.assertNever(t)}return{message:n}};let Jn=Qe;function na(t){Jn=t}function rn(){return Jn}const an=t=>{const{data:e,path:n,errorMaps:r,issueData:a}=t,s=[...n,...a.path||[]],o={...a,path:s};if(a.message!==void 0)return{...a,path:s,message:a.message};let d="";const c=r.filter(l=>!!l).slice().reverse();for(const l of c)d=l(o,{data:e,defaultError:d}).message;return{...a,path:s,message:d}},ra=[];function f(t,e){const n=rn(),r=an({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Qe?void 0:Qe].filter(a=>!!a)});t.common.issues.push(r)}class B{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const a of n){if(a.status==="aborted")return T;a.status==="dirty"&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const a of n){const s=await a.key,o=await a.value;r.push({key:s,value:o})}return B.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const a of n){const{key:s,value:o}=a;if(s.status==="aborted"||o.status==="aborted")return T;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||a.alwaysSet)&&(r[s.value]=o.value)}return{status:e.value,value:r}}}const T=Object.freeze({status:"aborted"}),sn=t=>({status:"dirty",value:t}),W=t=>({status:"valid",value:t}),kn=t=>t.status==="aborted",Tn=t=>t.status==="dirty",ft=t=>t.status==="valid",_t=t=>typeof Promise<"u"&&t instanceof Promise;function on(t,e,n,r){if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function qn(t,e,n,r,a){if(typeof e=="function"?t!==e||!a:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}var b;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(b||(b={}));var gt,yt;class re{constructor(e,n,r,a){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=a}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 Qn=(t,e)=>{if(ft(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new q(t.common.issues);return this._error=n,this._error}}};function O(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:a}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(s,o)=>{var d,c;const{message:l}=t;return s.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:(d=l??r)!==null&&d!==void 0?d:o.defaultError}:s.code!=="invalid_type"?{message:o.defaultError}:{message:(c=l??n)!==null&&c!==void 0?c:o.defaultError}},description:a}}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 ve(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:ve(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new B,ctx:{common:e.parent.common,data:e.data,parsedType:ve(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(_t(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){var r;const a={common:{issues:[],async:(r=n==null?void 0:n.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ve(e)},s=this._parseSync({data:e,path:a.path,parent:a});return Qn(a,s)}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ve(e)},a=this._parse({data:e,path:r.path,parent:r}),s=await(_t(a)?a:Promise.resolve(a));return Qn(r,s)}refine(e,n){const r=a=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(a):n;return this._refinement((a,s)=>{const o=e(a),d=()=>s.addIssue({code:h.custom,...r(a)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(d(),!1)):o?!0:(d(),!1)})}refinement(e,n){return this._refinement((r,a)=>e(r)?!0:(a.addIssue(typeof n=="function"?n(r,a):n),!1))}_refinement(e){return new X({schema:this,typeName:x.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return se.create(this,this._def)}nullable(){return ke.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Y.create(this,this._def)}promise(){return Xe.create(this,this._def)}or(e){return xt.create([this,e],this._def)}and(e){return Nt.create(this,e,this._def)}transform(e){return new X({...O(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new St({...O(this._def),innerType:this,defaultValue:n,typeName:x.ZodDefault})}brand(){return new Sn({typeName:x.ZodBranded,type:this,...O(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new jt({...O(this._def),innerType:this,catchValue:n,typeName:x.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return It.create(this,e)}readonly(){return Zt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const aa=/^c[^\s-]{8,}$/i,sa=/^[0-9a-z]+$/,ia=/^[0-9A-HJKMNP-TV-Z]{26}$/,oa=/^[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,da=/^[a-z0-9_-]{21}$/i,ca=/^[-+]?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)?)??$/,la=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ua="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Cn;const ha=/^(?:(?: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])$/,pa=/^(([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})))$/,ma=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Hn="((\\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])))",fa=new RegExp(`^${Hn}$`);function Gn(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`),e}function _a(t){return new RegExp(`^${Gn(t)}$`)}function Yn(t){let e=`${Hn}T${Gn(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function ga(t,e){return!!((e==="v4"||!e)&&ha.test(t)||(e==="v6"||!e)&&pa.test(t))}class G extends j{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){const a=this._getOrReturnCtx(e);return f(a,{code:h.invalid_type,expected:g.string,received:a.parsedType}),T}const n=new B;let r;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const s=e.data.length>a.value,o=e.data.length<a.value;(s||o)&&(r=this._getOrReturnCtx(e,r),s?f(r,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&f(r,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")la.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"email",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Cn||(Cn=new RegExp(ua,"u")),Cn.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"emoji",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")oa.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"uuid",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")da.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"nanoid",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")aa.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"cuid",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")sa.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"cuid2",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")ia.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"ulid",code:h.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),f(r,{validation:"url",code:h.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"regex",code:h.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(e,r),f(r,{code:h.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(r=this._getOrReturnCtx(e,r),f(r,{code:h.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(r=this._getOrReturnCtx(e,r),f(r,{code:h.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Yn(a).test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:h.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?fa.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:h.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?_a(a).test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{code:h.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?ca.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"duration",code:h.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?ga(e.data,a.version)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"ip",code:h.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?ma.test(e.data)||(r=this._getOrReturnCtx(e,r),f(r,{validation:"base64",code:h.invalid_string,message:a.message}),n.dirty()):E.assertNever(a);return{status:n.value,value:e.data}}_regex(e,n,r){return this.refinement(a=>e.test(a),{validation:n,code:h.invalid_string,...b.errToObj(r)})}_addCheck(e){return new G({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...b.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...b.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...b.errToObj(e)})}datetime(e){var n,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(n=e==null?void 0:e.offset)!==null&&n!==void 0?n:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!1,...b.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,...b.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...b.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...b.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...b.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...b.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...b.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...b.errToObj(n)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new G({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new G({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new G({...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 n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}G.create=t=>{var e;return new G({checks:[],typeName:x.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...O(t)})};function ya(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,a=n>r?n:r,s=parseInt(t.toFixed(a).replace(".","")),o=parseInt(e.toFixed(a).replace(".",""));return s%o/Math.pow(10,a)}class be extends j{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==g.number){const a=this._getOrReturnCtx(e);return f(a,{code:h.invalid_type,expected:g.number,received:a.parsedType}),T}let n;const r=new B;for(const a of this._def.checks)a.kind==="int"?E.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:h.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:h.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:h.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?ya(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),f(n,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:h.not_finite,message:a.message}),r.dirty()):E.assertNever(a);return{status:r.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,r,a){return new be({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(a)}]})}_addCheck(e){return new be({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.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,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}}be.create=t=>new be({checks:[],typeName:x.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...O(t)});class we extends j{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==g.bigint){const a=this._getOrReturnCtx(e);return f(a,{code:h.invalid_type,expected:g.bigint,received:a.parsedType}),T}let n;const r=new B;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:h.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:h.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),f(n,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):E.assertNever(a);return{status:r.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,r,a){return new we({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:b.toString(a)}]})}_addCheck(e){return new we({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}we.create=t=>{var e;return new we({checks:[],typeName:x.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...O(t)})};class vt extends j{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.boolean,received:n.parsedType}),T}return W(e.data)}}vt.create=t=>new vt({typeName:x.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...O(t)});class De extends j{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){const a=this._getOrReturnCtx(e);return f(a,{code:h.invalid_type,expected:g.date,received:a.parsedType}),T}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return f(a,{code:h.invalid_date}),T}const n=new B;let r;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:h.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(r=this._getOrReturnCtx(e,r),f(r,{code:h.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):E.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new De({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:b.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}De.create=t=>new De({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:x.ZodDate,...O(t)});class dn extends j{_parse(e){if(this._getType(e)!==g.symbol){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.symbol,received:n.parsedType}),T}return W(e.data)}}dn.create=t=>new dn({typeName:x.ZodSymbol,...O(t)});class bt extends j{_parse(e){if(this._getType(e)!==g.undefined){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.undefined,received:n.parsedType}),T}return W(e.data)}}bt.create=t=>new bt({typeName:x.ZodUndefined,...O(t)});class wt extends j{_parse(e){if(this._getType(e)!==g.null){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.null,received:n.parsedType}),T}return W(e.data)}}wt.create=t=>new wt({typeName:x.ZodNull,...O(t)});class He extends j{constructor(){super(...arguments),this._any=!0}_parse(e){return W(e.data)}}He.create=t=>new He({typeName:x.ZodAny,...O(t)});class Re extends j{constructor(){super(...arguments),this._unknown=!0}_parse(e){return W(e.data)}}Re.create=t=>new Re({typeName:x.ZodUnknown,...O(t)});class pe extends j{_parse(e){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.never,received:n.parsedType}),T}}pe.create=t=>new pe({typeName:x.ZodNever,...O(t)});class cn extends j{_parse(e){if(this._getType(e)!==g.undefined){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.void,received:n.parsedType}),T}return W(e.data)}}cn.create=t=>new cn({typeName:x.ZodVoid,...O(t)});class Y extends j{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),a=this._def;if(n.parsedType!==g.array)return f(n,{code:h.invalid_type,expected:g.array,received:n.parsedType}),T;if(a.exactLength!==null){const o=n.data.length>a.exactLength.value,d=n.data.length<a.exactLength.value;(o||d)&&(f(n,{code:o?h.too_big:h.too_small,minimum:d?a.exactLength.value:void 0,maximum:o?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&n.data.length<a.minLength.value&&(f(n,{code:h.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&n.data.length>a.maxLength.value&&(f(n,{code:h.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,d)=>a.type._parseAsync(new re(n,o,n.path,d)))).then(o=>B.mergeArray(r,o));const s=[...n.data].map((o,d)=>a.type._parseSync(new re(n,o,n.path,d)));return B.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new Y({...this._def,minLength:{value:e,message:b.toString(n)}})}max(e,n){return new Y({...this._def,maxLength:{value:e,message:b.toString(n)}})}length(e,n){return new Y({...this._def,exactLength:{value:e,message:b.toString(n)}})}nonempty(e){return this.min(1,e)}}Y.create=(t,e)=>new Y({type:t,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...O(e)});function Ge(t){if(t instanceof M){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=se.create(Ge(r))}return new M({...t._def,shape:()=>e})}else return t instanceof Y?new Y({...t._def,type:Ge(t.element)}):t instanceof se?se.create(Ge(t.unwrap())):t instanceof ke?ke.create(Ge(t.unwrap())):t instanceof ae?ae.create(t.items.map(e=>Ge(e))):t}class M 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(),n=E.objectKeys(e);return this._cached={shape:e,keys:n}}_parse(e){if(this._getType(e)!==g.object){const c=this._getOrReturnCtx(e);return f(c,{code:h.invalid_type,expected:g.object,received:c.parsedType}),T}const{status:n,ctx:r}=this._processInputParams(e),{shape:a,keys:s}=this._getCached(),o=[];if(!(this._def.catchall instanceof pe&&this._def.unknownKeys==="strip"))for(const c in r.data)s.includes(c)||o.push(c);const d=[];for(const c of s){const l=a[c],u=r.data[c];d.push({key:{status:"valid",value:c},value:l._parse(new re(r,u,r.path,c)),alwaysSet:c in r.data})}if(this._def.catchall instanceof pe){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of o)d.push({key:{status:"valid",value:l},value:{status:"valid",value:r.data[l]}});else if(c==="strict")o.length>0&&(f(r,{code:h.unrecognized_keys,keys:o}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of o){const u=r.data[l];d.push({key:{status:"valid",value:l},value:c._parse(new re(r,u,r.path,l)),alwaysSet:l in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of d){const u=await l.key,Z=await l.value;c.push({key:u,value:Z,alwaysSet:l.alwaysSet})}return c}).then(c=>B.mergeObjectSync(n,c)):B.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new M({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{var a,s,o,d;const c=(o=(s=(a=this._def).errorMap)===null||s===void 0?void 0:s.call(a,n,r).message)!==null&&o!==void 0?o:r.defaultError;return n.code==="unrecognized_keys"?{message:(d=b.errToObj(e).message)!==null&&d!==void 0?d:c}:{message:c}}}:{}})}strip(){return new M({...this._def,unknownKeys:"strip"})}passthrough(){return new M({...this._def,unknownKeys:"passthrough"})}extend(e){return new M({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new M({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new M({...this._def,catchall:e})}pick(e){const n={};return E.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new M({...this._def,shape:()=>n})}omit(e){const n={};return E.objectKeys(this.shape).forEach(r=>{e[r]||(n[r]=this.shape[r])}),new M({...this._def,shape:()=>n})}deepPartial(){return Ge(this)}partial(e){const n={};return E.objectKeys(this.shape).forEach(r=>{const a=this.shape[r];e&&!e[r]?n[r]=a:n[r]=a.optional()}),new M({...this._def,shape:()=>n})}required(e){const n={};return E.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])n[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof se;)a=a._def.innerType;n[r]=a}}),new M({...this._def,shape:()=>n})}keyof(){return Xn(E.objectKeys(this.shape))}}M.create=(t,e)=>new M({shape:()=>t,unknownKeys:"strip",catchall:pe.create(),typeName:x.ZodObject,...O(e)}),M.strictCreate=(t,e)=>new M({shape:()=>t,unknownKeys:"strict",catchall:pe.create(),typeName:x.ZodObject,...O(e)}),M.lazycreate=(t,e)=>new M({shape:t,unknownKeys:"strip",catchall:pe.create(),typeName:x.ZodObject,...O(e)});class xt extends j{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function a(s){for(const d of s)if(d.result.status==="valid")return d.result;for(const d of s)if(d.result.status==="dirty")return n.common.issues.push(...d.ctx.common.issues),d.result;const o=s.map(d=>new q(d.ctx.common.issues));return f(n,{code:h.invalid_union,unionErrors:o}),T}if(n.common.async)return Promise.all(r.map(async s=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(a);{let s;const o=[];for(const c of r){const l={...n,common:{...n.common,issues:[]},parent:null},u=c._parseSync({data:n.data,path:n.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!s&&(s={result:u,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const d=o.map(c=>new q(c));return f(n,{code:h.invalid_union,unionErrors:d}),T}}get options(){return this._def.options}}xt.create=(t,e)=>new xt({options:t,typeName:x.ZodUnion,...O(e)});const xe=t=>t instanceof Tt?xe(t.schema):t instanceof X?xe(t.innerType()):t instanceof Ct?[t.value]:t instanceof Ne?t.options:t instanceof Ot?E.objectValues(t.enum):t instanceof St?xe(t._def.innerType):t instanceof bt?[void 0]:t instanceof wt?[null]:t instanceof se?[void 0,...xe(t.unwrap())]:t instanceof ke?[null,...xe(t.unwrap())]:t instanceof Sn||t instanceof Zt?xe(t.unwrap()):t instanceof jt?xe(t._def.innerType):[];class ln extends j{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.object)return f(n,{code:h.invalid_type,expected:g.object,received:n.parsedType}),T;const r=this.discriminator,a=n.data[r],s=this.optionsMap.get(a);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(f(n,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),T)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){const a=new Map;for(const s of n){const o=xe(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const d of o){if(a.has(d))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(d)}`);a.set(d,s)}}return new ln({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:a,...O(r)})}}function On(t,e){const n=ve(t),r=ve(e);if(t===e)return{valid:!0,data:t};if(n===g.object&&r===g.object){const a=E.objectKeys(e),s=E.objectKeys(t).filter(d=>a.indexOf(d)!==-1),o={...t,...e};for(const d of s){const c=On(t[d],e[d]);if(!c.valid)return{valid:!1};o[d]=c.data}return{valid:!0,data:o}}else if(n===g.array&&r===g.array){if(t.length!==e.length)return{valid:!1};const a=[];for(let s=0;s<t.length;s++){const o=t[s],d=e[s],c=On(o,d);if(!c.valid)return{valid:!1};a.push(c.data)}return{valid:!0,data:a}}else return n===g.date&&r===g.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Nt extends j{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),a=(s,o)=>{if(kn(s)||kn(o))return T;const d=On(s.value,o.value);return d.valid?((Tn(s)||Tn(o))&&n.dirty(),{status:n.value,value:d.data}):(f(r,{code:h.invalid_intersection_types}),T)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>a(s,o)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Nt.create=(t,e,n)=>new Nt({left:t,right:e,typeName:x.ZodIntersection,...O(n)});class ae extends j{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.array)return f(r,{code:h.invalid_type,expected:g.array,received:r.parsedType}),T;if(r.data.length<this._def.items.length)return f(r,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),T;!this._def.rest&&r.data.length>this._def.items.length&&(f(r,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const a=[...r.data].map((s,o)=>{const d=this._def.items[o]||this._def.rest;return d?d._parse(new re(r,s,r.path,o)):null}).filter(s=>!!s);return r.common.async?Promise.all(a).then(s=>B.mergeArray(n,s)):B.mergeArray(n,a)}get items(){return this._def.items}rest(e){return new ae({...this._def,rest:e})}}ae.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ae({items:t,typeName:x.ZodTuple,rest:null,...O(e)})};class kt extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.object)return f(r,{code:h.invalid_type,expected:g.object,received:r.parsedType}),T;const a=[],s=this._def.keyType,o=this._def.valueType;for(const d in r.data)a.push({key:s._parse(new re(r,d,r.path,d)),value:o._parse(new re(r,r.data[d],r.path,d)),alwaysSet:d in r.data});return r.common.async?B.mergeObjectAsync(n,a):B.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof j?new kt({keyType:e,valueType:n,typeName:x.ZodRecord,...O(r)}):new kt({keyType:G.create(),valueType:e,typeName:x.ZodRecord,...O(n)})}}class un extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.map)return f(r,{code:h.invalid_type,expected:g.map,received:r.parsedType}),T;const a=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([d,c],l)=>({key:a._parse(new re(r,d,r.path,[l,"key"])),value:s._parse(new re(r,c,r.path,[l,"value"]))}));if(r.common.async){const d=new Map;return Promise.resolve().then(async()=>{for(const c of o){const l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return T;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),d.set(l.value,u.value)}return{status:n.value,value:d}})}else{const d=new Map;for(const c of o){const l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return T;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),d.set(l.value,u.value)}return{status:n.value,value:d}}}}un.create=(t,e,n)=>new un({valueType:e,keyType:t,typeName:x.ZodMap,...O(n)});class Me extends j{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==g.set)return f(r,{code:h.invalid_type,expected:g.set,received:r.parsedType}),T;const a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(f(r,{code:h.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(f(r,{code:h.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty());const s=this._def.valueType;function o(c){const l=new Set;for(const u of c){if(u.status==="aborted")return T;u.status==="dirty"&&n.dirty(),l.add(u.value)}return{status:n.value,value:l}}const d=[...r.data.values()].map((c,l)=>s._parse(new re(r,c,r.path,l)));return r.common.async?Promise.all(d).then(c=>o(c)):o(d)}min(e,n){return new Me({...this._def,minSize:{value:e,message:b.toString(n)}})}max(e,n){return new Me({...this._def,maxSize:{value:e,message:b.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}Me.create=(t,e)=>new Me({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...O(e)});class Ye extends j{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.function)return f(n,{code:h.invalid_type,expected:g.function,received:n.parsedType}),T;function r(d,c){return an({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,rn(),Qe].filter(l=>!!l),issueData:{code:h.invalid_arguments,argumentsError:c}})}function a(d,c){return an({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,rn(),Qe].filter(l=>!!l),issueData:{code:h.invalid_return_type,returnTypeError:c}})}const s={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof Xe){const d=this;return W(async function(...c){const l=new q([]),u=await d._def.args.parseAsync(c,s).catch(z=>{throw l.addIssue(r(c,z)),l}),Z=await Reflect.apply(o,this,u);return await d._def.returns._def.type.parseAsync(Z,s).catch(z=>{throw l.addIssue(a(Z,z)),l})})}else{const d=this;return W(function(...c){const l=d._def.args.safeParse(c,s);if(!l.success)throw new q([r(c,l.error)]);const u=Reflect.apply(o,this,l.data),Z=d._def.returns.safeParse(u,s);if(!Z.success)throw new q([a(u,Z.error)]);return Z.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ye({...this._def,args:ae.create(e).rest(Re.create())})}returns(e){return new Ye({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new Ye({args:e||ae.create([]).rest(Re.create()),returns:n||Re.create(),typeName:x.ZodFunction,...O(r)})}}class Tt extends j{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Tt.create=(t,e)=>new Tt({getter:t,typeName:x.ZodLazy,...O(e)});class Ct extends j{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return f(n,{received:n.data,code:h.invalid_literal,expected:this._def.value}),T}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ct.create=(t,e)=>new Ct({value:t,typeName:x.ZodLiteral,...O(e)});function Xn(t,e){return new Ne({values:t,typeName:x.ZodEnum,...O(e)})}class Ne extends j{constructor(){super(...arguments),gt.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return f(n,{expected:E.joinValues(r),received:n.parsedType,code:h.invalid_type}),T}if(on(this,gt)||qn(this,gt,new Set(this._def.values)),!on(this,gt).has(e.data)){const n=this._getOrReturnCtx(e),r=this._def.values;return f(n,{received:n.data,code:h.invalid_enum_value,options:r}),T}return W(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return Ne.create(e,{...this._def,...n})}exclude(e,n=this._def){return Ne.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}gt=new WeakMap,Ne.create=Xn;class Ot extends j{constructor(){super(...arguments),yt.set(this,void 0)}_parse(e){const n=E.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==g.string&&r.parsedType!==g.number){const a=E.objectValues(n);return f(r,{expected:E.joinValues(a),received:r.parsedType,code:h.invalid_type}),T}if(on(this,yt)||qn(this,yt,new Set(E.getValidEnumValues(this._def.values))),!on(this,yt).has(e.data)){const a=E.objectValues(n);return f(r,{received:r.data,code:h.invalid_enum_value,options:a}),T}return W(e.data)}get enum(){return this._def.values}}yt=new WeakMap,Ot.create=(t,e)=>new Ot({values:t,typeName:x.ZodNativeEnum,...O(e)});class Xe extends j{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.promise&&n.common.async===!1)return f(n,{code:h.invalid_type,expected:g.promise,received:n.parsedType}),T;const r=n.parsedType===g.promise?n.data:Promise.resolve(n.data);return W(r.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Xe.create=(t,e)=>new Xe({type:t,typeName:x.ZodPromise,...O(e)});class X extends j{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),a=this._def.effect||null,s={addIssue:o=>{f(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),a.type==="preprocess"){const o=a.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async d=>{if(n.value==="aborted")return T;const c=await this._def.schema._parseAsync({data:d,path:r.path,parent:r});return c.status==="aborted"?T:c.status==="dirty"||n.value==="dirty"?sn(c.value):c});{if(n.value==="aborted")return T;const d=this._def.schema._parseSync({data:o,path:r.path,parent:r});return d.status==="aborted"?T:d.status==="dirty"||n.value==="dirty"?sn(d.value):d}}if(a.type==="refinement"){const o=d=>{const c=a.refinement(d,s);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return d};if(r.common.async===!1){const d=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return d.status==="aborted"?T:(d.status==="dirty"&&n.dirty(),o(d.value),{status:n.value,value:d.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(d=>d.status==="aborted"?T:(d.status==="dirty"&&n.dirty(),o(d.value).then(()=>({status:n.value,value:d.value}))))}if(a.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!ft(o))return o;const d=a.transform(o.value,s);if(d instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:d}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>ft(o)?Promise.resolve(a.transform(o.value,s)).then(d=>({status:n.value,value:d})):o);E.assertNever(a)}}X.create=(t,e,n)=>new X({schema:t,typeName:x.ZodEffects,effect:e,...O(n)}),X.createWithPreprocess=(t,e,n)=>new X({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...O(n)});class se extends j{_parse(e){return this._getType(e)===g.undefined?W(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}se.create=(t,e)=>new se({innerType:t,typeName:x.ZodOptional,...O(e)});class ke extends j{_parse(e){return this._getType(e)===g.null?W(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ke.create=(t,e)=>new ke({innerType:t,typeName:x.ZodNullable,...O(e)});class St extends j{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===g.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}St.create=(t,e)=>new St({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...O(e)});class jt extends j{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return _t(a)?a.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new q(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new q(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}jt.create=(t,e)=>new jt({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...O(e)});class hn extends j{_parse(e){if(this._getType(e)!==g.nan){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.nan,received:n.parsedType}),T}return{status:"valid",value:e.data}}}hn.create=t=>new hn({typeName:x.ZodNaN,...O(t)});const va=Symbol("zod_brand");class Sn extends j{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class It extends j{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?T:a.status==="dirty"?(n.dirty(),sn(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const a=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?T:a.status==="dirty"?(n.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:r.path,parent:r})}}static create(e,n){return new It({in:e,out:n,typeName:x.ZodPipeline})}}class Zt extends j{_parse(e){const n=this._def.innerType._parse(e),r=a=>(ft(a)&&(a.value=Object.freeze(a.value)),a);return _t(n)?n.then(a=>r(a)):r(n)}unwrap(){return this._def.innerType}}Zt.create=(t,e)=>new Zt({innerType:t,typeName:x.ZodReadonly,...O(e)});function er(t,e={},n){return t?He.create().superRefine((r,a)=>{var s,o;if(!t(r)){const d=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,c=(o=(s=d.fatal)!==null&&s!==void 0?s:n)!==null&&o!==void 0?o:!0,l=typeof d=="string"?{message:d}:d;a.addIssue({code:"custom",...l,fatal:c})}}):He.create()}const ba={object:M.lazycreate};var x;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(x||(x={}));const wa=(t,e={message:`Input not instance of ${t.name}`})=>er(n=>n instanceof t,e),tr=G.create,nr=be.create,xa=hn.create,Na=we.create,rr=vt.create,ka=De.create,Ta=dn.create,Ca=bt.create,Oa=wt.create,Sa=He.create,ja=Re.create,Ia=pe.create,Za=cn.create,Ea=Y.create,$a=M.create,Aa=M.strictCreate,Pa=xt.create,Da=ln.create,Ra=Nt.create,Ma=ae.create,La=kt.create,za=un.create,Ua=Me.create,Fa=Ye.create,Va=Tt.create,Ba=Ct.create,Ka=Ne.create,Wa=Ot.create,Ja=Xe.create,ar=X.create,qa=se.create,Qa=ke.create,Ha=X.createWithPreprocess,Ga=It.create;var i=Object.freeze({__proto__:null,defaultErrorMap:Qe,setErrorMap:na,getErrorMap:rn,makeIssue:an,EMPTY_PATH:ra,addIssueToContext:f,ParseStatus:B,INVALID:T,DIRTY:sn,OK:W,isAborted:kn,isDirty:Tn,isValid:ft,isAsync:_t,get util(){return E},get objectUtil(){return Nn},ZodParsedType:g,getParsedType:ve,ZodType:j,datetimeRegex:Yn,ZodString:G,ZodNumber:be,ZodBigInt:we,ZodBoolean:vt,ZodDate:De,ZodSymbol:dn,ZodUndefined:bt,ZodNull:wt,ZodAny:He,ZodUnknown:Re,ZodNever:pe,ZodVoid:cn,ZodArray:Y,ZodObject:M,ZodUnion:xt,ZodDiscriminatedUnion:ln,ZodIntersection:Nt,ZodTuple:ae,ZodRecord:kt,ZodMap:un,ZodSet:Me,ZodFunction:Ye,ZodLazy:Tt,ZodLiteral:Ct,ZodEnum:Ne,ZodNativeEnum:Ot,ZodPromise:Xe,ZodEffects:X,ZodTransformer:X,ZodOptional:se,ZodNullable:ke,ZodDefault:St,ZodCatch:jt,ZodNaN:hn,BRAND:va,ZodBranded:Sn,ZodPipeline:It,ZodReadonly:Zt,custom:er,Schema:j,ZodSchema:j,late:ba,get ZodFirstPartyTypeKind(){return x},coerce:{string:t=>G.create({...t,coerce:!0}),number:t=>be.create({...t,coerce:!0}),boolean:t=>vt.create({...t,coerce:!0}),bigint:t=>we.create({...t,coerce:!0}),date:t=>De.create({...t,coerce:!0})},any:Sa,array:Ea,bigint:Na,boolean:rr,date:ka,discriminatedUnion:Da,effect:ar,enum:Ka,function:Fa,instanceof:wa,intersection:Ra,lazy:Va,literal:Ba,map:za,nan:xa,nativeEnum:Wa,never:Ia,null:Oa,nullable:Qa,number:nr,object:$a,oboolean:()=>rr().optional(),onumber:()=>nr().optional(),optional:qa,ostring:()=>tr().optional(),pipeline:Ga,preprocess:Ha,promise:Ja,record:La,set:Ua,strictObject:Aa,string:tr,symbol:Ta,transformer:ar,tuple:Ma,undefined:Ca,union:Pa,unknown:ja,void:Za,NEVER:T,ZodIssueCode:h,quotelessJson:ta,ZodError:q});ea(i),i.object({start:i.number(),limit:i.number(),length:i.number()});const jn=i.object({created_at:i.string(),updated_at:i.string()}),Ya=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()),Xa=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:Ya.optional()}),sr=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(),app_metadata:i.any().default({}).optional(),user_metadata:i.any().default({}).optional()}),es=sr.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")});i.object({...es.shape,...jn.shape,user_id:i.string(),email:i.string(),is_social:i.boolean(),login_count:i.number(),identities:i.array(Xa).optional()}),sr.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 ts="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ns=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=ts[n[t]&63];return e};const rs=i.object({audience:i.string().optional(),recipient:i.string().optional(),createUpnClaim:i.boolean().optional(),mapUnknownClaimsAsIs:i.boolean().optional(),passthroughClaimsWithNoMapping:i.boolean().optional(),mapIdentities:i.boolean().optional(),signatureAlgorithm:i.string().optional(),digestAlgorithm:i.string().optional(),issuer:i.string().optional(),destination:i.string().optional(),lifetimeInSeconds:i.number().optional(),signResponse:i.boolean().optional(),nameIdentifierFormat:i.string().optional(),nameIdentifierProbes:i.array(i.string()).optional(),authnContextClassRef:i.string().optional(),mappings:i.record(i.string()).optional()}),as=i.object({id:i.string(),name:i.string(),callbacks:i.array(i.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:i.array(i.string()).default([]).optional().openapi({description:"Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level. Query strings and hash information are not taken into account when validating these URLs."}),web_origins:i.array(i.string()).default([]).optional().openapi({description:"Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode."}),allowed_logout_urls:i.array(i.string()).default([]).optional().openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),allowed_clients:i.array(i.string()).default([]).optional().openapi({description:"Ids of clients that will be allowed to perform delegation requests. Clients that will be allowed to make delegation request. By default, all your clients will be allowed. This field allows you to specify specific clients"}),addons:i.object({samlp:rs.optional()}).default({}).optional().openapi({description:"Addons associated with the client. The key is the addon's package name and the value is an object with the configuration for the addon."}),email_validation:i.enum(["enabled","disabled","enforced"]).default("enforced").optional().openapi({description:"Defines if it possible to sign in with an unverified email and if verification emails will be sent. This is not available in auth0"}),client_secret:i.string().default(()=>ns()).optional(),disable_sign_ups:i.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),ss=i.object({created_at:i.string().transform(t=>t===null?"":t),updated_at:i.string().transform(t=>t===null?"":t),...as.shape});var ir=(t=>(t.TOKEN="token",t.TOKEN_ID_TOKEN="token id_token",t.CODE="code",t))(ir||{}),or=(t=>(t.QUERY="query",t.FRAGMENT="fragment",t.FORM_POST="form_post",t.WEB_MESSAGE="web_message",t.SAML_POST="saml_post",t))(or||{}),dr=(t=>(t.S265="S256",t.plain="plain",t))(dr||{});const is=i.object({client_id:i.string(),vendor_id:i.string().optional(),act_as:i.string().optional(),response_type:i.nativeEnum(ir).optional(),response_mode:i.nativeEnum(or).optional(),redirect_uri:i.string().optional(),audience:i.string().optional(),state:i.string().optional(),nonce:i.string().optional(),scope:i.string().optional(),prompt:i.string().optional(),code_challenge_method:i.nativeEnum(dr).optional(),code_challenge:i.string().optional(),username:i.string().optional(),ui_locales:i.string().optional()});i.object({colors:i.object({primary:i.string(),page_background:i.object({type:i.string().optional(),start:i.string().optional(),end:i.string().optional(),angle_deg:i.number().optional()}).optional()}).optional(),logo_url:i.string().optional(),favicon_url:i.string().optional(),font:i.object({url:i.string()}).optional()});const os=i.object({id:i.string().optional(),name:i.string(),strategy:i.enum(["google-oauth2","facebook","vipps","freja","apple","email","Username-Password-Authentication","oidc","oauth2","custom"]).optional(),options:i.object({kid:i.string().optional(),team_id:i.string().optional(),realms:i.string().optional(),client_id:i.string().optional(),client_secret:i.string().optional(),app_secret:i.string().optional(),scope:i.string().optional(),authorization_endpoint:i.string().default("").optional(),token_endpoint:i.string().default("").optional(),userinfo_endpoint:i.string().default("").optional(),jwks_uri:i.string().default("").optional(),discovery_url:i.string().default("").optional(),issuer:i.string().default("").optional()}).default({}).optional(),enabled_clients:i.array(i.string()).default([]).optional(),response_type:i.custom().optional(),response_mode:i.custom().optional()}),cr=i.object({id:i.string(),created_at:i.string().transform(t=>t===null?"":t),updated_at:i.string().transform(t=>t===null?"":t)}).extend(os.shape),ds=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()}),cs=i.object({created_at:i.string().transform(t=>t===null?"":t),updated_at:i.string().transform(t=>t===null?"":t),id:i.string(),...ds.shape});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()});const ls=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()});i.object({...ss.shape,domains:i.array(ls),tenant:cs,connections:i.array(cr)});const us=i.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),hs=i.object({code_id:i.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:i.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:i.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:us,expires_at:i.string(),used_at:i.string().optional(),user_id:i.string().optional()}),ps=i.object({...hs.shape,created_at:i.string()}),ms=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"])});jn.extend({...ms.shape,id:i.string()}),i.object({trigger_id:i.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:i.boolean().default(!1),url:i.string(),hook_id:i.string().optional(),synchronous:i.boolean().default(!1),priority:i.number().optional()}).extend({...jn.shape,hook_id:i.string()});const fs=i.object({alg:i.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:i.string(),kid:i.string(),kty:i.enum(["RSA","EC","oct"]),n:i.string(),x5t:i.string().optional(),x5c:i.array(i.string()).optional(),use:i.enum(["sig","enc"]).optional()});i.object({keys:i.array(fs)}),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 _s=i.object({auth0Client:i.string().optional(),authParams:is,expires_at:i.string(),deleted_at:i.string().optional(),ip:i.string().optional()}).openapi({description:"This represents a login sesion"}),gs=i.object({..._s.shape,login_id:i.string().openapi({description:"This is is used as the state in the universal login"}),created_at:i.string(),updated_at:i.string()}),ys=i.enum(["cls","fsa","fs","f","fc","fcoa","fcp","fh","fp","fs","fu","s","sapi","scoa","scp","scpr","scu","seacft","serft","slo","ss","ssa","sv","svr"]),vs=i.object({name:i.string(),version:i.string(),env:i.object({node:i.string().optional()}).optional()});i.object({type:ys,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:vs.optional()});const bs=i.object({user_id:i.string(),password:i.string(),algorithm:i.enum(["bcrypt","argon2id"]).default("argon2id")});i.object({...bs.shape,created_at:i.string(),updated_at:i.string()});const ws=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(),...ws.shape}),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 private 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"})});var lr=(t=>(t.RefreshToken="refresh_token",t.AuthorizationCode="authorization_code",t.ClientCredential="client_credentials",t.Passwordless="passwordless",t.Password="password",t))(lr||{});const In=i.nativeEnum(lr);i.object({grant_type:In.refine(t=>t==="authorization_code"),code:i.string(),client_secret:i.string(),client_id:i.string()}),i.object({grant_type:In.refine(t=>t==="authorization_code"),code:i.string(),code_verifier:i.string(),client_id:i.string().optional(),redirect_uri:i.string()}),i.object({grant_type:In.refine(t=>t==="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 xs=i.object({button_border_radius:i.number(),button_border_weight:i.number(),buttons_style:i.enum(["pill"]),input_border_radius:i.number(),input_border_weight:i.number(),inputs_style:i.enum(["pill"]),show_widget_shadow:i.boolean(),widget_border_weight:i.number(),widget_corner_radius:i.number()}),Ns=i.object({base_focus_color:i.string(),base_hover_color:i.string(),body_text:i.string(),captcha_widget_theme:i.enum(["auto"]),error:i.string(),header:i.string(),icons:i.string(),input_background:i.string(),input_border:i.string(),input_filled_text:i.string(),input_labels_placeholders:i.string(),links_focused_components:i.string(),primary_button:i.string(),primary_button_label:i.string(),secondary_button_border:i.string(),secondary_button_label:i.string(),success:i.string(),widget_background:i.string(),widget_border:i.string()}),et=i.object({bold:i.boolean(),size:i.number()}),ks=i.object({body_text:et,buttons_text:et,font_url:i.string(),input_labels:et,links:et,links_style:i.enum(["normal"]),reference_text_size:i.number(),subtitle:et,title:et}),Ts=i.object({background_color:i.string(),background_image_url:i.string(),page_layout:i.enum(["center"])}),Cs=i.object({header_text_alignment:i.enum(["center"]),logo_height:i.number(),logo_position:i.enum(["center"]),logo_url:i.string(),social_buttons_layout:i.enum(["bottom"])});i.object({borders:xs,colors:Ns,displayName:i.string(),fonts:ks,page_background:Ts,widget:Cs}).extend({themeId:i.string()});const Os=i.object({universal_login_experience:i.enum(["new","classic"]).default("new"),identifier_first:i.boolean().default(!0),password_first:i.boolean().default(!1),webauthn_platform_first_factor:i.boolean()});function Zn(t){const[e,n]=t.split("|");if(!e||!n)throw new Error(`Invalid user_id: ${t}`);return{connection:e,id:n}}function ur(t){let e={};try{e=JSON.parse(t.profileData||"{}")}catch(n){console.error("Error parsing profileData",n)}return{connection:t.connection,provider:t.provider,user_id:Zn(t.user_id).id,isSocial:!!t.is_social,profileData:{email:t.email,email_verified:!!t.email_verified,...e}}}function Ss(t){return async(e,n)=>{const[r,a]=await Promise.all([t.selectFrom("users").where("users.tenant_id","=",e).where("users.user_id","=",n).selectAll().executeTakeFirst(),t.selectFrom("users").where("users.tenant_id","=",e).where("users.linked_to","=",n).selectAll().execute()]);if(!r)return null;const{tenant_id:s,...o}=r,d={...o,email:r.email||"",email_verified:r.email_verified===1,is_social:r.is_social===1,app_metadata:JSON.parse(r.app_metadata),user_metadata:JSON.parse(r.user_metadata),identities:[{connection:r.connection,provider:r.provider,user_id:Zn(r.user_id).id,isSocial:!!r.is_social},...a.map(ur)]};return R(d)}}function Le(t,e,n,r){return n.split(/\s+/).map(s=>s.replace(/^([^:]+)=/g,"$1:")).map(s=>{let o=s.startsWith("-"),d,c,l,u;return s.startsWith("-_exists_:")?(d=s.substring(10),l=!0,o=!0):s.startsWith("_exists_:")?(d=s.substring(9),l=!0,o=!1):s.includes(":")?(o=s.startsWith("-"),[d,c]=o?s.substring(1).split(":"):s.split(":"),l=!1,c.startsWith(">=")?(u=">=",c=c.substring(2)):c.startsWith(">")?(u=">",c=c.substring(1)):c.startsWith("<=")?(console.log("value",c),u="<=",c=c.substring(2)):c.startsWith("<")?(u="<",c=c.substring(1)):u="="):(d=null,c=s,l=!1),{key:d,value:c,isNegation:o,isExistsQuery:l,operator:u}}).forEach(({key:s,value:o,isNegation:d,isExistsQuery:c,operator:l})=>{if(s)if(c)d?e=e.where(s,"is",null):e=e.where(s,"is not",null);else if(d)switch(l){case">":e=e.where(s,"<=",o);break;case">=":e=e.where(s,"<",o);break;case"<":e=e.where(s,">=",o);break;case"<=":e=e.where(s,">",o);break;default:e=e.where(s,"!=",o)}else e=e.where(s,l,o);else{const{ref:u}=t.dynamic;e=e.where(Z=>Z.or(r.map(z=>Z(u(z),"like",`%${o}%`))))}}),e}function Te(t){return typeof t=="string"?parseInt(t,10):typeof t=="bigint"?Number(t):t}function js(t){return async(e,n)=>{let r=t.selectFrom("users").where("users.tenant_id","=",e);if(n.q&&(r=Le(t,r,n.q,["email","name"])),n.sort&&n.sort.sort_by){const{ref:u}=t.dynamic;r=r.orderBy(u(n.sort.sort_by),n.sort.sort_order)}const s=await r.offset(n.page*n.per_page).limit(n.per_page).selectAll().execute(),o=s.map(u=>u.user_id),d=o.length?await t.selectFrom("users").selectAll().where("users.tenant_id","=",e).where("users.linked_to","in",o).execute():[],c=s.map(u=>{const Z=d.filter(z=>z.linked_to===u.user_id);return R({...u,email_verified:u.email_verified===1,is_social:u.is_social===1,app_metadata:JSON.parse(u.app_metadata),user_metadata:JSON.parse(u.user_metadata),identities:[{connection:u.connection,provider:u.provider,user_id:Zn(u.user_id).id,isSocial:!!u.is_social},...Z.map(ur)]})}),{count:l}=await r.select(u=>u.fn.countAll().as("count")).executeTakeFirstOrThrow();return{users:c,start:n.page*n.per_page,limit:n.per_page,length:Te(l)}}}function Is(t){return async(e,n)=>(await t.deleteFrom("users").where("users.tenant_id","=",e).where("users.linked_to","=",n).execute(),(await t.deleteFrom("users").where("users.tenant_id","=",e).where("users.user_id","=",n).execute()).length===1)}function Zs(t){if(t.email_verified!==void 0)return t.email_verified?1:0}function Es(t){return async(e,n,r)=>{const a={...r,email_verified:Zs(r),updated_at:new Date().toISOString()};return r.app_metadata&&(a.app_metadata=JSON.stringify(r.app_metadata)),r.user_metadata&&(a.user_metadata=JSON.stringify(r.user_metadata)),(await t.updateTable("users").set(a).where("users.tenant_id","=",e).where("users.user_id","=",n).execute()).length===1}}function $s(t){return async(e,n,r,a)=>{const s={linked_to:null};return(await t.updateTable("users").set(s).where("users.tenant_id","=",e).where("users.user_id","=",`${r}|${a}`).where("users.linked_to","=",`${n}`).execute()).length===1}}function As(t){return{create:U(t),remove:Is(t),get:Ss(t),list:js(t),update:Es(t),unlink:$s(t)}}const Ps="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ze=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=Ps[n[t]&63];return e};function Ds(t){return async e=>{const n={id:e.id||ze(),created_at:new Date().toISOString(),updated_at:new Date().toISOString(),...e};return await t.insertInto("tenants").values(n).execute(),n}}function Rs(t){return async e=>{const n=await t.selectFrom("tenants").where("tenants.id","=",e).selectAll().executeTakeFirst();return n?R(n):null}}function Ms(t){return async e=>{let n=t.selectFrom("tenants");if(e.sort&&e.sort.sort_by){const{ref:d}=t.dynamic;n=n.orderBy(d(e.sort.sort_by),e.sort.sort_order)}e.q&&(n=n.where(d=>d.or([d("name","like",`%${e.q}%`)])));const a=await n.offset(e.page*e.per_page).limit(e.per_page).selectAll().execute();if(!e.include_totals)return{tenants:a};const{count:s}=await n.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow(),o=Te(s);return{tenants:a.map(R),start:(e.page-1)*e.per_page,limit:e.per_page,length:o}}}function Ls(t){return async(e,n)=>{const r={...n,id:e,updated_at:new Date().toISOString()};await t.updateTable("tenants").set(r).where("id","=",e).execute()}}function zs(t){return async e=>(await t.deleteFrom("tenants").where("tenants.id","=",e).execute()).length===1}function Us(t){return{create:Ds(t),get:Rs(t),list:Ms(t),update:Ls(t),remove:zs(t)}}function hr(t){return t?JSON.stringify(t):void 0}const Fs=1024;function Vs(t){return async(e,n)=>{var a,s,o;const r={id:ze(),...n,user_agent:n.user_agent.slice(0,Fs)};return await t.insertInto("logs").values({...r,description:(a=r.description)==null?void 0:a.substring(0,256),isMobile:n.isMobile?1:0,tenant_id:e,scope:(s=n.scope)==null?void 0:s.join(","),auth0_client:hr(n.auth0_client),details:(o=hr(n.details))==null?void 0:o.substring(0,8192)}).execute(),r}}function pr(t){if(!t)return"";try{return JSON.parse(t)}catch{return t}}function mr(t){return{...t,client_id:t.client_id,client_name:"",auth0_client:pr(t.auth0_client),details:pr(t.details),isMobile:!!t.isMobile,scope:t.scope?t.scope.split(","):void 0,log_id:t.id,_id:t.id}}function Bs(t){return async(e,n)=>{let r=t.selectFrom("logs").where("logs.tenant_id","=",e);n.q&&(r=Le(t,r,n.q,["user_id","ip"]));let a=r;if(n.sort&&n.sort.sort_by){const{ref:d}=t.dynamic;a=a.orderBy(d(n.sort.sort_by),n.sort.sort_order)}a=a.offset(n.page*n.per_page).limit(n.per_page);const s=await a.selectAll().execute(),{count:o}=await r.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow();return{logs:s.map(mr),start:n.page*n.per_page,limit:n.per_page,length:Te(o)}}}function Ks(t){return async(e,n)=>{const r=await t.selectFrom("logs").where("logs.tenant_id","=",e).where("logs.id","=",n).selectAll().executeTakeFirst();return r?mr(r):null}}function Ws(t){return{create:Vs(t),list:Bs(t),get:Ks(t)}}function Js(t){return async(e,n)=>await t.selectFrom("sessions").where("sessions.tenant_id","=",e).where("sessions.session_id","=",n).where("sessions.deleted_at","is",null).selectAll().executeTakeFirst()??null}function qs(t){return async(e,n)=>{const r={...n,created_at:new Date().toISOString(),expires_at:new Date().toISOString()};return await t.insertInto("sessions").values({...r,tenant_id:e}).execute(),{...n,...r}}}function Qs(t){return async(e,n)=>!!(await t.updateTable("sessions").set({deleted_at:new Date().toISOString()}).where("tenant_id","=",e).where("sessions.session_id","=",n).where("sessions.deleted_at","is",null).execute()).length}function Hs(t){return async(e,n,r)=>!!(await t.updateTable("sessions").set(r).where("tenant_id","=",e).where("sessions.session_id","=",n).where("sessions.deleted_at","is",null).execute()).length}function Gs(t){return async(e,n)=>{let r=t.selectFrom("sessions").where("sessions.tenant_id","=",e);n.q&&(r=Le(t,r,n.q,["user_id","session_id"]));let a=r;if(n.sort&&n.sort.sort_by){const{ref:c}=t.dynamic;a=a.orderBy(c(n.sort.sort_by),n.sort.sort_order)}a=a.offset(n.page*n.per_page).limit(n.per_page);const s=await a.selectAll().execute(),{count:o}=await r.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow(),d=Te(o);return{sessions:s,start:n.page*n.per_page,limit:n.per_page,length:d}}}function Ys(t){return{create:qs(t),get:Js(t),list:Gs(t),remove:Qs(t),update:Hs(t)}}function Xs(t){return async(e,n)=>{const r=await t.selectFrom("tickets").where("tickets.tenant_id","=",e).where("tickets.id","=",n).where("tickets.used_at","is",null).selectAll().executeTakeFirst();if(!r)return null;const{nonce:a,state:s,scope:o,response_type:d,response_mode:c,redirect_uri:l,...u}=r;return{...u,authParams:{nonce:a,state:s,scope:o,response_type:d,response_mode:c,redirect_uri:l},created_at:new Date(r.created_at),expires_at:new Date(r.expires_at),used_at:r.used_at?new Date(r.used_at):void 0}}}function ei(t){return async e=>{const{authParams:n,...r}=e,a={...r,...n,created_at:e.created_at.toISOString(),expires_at:e.expires_at.toISOString(),used_at:e.used_at?e.used_at.toISOString():void 0};await t.insertInto("tickets").values(a).execute()}}function ti(t){return async(e,n)=>{await t.updateTable("tickets").set({used_at:new Date().toISOString()}).where("tickets.tenant_id","=",e).where("tickets.id","=",n).execute()}}function ni(t){return{create:ei(t),get:Xs(t),remove:ti(t)}}function ri(t){return async(e,n)=>{const r=await t.selectFrom("passwords").where("passwords.tenant_id","=",e).where("passwords.user_id","=",n).selectAll().executeTakeFirstOrThrow(),{tenant_id:a,...s}=r;return s}}function ai(t){return async(e,n)=>{const r={...n,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await t.insertInto("passwords").values({...r,tenant_id:e}).execute(),r}}function si(t){return async(e,n)=>(await t.updateTable("passwords").set({password:n.password,updated_at:new Date().toISOString()}).where("tenant_id","=",e).where("user_id","=",n.user_id).execute()).length===1}function ii(t){return{create:ai(t),update:si(t),get:ri(t)}}function oi(t){return async(e,n)=>{let r=t.selectFrom("codes").where("codes.tenant_id","=",e);n.q&&(r=Le(t,r,n.q,["code","login_id"]));const s=await r.offset(n.page*n.per_page).limit(n.per_page).selectAll().execute(),{count:o}=await r.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{codes:s.map(c=>{const{tenant_id:l,...u}=c;return ps.parse(R(u))}),start:n.page*n.per_page,limit:n.per_page,length:Te(o)}}}function di(t){return async(e,n)=>{const r={...n,created_at:new Date().toISOString()};return await t.insertInto("codes").values({...r,tenant_id:e}).execute(),r}}function ci(t){return async(e,n)=>(await t.deleteFrom("codes").where("codes.tenant_id","=",e).where("codes.code_id","=",n).executeTakeFirst()).numDeletedRows>0}function li(t){return async(e,n,r)=>{let a=t.selectFrom("codes").where("codes.code_id","=",n).where("codes.code_type","=",r).where("codes.expires_at",">",new Date().toISOString());e.length&&(a=a.where("codes.tenant_id","=",e));const s=await a.selectAll().executeTakeFirst();return s?R(s):null}}function ui(t){return{create:di(t),list:oi(t),remove:ci(t),get:li(t)}}function hi(t){return async(e,n)=>{const r={created_at:new Date().toISOString(),updated_at:new Date().toISOString(),...n},a=JSON.stringify(n.allowed_origins),s=JSON.stringify(n.callbacks),o=JSON.stringify(n.web_origins),d=JSON.stringify(n.allowed_logout_urls),c=JSON.stringify(n.allowed_clients);return await t.insertInto("applications").values({...r,tenant_id:e,disable_sign_ups:n.disable_sign_ups?1:0,addons:n.addons?JSON.stringify(n.addons):"{}",callbacks:s,allowed_origins:a,web_origins:o,allowed_logout_urls:d,allowed_clients:c}).execute(),r}}function pi(t){return async e=>({applications:(await t.selectFrom("applications").where("applications.tenant_id","=",e).selectAll().execute()).map(s=>({...s,disable_sign_ups:!!s.disable_sign_ups,addons:s.addons?JSON.parse(s.addons):{},callbacks:s.callbacks?JSON.parse(s.callbacks):[],allowed_origins:s.allowed_origins?JSON.parse(s.allowed_origins):[],web_origins:s.web_origins?JSON.parse(s.web_origins):[],allowed_logout_urls:s.allowed_logout_urls?JSON.parse(s.allowed_logout_urls):[],allowed_clients:s.allowed_logout_urls?JSON.parse(s.allowed_logout_urls):[]}))})}function mi(t){return async(e,n)=>{const r=await t.selectFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",n).selectAll().executeTakeFirst();return r?R({...r,disable_sign_ups:!!r.disable_sign_ups,addons:JSON.parse(r.addons),callbacks:JSON.parse(r.callbacks),allowed_origins:JSON.parse(r.allowed_origins),web_origins:JSON.parse(r.web_origins),allowed_logout_urls:JSON.parse(r.allowed_logout_urls)}):null}}function fi(t){return async(e,n)=>(await t.deleteFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",n).executeTakeFirst()).numDeletedRows>0}function _i(t){return async(e,n,r)=>{const a={...r,updated_at:new Date().toISOString(),allowed_origins:r.allowed_origins?JSON.stringify(r.allowed_origins):void 0,callbacks:r.callbacks?JSON.stringify(r.callbacks):void 0,web_origins:r.web_origins?JSON.stringify(r.web_origins):void 0,allowed_logout_urls:r.allowed_logout_urls?JSON.stringify(r.allowed_logout_urls):void 0,allowed_clients:r.allowed_clients?JSON.stringify(r.allowed_clients):void 0,addons:r.addons?JSON.stringify(r.addons):"{}",disable_sign_ups:r.disable_sign_ups?1:0};return await t.updateTable("applications").set(a).where("applications.id","=",n).where("applications.tenant_id","=",e).execute(),!0}}function gi(t){return{create:hi(t),list:pi(t),get:mi(t),remove:fi(t),update:_i(t)}}function yi(t){return async(e,n)=>{const r={id:ze(),...n,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await t.insertInto("connections").values({...r,options:JSON.stringify(r.options||{}),tenant_id:e}).execute(),r}}function vi(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,r=Object.getOwnPropertySymbols(t);a<r.length;a++)e.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(t,r[a])&&(n[r[a]]=t[r[a]]);return n}typeof SuppressedError=="function"&&SuppressedError;function bi(t,e){var n;return((n=t==null?void 0:t._def)===null||n===void 0?void 0:n.typeName)===e}function Et(t,e){const n=t.ZodType.prototype[e];t.ZodType.prototype[e]=function(...r){const a=n.apply(this,r);return a._def.openapi=this._def.openapi,a}}function wi(t){if(typeof t.ZodType.prototype.openapi<"u")return;t.ZodType.prototype.openapi=function(a,s){var o,d,c,l,u,Z;const z=typeof a=="string"?s:a,H=z??{},{param:Ze}=H,dt=vi(H,["param"]),Ee=Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o._internal),typeof a=="string"?{refId:a}:void 0),$e=Object.assign(Object.assign(Object.assign({},(d=this._def.openapi)===null||d===void 0?void 0:d.metadata),dt),!((l=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||l===void 0)&&l.param||Ze?{param:Object.assign(Object.assign({},(Z=(u=this._def.openapi)===null||u===void 0?void 0:u.metadata)===null||Z===void 0?void 0:Z.param),Ze)}:void 0),Ae=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(Ee).length>0?{_internal:Ee}:void 0),Object.keys($e).length>0?{metadata:$e}:void 0)}));if(bi(this,"ZodObject")){const ct=this.extend;Ae.extend=function(...lt){var ce,le,ue,Pe,We,Je;const qe=ct.apply(this,lt);return qe._def.openapi={_internal:{extendedFrom:!((le=(ce=this._def.openapi)===null||ce===void 0?void 0:ce._internal)===null||le===void 0)&&le.refId?{refId:(Pe=(ue=this._def.openapi)===null||ue===void 0?void 0:ue._internal)===null||Pe===void 0?void 0:Pe.refId,schema:this}:(We=this._def.openapi)===null||We===void 0?void 0:We._internal.extendedFrom},metadata:(Je=qe._def.openapi)===null||Je===void 0?void 0:Je.metadata},qe}}return Ae},Et(t,"optional"),Et(t,"nullable"),Et(t,"default"),Et(t,"transform"),Et(t,"refine");const e=t.ZodObject.prototype.deepPartial;t.ZodObject.prototype.deepPartial=function(){const a=this._def.shape(),s=e.apply(this),o=s._def.shape();return Object.entries(o).forEach(([d,c])=>{var l,u;c._def.openapi=(u=(l=a[d])===null||l===void 0?void 0:l._def)===null||u===void 0?void 0:u.openapi}),s._def.openapi=void 0,s};const n=t.ZodObject.prototype.pick;t.ZodObject.prototype.pick=function(...a){const s=n.apply(this,a);return s._def.openapi=void 0,s};const r=t.ZodObject.prototype.omit;t.ZodObject.prototype.omit=function(...a){const s=r.apply(this,a);return s._def.openapi=void 0,s}}new Set(".\\+*[^]$()");var $;(function(t){t.assertEqual=a=>a;function e(a){}t.assertIs=e;function n(a){throw new Error}t.assertNever=n,t.arrayToEnum=a=>{const s={};for(const o of a)s[o]=o;return s},t.getValidEnumValues=a=>{const s=t.objectKeys(a).filter(d=>typeof a[a[d]]!="number"),o={};for(const d of s)o[d]=a[d];return t.objectValues(o)},t.objectValues=a=>t.objectKeys(a).map(function(s){return a[s]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const s=[];for(const o in a)Object.prototype.hasOwnProperty.call(a,o)&&s.push(o);return s},t.find=(a,s)=>{for(const o of a)if(s(o))return o},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&isFinite(a)&&Math.floor(a)===a;function r(a,s=" | "){return a.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}t.joinValues=r,t.jsonStringifyReplacer=(a,s)=>typeof s=="bigint"?s.toString():s})($||($={}));var En;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(En||(En={}));const y=$.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ce=t=>{switch(typeof t){case"undefined":return y.undefined;case"string":return y.string;case"number":return isNaN(t)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(t)?y.array:t===null?y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?y.promise:typeof Map<"u"&&t instanceof Map?y.map:typeof Set<"u"&&t instanceof Set?y.set:typeof Date<"u"&&t instanceof Date?y.date:y.object;default:return y.unknown}},p=$.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"]),xi=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class Q extends Error{constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const n=e||function(s){return s.message},r={_errors:[]},a=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(a);else if(o.code==="invalid_return_type")a(o.returnTypeError);else if(o.code==="invalid_arguments")a(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let d=r,c=0;for(;c<o.path.length;){const l=o.path[c];c===o.path.length-1?(d[l]=d[l]||{_errors:[]},d[l]._errors.push(n(o))):d[l]=d[l]||{_errors:[]},d=d[l],c++}}};return a(this),r}static assert(e){if(!(e instanceof Q))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,$.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},r=[];for(const a of this.issues)a.path.length>0?(n[a.path[0]]=n[a.path[0]]||[],n[a.path[0]].push(e(a))):r.push(e(a));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Q.create=t=>new Q(t);const tt=(t,e)=>{let n;switch(t.code){case p.invalid_type:t.received===y.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case p.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,$.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:n=`Unrecognized key(s) in object: ${$.joinValues(t.keys,", ")}`;break;case p.invalid_union:n="Invalid input";break;case p.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${$.joinValues(t.options)}`;break;case p.invalid_enum_value:n=`Invalid enum value. Expected ${$.joinValues(t.options)}, received '${t.received}'`;break;case p.invalid_arguments:n="Invalid function arguments";break;case p.invalid_return_type:n="Invalid function return type";break;case p.invalid_date:n="Invalid date";break;case p.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:$.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case p.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case p.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case p.custom:n="Invalid input";break;case p.invalid_intersection_types:n="Intersection results could not be merged";break;case p.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case p.not_finite:n="Number must be finite";break;default:n=e.defaultError,$.assertNever(t)}return{message:n}};let fr=tt;function Ni(t){fr=t}function pn(){return fr}const mn=t=>{const{data:e,path:n,errorMaps:r,issueData:a}=t,s=[...n,...a.path||[]],o={...a,path:s};if(a.message!==void 0)return{...a,path:s,message:a.message};let d="";const c=r.filter(l=>!!l).slice().reverse();for(const l of c)d=l(o,{data:e,defaultError:d}).message;return{...a,path:s,message:d}},ki=[];function _(t,e){const n=pn(),r=mn({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===tt?void 0:tt].filter(a=>!!a)});t.common.issues.push(r)}class K{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const a of n){if(a.status==="aborted")return k;a.status==="dirty"&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const a of n){const s=await a.key,o=await a.value;r.push({key:s,value:o})}return K.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const a of n){const{key:s,value:o}=a;if(s.status==="aborted"||o.status==="aborted")return k;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||a.alwaysSet)&&(r[s.value]=o.value)}return{status:e.value,value:r}}}const k=Object.freeze({status:"aborted"}),nt=t=>({status:"dirty",value:t}),J=t=>({status:"valid",value:t}),$n=t=>t.status==="aborted",An=t=>t.status==="dirty",$t=t=>t.status==="valid",At=t=>typeof Promise<"u"&&t instanceof Promise;function fn(t,e,n,r){if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function _r(t,e,n,r,a){if(typeof e=="function"?t!==e||!a:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}typeof SuppressedError=="function"&&SuppressedError;var w;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(w||(w={}));var Pt,Dt;class ie{constructor(e,n,r,a){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=a}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 gr=(t,e)=>{if($t(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Q(t.common.issues);return this._error=n,this._error}}};function S(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:a}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(o,d)=>{var c,l;const{message:u}=t;return o.code==="invalid_enum_value"?{message:u??d.defaultError}:typeof d.data>"u"?{message:(c=u??r)!==null&&c!==void 0?c:d.defaultError}:o.code!=="invalid_type"?{message:d.defaultError}:{message:(l=u??n)!==null&&l!==void 0?l:d.defaultError}},description:a}}class I{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 Ce(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:Ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new K,ctx:{common:e.parent.common,data:e.data,parsedType:Ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(At(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){var r;const a={common:{issues:[],async:(r=n==null?void 0:n.async)!==null&&r!==void 0?r:!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ce(e)},s=this._parseSync({data:e,path:a.path,parent:a});return gr(a,s)}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ce(e)},a=this._parse({data:e,path:r.path,parent:r}),s=await(At(a)?a:Promise.resolve(a));return gr(r,s)}refine(e,n){const r=a=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(a):n;return this._refinement((a,s)=>{const o=e(a),d=()=>s.addIssue({code:p.custom,...r(a)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(d(),!1)):o?!0:(d(),!1)})}refinement(e,n){return this._refinement((r,a)=>e(r)?!0:(a.addIssue(typeof n=="function"?n(r,a):n),!1))}_refinement(e){return new ne({schema:this,typeName:N.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return de.create(this,this._def)}nullable(){return Ie.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return te.create(this,this._def)}promise(){return it.create(this,this._def)}or(e){return zt.create([this,e],this._def)}and(e){return Ut.create(this,e,this._def)}transform(e){return new ne({...S(this._def),schema:this,typeName:N.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new Wt({...S(this._def),innerType:this,defaultValue:n,typeName:N.ZodDefault})}brand(){return new Rn({typeName:N.ZodBranded,type:this,...S(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new Jt({...S(this._def),innerType:this,catchValue:n,typeName:N.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return qt.create(this,e)}readonly(){return Qt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ti=/^c[^\s-]{8,}$/i,Ci=/^[0-9a-z]+$/,Oi=/^[0-9A-HJKMNP-TV-Z]{26}$/,Si=/^[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,ji=/^[a-z0-9_-]{21}$/i,Ii=/^[-+]?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)?)??$/,Zi=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ei="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Pn;const $i=/^(?:(?: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])$/,Ai=/^(([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})))$/,Pi=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,yr="((\\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])))",Di=new RegExp(`^${yr}$`);function vr(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Ri(t){return new RegExp(`^${vr(t)}$`)}function br(t){let e=`${yr}T${vr(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Mi(t,e){return!!((e==="v4"||!e)&&$i.test(t)||(e==="v6"||!e)&&Ai.test(t))}class ee extends I{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){const s=this._getOrReturnCtx(e);return _(s,{code:p.invalid_type,expected:y.string,received:s.parsedType}),k}const r=new K;let a;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(a=this._getOrReturnCtx(e,a),_(a,{code:p.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(a=this._getOrReturnCtx(e,a),_(a,{code:p.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=e.data.length>s.value,d=e.data.length<s.value;(o||d)&&(a=this._getOrReturnCtx(e,a),o?_(a,{code:p.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):d&&_(a,{code:p.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")Zi.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"email",code:p.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Pn||(Pn=new RegExp(Ei,"u")),Pn.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"emoji",code:p.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")Si.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"uuid",code:p.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")ji.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"nanoid",code:p.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")Ti.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"cuid",code:p.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")Ci.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"cuid2",code:p.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")Oi.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"ulid",code:p.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),_(a,{validation:"url",code:p.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"regex",code:p.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(a=this._getOrReturnCtx(e,a),_(a,{code:p.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(a=this._getOrReturnCtx(e,a),_(a,{code:p.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(a=this._getOrReturnCtx(e,a),_(a,{code:p.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?br(s).test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{code:p.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?Di.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{code:p.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?Ri(s).test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{code:p.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?Ii.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"duration",code:p.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?Mi(e.data,s.version)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"ip",code:p.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?Pi.test(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{validation:"base64",code:p.invalid_string,message:s.message}),r.dirty()):$.assertNever(s);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(a=>e.test(a),{validation:n,code:p.invalid_string,...w.errToObj(r)})}_addCheck(e){return new ee({...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 n,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(n=e==null?void 0:e.offset)!==null&&n!==void 0?n:!1,local:(r=e==null?void 0:e.local)!==null&&r!==void 0?r:!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,n){return this._addCheck({kind:"regex",regex:e,...w.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...w.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...w.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...w.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...w.errToObj(n)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new ee({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ee({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ee({...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 n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}ee.create=t=>{var e;return new ee({checks:[],typeName:N.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...S(t)})};function Li(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,a=n>r?n:r,s=parseInt(t.toFixed(a).replace(".","")),o=parseInt(e.toFixed(a).replace(".",""));return s%o/Math.pow(10,a)}class Oe extends I{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)!==y.number){const s=this._getOrReturnCtx(e);return _(s,{code:p.invalid_type,expected:y.number,received:s.parsedType}),k}let r;const a=new K;for(const s of this._def.checks)s.kind==="int"?$.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{code:p.invalid_type,expected:"integer",received:"float",message:s.message}),a.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),_(r,{code:p.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),a.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),_(r,{code:p.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),a.dirty()):s.kind==="multipleOf"?Li(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),_(r,{code:p.not_multiple_of,multipleOf:s.value,message:s.message}),a.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{code:p.not_finite,message:s.message}),a.dirty()):$.assertNever(s);return{status:a.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,w.toString(n))}gt(e,n){return this.setLimit("min",e,!1,w.toString(n))}lte(e,n){return this.setLimit("max",e,!0,w.toString(n))}lt(e,n){return this.setLimit("max",e,!1,w.toString(n))}setLimit(e,n,r,a){return new Oe({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:w.toString(a)}]})}_addCheck(e){return new Oe({...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,n){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(n)})}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 n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&$.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}}Oe.create=t=>new Oe({checks:[],typeName:N.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...S(t)});class Se extends I{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)!==y.bigint){const s=this._getOrReturnCtx(e);return _(s,{code:p.invalid_type,expected:y.bigint,received:s.parsedType}),k}let r;const a=new K;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),_(r,{code:p.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),a.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),_(r,{code:p.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),a.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),_(r,{code:p.not_multiple_of,multipleOf:s.value,message:s.message}),a.dirty()):$.assertNever(s);return{status:a.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,w.toString(n))}gt(e,n){return this.setLimit("min",e,!1,w.toString(n))}lte(e,n){return this.setLimit("max",e,!0,w.toString(n))}lt(e,n){return this.setLimit("max",e,!1,w.toString(n))}setLimit(e,n,r,a){return new Se({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:w.toString(a)}]})}_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,n){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}Se.create=t=>{var e;return new Se({checks:[],typeName:N.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...S(t)})};class Rt extends I{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){const r=this._getOrReturnCtx(e);return _(r,{code:p.invalid_type,expected:y.boolean,received:r.parsedType}),k}return J(e.data)}}Rt.create=t=>new Rt({typeName:N.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...S(t)});class Ue extends I{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){const s=this._getOrReturnCtx(e);return _(s,{code:p.invalid_type,expected:y.date,received:s.parsedType}),k}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return _(s,{code:p.invalid_date}),k}const r=new K;let a;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(a=this._getOrReturnCtx(e,a),_(a,{code:p.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(a=this._getOrReturnCtx(e,a),_(a,{code:p.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):$.assertNever(s);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ue({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}Ue.create=t=>new Ue({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:N.ZodDate,...S(t)});class _n extends I{_parse(e){if(this._getType(e)!==y.symbol){const r=this._getOrReturnCtx(e);return _(r,{code:p.invalid_type,expected:y.symbol,received:r.parsedType}),k}return J(e.data)}}_n.create=t=>new _n({typeName:N.ZodSymbol,...S(t)});class Mt extends I{_parse(e){if(this._getType(e)!==y.undefined){const r=this._getOrReturnCtx(e);return _(r,{code:p.invalid_type,expected:y.undefined,received:r.parsedType}),k}return J(e.data)}}Mt.create=t=>new Mt({typeName:N.ZodUndefined,...S(t)});class Lt extends I{_parse(e){if(this._getType(e)!==y.null){const r=this._getOrReturnCtx(e);return _(r,{code:p.invalid_type,expected:y.null,received:r.parsedType}),k}return J(e.data)}}Lt.create=t=>new Lt({typeName:N.ZodNull,...S(t)});class rt extends I{constructor(){super(...arguments),this._any=!0}_parse(e){return J(e.data)}}rt.create=t=>new rt({typeName:N.ZodAny,...S(t)});class Fe extends I{constructor(){super(...arguments),this._unknown=!0}_parse(e){return J(e.data)}}Fe.create=t=>new Fe({typeName:N.ZodUnknown,...S(t)});class me extends I{_parse(e){const n=this._getOrReturnCtx(e);return _(n,{code:p.invalid_type,expected:y.never,received:n.parsedType}),k}}me.create=t=>new me({typeName:N.ZodNever,...S(t)});class gn extends I{_parse(e){if(this._getType(e)!==y.undefined){const r=this._getOrReturnCtx(e);return _(r,{code:p.invalid_type,expected:y.void,received:r.parsedType}),k}return J(e.data)}}gn.create=t=>new gn({typeName:N.ZodVoid,...S(t)});class te extends I{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),a=this._def;if(n.parsedType!==y.array)return _(n,{code:p.invalid_type,expected:y.array,received:n.parsedType}),k;if(a.exactLength!==null){const o=n.data.length>a.exactLength.value,d=n.data.length<a.exactLength.value;(o||d)&&(_(n,{code:o?p.too_big:p.too_small,minimum:d?a.exactLength.value:void 0,maximum:o?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(a.minLength!==null&&n.data.length<a.minLength.value&&(_(n,{code:p.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),a.maxLength!==null&&n.data.length>a.maxLength.value&&(_(n,{code:p.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,d)=>a.type._parseAsync(new ie(n,o,n.path,d)))).then(o=>K.mergeArray(r,o));const s=[...n.data].map((o,d)=>a.type._parseSync(new ie(n,o,n.path,d)));return K.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new te({...this._def,minLength:{value:e,message:w.toString(n)}})}max(e,n){return new te({...this._def,maxLength:{value:e,message:w.toString(n)}})}length(e,n){return new te({...this._def,exactLength:{value:e,message:w.toString(n)}})}nonempty(e){return this.min(1,e)}}te.create=(t,e)=>new te({type:t,minLength:null,maxLength:null,exactLength:null,typeName:N.ZodArray,...S(e)});function at(t){if(t instanceof L){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=de.create(at(r))}return new L({...t._def,shape:()=>e})}else return t instanceof te?new te({...t._def,type:at(t.element)}):t instanceof de?de.create(at(t.unwrap())):t instanceof Ie?Ie.create(at(t.unwrap())):t instanceof oe?oe.create(t.items.map(e=>at(e))):t}class L extends I{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(),n=$.objectKeys(e);return this._cached={shape:e,keys:n}}_parse(e){if(this._getType(e)!==y.object){const l=this._getOrReturnCtx(e);return _(l,{code:p.invalid_type,expected:y.object,received:l.parsedType}),k}const{status:r,ctx:a}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),d=[];if(!(this._def.catchall instanceof me&&this._def.unknownKeys==="strip"))for(const l in a.data)o.includes(l)||d.push(l);const c=[];for(const l of o){const u=s[l],Z=a.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new ie(a,Z,a.path,l)),alwaysSet:l in a.data})}if(this._def.catchall instanceof me){const l=this._def.unknownKeys;if(l==="passthrough")for(const u of d)c.push({key:{status:"valid",value:u},value:{status:"valid",value:a.data[u]}});else if(l==="strict")d.length>0&&(_(a,{code:p.unrecognized_keys,keys:d}),r.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const u of d){const Z=a.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new ie(a,Z,a.path,u)),alwaysSet:u in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const l=[];for(const u of c){const Z=await u.key,z=await u.value;l.push({key:Z,value:z,alwaysSet:u.alwaysSet})}return l}).then(l=>K.mergeObjectSync(r,l)):K.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new L({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{var a,s,o,d;const c=(o=(s=(a=this._def).errorMap)===null||s===void 0?void 0:s.call(a,n,r).message)!==null&&o!==void 0?o:r.defaultError;return n.code==="unrecognized_keys"?{message:(d=w.errToObj(e).message)!==null&&d!==void 0?d:c}:{message:c}}}:{}})}strip(){return new L({...this._def,unknownKeys:"strip"})}passthrough(){return new L({...this._def,unknownKeys:"passthrough"})}extend(e){return new L({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new L({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:N.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new L({...this._def,catchall:e})}pick(e){const n={};return $.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(n[r]=this.shape[r])}),new L({...this._def,shape:()=>n})}omit(e){const n={};return $.objectKeys(this.shape).forEach(r=>{e[r]||(n[r]=this.shape[r])}),new L({...this._def,shape:()=>n})}deepPartial(){return at(this)}partial(e){const n={};return $.objectKeys(this.shape).forEach(r=>{const a=this.shape[r];e&&!e[r]?n[r]=a:n[r]=a.optional()}),new L({...this._def,shape:()=>n})}required(e){const n={};return $.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof de;)s=s._def.innerType;n[r]=s}}),new L({...this._def,shape:()=>n})}keyof(){return wr($.objectKeys(this.shape))}}L.create=(t,e)=>new L({shape:()=>t,unknownKeys:"strip",catchall:me.create(),typeName:N.ZodObject,...S(e)}),L.strictCreate=(t,e)=>new L({shape:()=>t,unknownKeys:"strict",catchall:me.create(),typeName:N.ZodObject,...S(e)}),L.lazycreate=(t,e)=>new L({shape:t,unknownKeys:"strip",catchall:me.create(),typeName:N.ZodObject,...S(e)});class zt extends I{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function a(s){for(const d of s)if(d.result.status==="valid")return d.result;for(const d of s)if(d.result.status==="dirty")return n.common.issues.push(...d.ctx.common.issues),d.result;const o=s.map(d=>new Q(d.ctx.common.issues));return _(n,{code:p.invalid_union,unionErrors:o}),k}if(n.common.async)return Promise.all(r.map(async s=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(a);{let s;const o=[];for(const c of r){const l={...n,common:{...n.common,issues:[]},parent:null},u=c._parseSync({data:n.data,path:n.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!s&&(s={result:u,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const d=o.map(c=>new Q(c));return _(n,{code:p.invalid_union,unionErrors:d}),k}}get options(){return this._def.options}}zt.create=(t,e)=>new zt({options:t,typeName:N.ZodUnion,...S(e)});const fe=t=>t instanceof Vt?fe(t.schema):t instanceof ne?fe(t.innerType()):t instanceof Bt?[t.value]:t instanceof je?t.options:t instanceof Kt?$.objectValues(t.enum):t instanceof Wt?fe(t._def.innerType):t instanceof Mt?[void 0]:t instanceof Lt?[null]:t instanceof de?[void 0,...fe(t.unwrap())]:t instanceof Ie?[null,...fe(t.unwrap())]:t instanceof Rn||t instanceof Qt?fe(t.unwrap()):t instanceof Jt?fe(t._def.innerType):[];class yn extends I{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.object)return _(n,{code:p.invalid_type,expected:y.object,received:n.parsedType}),k;const r=this.discriminator,a=n.data[r],s=this.optionsMap.get(a);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(_(n,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),k)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){const a=new Map;for(const s of n){const o=fe(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const d of o){if(a.has(d))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(d)}`);a.set(d,s)}}return new yn({typeName:N.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:a,...S(r)})}}function Dn(t,e){const n=Ce(t),r=Ce(e);if(t===e)return{valid:!0,data:t};if(n===y.object&&r===y.object){const a=$.objectKeys(e),s=$.objectKeys(t).filter(d=>a.indexOf(d)!==-1),o={...t,...e};for(const d of s){const c=Dn(t[d],e[d]);if(!c.valid)return{valid:!1};o[d]=c.data}return{valid:!0,data:o}}else if(n===y.array&&r===y.array){if(t.length!==e.length)return{valid:!1};const a=[];for(let s=0;s<t.length;s++){const o=t[s],d=e[s],c=Dn(o,d);if(!c.valid)return{valid:!1};a.push(c.data)}return{valid:!0,data:a}}else return n===y.date&&r===y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Ut extends I{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),a=(s,o)=>{if($n(s)||$n(o))return k;const d=Dn(s.value,o.value);return d.valid?((An(s)||An(o))&&n.dirty(),{status:n.value,value:d.data}):(_(r,{code:p.invalid_intersection_types}),k)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>a(s,o)):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Ut.create=(t,e,n)=>new Ut({left:t,right:e,typeName:N.ZodIntersection,...S(n)});class oe extends I{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.array)return _(r,{code:p.invalid_type,expected:y.array,received:r.parsedType}),k;if(r.data.length<this._def.items.length)return _(r,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),k;!this._def.rest&&r.data.length>this._def.items.length&&(_(r,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const s=[...r.data].map((o,d)=>{const c=this._def.items[d]||this._def.rest;return c?c._parse(new ie(r,o,r.path,d)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>K.mergeArray(n,o)):K.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new oe({...this._def,rest:e})}}oe.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new oe({items:t,typeName:N.ZodTuple,rest:null,...S(e)})};class Ft extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.object)return _(r,{code:p.invalid_type,expected:y.object,received:r.parsedType}),k;const a=[],s=this._def.keyType,o=this._def.valueType;for(const d in r.data)a.push({key:s._parse(new ie(r,d,r.path,d)),value:o._parse(new ie(r,r.data[d],r.path,d)),alwaysSet:d in r.data});return r.common.async?K.mergeObjectAsync(n,a):K.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof I?new Ft({keyType:e,valueType:n,typeName:N.ZodRecord,...S(r)}):new Ft({keyType:ee.create(),valueType:e,typeName:N.ZodRecord,...S(n)})}}class vn extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.map)return _(r,{code:p.invalid_type,expected:y.map,received:r.parsedType}),k;const a=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([d,c],l)=>({key:a._parse(new ie(r,d,r.path,[l,"key"])),value:s._parse(new ie(r,c,r.path,[l,"value"]))}));if(r.common.async){const d=new Map;return Promise.resolve().then(async()=>{for(const c of o){const l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return k;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),d.set(l.value,u.value)}return{status:n.value,value:d}})}else{const d=new Map;for(const c of o){const l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return k;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),d.set(l.value,u.value)}return{status:n.value,value:d}}}}vn.create=(t,e,n)=>new vn({valueType:e,keyType:t,typeName:N.ZodMap,...S(n)});class Ve extends I{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.set)return _(r,{code:p.invalid_type,expected:y.set,received:r.parsedType}),k;const a=this._def;a.minSize!==null&&r.data.size<a.minSize.value&&(_(r,{code:p.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()),a.maxSize!==null&&r.data.size>a.maxSize.value&&(_(r,{code:p.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty());const s=this._def.valueType;function o(c){const l=new Set;for(const u of c){if(u.status==="aborted")return k;u.status==="dirty"&&n.dirty(),l.add(u.value)}return{status:n.value,value:l}}const d=[...r.data.values()].map((c,l)=>s._parse(new ie(r,c,r.path,l)));return r.common.async?Promise.all(d).then(c=>o(c)):o(d)}min(e,n){return new Ve({...this._def,minSize:{value:e,message:w.toString(n)}})}max(e,n){return new Ve({...this._def,maxSize:{value:e,message:w.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}Ve.create=(t,e)=>new Ve({valueType:t,minSize:null,maxSize:null,typeName:N.ZodSet,...S(e)});class st extends I{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.function)return _(n,{code:p.invalid_type,expected:y.function,received:n.parsedType}),k;function r(d,c){return mn({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,pn(),tt].filter(l=>!!l),issueData:{code:p.invalid_arguments,argumentsError:c}})}function a(d,c){return mn({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,pn(),tt].filter(l=>!!l),issueData:{code:p.invalid_return_type,returnTypeError:c}})}const s={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof it){const d=this;return J(async function(...c){const l=new Q([]),u=await d._def.args.parseAsync(c,s).catch(H=>{throw l.addIssue(r(c,H)),l}),Z=await Reflect.apply(o,this,u);return await d._def.returns._def.type.parseAsync(Z,s).catch(H=>{throw l.addIssue(a(Z,H)),l})})}else{const d=this;return J(function(...c){const l=d._def.args.safeParse(c,s);if(!l.success)throw new Q([r(c,l.error)]);const u=Reflect.apply(o,this,l.data),Z=d._def.returns.safeParse(u,s);if(!Z.success)throw new Q([a(u,Z.error)]);return Z.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new st({...this._def,args:oe.create(e).rest(Fe.create())})}returns(e){return new st({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new st({args:e||oe.create([]).rest(Fe.create()),returns:n||Fe.create(),typeName:N.ZodFunction,...S(r)})}}class Vt extends I{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Vt.create=(t,e)=>new Vt({getter:t,typeName:N.ZodLazy,...S(e)});class Bt extends I{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return _(n,{received:n.data,code:p.invalid_literal,expected:this._def.value}),k}return{status:"valid",value:e.data}}get value(){return this._def.value}}Bt.create=(t,e)=>new Bt({value:t,typeName:N.ZodLiteral,...S(e)});function wr(t,e){return new je({values:t,typeName:N.ZodEnum,...S(e)})}class je extends I{constructor(){super(...arguments),Pt.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return _(n,{expected:$.joinValues(r),received:n.parsedType,code:p.invalid_type}),k}if(fn(this,Pt)||_r(this,Pt,new Set(this._def.values)),!fn(this,Pt).has(e.data)){const n=this._getOrReturnCtx(e),r=this._def.values;return _(n,{received:n.data,code:p.invalid_enum_value,options:r}),k}return J(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return je.create(e,{...this._def,...n})}exclude(e,n=this._def){return je.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}Pt=new WeakMap,je.create=wr;class Kt extends I{constructor(){super(...arguments),Dt.set(this,void 0)}_parse(e){const n=$.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){const a=$.objectValues(n);return _(r,{expected:$.joinValues(a),received:r.parsedType,code:p.invalid_type}),k}if(fn(this,Dt)||_r(this,Dt,new Set($.getValidEnumValues(this._def.values))),!fn(this,Dt).has(e.data)){const a=$.objectValues(n);return _(r,{received:r.data,code:p.invalid_enum_value,options:a}),k}return J(e.data)}get enum(){return this._def.values}}Dt=new WeakMap,Kt.create=(t,e)=>new Kt({values:t,typeName:N.ZodNativeEnum,...S(e)});class it extends I{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.promise&&n.common.async===!1)return _(n,{code:p.invalid_type,expected:y.promise,received:n.parsedType}),k;const r=n.parsedType===y.promise?n.data:Promise.resolve(n.data);return J(r.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}}it.create=(t,e)=>new it({type:t,typeName:N.ZodPromise,...S(e)});class ne extends I{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===N.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),a=this._def.effect||null,s={addIssue:o=>{_(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),a.type==="preprocess"){const o=a.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async d=>{if(n.value==="aborted")return k;const c=await this._def.schema._parseAsync({data:d,path:r.path,parent:r});return c.status==="aborted"?k:c.status==="dirty"||n.value==="dirty"?nt(c.value):c});{if(n.value==="aborted")return k;const d=this._def.schema._parseSync({data:o,path:r.path,parent:r});return d.status==="aborted"?k:d.status==="dirty"||n.value==="dirty"?nt(d.value):d}}if(a.type==="refinement"){const o=d=>{const c=a.refinement(d,s);if(r.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return d};if(r.common.async===!1){const d=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return d.status==="aborted"?k:(d.status==="dirty"&&n.dirty(),o(d.value),{status:n.value,value:d.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(d=>d.status==="aborted"?k:(d.status==="dirty"&&n.dirty(),o(d.value).then(()=>({status:n.value,value:d.value}))))}if(a.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!$t(o))return o;const d=a.transform(o.value,s);if(d instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:d}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>$t(o)?Promise.resolve(a.transform(o.value,s)).then(d=>({status:n.value,value:d})):o);$.assertNever(a)}}ne.create=(t,e,n)=>new ne({schema:t,typeName:N.ZodEffects,effect:e,...S(n)}),ne.createWithPreprocess=(t,e,n)=>new ne({schema:e,effect:{type:"preprocess",transform:t},typeName:N.ZodEffects,...S(n)});class de extends I{_parse(e){return this._getType(e)===y.undefined?J(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}de.create=(t,e)=>new de({innerType:t,typeName:N.ZodOptional,...S(e)});class Ie extends I{_parse(e){return this._getType(e)===y.null?J(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ie.create=(t,e)=>new Ie({innerType:t,typeName:N.ZodNullable,...S(e)});class Wt extends I{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Wt.create=(t,e)=>new Wt({innerType:t,typeName:N.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...S(e)});class Jt extends I{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return At(a)?a.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Q(r.common.issues)},input:r.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Q(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Jt.create=(t,e)=>new Jt({innerType:t,typeName:N.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...S(e)});class bn extends I{_parse(e){if(this._getType(e)!==y.nan){const r=this._getOrReturnCtx(e);return _(r,{code:p.invalid_type,expected:y.nan,received:r.parsedType}),k}return{status:"valid",value:e.data}}}bn.create=t=>new bn({typeName:N.ZodNaN,...S(t)});const zi=Symbol("zod_brand");class Rn extends I{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class qt extends I{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?k:s.status==="dirty"?(n.dirty(),nt(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const a=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?k:a.status==="dirty"?(n.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:r.path,parent:r})}}static create(e,n){return new qt({in:e,out:n,typeName:N.ZodPipeline})}}class Qt extends I{_parse(e){const n=this._def.innerType._parse(e),r=a=>($t(a)&&(a.value=Object.freeze(a.value)),a);return At(n)?n.then(a=>r(a)):r(n)}unwrap(){return this._def.innerType}}Qt.create=(t,e)=>new Qt({innerType:t,typeName:N.ZodReadonly,...S(e)});function xr(t,e={},n){return t?rt.create().superRefine((r,a)=>{var s,o;if(!t(r)){const d=typeof e=="function"?e(r):typeof e=="string"?{message:e}:e,c=(o=(s=d.fatal)!==null&&s!==void 0?s:n)!==null&&o!==void 0?o:!0,l=typeof d=="string"?{message:d}:d;a.addIssue({code:"custom",...l,fatal:c})}}):rt.create()}const Ui={object:L.lazycreate};var N;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(N||(N={}));const Fi=(t,e={message:`Input not instance of ${t.name}`})=>xr(n=>n instanceof t,e),Nr=ee.create,kr=Oe.create,Vi=bn.create,Bi=Se.create,Tr=Rt.create,Ki=Ue.create,Wi=_n.create,Ji=Mt.create,qi=Lt.create,Qi=rt.create,Hi=Fe.create,Gi=me.create,Yi=gn.create,Xi=te.create,eo=L.create,to=L.strictCreate,no=zt.create,ro=yn.create,ao=Ut.create,so=oe.create,io=Ft.create,oo=vn.create,co=Ve.create,lo=st.create,uo=Vt.create,ho=Bt.create,po=je.create,mo=Kt.create,fo=it.create,Cr=ne.create,_o=de.create,go=Ie.create,yo=ne.createWithPreprocess,vo=qt.create;var bo=Object.freeze({__proto__:null,defaultErrorMap:tt,setErrorMap:Ni,getErrorMap:pn,makeIssue:mn,EMPTY_PATH:ki,addIssueToContext:_,ParseStatus:K,INVALID:k,DIRTY:nt,OK:J,isAborted:$n,isDirty:An,isValid:$t,isAsync:At,get util(){return $},get objectUtil(){return En},ZodParsedType:y,getParsedType:Ce,ZodType:I,datetimeRegex:br,ZodString:ee,ZodNumber:Oe,ZodBigInt:Se,ZodBoolean:Rt,ZodDate:Ue,ZodSymbol:_n,ZodUndefined:Mt,ZodNull:Lt,ZodAny:rt,ZodUnknown:Fe,ZodNever:me,ZodVoid:gn,ZodArray:te,ZodObject:L,ZodUnion:zt,ZodDiscriminatedUnion:yn,ZodIntersection:Ut,ZodTuple:oe,ZodRecord:Ft,ZodMap:vn,ZodSet:Ve,ZodFunction:st,ZodLazy:Vt,ZodLiteral:Bt,ZodEnum:je,ZodNativeEnum:Kt,ZodPromise:it,ZodEffects:ne,ZodTransformer:ne,ZodOptional:de,ZodNullable:Ie,ZodDefault:Wt,ZodCatch:Jt,ZodNaN:bn,BRAND:zi,ZodBranded:Rn,ZodPipeline:qt,ZodReadonly:Qt,custom:xr,Schema:I,ZodSchema:I,late:Ui,get ZodFirstPartyTypeKind(){return N},coerce:{string:t=>ee.create({...t,coerce:!0}),number:t=>Oe.create({...t,coerce:!0}),boolean:t=>Rt.create({...t,coerce:!0}),bigint:t=>Se.create({...t,coerce:!0}),date:t=>Ue.create({...t,coerce:!0})},any:Qi,array:Xi,bigint:Bi,boolean:Tr,date:Ki,discriminatedUnion:ro,effect:Cr,enum:po,function:lo,instanceof:Fi,intersection:ao,lazy:uo,literal:ho,map:oo,nan:Vi,nativeEnum:mo,never:Gi,null:qi,nullable:go,number:kr,object:eo,oboolean:()=>Tr().optional(),onumber:()=>kr().optional(),optional:_o,ostring:()=>Nr().optional(),pipeline:vo,preprocess:yo,promise:fo,record:io,set:co,strictObject:to,string:Nr,symbol:Wi,transformer:Cr,tuple:so,undefined:Ji,union:no,unknown:Hi,void:Yi,NEVER:k,ZodIssueCode:p,quotelessJson:xi,ZodError:Q});wi(bo);function Ht(t,e="",n={}){for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){const a=e?`${e}_${r}`:r;typeof t[r]=="object"&&t[r]!==null&&!Array.isArray(t[r])?Ht(t[r],a,n):n[a]=t[r]}return n}function Or(t,e){const n={};for(const[r,a]of Object.entries(t)){const s=e.find(o=>r.startsWith(`${o}_`));if(!s)n[r]=a;else{const o=r.slice(s.length+1);n[s]={...n[s],[o]:a}}}return n}function wo(t){return async(e,n)=>{let r=t.selectFrom("connections").where("connections.tenant_id","=",e);n.q&&(r=Le(t,r,n.q,["user_id","ip"]));const o=(await r.offset(n.page*n.per_page).limit(n.per_page).selectAll().execute()).map(c=>R(Or(c,["options"]))),{count:d}=await r.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{connections:o,start:n.page*n.per_page,limit:n.per_page,length:Te(d)}}}function xo(t){return async(e,n)=>(await t.deleteFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",n).executeTakeFirst()).numDeletedRows>0}function No(t){return async(e,n)=>{const r=await t.selectFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",n).selectAll().executeTakeFirst();return r?R({...r,options:JSON.parse(r.options)}):null}}function ko(t){return async(e,n,r)=>{const a={...r,updated_at:new Date().toISOString()};return await t.updateTable("connections").set({...a,options:a.options?JSON.stringify(a.options):void 0}).where("connections.id","=",n).where("connections.tenant_id","=",e).execute(),!0}}function To(t){return{create:yi(t),get:No(t),list:wo(t),remove:xo(t),update:ko(t)}}function Co(t){return{get:async e=>{const n=await t.selectFrom("applications").selectAll().where("id","=",e).executeTakeFirst();if(!n)return null;const r=await t.selectFrom("tenants").selectAll().where("id","=",n.tenant_id).executeTakeFirst();if(!r)throw new P(404,{message:"Tenant not found"});const a=await t.selectFrom("connections").where("tenant_id","=",n.tenant_id).selectAll().execute(),s=await t.selectFrom("domains").where("tenant_id","=",n.tenant_id).selectAll().execute();return{...n,connections:a.map(d=>cr.parse(R({...d,options:d.options?JSON.parse(d.options):{}}))),domains:s,addons:n.addons?JSON.parse(n.addons):{},callbacks:n.callbacks?JSON.parse(n.callbacks):[],allowed_origins:n.allowed_origins?JSON.parse(n.allowed_origins):[],web_origins:n.web_origins?JSON.parse(n.web_origins):[],allowed_logout_urls:n.allowed_logout_urls?JSON.parse(n.allowed_logout_urls):[],allowed_clients:n.allowed_clients?JSON.parse(n.allowed_clients):[],tenant:R(r),disable_sign_ups:!!n.disable_sign_ups}}}}function Oo(t){return async()=>await t.selectFrom("keys").where(n=>n.or([n("revoked_at",">",new Date().toISOString()),n("revoked_at","is",null)])).selectAll().execute()}function So(t){return async e=>{await t.insertInto("keys").values({...e,created_at:new Date().toDateString()}).execute()}}function jo(t){return async(e,n)=>!!(await t.updateTable("keys").set(n).where("kid","=",e).execute()).length}function Io(t){return{create:So(t),list:Oo(t),update:jo(t)}}function Zo(t){return async(e,n)=>{const r={created_at:new Date().toISOString(),updated_at:new Date().toISOString(),tenant_id:e,id:ze(),...n};return await t.insertInto("domains").values(r).execute(),r}}function Eo(t){return async(e,n)=>{let r=t.selectFrom("domains").where("domains.tenant_id","=",e);n.q&&(r=Le(t,r,n.q,["user_id","ip"]));const s=await r.offset(n.page*n.per_page).limit(n.per_page).selectAll().execute(),{count:o}=await r.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow();return{domains:s,start:n.page*n.per_page,limit:n.per_page,length:Te(o)}}}function $o(t){return{create:Zo(t),list:Eo(t)}}function Ao(t){return async e=>{const[n]=await t.selectFrom("branding").where("branding.tenant_id","=",e).selectAll().execute();if(!n)return null;const{tenant_id:r,colors_primary:a,colors_page_background_type:s,colors_page_background_start:o,colors_page_background_end:d,colors_page_background_angle_dev:c,font_url:l,...u}=n;return R({...u,colors:{primary:a,page_background:{type:s,start:o,end:d,angle_deg:c}},font:l?{url:l}:void 0})}}function Po(t){return async(e,n)=>{var o,d,c,l,u,Z,z,H,Ze,dt,Ee,$e,Ae,ct,lt,ce,le,ue;const{colors:r,font:a,...s}=n;try{await t.insertInto("branding").values({...s,colors_primary:r==null?void 0:r.primary,colors_page_background_type:(d=(o=n.colors)==null?void 0:o.page_background)==null?void 0:d.type,colors_page_background_start:(l=(c=n.colors)==null?void 0:c.page_background)==null?void 0:l.start,colors_page_background_end:(Z=(u=n.colors)==null?void 0:u.page_background)==null?void 0:Z.end,colors_page_background_angle_dev:(H=(z=n.colors)==null?void 0:z.page_background)==null?void 0:H.angle_deg,font_url:(Ze=n.font)==null?void 0:Ze.url,tenant_id:e}).execute()}catch{await t.updateTable("branding").set({...s,colors_primary:r==null?void 0:r.primary,colors_page_background_type:(Ee=(dt=n.colors)==null?void 0:dt.page_background)==null?void 0:Ee.type,colors_page_background_start:(Ae=($e=n.colors)==null?void 0:$e.page_background)==null?void 0:Ae.start,colors_page_background_end:(lt=(ct=n.colors)==null?void 0:ct.page_background)==null?void 0:lt.end,colors_page_background_angle_dev:(le=(ce=n.colors)==null?void 0:ce.page_background)==null?void 0:le.angle_deg,font_url:(ue=n.font)==null?void 0:ue.url}).where("tenant_id","=",e).execute()}}}function Do(t){return{get:Ao(t),set:Po(t)}}function Ro(t){return async(e,n)=>{let r=t.selectFrom("hooks").where("hooks.tenant_id","=",e);n.q&&(r=Le(t,r,n.q,["url"]));const s=await r.offset(n.page*n.per_page).limit(n.per_page).selectAll().execute(),{count:o}=await r.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{hooks:s.map(c=>{const{tenant_id:l,enabled:u,synchronous:Z,...z}=c;return R({...z,enabled:!!u,synchronous:!!Z})}),start:n.page*n.per_page,limit:n.per_page,length:Te(o)}}}function Mo(t){return async(e,n)=>{const r=await t.selectFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",n).selectAll().executeTakeFirst();return r?R({...r,enabled:!!r.enabled,synchronous:!!r.synchronous}):null}}function Lo(t){return async(e,n)=>(await t.deleteFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",n).executeTakeFirst()).numDeletedRows>0}function zo(t){return async(e,n)=>{const r={hook_id:ze(),...n,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await t.insertInto("hooks").values({...r,tenant_id:e,enabled:n.enabled?1:0,synchronous:n.synchronous?1:0}).execute(),r}}function Uo(t){return async(e,n,r)=>{const a={...r,updated_at:new Date().toISOString(),enabled:r.enabled!==void 0?r.enabled?1:0:void 0,synchronous:r.enabled!==void 0?r.synchronous?1:0:void 0};return await t.updateTable("hooks").set(a).where("hooks.hook_id","=",n).where("hooks.tenant_id","=",e).execute(),!0}}function Fo(t){return{create:zo(t),get:Mo(t),list:Ro(t),update:Uo(t),remove:Lo(t)}}function Vo(t){return async(e,n)=>{const r={themeId:ze(),...n,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await t.insertInto("themes").values({...Ht(r),tenant_id:e}).execute(),r}}function Bo(t){return async(e,n)=>(await t.deleteFrom("themes").where("themes.tenant_id","=",e).where("themes.theme_id","=",n).executeTakeFirst()).numDeletedRows>0}function Ko(t){return async(e,n)=>{const r=await t.selectFrom("themes").where("themes.tenant_id","=",e).where("themes.theme_id","=",n).selectAll().executeTakeFirst();return r?R(r):null}}function Wo(t){return async(e,n,r)=>{const a=Ht({...r,updated_at:new Date().toISOString()});return await t.updateTable("themes").set(a).where("themes.id","=",n).where("themes.tenant_id","=",e).execute(),!0}}function Jo(t){return{create:Vo(t),get:Ko(t),remove:Bo(t),update:Wo(t)}}function qo(t){return async(e,n)=>{const r=new Date().toISOString(),a=await t.selectFrom("logins").where("logins.expires_at",">",r).where("logins.login_id","=",n).selectAll().executeTakeFirst();return a?gs.parse(Or(R(a),["authParams"])):null}}function Qo(t){return async(e,n)=>{const r={login_id:ze(),...n,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await t.insertInto("logins").values({...Ht(r),tenant_id:e}).execute(),r}}function Ho(t){return async(e,n,r)=>(await t.updateTable("logins").set(Ht(r)).where("logins.login_id","=",n).where("logins.tenant_id","=",e).execute()).length===1}function Go(t){return async(e,n)=>(await t.deleteFrom("logins").where("logins.tenant_id","=",e).where("logins.login_id","=",n).execute()).length>0}function Yo(t){return{create:Qo(t),get:qo(t),update:Ho(t),remove:Go(t)}}function Xo(t){return async e=>{const[n]=await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id","=",e).selectAll().execute();return R({identifier_first:!!(n!=null&&n.identifier_first),password_first:!!(n!=null&&n.password_first),webauthn_platform_first_factor:!!(n!=null&&n.webauthn_platform_first_factor),universal_login_experience:(n==null?void 0:n.universal_login_experience)||"new"})}}function Sr(t){return R({...t,webauthn_platform_first_factor:t.webauthn_platform_first_factor?!!t.webauthn_platform_first_factor:void 0,identifier_first:t.identifier_first?!!t.identifier_first:void 0,password_first:t.password_first?!!t.password_first:void 0,universal_login_experience:t.universal_login_experience})}function ed(t){return async(e,n)=>{try{const r=Os.parse(n);await t.insertInto("prompt_settings").values({...Sr(r),tenant_id:e}).execute()}catch{await t.updateTable("prompt_settings").set(Sr(n)).where("tenant_id","=",e).execute()}}}function td(t){return{get:Xo(t),set:ed(t)}}function nd(t){return t[t.length-1]}function F(t){return Object.freeze(t)}const wn=F({is(t){return t.kind==="IdentifierNode"},create(t){return F({kind:"IdentifierNode",name:t})}}),Mn=F({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return F({kind:"SchemableIdentifierNode",identifier:wn.create(t)})},createWithSchema(t,e){return F({kind:"SchemableIdentifierNode",schema:wn.create(t),identifier:wn.create(e)})}}),rd=F({is(t){return t.kind==="AliasNode"},create(t,e){return F({kind:"AliasNode",node:t,alias:e})}}),Ln=F({is(t){return t.kind==="TableNode"},create(t){return F({kind:"TableNode",table:Mn.create(t)})},createWithSchema(t,e){return F({kind:"TableNode",table:Mn.createWithSchema(t,e)})}});function th(t){return t}class ad{constructor(){Xt(this,"nodeStack",[]);he(this,xn,F({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this)}))}transformNode(e){if(!e)return e;this.nodeStack.push(e);const n=this.transformNodeImpl(e);return this.nodeStack.pop(),F(n)}transformNodeImpl(e){return v(this,xn)[e.kind](e)}transformNodeList(e){return e&&F(e.map(n=>this.transformNode(n)))}transformSelectQuery(e){return{kind:"SelectQueryNode",from:this.transformNode(e.from),selections:this.transformNodeList(e.selections),distinctOn:this.transformNodeList(e.distinctOn),joins:this.transformNodeList(e.joins),groupBy:this.transformNode(e.groupBy),orderBy:this.transformNode(e.orderBy),where:this.transformNode(e.where),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),limit:this.transformNode(e.limit),offset:this.transformNode(e.offset),with:this.transformNode(e.with),having:this.transformNode(e.having),explain:this.transformNode(e.explain),setOperations:this.transformNodeList(e.setOperations),fetch:this.transformNode(e.fetch),top:this.transformNode(e.top)}}transformSelection(e){return{kind:"SelectionNode",selection:this.transformNode(e.selection)}}transformColumn(e){return{kind:"ColumnNode",column:this.transformNode(e.column)}}transformAlias(e){return{kind:"AliasNode",node:this.transformNode(e.node),alias:this.transformNode(e.alias)}}transformTable(e){return{kind:"TableNode",table:this.transformNode(e.table)}}transformFrom(e){return{kind:"FromNode",froms:this.transformNodeList(e.froms)}}transformReference(e){return{kind:"ReferenceNode",column:this.transformNode(e.column),table:this.transformNode(e.table)}}transformAnd(e){return{kind:"AndNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformOr(e){return{kind:"OrNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformValueList(e){return{kind:"ValueListNode",values:this.transformNodeList(e.values)}}transformParens(e){return{kind:"ParensNode",node:this.transformNode(e.node)}}transformJoin(e){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table),on:this.transformNode(e.on)}}transformRaw(e){return{kind:"RawNode",sqlFragments:F([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters)}}transformWhere(e){return{kind:"WhereNode",where:this.transformNode(e.where)}}transformInsertQuery(e){return{kind:"InsertQueryNode",into:this.transformNode(e.into),columns:this.transformNodeList(e.columns),values:this.transformNode(e.values),returning:this.transformNode(e.returning),onConflict:this.transformNode(e.onConflict),onDuplicateKey:this.transformNode(e.onDuplicateKey),with:this.transformNode(e.with),ignore:e.ignore,replace:e.replace,explain:this.transformNode(e.explain),defaultValues:e.defaultValues,top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformValues(e){return{kind:"ValuesNode",values:this.transformNodeList(e.values)}}transformDeleteQuery(e){return{kind:"DeleteQueryNode",from:this.transformNode(e.from),using:this.transformNode(e.using),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),returning:this.transformNode(e.returning),with:this.transformNode(e.with),orderBy:this.transformNode(e.orderBy),limit:this.transformNode(e.limit),explain:this.transformNode(e.explain),top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformReturning(e){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections)}}transformCreateTable(e){return{kind:"CreateTableNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),constraints:this.transformNodeList(e.constraints),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),selectQuery:this.transformNode(e.selectQuery)}}transformColumnDefinition(e){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),references:this.transformNode(e.references),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo),check:this.transformNode(e.check),generated:this.transformNode(e.generated),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists}}transformAddColumn(e){return{kind:"AddColumnNode",column:this.transformNode(e.column)}}transformDropTable(e){return{kind:"DropTableNode",table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e){return{kind:"OrderByNode",items:this.transformNodeList(e.items)}}transformOrderByItem(e){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy),direction:this.transformNode(e.direction)}}transformGroupBy(e){return{kind:"GroupByNode",items:this.transformNodeList(e.items)}}transformGroupByItem(e){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy)}}transformUpdateQuery(e){return{kind:"UpdateQueryNode",table:this.transformNode(e.table),from:this.transformNode(e.from),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),updates:this.transformNodeList(e.updates),returning:this.transformNode(e.returning),with:this.transformNode(e.with),explain:this.transformNode(e.explain),limit:this.transformNode(e.limit),top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformColumnUpdate(e){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column),value:this.transformNode(e.value)}}transformLimit(e){return{kind:"LimitNode",limit:this.transformNode(e.limit)}}transformOffset(e){return{kind:"OffsetNode",offset:this.transformNode(e.offset)}}transformOnConflict(e){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns),constraint:this.transformNode(e.constraint),indexExpression:this.transformNode(e.indexExpression),indexWhere:this.transformNode(e.indexWhere),updates:this.transformNodeList(e.updates),updateWhere:this.transformNode(e.updateWhere),doNothing:e.doNothing}}transformOnDuplicateKey(e){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates)}}transformCreateIndex(e){return{kind:"CreateIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists,where:this.transformNode(e.where),nullsNotDistinct:e.nullsNotDistinct}}transformList(e){return{kind:"ListNode",items:this.transformNodeList(e.items)}}transformDropIndex(e){return{kind:"DropIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformUniqueConstraint(e){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name),nullsNotDistinct:e.nullsNotDistinct}}transformForeignKeyConstraint(e){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns),references:this.transformNode(e.references),name:this.transformNode(e.name),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformSetOperation(e){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression),all:e.all}}transformReferences(e){return{kind:"ReferencesNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression),name:this.transformNode(e.name)}}transformWith(e){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions),recursive:e.recursive}}transformCommonTableExpression(e){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name),materialized:e.materialized,expression:this.transformNode(e.expression)}}transformCommonTableExpressionName(e){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns)}}transformHaving(e){return{kind:"HavingNode",having:this.transformNode(e.having)}}transformCreateSchema(e){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema),ifNotExists:e.ifNotExists}}transformDropSchema(e){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e){return{kind:"AlterTableNode",table:this.transformNode(e.table),renameTo:this.transformNode(e.renameTo),setSchema:this.transformNode(e.setSchema),columnAlterations:this.transformNodeList(e.columnAlterations),addConstraint:this.transformNode(e.addConstraint),dropConstraint:this.transformNode(e.dropConstraint),addIndex:this.transformNode(e.addIndex),dropIndex:this.transformNode(e.dropIndex)}}transformDropColumn(e){return{kind:"DropColumnNode",column:this.transformNode(e.column)}}transformRenameColumn(e){return{kind:"RenameColumnNode",column:this.transformNode(e.column),renameTo:this.transformNode(e.renameTo)}}transformAlterColumn(e){return{kind:"AlterColumnNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),dataTypeExpression:this.transformNode(e.dataTypeExpression),setDefault:this.transformNode(e.setDefault),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e){return{kind:"ModifyColumnNode",column:this.transformNode(e.column)}}transformAddConstraint(e){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint)}}transformDropConstraint(e){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName),ifExists:e.ifExists,modifier:e.modifier}}transformCreateView(e){return{kind:"CreateViewNode",name:this.transformNode(e.name),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns),as:this.transformNode(e.as)}}transformDropView(e){return{kind:"DropViewNode",name:this.transformNode(e.name),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression)}}transformDefaultValue(e){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue)}}transformOn(e){return{kind:"OnNode",on:this.transformNode(e.on)}}transformSelectModifier(e){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier),of:this.transformNodeList(e.of)}}transformCreateType(e){return{kind:"CreateTypeNode",name:this.transformNode(e.name),enum:this.transformNode(e.enum)}}transformDropType(e){return{kind:"DropTypeNode",name:this.transformNode(e.name),ifExists:e.ifExists}}transformExplain(e){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options)}}transformSchemableIdentifier(e){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema),identifier:this.transformNode(e.identifier)}}transformAggregateFunction(e){return{kind:"AggregateFunctionNode",aggregated:this.transformNodeList(e.aggregated),distinct:e.distinct,filter:this.transformNode(e.filter),func:e.func,over:this.transformNode(e.over)}}transformOver(e){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy),partitionBy:this.transformNode(e.partitionBy)}}transformPartitionBy(e){return{kind:"PartitionByNode",items:this.transformNodeList(e.items)}}transformPartitionByItem(e){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy)}}transformBinaryOperation(e){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand),operator:this.transformNode(e.operator),rightOperand:this.transformNode(e.rightOperand)}}transformUnaryOperation(e){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator),operand:this.transformNode(e.operand)}}transformUsing(e){return{kind:"UsingNode",tables:this.transformNodeList(e.tables)}}transformFunction(e){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments)}}transformCase(e){return{kind:"CaseNode",value:this.transformNode(e.value),when:this.transformNodeList(e.when),else:this.transformNode(e.else),isStatement:e.isStatement}}transformWhen(e){return{kind:"WhenNode",condition:this.transformNode(e.condition),result:this.transformNode(e.result)}}transformJSONReference(e){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference),traversal:this.transformNode(e.traversal)}}transformJSONPath(e){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator),pathLegs:this.transformNodeList(e.pathLegs)}}transformJSONPathLeg(e){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator),values:this.transformNodeList(e.values)}}transformTuple(e){return{kind:"TupleNode",values:this.transformNodeList(e.values)}}transformMergeQuery(e){return{kind:"MergeQueryNode",into:this.transformNode(e.into),using:this.transformNode(e.using),whens:this.transformNodeList(e.whens),with:this.transformNode(e.with),top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformMatched(e){return{kind:"MatchedNode",not:e.not,bySource:e.bySource}}transformAddIndex(e){return{kind:"AddIndexNode",name:this.transformNode(e.name),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists}}transformCast(e){return{kind:"CastNode",expression:this.transformNode(e.expression),dataType:this.transformNode(e.dataType)}}transformFetch(e){return{kind:"FetchNode",rowCount:this.transformNode(e.rowCount),modifier:e.modifier}}transformTop(e){return{kind:"TopNode",expression:e.expression,modifiers:e.modifiers}}transformOutput(e){return{kind:"OutputNode",selections:this.transformNodeList(e.selections)}}transformDataType(e){return e}transformSelectAll(e){return e}transformIdentifier(e){return e}transformValue(e){return e}transformPrimitiveValueList(e){return e}transformOperator(e){return e}transformDefaultInsertValue(e){return e}}xn=new WeakMap;const sd=F({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0});class id extends ad{constructor(n){super();he(this,V);he(this,ot);he(this,Be,new Set);he(this,Ke,new Set);en(this,ot,n)}transformNodeImpl(n){if(!C(this,V,Ar).call(this,n))return super.transformNodeImpl(n);const r=C(this,V,Dr).call(this,n);for(const o of r)v(this,Ke).add(o);const a=C(this,V,Pr).call(this,n);for(const o of a)v(this,Be).add(o);const s=super.transformNodeImpl(n);for(const o of a)v(this,Be).delete(o);for(const o of r)v(this,Ke).delete(o);return s}transformSchemableIdentifier(n){const r=super.transformSchemableIdentifier(n);return r.schema||!v(this,Be).has(n.identifier.name)?r:{...r,schema:wn.create(v(this,ot))}}transformReferences(n){const r=super.transformReferences(n);return r.table.table.schema?r:{...r,table:Ln.createWithSchema(v(this,ot),r.table.table.identifier.name)}}}ot=new WeakMap,Be=new WeakMap,Ke=new WeakMap,V=new WeakSet,Ar=function(n){return n.kind in sd},Pr=function(n){const r=new Set;if("name"in n&&n.name&&Mn.is(n.name)&&C(this,V,Vn).call(this,n.name,r),"from"in n&&n.from)for(const a of n.from.froms)C(this,V,ut).call(this,a,r);if("into"in n&&n.into&&C(this,V,ut).call(this,n.into,r),"table"in n&&n.table&&C(this,V,ut).call(this,n.table,r),"joins"in n&&n.joins)for(const a of n.joins)C(this,V,ut).call(this,a.table,r);return"using"in n&&n.using&&C(this,V,ut).call(this,n.using,r),r},Dr=function(n){const r=new Set;return"with"in n&&n.with&&C(this,V,Rr).call(this,n.with,r),r},ut=function(n,r){const a=Ln.is(n)?n:rd.is(n)&&Ln.is(n.node)?n.node:null;a&&C(this,V,Vn).call(this,a.table,r)},Vn=function(n,r){const a=n.identifier.name;!v(this,Be).has(a)&&!v(this,Ke).has(a)&&r.add(a)},Rr=function(n,r){for(const a of n.expressions){const s=a.name.table.table.identifier.name;v(this,Ke).has(s)||r.add(s)}};class od{constructor(e){he(this,Gt);en(this,Gt,new id(e))}transformQuery(e){return v(this,Gt).transformNode(e.node)}async transformResult(e){return e.result}}Gt=new WeakMap;class dd{transformQuery(e){return e.node}async transformResult(e){return e.result}}const cd="kysely_migration",jr="kysely_migration_lock",ld=!1,zn="migration_lock",ud=F({__noMigrations__:!0});class Ir{constructor(e){he(this,m);he(this,D);en(this,D,F(e))}async getMigrations(){const e=await C(this,m,pt).call(this,v(this,m,ge))?await v(this,D).db.withPlugin(v(this,m,ye)).selectFrom(v(this,m,ge)).select(["name","timestamp"]).execute():[];return(await C(this,m,Wn).call(this)).map(({name:r,...a})=>{const s=e.find(o=>o.name===r);return{name:r,migration:a,executedAt:s?new Date(s.timestamp):void 0}})}async migrateToLatest(){return C(this,m,tn).call(this,()=>({direction:"Up",step:1/0}))}async migrateTo(e){return C(this,m,tn).call(this,({migrations:n,executedMigrations:r,pendingMigrations:a})=>{if(e===ud)return{direction:"Down",step:1/0};if(!n.find(d=>d.name===e))throw new Error(`migration "${e}" doesn't exist`);const s=r.indexOf(e),o=a.findIndex(d=>d.name===e);if(s!==-1)return{direction:"Down",step:r.length-s-1};if(o!==-1)return{direction:"Up",step:o+1};throw new Error(`migration "${e}" isn't executed or pending`)})}async migrateUp(){return C(this,m,tn).call(this,()=>({direction:"Up",step:1}))}async migrateDown(){return C(this,m,tn).call(this,()=>({direction:"Down",step:1}))}}D=new WeakMap,m=new WeakSet,tn=async function(e){try{return await C(this,m,Lr).call(this),await C(this,m,Br).call(this,e)}catch(n){return n instanceof Un?n.resultSet:{error:n}}},_e=function(){return v(this,D).migrationTableSchema},ge=function(){return v(this,D).migrationTableName??cd},ht=function(){return v(this,D).migrationLockTableName??jr},Mr=function(){return v(this,D).allowUnorderedMigrations??ld},ye=function(){return v(this,m,_e)?new od(v(this,m,_e)):new dd},Lr=async function(){await C(this,m,zr).call(this),await C(this,m,Ur).call(this),await C(this,m,Fr).call(this),await C(this,m,Vr).call(this)},zr=async function(){if(v(this,m,_e)&&!await C(this,m,Bn).call(this))try{await C(this,m,nn).call(this,v(this,D).db.schema.createSchema(v(this,m,_e)))}catch(e){if(!await C(this,m,Bn).call(this))throw e}},Ur=async function(){if(!await C(this,m,pt).call(this,v(this,m,ge)))try{v(this,m,_e)&&await C(this,m,nn).call(this,v(this,D).db.schema.createSchema(v(this,m,_e))),await C(this,m,nn).call(this,v(this,D).db.schema.withPlugin(v(this,m,ye)).createTable(v(this,m,ge)).addColumn("name","varchar(255)",e=>e.notNull().primaryKey()).addColumn("timestamp","varchar(255)",e=>e.notNull()))}catch(e){if(!await C(this,m,pt).call(this,v(this,m,ge)))throw e}},Fr=async function(){if(!await C(this,m,pt).call(this,v(this,m,ht)))try{await C(this,m,nn).call(this,v(this,D).db.schema.withPlugin(v(this,m,ye)).createTable(v(this,m,ht)).addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("is_locked","integer",e=>e.notNull().defaultTo(0)))}catch(e){if(!await C(this,m,pt).call(this,v(this,m,ht)))throw e}},Vr=async function(){if(!await C(this,m,Kn).call(this))try{await v(this,D).db.withPlugin(v(this,m,ye)).insertInto(v(this,m,ht)).values({id:zn,is_locked:0}).execute()}catch(e){if(!await C(this,m,Kn).call(this))throw e}},Bn=async function(){return(await v(this,D).db.introspection.getSchemas()).some(n=>n.name===v(this,m,_e))},pt=async function(e){const n=v(this,m,_e);return(await v(this,D).db.introspection.getTables({withInternalKyselyTables:!0})).some(a=>a.name===e&&(!n||a.schema===n))},Kn=async function(){return!!await v(this,D).db.withPlugin(v(this,m,ye)).selectFrom(v(this,m,ht)).where("id","=",zn).select("id").executeTakeFirst()},Br=async function(e){const n=v(this,D).db.getExecutor().adapter,r=F({lockTable:v(this,D).migrationLockTableName??jr,lockRowId:zn,lockTableSchema:v(this,D).migrationTableSchema}),a=async s=>{try{await n.acquireMigrationLock(s,r);const o=await C(this,m,Kr).call(this,s);if(o.migrations.length===0)return{results:[]};const{direction:d,step:c}=e(o);return c<=0?{results:[]}:d==="Down"?await C(this,m,Hr).call(this,s,o,c):d==="Up"?await C(this,m,Gr).call(this,s,o,c):{results:[]}}finally{await n.releaseMigrationLock(s,r)}};return n.supportsTransactionalDdl?v(this,D).db.transaction().execute(a):v(this,D).db.connection().execute(a)},Kr=async function(e){const n=await C(this,m,Wn).call(this),r=await C(this,m,Jr).call(this,e);C(this,m,qr).call(this,n,r),v(this,m,Mr)||C(this,m,Qr).call(this,n,r);const a=C(this,m,Wr).call(this,n,r);return F({migrations:n,executedMigrations:r,lastMigration:nd(r),pendingMigrations:a})},Wr=function(e,n){return e.filter(r=>!n.includes(r.name))},Wn=async function(){const e=await v(this,D).provider.getMigrations();return Object.keys(e).sort().map(n=>({...e[n],name:n}))},Jr=async function(e){return(await e.withPlugin(v(this,m,ye)).selectFrom(v(this,m,ge)).select("name").orderBy(["timestamp","name"]).execute()).map(r=>r.name)},qr=function(e,n){for(const r of n)if(!e.some(a=>a.name===r))throw new Error(`corrupted migrations: previously executed migration ${r} is missing`)},Qr=function(e,n){for(let r=0;r<n.length;++r)if(e[r].name!==n[r])throw new Error(`corrupted migrations: expected previously executed migration ${n[r]} to be at index ${r} but ${e[r].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`)},Hr=async function(e,n,r){const a=n.executedMigrations.slice().reverse().slice(0,r).map(o=>n.migrations.find(d=>d.name===o)),s=a.map(o=>({migrationName:o.name,direction:"Down",status:"NotExecuted"}));for(let o=0;o<s.length;++o){const d=a[o];try{d.down&&(await d.down(e),await e.withPlugin(v(this,m,ye)).deleteFrom(v(this,m,ge)).where("name","=",d.name).execute(),s[o]={migrationName:d.name,direction:"Down",status:"Success"})}catch(c){throw s[o]={migrationName:d.name,direction:"Down",status:"Error"},new Un({error:c,results:s})}}return{results:s}},Gr=async function(e,n,r){const s=n.pendingMigrations.slice(0,r).map(o=>({migrationName:o.name,direction:"Up",status:"NotExecuted"}));for(let o=0;o<s.length;o++){const d=n.pendingMigrations[o];try{await d.up(e),await e.withPlugin(v(this,m,ye)).insertInto(v(this,m,ge)).values({name:d.name,timestamp:new Date().toISOString()}).execute(),s[o]={migrationName:d.name,direction:"Up",status:"Success"}}catch(c){throw s[o]={migrationName:d.name,direction:"Up",status:"Error"},new Un({error:c,results:s})}}return{results:s}},nn=async function(e){v(this,D).db.getExecutor().adapter.supportsCreateIfNotExists&&(e=e.ifNotExists()),await e.execute()};class Un extends Error{constructor(n){super();he(this,Yt);en(this,Yt,n)}get resultSet(){return v(this,Yt)}}Yt=new WeakMap;class Zr{constructor(e){Xt(this,"migrations");this.migrations=e}async getMigrations(){return this.migrations}}async function hd(t){await t.schema.createTable("tenants").addColumn("id","varchar(255)",e=>e.primaryKey()).addColumn("name","varchar(255)").addColumn("audience","varchar(255)").addColumn("sender_email","varchar(255)").addColumn("sender_name","varchar(255)").addColumn("language","varchar(255)").addColumn("logo","varchar(255)").addColumn("primary_color","varchar(255)").addColumn("secondary_color","varchar(255)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).execute(),await t.schema.createTable("users").addColumn("user_id","varchar(255)",e=>e.notNull()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("email","varchar(255)",e=>e.notNull()).addColumn("given_name","varchar(255)").addColumn("family_name","varchar(255)").addColumn("nickname","varchar(255)").addColumn("name","varchar(255)").addColumn("picture","varchar(2083)").addColumn("tags","varchar(255)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).addPrimaryKeyConstraint("users_tenants",["user_id","tenant_id"]).addColumn("linked_to","varchar(255)").addForeignKeyConstraint("linked_to_constraint",["linked_to","tenant_id"],"users",["user_id","tenant_id"]).addColumn("last_ip","varchar(255)").addColumn("login_count","integer",e=>e.notNull()).addColumn("last_login","varchar(255)").addColumn("provider","varchar(255)",e=>e.notNull()).addColumn("connection","varchar(255)").addColumn("email_verified","boolean",e=>e.notNull()).addColumn("is_social","boolean",e=>e.notNull()).addColumn("app_metadata","varchar(4096)",e=>e.defaultTo("{}").notNull()).addColumn("user_metadata","varchar(4096)",e=>e.defaultTo("{}").notNull()).addUniqueConstraint("unique_email_provider",["email","provider","tenant_id"]).execute(),await t.schema.createTable("members").addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("sub","varchar(255)").addColumn("email","varchar(255)").addColumn("name","varchar(255)").addColumn("status","varchar(255)").addColumn("role","varchar(255)").addColumn("picture","varchar(2083)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).execute(),await t.schema.createTable("applications").addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("name","varchar(255)",e=>e.notNull()).addColumn("client_secret","varchar(255)").addColumn("allowed_logout_urls","varchar(255)").addColumn("authentication_settings","varchar(255)").addColumn("addons","varchar(4096)",e=>e.notNull().defaultTo("{}")).addColumn("callbacks","varchar(1024)",e=>e.notNull().defaultTo("[]")).addColumn("allowed_origins","varchar(1024)",e=>e.notNull().defaultTo("[]")).addColumn("web_origins","varchar(1024)",e=>e.notNull().defaultTo("[]")).addColumn("allowed_clients","varchar(1024)",e=>e.defaultTo("[]").notNull()).addColumn("options_kid","varchar(32)").addColumn("options_team_id","varchar(32)").addColumn("options_client_id","varchar(128)").addColumn("options_client_secret","varchar(255)").addColumn("options_scope","varchar(255)").addColumn("options_realms","varchar(255)").addColumn("options_app_secret","varchar(1024)").addColumn("email_validation","varchar(255)").addColumn("disable_sign_ups","boolean",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).execute(),await t.schema.createTable("connections").addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("name","varchar(255)",e=>e.notNull()).addColumn("response_type","varchar(255)").addColumn("response_mode","varchar(255)").addColumn("strategy","varchar(64)").addColumn("options","varchar(2048)",e=>e.defaultTo("{}").notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).execute(),await t.schema.createTable("migrations").addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("provider","varchar(255)").addColumn("client_id","varchar(255)").addColumn("origin","varchar(255)").addColumn("domain","varchar(255)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).execute(),await t.schema.createTable("domains").addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("domain","varchar(255)",e=>e.notNull()).addColumn("email_service","varchar(255)").addColumn("email_api_key","varchar(255)").addColumn("dkim_private_key","varchar(2048)").addColumn("dkim_public_key","varchar(2048)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).execute()}async function pd(t){await t.schema.dropTable("domains").execute(),await t.schema.dropTable("members").execute(),await t.schema.dropTable("users").execute(),await t.schema.dropTable("connections").execute(),await t.schema.dropTable("applications").execute(),await t.schema.dropTable("migrations").execute(),await t.schema.dropTable("tenants").execute()}const md=Object.freeze(Object.defineProperty({__proto__:null,down:pd,up:hd},Symbol.toStringTag,{value:"Module"}));async function fd(t){await t.schema.alterTable("tenants").addColumn("support_url","varchar(255)").execute()}async function _d(t){await t.schema.alterTable("tenants").dropColumn("support_url").execute()}const gd=Object.freeze(Object.defineProperty({__proto__:null,down:_d,up:fd},Symbol.toStringTag,{value:"Module"}));async function yd(t){}async function vd(t){}const bd=Object.freeze(Object.defineProperty({__proto__:null,down:vd,up:yd},Symbol.toStringTag,{value:"Module"}));async function wd(t){await t.schema.createTable("logs").addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("category","varchar(255)",e=>e.notNull()).addColumn("tenant_id","varchar(64)").addColumn("user_id","varchar(64)").addForeignKeyConstraint("tenant_id_constraint",["tenant_id"],"tenants",["id"],e=>e.onDelete("cascade")).addColumn("ip","varchar(255)").addColumn("type","varchar(8)",e=>e.notNull()).addColumn("date","varchar(25)",e=>e.notNull()).addColumn("client_id","varchar(255)").addColumn("client_name","varchar(255)").addColumn("user_agent","varchar(255)").addColumn("description","varchar(255)").addColumn("details","varchar(2048)").execute()}async function xd(t){await t.schema.dropTable("logs").execute()}const Nd=Object.freeze(Object.defineProperty({__proto__:null,down:xd,up:wd},Symbol.toStringTag,{value:"Module"}));async function kd(t){}async function Td(t){}const Cd=Object.freeze(Object.defineProperty({__proto__:null,down:Td,up:kd},Symbol.toStringTag,{value:"Module"}));async function Od(t){await t.schema.createTable("sessions").addColumn("session_id","varchar(255)",e=>e.primaryKey()).addColumn("client_id","varchar(255)",e=>e.references("applications.id").onDelete("cascade").notNull()).addColumn("tenant_id","varchar(255)").addColumn("user_id","varchar(255)").addForeignKeyConstraint("user_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").addColumn("deleted_at","varchar(255)").execute(),await t.schema.createTable("tickets").addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("id","varchar(255)",e=>e.primaryKey()).addColumn("client_id","varchar(255)",e=>e.references("applications.id").onDelete("cascade").notNull()).addColumn("email","varchar(255)",e=>e.notNull()).addColumn("nonce","varchar(255)").addColumn("state","varchar(1024)").addColumn("scope","varchar(1024)").addColumn("response_type","varchar(256)").addColumn("response_mode","varchar(256)").addColumn("redirect_uri","varchar(1024)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute(),await t.schema.createTable("otps").addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("id","varchar(255)",e=>e.primaryKey()).addColumn("client_id","varchar(255)",e=>e.references("applications.id").onDelete("cascade").notNull()).addColumn("code","varchar(255)",e=>e.notNull()).addColumn("email","varchar(255)",e=>e.notNull()).addColumn("user_id","varchar(255)").addColumn("send","varchar(255)").addColumn("nonce","varchar(255)").addColumn("state","varchar(1024)").addColumn("scope","varchar(1024)").addColumn("response_type","varchar(256)").addColumn("response_mode","varchar(256)").addColumn("redirect_uri","varchar(1024)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute(),await t.schema.createIndex("otps_email_index").on("otps").column("email").execute(),await t.schema.createIndex("otps_expires_at_index").on("otps").column("expires_at").execute()}async function Sd(t){await t.schema.dropTable("sessions").execute(),await t.schema.dropTable("tickets").execute(),await t.schema.dropTable("otps").execute()}const jd=Object.freeze(Object.defineProperty({__proto__:null,down:Sd,up:Od},Symbol.toStringTag,{value:"Module"}));async function Id(t){await t.schema.createTable("passwords").addColumn("tenant_id","varchar(255)").addColumn("user_id","varchar(255)").addForeignKeyConstraint("user_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("created_at","varchar(255)").addColumn("updated_at","varchar(255)").execute(),await t.schema.createTable("codes").addColumn("id","varchar(255)",e=>e.primaryKey()).addColumn("user_id","varchar(255)").addColumn("tenant_id","varchar(255)").addForeignKeyConstraint("user_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("type","varchar(255)",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute(),await t.schema.createIndex("codes_expires_at_index").on("codes").column("expires_at").execute()}async function Zd(t){await t.schema.dropTable("passwords").execute(),await t.schema.dropTable("codes").execute()}const Ed=Object.freeze(Object.defineProperty({__proto__:null,down:Zd,up:Id},Symbol.toStringTag,{value:"Module"}));async function $d(t){}async function Ad(t){}const Pd=Object.freeze(Object.defineProperty({__proto__:null,down:Ad,up:$d},Symbol.toStringTag,{value:"Module"}));async function Dd(t){await t.schema.alterTable("passwords").addColumn("password","varchar(255)",e=>e.notNull()).execute()}async function Rd(t){await t.schema.alterTable("passwords").dropColumn("password").execute()}const Md=Object.freeze(Object.defineProperty({__proto__:null,down:Rd,up:Dd},Symbol.toStringTag,{value:"Module"}));async function Ld(t){}async function zd(t){}const Ud=Object.freeze(Object.defineProperty({__proto__:null,down:zd,up:Ld},Symbol.toStringTag,{value:"Module"}));async function Fd(t){}async function Vd(t){}const Bd=Object.freeze(Object.defineProperty({__proto__:null,down:Vd,up:Fd},Symbol.toStringTag,{value:"Module"}));async function Kd(t){}async function Wd(t){}const Jd=Object.freeze(Object.defineProperty({__proto__:null,down:Wd,up:Kd},Symbol.toStringTag,{value:"Module"}));async function qd(t){await t.schema.createIndex("users_email_index").on("users").column("email").execute()}async function Qd(t){await t.schema.dropIndex("users_email_index").execute()}const Hd=Object.freeze(Object.defineProperty({__proto__:null,down:Qd,up:qd},Symbol.toStringTag,{value:"Module"}));async function Gd(t){await t.schema.alterTable("users").addColumn("profileData","varchar(2048)").execute()}async function Yd(t){await t.schema.alterTable("users").dropColumn("profileData").execute()}const Xd=Object.freeze(Object.defineProperty({__proto__:null,down:Yd,up:Gd},Symbol.toStringTag,{value:"Module"}));async function ec(t){await t.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute()}async function tc(t){await t.schema.dropIndex("users_linked_to_index")}const nc=Object.freeze(Object.defineProperty({__proto__:null,down:tc,up:ec},Symbol.toStringTag,{value:"Module"}));async function rc(t){await t.schema.alterTable("users").addColumn("locale","varchar(255)").execute()}async function ac(t){await t.schema.alterTable("users").dropColumn("locale").execute()}const sc=Object.freeze(Object.defineProperty({__proto__:null,down:ac,up:rc},Symbol.toStringTag,{value:"Module"}));async function ic(t){await t.schema.createTable("keys").addColumn("kid","varchar(255)",e=>e.primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade")).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("revoked_at","varchar(255)").addColumn("cert","varchar(2048)").addColumn("pkcs7","varchar(2048)").addColumn("fingerprint","varchar(256)").addColumn("thumbprint","varchar(256)").addColumn("current_since","varchar(256)").addColumn("current_until","varchar(256)").execute()}async function oc(t){await t.schema.dropTable("keys").execute()}const dc=Object.freeze(Object.defineProperty({__proto__:null,down:oc,up:ic},Symbol.toStringTag,{value:"Module"}));async function cc(t){}async function lc(t){}const uc=Object.freeze(Object.defineProperty({__proto__:null,down:lc,up:cc},Symbol.toStringTag,{value:"Module"}));async function hc(t){}async function pc(t){}const mc=Object.freeze(Object.defineProperty({__proto__:null,down:pc,up:hc},Symbol.toStringTag,{value:"Module"}));async function fc(t){await t.schema.alterTable("otps").addColumn("audience","varchar(255)").execute()}async function _c(t){await t.schema.alterTable("otps").dropColumn("audience").execute()}const gc=Object.freeze(Object.defineProperty({__proto__:null,down:_c,up:fc},Symbol.toStringTag,{value:"Module"}));async function yc(t){}async function vc(t){}const bc=Object.freeze(Object.defineProperty({__proto__:null,down:vc,up:yc},Symbol.toStringTag,{value:"Module"}));async function wc(t){await t.schema.alterTable("logs").dropColumn("category").execute()}async function xc(t){await t.schema.alterTable("logs").addColumn("category","varchar(255)",e=>e.notNull()).execute()}const Nc=Object.freeze(Object.defineProperty({__proto__:null,down:xc,up:wc},Symbol.toStringTag,{value:"Module"}));async function kc(t){await t.schema.alterTable("users").dropColumn("tags").execute()}async function Tc(t){await t.schema.alterTable("users").addColumn("tags","varchar(255)").execute()}const Cc=Object.freeze(Object.defineProperty({__proto__:null,down:Tc,up:kc},Symbol.toStringTag,{value:"Module"}));async function Oc(t){await t.schema.createIndex("logs_user_id").on("logs").column("user_id").execute(),await t.schema.createIndex("logs_tenant_id").on("logs").column("tenant_id").execute(),await t.schema.createIndex("logs_date").on("logs").column("date").execute()}async function Sc(t){await t.schema.dropIndex("logs_user_id"),await t.schema.dropIndex("logs_tenant_id"),await t.schema.dropIndex("logs_date")}const jc=Object.freeze(Object.defineProperty({__proto__:null,down:Sc,up:Oc},Symbol.toStringTag,{value:"Module"}));async function Ic(t){await t.schema.alterTable("logs").dropColumn("details").execute(),await t.schema.alterTable("logs").addColumn("details","varchar(8192)").execute()}async function Zc(t){await t.schema.alterTable("logs").dropColumn("details").execute(),await t.schema.alterTable("logs").addColumn("details","varchar(2048)").execute()}const Ec=Object.freeze(Object.defineProperty({__proto__:null,down:Zc,up:Ic},Symbol.toStringTag,{value:"Module"}));async function $c(t){await t.schema.alterTable("logs").addColumn("user_name","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("auth0_client","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("isMobile","boolean").execute(),await t.schema.alterTable("logs").addColumn("connection","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("connection_id","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("audience","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("scope","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("strategy","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("strategy_type","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("hostname","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("session_connection","varchar(255)").execute()}async function Ac(t){await t.schema.alterTable("logs").dropColumn("user_name").execute(),await t.schema.alterTable("logs").dropColumn("auth0_client").execute(),await t.schema.alterTable("logs").dropColumn("isMobile").execute(),await t.schema.alterTable("logs").dropColumn("connection").execute(),await t.schema.alterTable("logs").dropColumn("connection_id").execute(),await t.schema.alterTable("logs").dropColumn("audience").execute(),await t.schema.alterTable("logs").dropColumn("scope").execute(),await t.schema.alterTable("logs").dropColumn("strategy").execute(),await t.schema.alterTable("logs").dropColumn("strategy_type").execute(),await t.schema.alterTable("logs").dropColumn("hostname").execute(),await t.schema.alterTable("logs").dropColumn("session_connection").execute()}const Pc=Object.freeze(Object.defineProperty({__proto__:null,down:Ac,up:$c},Symbol.toStringTag,{value:"Module"}));async function Dc(t){await t.schema.createIndex("users_name_index").on("users").column("name").execute()}async function Rc(t){await t.schema.dropIndex("users_name_index").execute()}const Mc=Object.freeze(Object.defineProperty({__proto__:null,down:Rc,up:Dc},Symbol.toStringTag,{value:"Module"}));async function Lc(t){}async function zc(t){await t.schema.alterTable("users").dropConstraint("unique_email_provider").execute()}const Uc=Object.freeze(Object.defineProperty({__proto__:null,down:zc,up:Lc},Symbol.toStringTag,{value:"Module"}));async function Fc(t){await t.schema.alterTable("otps").dropColumn("state").execute(),await t.schema.alterTable("otps").addColumn("state","varchar(8192)").execute()}async function Vc(t){await t.schema.alterTable("otps").dropColumn("state").execute(),await t.schema.alterTable("otps").addColumn("state","varchar(1024)").execute()}const Bc=Object.freeze(Object.defineProperty({__proto__:null,down:Vc,up:Fc},Symbol.toStringTag,{value:"Module"}));async function Kc(t){await t.schema.alterTable("tickets").dropColumn("state").execute(),await t.schema.alterTable("tickets").addColumn("state","varchar(8192)").execute()}async function Wc(t){await t.schema.alterTable("tickets").dropColumn("state").execute(),await t.schema.alterTable("tickets").addColumn("state","varchar(1024)").execute()}const Jc=Object.freeze(Object.defineProperty({__proto__:null,down:Wc,up:Kc},Symbol.toStringTag,{value:"Module"}));async function qc(t){await t.schema.createTable("branding").addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull().primaryKey()).addColumn("logo_url","varchar(512)").addColumn("favicon_url","varchar(512)").addColumn("font_url","varchar(512)").addColumn("colors_primary","varchar(8)").addColumn("colors_page_background_type","varchar(32)").addColumn("colors_page_background_start","varchar(8)").addColumn("colors_page_background_end","varchar(8)").addColumn("colors_page_background_angle_dev","integer").execute()}async function Qc(t){await t.schema.dropTable("branding").execute()}const Hc=Object.freeze(Object.defineProperty({__proto__:null,down:Qc,up:qc},Symbol.toStringTag,{value:"Module"}));async function Gc(t){}async function Yc(t){}const Xc=Object.freeze(Object.defineProperty({__proto__:null,down:Yc,up:Gc},Symbol.toStringTag,{value:"Module"}));async function el(t){}async function tl(t){}const nl=Object.freeze(Object.defineProperty({__proto__:null,down:tl,up:el},Symbol.toStringTag,{value:"Module"}));async function rl(t){}async function al(t){}const sl=Object.freeze(Object.defineProperty({__proto__:null,down:al,up:rl},Symbol.toStringTag,{value:"Module"}));async function il(t){}async function ol(t){}const dl=Object.freeze(Object.defineProperty({__proto__:null,down:ol,up:il},Symbol.toStringTag,{value:"Module"}));async function cl(t){await t.schema.createTable("authentication_codes").addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("code","varchar(255)",e=>e.primaryKey()).addColumn("client_id","varchar(255)",e=>e.references("applications.id").onDelete("cascade").notNull()).addColumn("user_id","varchar(255)",e=>e.notNull()).addColumn("nonce","varchar(255)").addColumn("state","varchar(8192)").addColumn("scope","varchar(1024)").addColumn("response_type","varchar(256)").addColumn("response_mode","varchar(256)").addColumn("redirect_uri","varchar(1024)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute()}async function ll(t){await t.schema.dropTable("authentication_codes").execute()}const ul=Object.freeze(Object.defineProperty({__proto__:null,down:ll,up:cl},Symbol.toStringTag,{value:"Module"}));async function hl(t){}async function pl(t){}const ml=Object.freeze(Object.defineProperty({__proto__:null,down:pl,up:hl},Symbol.toStringTag,{value:"Module"}));async function fl(t){await t.schema.alterTable("otps").addColumn("ip","varchar(64)").execute()}async function _l(t){await t.schema.alterTable("otps").dropColumn("ip").execute()}const gl=Object.freeze(Object.defineProperty({__proto__:null,down:_l,up:fl},Symbol.toStringTag,{value:"Module"}));async function yl(t){await t.schema.alterTable("logs").dropColumn("user_agent").execute(),await t.schema.alterTable("logs").addColumn("user_agent","varchar(1024)").execute()}async function vl(t){await t.schema.alterTable("logs").dropColumn("user_agent").execute(),await t.schema.alterTable("logs").addColumn("user_agent","varchar(255)").execute()}const bl=Object.freeze(Object.defineProperty({__proto__:null,down:vl,up:yl},Symbol.toStringTag,{value:"Module"}));async function wl(t){}async function xl(t){}const Nl=Object.freeze(Object.defineProperty({__proto__:null,down:xl,up:wl},Symbol.toStringTag,{value:"Module"}));async function kl(t){await t.schema.createTable("hooks").addColumn("hook_id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("url","varchar(512)",e=>e.notNull()).addColumn("trigger_id","varchar(255)",e=>e.notNull()).addColumn("enabled","boolean",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).addColumn("synchronous","boolean",e=>e.defaultTo(!1).notNull()).addColumn("priority","integer").execute()}async function Tl(t){await t.schema.dropTable("hooks").execute()}const Cl=Object.freeze(Object.defineProperty({__proto__:null,down:Tl,up:kl},Symbol.toStringTag,{value:"Module"}));async function Ol(t){}async function Sl(t){}const jl=Object.freeze(Object.defineProperty({__proto__:null,down:Sl,up:Ol},Symbol.toStringTag,{value:"Module"}));async function Il(t){}async function Zl(t){}const El=Object.freeze(Object.defineProperty({__proto__:null,down:Zl,up:Il},Symbol.toStringTag,{value:"Module"}));async function $l(t){await t.schema.createTable("logins").addColumn("login_id","varchar(255)",e=>e.primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("authParams_client_id","varchar(255)",e=>e.notNull()).addColumn("authParams_vendor_id","varchar(255)").addColumn("authParams_username","varchar(255)").addColumn("authParams_response_type","varchar(255)").addColumn("authParams_response_mode","varchar(255)").addColumn("authParams_audience","varchar(255)").addColumn("authParams_scope","varchar(511)").addColumn("authParams_state","varchar(511)").addColumn("authParams_code_challenge_method","varchar(256)").addColumn("authParams_code_challenge","varchar(256)").addColumn("authParams_redirect_uri","varchar(256)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).execute(),await t.schema.alterTable("passwords").addColumn("algorithm","varchar(16)").execute(),await t.schema.dropTable("codes").execute(),await t.schema.createTable("codes").addColumn("code_id","varchar(255)",e=>e.primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("user_id","varchar(255)").addColumn("login_id","varchar(255)").addForeignKeyConstraint("codes_user_id_tenant_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("code_type","varchar(255)",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute()}async function Al(t){await t.schema.dropTable("logins").execute(),await t.schema.alterTable("passwords").dropColumn("algorithm").execute(),await t.schema.dropTable("codes").execute(),await t.schema.createTable("codes").addColumn("id","varchar(255)",e=>e.primaryKey()).addColumn("code","varchar(255)",e=>e.notNull()).addColumn("user_id","varchar(255)").addColumn("tenant_id","varchar(255)").addForeignKeyConstraint("codes_user_id_tenant_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("type","varchar(255)",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute()}const Pl=Object.freeze(Object.defineProperty({__proto__:null,down:Al,up:$l},Symbol.toStringTag,{value:"Module"}));async function Dl(t){}async function Rl(t){}const Ml=Object.freeze(Object.defineProperty({__proto__:null,down:Rl,up:Dl},Symbol.toStringTag,{value:"Module"}));async function Ll(t){await t.schema.alterTable("logins").addColumn("auth0Client","varchar(256)").execute()}async function zl(t){await t.schema.alterTable("logins").dropColumn("auth0Client").execute()}const Ul=Object.freeze(Object.defineProperty({__proto__:null,down:zl,up:Ll},Symbol.toStringTag,{value:"Module"}));async function Fl(t){await t.schema.alterTable("logins").dropColumn("authParams_state").execute(),await t.schema.alterTable("logins").addColumn("authParams_state","varchar(8192)").execute()}async function Vl(t){await t.schema.alterTable("logins").dropColumn("authParams_state").execute(),await t.schema.alterTable("logins").addColumn("authParams_state","varchar(511)").execute()}const Bl=Object.freeze(Object.defineProperty({__proto__:null,down:Vl,up:Fl},Symbol.toStringTag,{value:"Module"}));async function Kl(t){}async function Wl(t){}const Jl=Object.freeze(Object.defineProperty({__proto__:null,down:Wl,up:Kl},Symbol.toStringTag,{value:"Module"}));async function ql(t){}async function Ql(t){}const Hl=Object.freeze(Object.defineProperty({__proto__:null,down:Ql,up:ql},Symbol.toStringTag,{value:"Module"}));async function Gl(t){await t.schema.alterTable("logins").addColumn("authParams_nonce","varchar(255)").execute()}async function Yl(t){await t.schema.alterTable("logins").dropColumn("nonce").execute()}const Xl=Object.freeze(Object.defineProperty({__proto__:null,down:Yl,up:Gl},Symbol.toStringTag,{value:"Module"}));async function eu(t){}async function tu(t){}const nu=Object.freeze(Object.defineProperty({__proto__:null,down:tu,up:eu},Symbol.toStringTag,{value:"Module"}));async function ru(t){}async function au(t){}const su=Object.freeze(Object.defineProperty({__proto__:null,down:au,up:ru},Symbol.toStringTag,{value:"Module"}));async function iu(t){await t.schema.dropTable("codes").execute(),await t.schema.createTable("codes").addColumn("code_id","varchar(255)",e=>e.notNull()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("user_id","varchar(255)").addColumn("login_id","varchar(255)").addColumn("connection_id","varchar(255)").addForeignKeyConstraint("codes_user_id_tenant_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("code_type","varchar(255)",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").addPrimaryKeyConstraint("PK_codes_code_id_code_type",["code_id","code_type"]).execute()}async function ou(t){await t.schema.dropTable("codes").execute(),await t.schema.createTable("codes").addColumn("code_id","varchar(255)",e=>e.primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("user_id","varchar(255)").addColumn("connection_id","varchar(255)").addColumn("login_id","varchar(255)").addForeignKeyConstraint("codes_user_id_tenant_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("code_type","varchar(255)",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute()}const du=Object.freeze(Object.defineProperty({__proto__:null,down:ou,up:iu},Symbol.toStringTag,{value:"Module"}));async function cu(t){await t.schema.dropTable("otps").execute(),await t.schema.dropTable("authentication_codes").execute()}async function lu(t){await t.schema.alterTable("keys").addColumn("private_key","varchar(2048)").addColumn("public_key","varchar(2048)").execute(),await t.schema.createTable("otps").addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("id","varchar(255)",e=>e.primaryKey()).addColumn("client_id","varchar(255)",e=>e.references("applications.id").onDelete("cascade").notNull()).addColumn("code","varchar(255)",e=>e.notNull()).addColumn("email","varchar(255)",e=>e.notNull()).addColumn("user_id","varchar(255)").addColumn("send","varchar(255)").addColumn("nonce","varchar(255)").addColumn("state","varchar(1024)").addColumn("scope","varchar(1024)").addColumn("response_type","varchar(256)").addColumn("response_mode","varchar(256)").addColumn("redirect_uri","varchar(1024)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute(),await t.schema.createTable("authentication_codes").addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("code","varchar(255)",e=>e.primaryKey()).addColumn("client_id","varchar(255)",e=>e.references("applications.id").onDelete("cascade").notNull()).addColumn("user_id","varchar(255)",e=>e.notNull()).addColumn("nonce","varchar(255)").addColumn("state","varchar(8192)").addColumn("scope","varchar(1024)").addColumn("response_type","varchar(256)").addColumn("response_mode","varchar(256)").addColumn("redirect_uri","varchar(1024)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute()}const uu=Object.freeze(Object.defineProperty({__proto__:null,down:lu,up:cu},Symbol.toStringTag,{value:"Module"}));async function hu(t){await t.schema.createIndex("IDX_logs_tenant_date_type_user").on("logs").columns(["tenant_id","date","type","user_id"]).execute()}async function pu(t){await t.schema.dropIndex("IDX_logs_tenant_date_type_user").on("logs").execute()}const mu=Object.freeze(Object.defineProperty({__proto__:null,down:pu,up:hu},Symbol.toStringTag,{value:"Module"}));async function fu(t){}async function _u(t){}const gu=Object.freeze(Object.defineProperty({__proto__:null,down:_u,up:fu},Symbol.toStringTag,{value:"Module"}));async function yu(t){await t.schema.createTable("prompt_settings").addColumn("tenant_id","varchar(64)",e=>e.primaryKey()).addColumn("universal_login_experience","varchar(16)",e=>e.defaultTo("new").notNull()).addColumn("identifier_first","boolean",e=>e.defaultTo(!0).notNull()).addColumn("password_first","boolean",e=>e.defaultTo(!1).notNull()).addColumn("webauthn_platform_first_factor","boolean",e=>e.defaultTo(!1).notNull()).execute()}async function vu(t){await t.schema.dropTable("prompt_settings").execute()}const bu=Object.freeze(Object.defineProperty({__proto__:null,down:vu,up:yu},Symbol.toStringTag,{value:"Module"}));async function wu(t){}async function xu(t){}const Nu=Object.freeze(Object.defineProperty({__proto__:null,down:xu,up:wu},Symbol.toStringTag,{value:"Module"}));async function ku(t){}async function Tu(t){}const Cu=Object.freeze(Object.defineProperty({__proto__:null,down:Tu,up:ku},Symbol.toStringTag,{value:"Module"}));async function Ou(t){}async function Su(t){}const ju=Object.freeze(Object.defineProperty({__proto__:null,down:Su,up:Ou},Symbol.toStringTag,{value:"Module"}));async function Iu(t){await t.schema.alterTable("logins").addColumn("authParams_ui_locales","varchar(32)").execute()}async function Zu(t){await t.schema.alterTable("logins").dropColumn("authParams_ui_locales").execute()}const Eu=Object.freeze(Object.defineProperty({__proto__:null,down:Zu,up:Iu},Symbol.toStringTag,{value:"Module"}));async function $u(t){await t.schema.alterTable("logins").addColumn("authParams_prompt","varchar(16)").execute()}async function Au(t){await t.schema.alterTable("logins").dropColumn("authParams_prompt").execute()}const Pu=Object.freeze(Object.defineProperty({__proto__:null,down:Au,up:$u},Symbol.toStringTag,{value:"Module"}));async function Du(t){}async function Ru(t){}const Er={m1_init:md,m2_magicLink:gd,m3_updateAt:bd,m4_logTable:Nd,m5_userProfile:Cd,m6_sessions:jd,m7_passwords:Ed,m8_logsTableNewFields:Pd,m9_passwordTableNewField:Md,n01_codesTable:Ud,n11_universalLoginSession:Bd,n12_userFields:Jd,n13_userEmailIndex:Hd,n14_profileDataField:Xd,n15_userEmailIndex:nc,n16_userLocale:sc,n17_signingKeys:dc,n18_logsFields:uc,n19_connectionsUserinfo:mc,n20_missingFields:gc,n21_sessionDeletedAt:bc,n22_dropLogsFields:Nc,n23_dropUsersFields:Cc,n24_logsIndexes:jc,n25_logDescMaxLength:Ec,n26_logsTableExtraFields:Pc,n27_usersTableNameIndex:Mc,n28_usersEmailConstrain:Uc,n29_increaseOtpStateLength:Bc,n30_increaseTicketStateLength:Jc,n31_branding:Hc,n32_indexesAndNotNull:Xc,n33_vendorIdInUniversalLoginSession:nl,n34_auth0ClientInUniversalLoginSession:sl,n35_increaseUniversalSessionStateLength:dl,n36_authenticationCodes:ul,n37_disableSignUps:ml,n38_otpIpAddress:gl,n39_increaseUserAgentLength:bl,n40_userId:Nl,n41_hooks:Cl,n42_userIdIndexes:jl,n43_userIdIndexes:El,n44_codes:Pl,n45_hookProperties:Ml,n46_loginAuth0Client:Ul,n47_loginAuth0Client:Bl,n48_saml:Jl,n49_removeFields:Hl,n50_authParamsNonce:Xl,n51_connectionid:nu,n52_cert:su,n53_codes_primary_key:du,n54_cleanup_tables:uu,n55_logs_index:mu,n56_application_fields:gu,n57_prompt_settings:bu,n58_connection_client_id:Nu,n59_connection_options:Cu,n60_users_metadata:ju,n61_userLocales:Eu,n62_prompt:Pu,n63_connection_cleanup:Object.freeze(Object.defineProperty({__proto__:null,down:Ru,up:Du},Symbol.toStringTag,{value:"Module"}))};async function Mu(t,e=!1){e&&console.log("migrating...");const n=new Zr(Er),r=new Ir({db:t,provider:n}),{error:a,results:s}=await r.migrateToLatest();if(s==null||s.forEach(o=>{o.status==="Success"?e&&console.log(`migration "${o.migrationName}" was executed successfully`):o.status==="Error"&&console.error(`failed to execute migration "${o.migrationName}"`)}),a)throw console.error("failed to migrate"),console.error(a),a}async function Lu(t){console.log("migrating...");const e=new Zr(Er),n=new Ir({db:t,provider:e}),{error:r,results:a}=await n.migrateDown();if(a==null||a.forEach(s=>{s.status==="Success"?console.log(`migration "${s.migrationName}" was reverted successfully`):s.status==="Error"&&console.error(`failed to execute migration "${s.migrationName}"`)}),r)throw console.error("failed to migrate"),console.error(r),r}function zu(t){return{applications:gi(t),branding:Do(t),clients:Co(t),codes:ui(t),connections:To(t),domains:$o(t),hooks:Fo(t),keys:Io(t),logins:Yo(t),logs:Ws(t),passwords:ii(t),promptSettings:td(t),users:As(t),sessions:Ys(t),tenants:Us(t),themes:Jo(t),tickets:ni(t)}}return A.default=zu,A.migrateDown=Lu,A.migrateToLatest=Mu,Object.defineProperties(A,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),A}({});
|