zaileys 0.29.17-beta → 0.29.19-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -0
- package/dist/{types/classes/client.d.ts → index.d.mts} +83 -22
- package/dist/index.mjs +1 -0
- package/package.json +12 -8
- package/dist/classes/Client.d.ts +0 -17
- package/dist/classes/Event.d.ts +0 -12
- package/dist/classes/Parser.d.ts +0 -3
- package/dist/database/handler.d.ts +0 -12
- package/dist/database/schema.d.ts +0 -63
- package/dist/helpers/adapter.d.ts +0 -57
- package/dist/helpers/error.d.ts +0 -8
- package/dist/index.esm.js +0 -2
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/types/adapter/general.d.ts +0 -156
- package/dist/types/classes/event.d.ts +0 -65
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
export declare const AuthSchema: z.ZodObject<{
|
|
3
|
-
session: z.ZodString;
|
|
4
|
-
id: z.ZodString;
|
|
5
|
-
value: z.ZodNullable<z.ZodString>;
|
|
6
|
-
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
session: string;
|
|
8
|
-
value: string | null;
|
|
9
|
-
id: string;
|
|
10
|
-
}, {
|
|
11
|
-
session: string;
|
|
12
|
-
value: string | null;
|
|
13
|
-
id: string;
|
|
14
|
-
}>;
|
|
15
|
-
export declare const ChatSchema: z.ZodObject<{
|
|
16
|
-
session: z.ZodString;
|
|
17
|
-
id: z.ZodString;
|
|
18
|
-
value: z.ZodNullable<z.ZodString>;
|
|
19
|
-
}, "strip", z.ZodTypeAny, {
|
|
20
|
-
session: string;
|
|
21
|
-
value: string | null;
|
|
22
|
-
id: string;
|
|
23
|
-
}, {
|
|
24
|
-
session: string;
|
|
25
|
-
value: string | null;
|
|
26
|
-
id: string;
|
|
27
|
-
}>;
|
|
28
|
-
export declare const ContactSchema: z.ZodObject<{
|
|
29
|
-
session: z.ZodString;
|
|
30
|
-
id: z.ZodString;
|
|
31
|
-
value: z.ZodNullable<z.ZodString>;
|
|
32
|
-
}, "strip", z.ZodTypeAny, {
|
|
33
|
-
session: string;
|
|
34
|
-
value: string | null;
|
|
35
|
-
id: string;
|
|
36
|
-
}, {
|
|
37
|
-
session: string;
|
|
38
|
-
value: string | null;
|
|
39
|
-
id: string;
|
|
40
|
-
}>;
|
|
41
|
-
export declare const MessageSchema: z.ZodObject<{
|
|
42
|
-
session: z.ZodString;
|
|
43
|
-
id: z.ZodString;
|
|
44
|
-
value: z.ZodNullable<z.ZodString>;
|
|
45
|
-
}, "strip", z.ZodTypeAny, {
|
|
46
|
-
session: string;
|
|
47
|
-
value: string | null;
|
|
48
|
-
id: string;
|
|
49
|
-
}, {
|
|
50
|
-
session: string;
|
|
51
|
-
value: string | null;
|
|
52
|
-
id: string;
|
|
53
|
-
}>;
|
|
54
|
-
export type AuthTable = z.infer<typeof AuthSchema>;
|
|
55
|
-
export type ChatTable = z.infer<typeof ChatSchema>;
|
|
56
|
-
export type ContactTable = z.infer<typeof ContactSchema>;
|
|
57
|
-
export type MessageTable = z.infer<typeof MessageSchema>;
|
|
58
|
-
export type DB = {
|
|
59
|
-
auth: AuthTable;
|
|
60
|
-
chats: ChatTable;
|
|
61
|
-
contacts: ContactTable;
|
|
62
|
-
messages: MessageTable;
|
|
63
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { AppDataSync, valueReplacer, valueReviver } from "../types/adapter/general";
|
|
2
|
-
export declare const fromObject: (args: AppDataSync) => {
|
|
3
|
-
keyData: Uint8Array<ArrayBuffer> | (Uint8Array<ArrayBufferLike> & any[]);
|
|
4
|
-
fingerprint: {
|
|
5
|
-
rawId: number;
|
|
6
|
-
currentIndex: number;
|
|
7
|
-
deviceIndexes: number[];
|
|
8
|
-
};
|
|
9
|
-
timestamp: number | import("long").Long;
|
|
10
|
-
};
|
|
11
|
-
export declare const BufferJSON: {
|
|
12
|
-
replacer: (_: string, value: valueReplacer) => valueReplacer | {
|
|
13
|
-
type: string;
|
|
14
|
-
data: string;
|
|
15
|
-
};
|
|
16
|
-
reviver: (_: string, value: valueReviver) => valueReviver | Buffer<ArrayBuffer>;
|
|
17
|
-
};
|
|
18
|
-
export declare const initAuthCreds: () => {
|
|
19
|
-
noiseKey: {
|
|
20
|
-
private: Buffer<any>;
|
|
21
|
-
public: Buffer<any>;
|
|
22
|
-
};
|
|
23
|
-
pairingEphemeralKeyPair: {
|
|
24
|
-
private: Buffer<any>;
|
|
25
|
-
public: Buffer<any>;
|
|
26
|
-
};
|
|
27
|
-
signedIdentityKey: {
|
|
28
|
-
private: Buffer<any>;
|
|
29
|
-
public: Buffer<any>;
|
|
30
|
-
};
|
|
31
|
-
signedPreKey: {
|
|
32
|
-
keyPair: {
|
|
33
|
-
private: Buffer<any>;
|
|
34
|
-
public: Buffer<any>;
|
|
35
|
-
};
|
|
36
|
-
signature: any;
|
|
37
|
-
keyId: number;
|
|
38
|
-
};
|
|
39
|
-
registrationId: number;
|
|
40
|
-
advSecretKey: string;
|
|
41
|
-
processedHistoryMessages: never[];
|
|
42
|
-
nextPreKeyId: number;
|
|
43
|
-
firstUnuploadedPreKeyId: number;
|
|
44
|
-
accountSyncCounter: number;
|
|
45
|
-
accountSettings: {
|
|
46
|
-
unarchiveChats: boolean;
|
|
47
|
-
};
|
|
48
|
-
deviceId: string;
|
|
49
|
-
phoneId: `${string}-${string}-${string}-${string}-${string}`;
|
|
50
|
-
identityId: Buffer<ArrayBufferLike>;
|
|
51
|
-
backupToken: Buffer<ArrayBufferLike>;
|
|
52
|
-
registered: boolean;
|
|
53
|
-
registration: never;
|
|
54
|
-
pairingCode: undefined;
|
|
55
|
-
lastPropHash: undefined;
|
|
56
|
-
routingInfo: undefined;
|
|
57
|
-
};
|
package/dist/helpers/error.d.ts
DELETED
package/dist/index.esm.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import Ye,{DisconnectReason as Ge,Browsers as Qe,makeCacheableSignalKeyStore as Xe}from"baileys";import Ae from"node-cache";import et from"pino";import tt from"better-sqlite3";import{mkdirSync as st,writeFileSync as rt}from"fs";import{Kysely as Te,SqliteDialect as nt,MysqlDialect as at,PostgresDialect as it}from"kysely";import ot from"mysql2";import Ee from"path";import{Pool as ct}from"pg";import{URL as dt}from"url";import{randomBytes as pe,randomUUID as Re}from"crypto";import{curve as ut}from"libsignal";const De=ut,me=()=>{const{pubKey:s,privKey:e}=De.generateKeyPair();return{private:Buffer.from(e),public:Buffer.from(s.slice(1))}},lt=s=>s.length===33?s:Buffer.concat([Buffer.from([5]),s]),ft=(s,e)=>De.calculateSignature(s,e),ht=(s,e)=>{const t=me(),r=lt(t.public),n=ft(s.private,r);return{keyPair:t,signature:n,keyId:e}},pt=s=>{let e=s.length;if(!e)return new Uint8Array(1);let t=0;for(;--e%4>1&&s.charAt(e)==="=";)++t;return new Uint8Array(Math.ceil(s.length*3)/4-t).fill(0)},mt=s=>typeof s=="string"?parseInt(s,10):s,yt=s=>{const e={...s.fingerprint,deviceIndexes:Array.isArray(s.fingerprint.deviceIndexes)?s.fingerprint.deviceIndexes:[]},t={keyData:Array.isArray(s.keyData)?s.keyData:new Uint8Array,fingerprint:{rawId:e.rawId||0,currentIndex:e.rawId||0,deviceIndexes:e.deviceIndexes},timestamp:mt(s.timestamp)};return typeof s.keyData=="string"&&(t.keyData=pt(s.keyData)),t},je={replacer:(s,e)=>e?.type==="Buffer"&&Array.isArray(e?.data)?{type:"Buffer",data:Buffer.from(e?.data).toString("base64")}:e,reviver:(s,e)=>e?.type==="Buffer"?Buffer.from(e?.data,"base64"):e},vt=()=>{const s=me();return{noiseKey:me(),pairingEphemeralKeyPair:me(),signedIdentityKey:s,signedPreKey:ht(s,1),registrationId:Uint16Array.from(pe(2))[0]&16383,advSecretKey:pe(32).toString("base64"),processedHistoryMessages:[],nextPreKeyId:1,firstUnuploadedPreKeyId:1,accountSyncCounter:0,accountSettings:{unarchiveChats:!1},deviceId:Buffer.from(Re().replace(/-/g,""),"hex").toString("base64url"),phoneId:Re(),identityId:pe(20),backupToken:pe(20),registered:!1,registration:{},pairingCode:void 0,lastPropHash:void 0,routingInfo:void 0}},gt=(s,e)=>{if(s==="sqlite"){const n=e||"./db/zaileys.db",a=Ee.resolve(n);return st(Ee.dirname(a),{recursive:!0}),rt(a,"",{flag:"a"}),new Te({dialect:new nt({database:new tt(a)})})}const t=new dt(e),r=t.protocol.replace(":","");if(s==="mysql")return new Te({dialect:new at({pool:ot.createPool({host:t.hostname,user:t.username,password:t.password,database:t.pathname.replace("/",""),port:parseInt(t.port||"3306",10)})})});if(s==="postgresql")return new Te({dialect:new it({pool:new ct({host:t.hostname,user:t.username,password:t.password,database:t.pathname.replace("/",""),port:parseInt(t.port||"5432",10)})})});throw new Error(`Unsupported database protocol: ${r}`)},_t=async s=>{await s.schema.createTable("auth").ifNotExists().addColumn("session","varchar(50)",e=>e.notNull()).addColumn("id","varchar(80)",e=>e.notNull()).addColumn("value","text",e=>e.defaultTo(null)).addUniqueConstraint("auth_session_id_unique",["session","id"]).execute(),await s.schema.createTable("chats").ifNotExists().addColumn("session","varchar(50)",e=>e.notNull()).addColumn("id","varchar(80)",e=>e.notNull()).addColumn("value","text",e=>e.defaultTo(null)).addUniqueConstraint("chats_session_id_unique",["session","id"]).execute(),await s.schema.createTable("contacts").ifNotExists().addColumn("session","varchar(50)",e=>e.notNull()).addColumn("id","varchar(80)",e=>e.notNull()).addColumn("value","text",e=>e.defaultTo(null)).addUniqueConstraint("contacts_session_id_unique",["session","id"]).execute(),await s.schema.createTable("messages").ifNotExists().addColumn("session","varchar(50)",e=>e.notNull()).addColumn("id","varchar(80)",e=>e.notNull()).addColumn("value","text",e=>e.defaultTo(null)).addUniqueConstraint("messages_session_id_unique",["session","id"]).execute(),await s.schema.createIndex("auth_session_idx").ifNotExists().on("auth").column("session").execute(),await s.schema.createIndex("auth_id_idx").ifNotExists().on("auth").column("id").execute(),await s.schema.createIndex("chats_session_idx").ifNotExists().on("chats").column("session").execute(),await s.schema.createIndex("chats_id_idx").ifNotExists().on("chats").column("id").execute(),await s.schema.createIndex("contacts_session_idx").ifNotExists().on("contacts").column("session").execute(),await s.schema.createIndex("contacts_id_idx").ifNotExists().on("contacts").column("id").execute(),await s.schema.createIndex("messages_session_idx").ifNotExists().on("messages").column("session").execute(),await s.schema.createIndex("messages_id_idx").ifNotExists().on("messages").column("id").execute()},xt=async(s,e)=>{const t="auth";await _t(s);const r=async h=>{for(let x=0;x<10;x++)try{return await h()}catch{await new Promise(k=>setTimeout(k,200))}throw new Error("Max retries reached")},n=async h=>{const x=await r(()=>s.selectFrom(t).select(["value"]).where("id","=",h).where("session","=",e).executeTakeFirst());if(!x?.value)return null;const k=typeof x.value=="object"?JSON.stringify(x.value):x.value;return JSON.parse(k,je.reviver)},a=async(h,x)=>{const k=JSON.stringify(x,je.replacer);await r(()=>s.insertInto(t).values({session:e,id:h,value:k}).onConflict(N=>N.columns(["session","id"]).doUpdateSet({value:k})).execute())},o=async h=>{await r(()=>s.deleteFrom(t).where("id","=",h).where("session","=",e).execute())},i=async()=>{await r(()=>s.deleteFrom(t).where("session","=",e).where("id","!=","creds").execute())},d=async()=>{await r(()=>s.deleteFrom(t).where("session","=",e).execute())},u=await n("creds")||vt();return{state:{creds:u,keys:{get:async(h,x)=>{const k={};for(const N of x){let z=await n(`${h}-${N}`);h==="app-state-sync-key"&&z&&(z=yt(z)),k[N]=z}return k},set:async h=>{for(const x in h)for(const k in h[x]){const N=h[x][k],z=`${x}-${k}`;N?await a(z,N):await o(z)}}}},saveCreds:async()=>{await a("creds",u)},clear:async()=>{await i()},removeCreds:async()=>{await d()}}},bt=async(s,e)=>({bind:t=>{t.on("messaging-history.set",async r=>{const{chats:n,contacts:a,messages:o}=r;for(const i of n)await s.insertInto("chats").values({session:e,id:i.id,value:JSON.stringify(i)}).onConflict(d=>d.columns(["session","id"]).doUpdateSet({value:JSON.stringify(i)})).execute();for(const i of a)await s.insertInto("contacts").values({session:e,id:i.id,value:JSON.stringify(i)}).onConflict(d=>d.columns(["session","id"]).doUpdateSet({value:JSON.stringify(i)})).execute();for(const i of o)await s.insertInto("messages").values({session:e,id:i.key.id,value:JSON.stringify(i)}).onConflict(d=>d.columns(["session","id"]).doUpdateSet({value:JSON.stringify(i)})).execute()}),t.on("messages.upsert",async({messages:r})=>{for(const n of r)await s.insertInto("messages").values({session:e,id:n.key.id,value:JSON.stringify(n)}).onConflict(a=>a.columns(["session","id"]).doUpdateSet({value:JSON.stringify(n)})).execute()}),t.on("chats.upsert",async r=>{for(const n of r)await s.insertInto("chats").values({session:e,id:n.id,value:JSON.stringify(n)}).onConflict(a=>a.columns(["session","id"]).doUpdateSet({value:JSON.stringify(n)})).execute()}),t.on("contacts.upsert",async r=>{for(const n of r)await s.insertInto("contacts").values({session:e,id:n.id,value:JSON.stringify(n)}).onConflict(a=>a.columns(["session","id"]).doUpdateSet({value:JSON.stringify(n)})).execute()})}});var _;(function(s){s.assertEqual=n=>n;function e(n){}s.assertIs=e;function t(n){throw new Error}s.assertNever=t,s.arrayToEnum=n=>{const a={};for(const o of n)a[o]=o;return a},s.getValidEnumValues=n=>{const a=s.objectKeys(n).filter(i=>typeof n[n[i]]!="number"),o={};for(const i of a)o[i]=n[i];return s.objectValues(o)},s.objectValues=n=>s.objectKeys(n).map(function(a){return n[a]}),s.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&a.push(o);return a},s.find=(n,a)=>{for(const o of n)if(a(o))return o},s.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function r(n,a=" | "){return n.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}s.joinValues=r,s.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(_||(_={}));var Se;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(Se||(Se={}));const f=_.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),$=s=>{switch(typeof s){case"undefined":return f.undefined;case"string":return f.string;case"number":return isNaN(s)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(s)?f.array:s===null?f.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?f.promise:typeof Map<"u"&&s instanceof Map?f.map:typeof Set<"u"&&s instanceof Set?f.set:typeof Date<"u"&&s instanceof Date?f.date:f.object;default:return f.unknown}},c=_.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),wt=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");class S extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},r={_errors:[]},n=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(n);else if(o.code==="invalid_return_type")n(o.returnTypeError);else if(o.code==="invalid_arguments")n(o.argumentsError);else if(o.path.length===0)r._errors.push(t(o));else{let i=r,d=0;for(;d<o.path.length;){const u=o.path[d];d===o.path.length-1?(i[u]=i[u]||{_errors:[]},i[u]._errors.push(t(o))):i[u]=i[u]||{_errors:[]},i=i[u],d++}}};return n(this),r}static assert(e){if(!(e instanceof S))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=t=>t.message){const t={},r=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}S.create=s=>new S(s);const H=(s,e)=>{let t;switch(s.code){case c.invalid_type:s.received===f.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case c.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,_.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:t=`Unrecognized key(s) in object: ${_.joinValues(s.keys,", ")}`;break;case c.invalid_union:t="Invalid input";break;case c.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${_.joinValues(s.options)}`;break;case c.invalid_enum_value:t=`Invalid enum value. Expected ${_.joinValues(s.options)}, received '${s.received}'`;break;case c.invalid_arguments:t="Invalid function arguments";break;case c.invalid_return_type:t="Invalid function return type";break;case c.invalid_date:t="Invalid date";break;case c.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:_.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case c.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case c.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case c.custom:t="Invalid input";break;case c.invalid_intersection_types:t="Intersection results could not be merged";break;case c.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case c.not_finite:t="Number must be finite";break;default:t=e.defaultError,_.assertNever(s)}return{message:t}};let Ve=H;function kt(s){Ve=s}function ye(){return Ve}const ve=s=>{const{data:e,path:t,errorMaps:r,issueData:n}=s,a=[...t,...n.path||[]],o={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let i="";const d=r.filter(u=>!!u).slice().reverse();for(const u of d)i=u(o,{data:e,defaultError:i}).message;return{...n,path:a,message:i}},Tt=[];function l(s,e){const t=ye(),r=ve({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===H?void 0:H].filter(n=>!!n)});s.common.issues.push(r)}class T{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const n of t){if(n.status==="aborted")return y;n.status==="dirty"&&e.dirty(),r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const n of t){const a=await n.key,o=await n.value;r.push({key:a,value:o})}return T.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const n of t){const{key:a,value:o}=n;if(a.status==="aborted"||o.status==="aborted")return y;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||n.alwaysSet)&&(r[a.value]=o.value)}return{status:e.value,value:r}}}const y=Object.freeze({status:"aborted"}),W=s=>({status:"dirty",value:s}),C=s=>({status:"valid",value:s}),Ne=s=>s.status==="aborted",Ze=s=>s.status==="dirty",B=s=>s.status==="valid",ee=s=>typeof Promise<"u"&&s instanceof Promise;function ge(s,e,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(s):r?r.value:e.get(s)}function Ue(s,e,t,r,n){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?s!==e||!n:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?n.call(s,t):n?n.value=t:e.set(s,t),t}var p;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e?.message})(p||(p={}));var Q,X;class E{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const $e=(s,e)=>{if(B(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new S(s.common.issues);return this._error=t,this._error}}};function v(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:n}=s;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(o,i)=>{var d,u;const{message:h}=s;return o.code==="invalid_enum_value"?{message:h??i.defaultError}:typeof i.data>"u"?{message:(d=h??r)!==null&&d!==void 0?d:i.defaultError}:o.code!=="invalid_type"?{message:i.defaultError}:{message:(u=h??t)!==null&&u!==void 0?u:i.defaultError}},description:n}}class g{get description(){return this._def.description}_getType(e){return $(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:$(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new T,ctx:{common:e.parent.common,data:e.data,parsedType:$(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ee(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const n={common:{issues:[],async:(r=t?.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$(e)},a=this._parseSync({data:e,path:n.path,parent:n});return $e(n,a)}"~validate"(e){var t,r;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:n});return B(a)?{value:a.value}:{issues:n.common.issues}}catch(a){!((r=(t=a?.message)===null||t===void 0?void 0:t.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(a=>B(a)?{value:a.value}:{issues:n.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$(e)},n=this._parse({data:e,path:r.path,parent:r}),a=await(ee(n)?n:Promise.resolve(n));return $e(r,a)}refine(e,t){const r=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const o=e(n),i=()=>a.addIssue({code:c.custom,...r(n)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(i(),!1)):o?!0:(i(),!1)})}refinement(e,t){return this._refinement((r,n)=>e(r)?!0:(n.addIssue(typeof t=="function"?t(r,n):t),!1))}_refinement(e){return new I({schema:this,typeName:m.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}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),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return A.create(this,this._def)}nullable(){return U.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return O.create(this)}promise(){return G.create(this,this._def)}or(e){return ne.create([this,e],this._def)}and(e){return ae.create(this,e,this._def)}transform(e){return new I({...v(this._def),schema:this,typeName:m.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ue({...v(this._def),innerType:this,defaultValue:t,typeName:m.ZodDefault})}brand(){return new Ie({typeName:m.ZodBranded,type:this,...v(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new le({...v(this._def),innerType:this,catchValue:t,typeName:m.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return he.create(this,e)}readonly(){return fe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ct=/^c[^\s-]{8,}$/i,St=/^[0-9a-z]+$/,Nt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Zt=/^[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,Ot=/^[a-z0-9_-]{21}$/i,It=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,At=/^[-+]?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)?)??$/,Et=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Rt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ce;const jt=/^(?:(?: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])$/,$t=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,Mt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Pt=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Dt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Vt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ze="((\\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])))",Ut=new RegExp(`^${ze}$`);function Le(s){let e="[0-5]\\d";s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`);const t=s.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function zt(s){return new RegExp(`^${Le(s)}$`)}function Be(s){let e=`${ze}T${Le(s)}`;const t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Lt(s,e){return!!((e==="v4"||!e)&&jt.test(s)||(e==="v6"||!e)&&Mt.test(s))}function Bt(s,e){if(!It.test(s))return!1;try{const[t]=s.split("."),r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(r));return!(typeof n!="object"||n===null||!n.typ||!n.alg||e&&n.alg!==e)}catch{return!1}}function qt(s,e){return!!((e==="v4"||!e)&&$t.test(s)||(e==="v6"||!e)&&Pt.test(s))}class Z extends g{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:f.string,received:a.parsedType}),y}const r=new T;let n;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const o=e.data.length>a.value,i=e.data.length<a.value;(o||i)&&(n=this._getOrReturnCtx(e,n),o?l(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):i&&l(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")Et.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"email",code:c.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")Ce||(Ce=new RegExp(Rt,"u")),Ce.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"emoji",code:c.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")Zt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"uuid",code:c.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")Ot.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"nanoid",code:c.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")Ct.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cuid",code:c.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")St.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cuid2",code:c.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")Nt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"ulid",code:c.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),l(n,{validation:"url",code:c.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"regex",code:c.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?Be(a).test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?Ut.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?zt(a).test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?At.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"duration",code:c.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?Lt(e.data,a.version)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"ip",code:c.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?Bt(e.data,a.alg)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"jwt",code:c.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?qt(e.data,a.version)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cidr",code:c.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?Dt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"base64",code:c.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?Vt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"base64url",code:c.invalid_string,message:a.message}),r.dirty()):_.assertNever(a);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(n=>e.test(n),{validation:t,code:c.invalid_string,...p.errToObj(r)})}_addCheck(e){return new Z({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.errToObj(e)})}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(t=e?.offset)!==null&&t!==void 0?t:!1,local:(r=e?.local)!==null&&r!==void 0?r:!1,...p.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...p.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...p.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...p.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...p.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...p.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...p.errToObj(t)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new Z({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Z({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Z({...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 isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Z.create=s=>{var e;return new Z({checks:[],typeName:m.ZodString,coerce:(e=s?.coerce)!==null&&e!==void 0?e:!1,...v(s)})};function Ft(s,e){const t=(s.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,n=t>r?t:r,a=parseInt(s.toFixed(n).replace(".","")),o=parseInt(e.toFixed(n).replace(".",""));return a%o/Math.pow(10,n)}class P extends g{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:f.number,received:a.parsedType}),y}let r;const n=new T;for(const a of this._def.checks)a.kind==="int"?_.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:c.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),l(r,{code:c.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),l(r,{code:c.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?Ft(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),l(r,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:c.not_finite,message:a.message}),n.dirty()):_.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,r,n){return new P({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:p.toString(n)}]})}_addCheck(e){return new P({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&_.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}P.create=s=>new P({checks:[],typeName:m.ZodNumber,coerce:s?.coerce||!1,...v(s)});class D extends g{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==f.bigint)return this._getInvalidInput(e);let r;const n=new T;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),l(r,{code:c.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),l(r,{code:c.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),l(r,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):_.assertNever(a);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return l(t,{code:c.invalid_type,expected:f.bigint,received:t.parsedType}),y}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,r,n){return new D({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:p.toString(n)}]})}_addCheck(e){return new D({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}D.create=s=>{var e;return new D({checks:[],typeName:m.ZodBigInt,coerce:(e=s?.coerce)!==null&&e!==void 0?e:!1,...v(s)})};class te extends g{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const r=this._getOrReturnCtx(e);return l(r,{code:c.invalid_type,expected:f.boolean,received:r.parsedType}),y}return C(e.data)}}te.create=s=>new te({typeName:m.ZodBoolean,coerce:s?.coerce||!1,...v(s)});class q extends g{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:f.date,received:a.parsedType}),y}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_date}),y}const r=new T;let n;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):_.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}q.create=s=>new q({checks:[],coerce:s?.coerce||!1,typeName:m.ZodDate,...v(s)});class _e extends g{_parse(e){if(this._getType(e)!==f.symbol){const r=this._getOrReturnCtx(e);return l(r,{code:c.invalid_type,expected:f.symbol,received:r.parsedType}),y}return C(e.data)}}_e.create=s=>new _e({typeName:m.ZodSymbol,...v(s)});class se extends g{_parse(e){if(this._getType(e)!==f.undefined){const r=this._getOrReturnCtx(e);return l(r,{code:c.invalid_type,expected:f.undefined,received:r.parsedType}),y}return C(e.data)}}se.create=s=>new se({typeName:m.ZodUndefined,...v(s)});class re extends g{_parse(e){if(this._getType(e)!==f.null){const r=this._getOrReturnCtx(e);return l(r,{code:c.invalid_type,expected:f.null,received:r.parsedType}),y}return C(e.data)}}re.create=s=>new re({typeName:m.ZodNull,...v(s)});class Y extends g{constructor(){super(...arguments),this._any=!0}_parse(e){return C(e.data)}}Y.create=s=>new Y({typeName:m.ZodAny,...v(s)});class L extends g{constructor(){super(...arguments),this._unknown=!0}_parse(e){return C(e.data)}}L.create=s=>new L({typeName:m.ZodUnknown,...v(s)});class M extends g{_parse(e){const t=this._getOrReturnCtx(e);return l(t,{code:c.invalid_type,expected:f.never,received:t.parsedType}),y}}M.create=s=>new M({typeName:m.ZodNever,...v(s)});class xe extends g{_parse(e){if(this._getType(e)!==f.undefined){const r=this._getOrReturnCtx(e);return l(r,{code:c.invalid_type,expected:f.void,received:r.parsedType}),y}return C(e.data)}}xe.create=s=>new xe({typeName:m.ZodVoid,...v(s)});class O extends g{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==f.array)return l(t,{code:c.invalid_type,expected:f.array,received:t.parsedType}),y;if(n.exactLength!==null){const o=t.data.length>n.exactLength.value,i=t.data.length<n.exactLength.value;(o||i)&&(l(t,{code:o?c.too_big:c.too_small,minimum:i?n.exactLength.value:void 0,maximum:o?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(l(t,{code:c.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(l(t,{code:c.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((o,i)=>n.type._parseAsync(new E(t,o,t.path,i)))).then(o=>T.mergeArray(r,o));const a=[...t.data].map((o,i)=>n.type._parseSync(new E(t,o,t.path,i)));return T.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new O({...this._def,minLength:{value:e,message:p.toString(t)}})}max(e,t){return new O({...this._def,maxLength:{value:e,message:p.toString(t)}})}length(e,t){return new O({...this._def,exactLength:{value:e,message:p.toString(t)}})}nonempty(e){return this.min(1,e)}}O.create=(s,e)=>new O({type:s,minLength:null,maxLength:null,exactLength:null,typeName:m.ZodArray,...v(e)});function J(s){if(s instanceof w){const e={};for(const t in s.shape){const r=s.shape[t];e[t]=A.create(J(r))}return new w({...s._def,shape:()=>e})}else return s instanceof O?new O({...s._def,type:J(s.element)}):s instanceof A?A.create(J(s.unwrap())):s instanceof U?U.create(J(s.unwrap())):s instanceof R?R.create(s.items.map(e=>J(e))):s}class w extends g{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=_.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==f.object){const u=this._getOrReturnCtx(e);return l(u,{code:c.invalid_type,expected:f.object,received:u.parsedType}),y}const{status:r,ctx:n}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),i=[];if(!(this._def.catchall instanceof M&&this._def.unknownKeys==="strip"))for(const u in n.data)o.includes(u)||i.push(u);const d=[];for(const u of o){const h=a[u],x=n.data[u];d.push({key:{status:"valid",value:u},value:h._parse(new E(n,x,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof M){const u=this._def.unknownKeys;if(u==="passthrough")for(const h of i)d.push({key:{status:"valid",value:h},value:{status:"valid",value:n.data[h]}});else if(u==="strict")i.length>0&&(l(n,{code:c.unrecognized_keys,keys:i}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const h of i){const x=n.data[h];d.push({key:{status:"valid",value:h},value:u._parse(new E(n,x,n.path,h)),alwaysSet:h in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const h of d){const x=await h.key,k=await h.value;u.push({key:x,value:k,alwaysSet:h.alwaysSet})}return u}).then(u=>T.mergeObjectSync(r,u)):T.mergeObjectSync(r,d)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new w({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var n,a,o,i;const d=(o=(a=(n=this._def).errorMap)===null||a===void 0?void 0:a.call(n,t,r).message)!==null&&o!==void 0?o:r.defaultError;return t.code==="unrecognized_keys"?{message:(i=p.errToObj(e).message)!==null&&i!==void 0?i:d}:{message:d}}}:{}})}strip(){return new w({...this._def,unknownKeys:"strip"})}passthrough(){return new w({...this._def,unknownKeys:"passthrough"})}extend(e){return new w({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new w({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:m.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new w({...this._def,catchall:e})}pick(e){const t={};return _.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new w({...this._def,shape:()=>t})}omit(e){const t={};return _.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new w({...this._def,shape:()=>t})}deepPartial(){return J(this)}partial(e){const t={};return _.objectKeys(this.shape).forEach(r=>{const n=this.shape[r];e&&!e[r]?t[r]=n:t[r]=n.optional()}),new w({...this._def,shape:()=>t})}required(e){const t={};return _.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof A;)a=a._def.innerType;t[r]=a}}),new w({...this._def,shape:()=>t})}keyof(){return qe(_.objectKeys(this.shape))}}w.create=(s,e)=>new w({shape:()=>s,unknownKeys:"strip",catchall:M.create(),typeName:m.ZodObject,...v(e)});w.strictCreate=(s,e)=>new w({shape:()=>s,unknownKeys:"strict",catchall:M.create(),typeName:m.ZodObject,...v(e)});w.lazycreate=(s,e)=>new w({shape:s,unknownKeys:"strip",catchall:M.create(),typeName:m.ZodObject,...v(e)});class ne extends g{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function n(a){for(const i of a)if(i.result.status==="valid")return i.result;for(const i of a)if(i.result.status==="dirty")return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(i=>new S(i.ctx.common.issues));return l(t,{code:c.invalid_union,unionErrors:o}),y}if(t.common.async)return Promise.all(r.map(async a=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(n);{let a;const o=[];for(const d of r){const u={...t,common:{...t.common,issues:[]},parent:null},h=d._parseSync({data:t.data,path:t.path,parent:u});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const i=o.map(d=>new S(d));return l(t,{code:c.invalid_union,unionErrors:i}),y}}get options(){return this._def.options}}ne.create=(s,e)=>new ne({options:s,typeName:m.ZodUnion,...v(e)});const j=s=>s instanceof oe?j(s.schema):s instanceof I?j(s.innerType()):s instanceof ce?[s.value]:s instanceof V?s.options:s instanceof de?_.objectValues(s.enum):s instanceof ue?j(s._def.innerType):s instanceof se?[void 0]:s instanceof re?[null]:s instanceof A?[void 0,...j(s.unwrap())]:s instanceof U?[null,...j(s.unwrap())]:s instanceof Ie||s instanceof fe?j(s.unwrap()):s instanceof le?j(s._def.innerType):[];class ke extends g{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return l(t,{code:c.invalid_type,expected:f.object,received:t.parsedType}),y;const r=this.discriminator,n=t.data[r],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(l(t,{code:c.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const n=new Map;for(const a of t){const o=j(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const i of o){if(n.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);n.set(i,a)}}return new ke({typeName:m.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...v(r)})}}function Oe(s,e){const t=$(s),r=$(e);if(s===e)return{valid:!0,data:s};if(t===f.object&&r===f.object){const n=_.objectKeys(e),a=_.objectKeys(s).filter(i=>n.indexOf(i)!==-1),o={...s,...e};for(const i of a){const d=Oe(s[i],e[i]);if(!d.valid)return{valid:!1};o[i]=d.data}return{valid:!0,data:o}}else if(t===f.array&&r===f.array){if(s.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<s.length;a++){const o=s[a],i=e[a],d=Oe(o,i);if(!d.valid)return{valid:!1};n.push(d.data)}return{valid:!0,data:n}}else return t===f.date&&r===f.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class ae extends g{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=(a,o)=>{if(Ne(a)||Ne(o))return y;const i=Oe(a.value,o.value);return i.valid?((Ze(a)||Ze(o))&&t.dirty(),{status:t.value,value:i.data}):(l(r,{code:c.invalid_intersection_types}),y)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,o])=>n(a,o)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}ae.create=(s,e,t)=>new ae({left:s,right:e,typeName:m.ZodIntersection,...v(t)});class R extends g{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.array)return l(r,{code:c.invalid_type,expected:f.array,received:r.parsedType}),y;if(r.data.length<this._def.items.length)return l(r,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&r.data.length>this._def.items.length&&(l(r,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...r.data].map((o,i)=>{const d=this._def.items[i]||this._def.rest;return d?d._parse(new E(r,o,r.path,i)):null}).filter(o=>!!o);return r.common.async?Promise.all(a).then(o=>T.mergeArray(t,o)):T.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new R({...this._def,rest:e})}}R.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new R({items:s,typeName:m.ZodTuple,rest:null,...v(e)})};class ie extends g{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.object)return l(r,{code:c.invalid_type,expected:f.object,received:r.parsedType}),y;const n=[],a=this._def.keyType,o=this._def.valueType;for(const i in r.data)n.push({key:a._parse(new E(r,i,r.path,i)),value:o._parse(new E(r,r.data[i],r.path,i)),alwaysSet:i in r.data});return r.common.async?T.mergeObjectAsync(t,n):T.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof g?new ie({keyType:e,valueType:t,typeName:m.ZodRecord,...v(r)}):new ie({keyType:Z.create(),valueType:e,typeName:m.ZodRecord,...v(t)})}}class be extends g{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.map)return l(r,{code:c.invalid_type,expected:f.map,received:r.parsedType}),y;const n=this._def.keyType,a=this._def.valueType,o=[...r.data.entries()].map(([i,d],u)=>({key:n._parse(new E(r,i,r.path,[u,"key"])),value:a._parse(new E(r,d,r.path,[u,"value"]))}));if(r.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const d of o){const u=await d.key,h=await d.value;if(u.status==="aborted"||h.status==="aborted")return y;(u.status==="dirty"||h.status==="dirty")&&t.dirty(),i.set(u.value,h.value)}return{status:t.value,value:i}})}else{const i=new Map;for(const d of o){const u=d.key,h=d.value;if(u.status==="aborted"||h.status==="aborted")return y;(u.status==="dirty"||h.status==="dirty")&&t.dirty(),i.set(u.value,h.value)}return{status:t.value,value:i}}}}be.create=(s,e,t)=>new be({valueType:e,keyType:s,typeName:m.ZodMap,...v(t)});class F extends g{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==f.set)return l(r,{code:c.invalid_type,expected:f.set,received:r.parsedType}),y;const n=this._def;n.minSize!==null&&r.data.size<n.minSize.value&&(l(r,{code:c.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&r.data.size>n.maxSize.value&&(l(r,{code:c.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function o(d){const u=new Set;for(const h of d){if(h.status==="aborted")return y;h.status==="dirty"&&t.dirty(),u.add(h.value)}return{status:t.value,value:u}}const i=[...r.data.values()].map((d,u)=>a._parse(new E(r,d,r.path,u)));return r.common.async?Promise.all(i).then(d=>o(d)):o(i)}min(e,t){return new F({...this._def,minSize:{value:e,message:p.toString(t)}})}max(e,t){return new F({...this._def,maxSize:{value:e,message:p.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}F.create=(s,e)=>new F({valueType:s,minSize:null,maxSize:null,typeName:m.ZodSet,...v(e)});class K extends g{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return l(t,{code:c.invalid_type,expected:f.function,received:t.parsedType}),y;function r(i,d){return ve({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ye(),H].filter(u=>!!u),issueData:{code:c.invalid_arguments,argumentsError:d}})}function n(i,d){return ve({data:i,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ye(),H].filter(u=>!!u),issueData:{code:c.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof G){const i=this;return C(async function(...d){const u=new S([]),h=await i._def.args.parseAsync(d,a).catch(N=>{throw u.addIssue(r(d,N)),u}),x=await Reflect.apply(o,this,h);return await i._def.returns._def.type.parseAsync(x,a).catch(N=>{throw u.addIssue(n(x,N)),u})})}else{const i=this;return C(function(...d){const u=i._def.args.safeParse(d,a);if(!u.success)throw new S([r(d,u.error)]);const h=Reflect.apply(o,this,u.data),x=i._def.returns.safeParse(h,a);if(!x.success)throw new S([n(h,x.error)]);return x.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new K({...this._def,args:R.create(e).rest(L.create())})}returns(e){return new K({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new K({args:e||R.create([]).rest(L.create()),returns:t||L.create(),typeName:m.ZodFunction,...v(r)})}}class oe extends g{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}oe.create=(s,e)=>new oe({getter:s,typeName:m.ZodLazy,...v(e)});class ce extends g{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return l(t,{received:t.data,code:c.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}}ce.create=(s,e)=>new ce({value:s,typeName:m.ZodLiteral,...v(e)});function qe(s,e){return new V({values:s,typeName:m.ZodEnum,...v(e)})}class V extends g{constructor(){super(...arguments),Q.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return l(t,{expected:_.joinValues(r),received:t.parsedType,code:c.invalid_type}),y}if(ge(this,Q,"f")||Ue(this,Q,new Set(this._def.values),"f"),!ge(this,Q,"f").has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return l(t,{received:t.data,code:c.invalid_enum_value,options:r}),y}return C(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return V.create(e,{...this._def,...t})}exclude(e,t=this._def){return V.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}Q=new WeakMap;V.create=qe;class de extends g{constructor(){super(...arguments),X.set(this,void 0)}_parse(e){const t=_.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==f.string&&r.parsedType!==f.number){const n=_.objectValues(t);return l(r,{expected:_.joinValues(n),received:r.parsedType,code:c.invalid_type}),y}if(ge(this,X,"f")||Ue(this,X,new Set(_.getValidEnumValues(this._def.values)),"f"),!ge(this,X,"f").has(e.data)){const n=_.objectValues(t);return l(r,{received:r.data,code:c.invalid_enum_value,options:n}),y}return C(e.data)}get enum(){return this._def.values}}X=new WeakMap;de.create=(s,e)=>new de({values:s,typeName:m.ZodNativeEnum,...v(e)});class G extends g{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return l(t,{code:c.invalid_type,expected:f.promise,received:t.parsedType}),y;const r=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return C(r.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}G.create=(s,e)=>new G({type:s,typeName:m.ZodPromise,...v(e)});class I extends g{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===m.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:o=>{l(r,o),o.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const o=n.transform(r.data,a);if(r.common.async)return Promise.resolve(o).then(async i=>{if(t.value==="aborted")return y;const d=await this._def.schema._parseAsync({data:i,path:r.path,parent:r});return d.status==="aborted"?y:d.status==="dirty"||t.value==="dirty"?W(d.value):d});{if(t.value==="aborted")return y;const i=this._def.schema._parseSync({data:o,path:r.path,parent:r});return i.status==="aborted"?y:i.status==="dirty"||t.value==="dirty"?W(i.value):i}}if(n.type==="refinement"){const o=i=>{const d=n.refinement(i,a);if(r.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?y:(i.status==="dirty"&&t.dirty(),o(i.value),{status:t.value,value:i.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>i.status==="aborted"?y:(i.status==="dirty"&&t.dirty(),o(i.value).then(()=>({status:t.value,value:i.value}))))}if(n.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!B(o))return o;const i=n.transform(o.value,a);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>B(o)?Promise.resolve(n.transform(o.value,a)).then(i=>({status:t.value,value:i})):o);_.assertNever(n)}}I.create=(s,e,t)=>new I({schema:s,typeName:m.ZodEffects,effect:e,...v(t)});I.createWithPreprocess=(s,e,t)=>new I({schema:e,effect:{type:"preprocess",transform:s},typeName:m.ZodEffects,...v(t)});class A extends g{_parse(e){return this._getType(e)===f.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}A.create=(s,e)=>new A({innerType:s,typeName:m.ZodOptional,...v(e)});class U extends g{_parse(e){return this._getType(e)===f.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}U.create=(s,e)=>new U({innerType:s,typeName:m.ZodNullable,...v(e)});class ue extends g{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===f.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ue.create=(s,e)=>new ue({innerType:s,typeName:m.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...v(e)});class le extends g{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return ee(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new S(r.common.issues)},input:r.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new S(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}le.create=(s,e)=>new le({innerType:s,typeName:m.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...v(e)});class we extends g{_parse(e){if(this._getType(e)!==f.nan){const r=this._getOrReturnCtx(e);return l(r,{code:c.invalid_type,expected:f.nan,received:r.parsedType}),y}return{status:"valid",value:e.data}}}we.create=s=>new we({typeName:m.ZodNaN,...v(s)});const Jt=Symbol("zod_brand");class Ie extends g{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class he extends g{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?y:a.status==="dirty"?(t.dirty(),W(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const n=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return n.status==="aborted"?y:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:r.path,parent:r})}}static create(e,t){return new he({in:e,out:t,typeName:m.ZodPipeline})}}class fe extends g{_parse(e){const t=this._def.innerType._parse(e),r=n=>(B(n)&&(n.value=Object.freeze(n.value)),n);return ee(t)?t.then(n=>r(n)):r(t)}unwrap(){return this._def.innerType}}fe.create=(s,e)=>new fe({innerType:s,typeName:m.ZodReadonly,...v(e)});function Me(s,e){const t=typeof s=="function"?s(e):typeof s=="string"?{message:s}:s;return typeof t=="string"?{message:t}:t}function Fe(s,e={},t){return s?Y.create().superRefine((r,n)=>{var a,o;const i=s(r);if(i instanceof Promise)return i.then(d=>{var u,h;if(!d){const x=Me(e,r),k=(h=(u=x.fatal)!==null&&u!==void 0?u:t)!==null&&h!==void 0?h:!0;n.addIssue({code:"custom",...x,fatal:k})}});if(!i){const d=Me(e,r),u=(o=(a=d.fatal)!==null&&a!==void 0?a:t)!==null&&o!==void 0?o:!0;n.addIssue({code:"custom",...d,fatal:u})}}):Y.create()}const Wt={object:w.lazycreate};var m;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(m||(m={}));const Kt=(s,e={message:`Input not instance of ${s.name}`})=>Fe(t=>t instanceof s,e),Je=Z.create,We=P.create,Ht=we.create,Yt=D.create,Ke=te.create,Gt=q.create,Qt=_e.create,Xt=se.create,es=re.create,ts=Y.create,ss=L.create,rs=M.create,ns=xe.create,as=O.create,is=w.create,os=w.strictCreate,cs=ne.create,ds=ke.create,us=ae.create,ls=R.create,fs=ie.create,hs=be.create,ps=F.create,ms=K.create,ys=oe.create,vs=ce.create,gs=V.create,_s=de.create,xs=G.create,Pe=I.create,bs=A.create,ws=U.create,ks=I.createWithPreprocess,Ts=he.create,Cs=()=>Je().optional(),Ss=()=>We().optional(),Ns=()=>Ke().optional(),Zs={string:s=>Z.create({...s,coerce:!0}),number:s=>P.create({...s,coerce:!0}),boolean:s=>te.create({...s,coerce:!0}),bigint:s=>D.create({...s,coerce:!0}),date:s=>q.create({...s,coerce:!0})},Os=y;var b=Object.freeze({__proto__:null,defaultErrorMap:H,setErrorMap:kt,getErrorMap:ye,makeIssue:ve,EMPTY_PATH:Tt,addIssueToContext:l,ParseStatus:T,INVALID:y,DIRTY:W,OK:C,isAborted:Ne,isDirty:Ze,isValid:B,isAsync:ee,get util(){return _},get objectUtil(){return Se},ZodParsedType:f,getParsedType:$,ZodType:g,datetimeRegex:Be,ZodString:Z,ZodNumber:P,ZodBigInt:D,ZodBoolean:te,ZodDate:q,ZodSymbol:_e,ZodUndefined:se,ZodNull:re,ZodAny:Y,ZodUnknown:L,ZodNever:M,ZodVoid:xe,ZodArray:O,ZodObject:w,ZodUnion:ne,ZodDiscriminatedUnion:ke,ZodIntersection:ae,ZodTuple:R,ZodRecord:ie,ZodMap:be,ZodSet:F,ZodFunction:K,ZodLazy:oe,ZodLiteral:ce,ZodEnum:V,ZodNativeEnum:de,ZodPromise:G,ZodEffects:I,ZodTransformer:I,ZodOptional:A,ZodNullable:U,ZodDefault:ue,ZodCatch:le,ZodNaN:we,BRAND:Jt,ZodBranded:Ie,ZodPipeline:he,ZodReadonly:fe,custom:Fe,Schema:g,ZodSchema:g,late:Wt,get ZodFirstPartyTypeKind(){return m},coerce:Zs,any:ts,array:as,bigint:Yt,boolean:Ke,date:Gt,discriminatedUnion:ds,effect:Pe,enum:gs,function:ms,instanceof:Kt,intersection:us,lazy:ys,literal:vs,map:hs,nan:Ht,nativeEnum:_s,never:rs,null:es,nullable:ws,number:We,object:is,oboolean:Ns,onumber:Ss,optional:bs,ostring:Cs,pipeline:Ts,preprocess:ks,promise:xs,record:fs,set:ps,strictObject:os,string:Je,symbol:Qt,transformer:Pe,tuple:ls,undefined:Xt,union:cs,unknown:ss,void:ns,NEVER:Os,ZodIssueCode:c,quotelessJson:wt,ZodError:S});const Is=b.object({type:b.enum(["sqlite","postgresql","mysql"]).default("sqlite"),connection:b.object({url:b.string().default("./zaileys.db")}).optional().default({})}).optional().default({}),He={prefix:b.string().optional(),ignoreMe:b.boolean().optional().default(!0),showLogs:b.boolean().optional().default(!0),autoMentions:b.boolean().optional().default(!0),autoOnline:b.boolean().optional().default(!0),autoRead:b.boolean().optional().default(!0),autoRejectCall:b.boolean().optional().default(!0),database:Is,citation:b.record(b.function().returns(b.union([b.number().array(),b.promise(b.number().array())]))).optional().transform(async s=>{const e={};if(s)for(const t of Object.keys(s)){const r=`is${t.charAt(0).toUpperCase()+t.slice(1)}`,n=await s[t]();e[r]=n}return e})},As=b.object({authType:b.literal("pairing"),phoneNumber:b.number(),...He}),Es=b.object({authType:b.literal("qr"),phoneNumber:b.undefined().optional(),...He}),Rs=b.discriminatedUnion("authType",[As,Es]);class js{client;events=new Map;constructor(e){this.client=e}setup(e){e.ev.on("connection.update",async t=>{const{connection:r,lastDisconnect:n,qr:a}=t;if(this.emit("connection",{status:r||"connecting"}),this.client.options?.authType=="qr"&&a&&console.log("Scan qrcode with your whatsapp: "),r==="close"){const o=n?.error?.output?.statusCode,i=o!==Ge.loggedOut;if(console.log(n?.error?.message),o==401||o==405||o==500)return;i&&await this.client.initialize()}else r==="open"&&this.emit("connection",{status:"open"})}),e.ev.on("messages.upsert",({messages:t})=>{this.emit("messages",t)}),e.ev.on("call",t=>{this.emit("call",t)})}on(e,t){this.events.has(e)||this.events.set(e,[]),this.events.get(e).push(t)}emit(e,t){(this.events.get(e)||[]).forEach(r=>r(t))}}class Ws{props;options;chatId="zaileys-chats";logger=et({level:"silent",enabled:!1});event;db;socket;groupCache=new Ae({stdTTL:5*60,useClones:!1});constructor(e){this.props=e,this.initialize(),this.event=new js(this)}async initialize(){this.options=await Rs.parseAsync(this.props),this.db=gt(this.options.database.type,this.options.database.connection.url);const{state:e,saveCreds:t,removeCreds:r}=await xt(this.db,this.chatId),n=await bt(this.db,this.chatId);this.socket=Ye({logger:this.logger,markOnlineOnConnect:this.options.autoOnline,syncFullHistory:!1,defaultQueryTimeoutMs:void 0,msgRetryCounterCache:new Ae,cachedGroupMetadata:async a=>this.groupCache.get(a),printQRInTerminal:this.options.authType=="qr",browser:Qe.ubuntu(this.options.authType=="qr"?"Zaileys Library":"Firefox"),auth:{creds:e.creds,keys:Xe(e.keys,this.logger)}}),this.options.authType=="pairing"&&this.options.phoneNumber&&!this.socket?.authState.creds.registered&&setTimeout(async()=>{try{if(this.options?.authType=="pairing"){const a=await this.socket?.requestPairingCode(this.options.phoneNumber.toString());console.log("\u{1F680} ~ Client.ts:53 ~ Client ~ setTimeout ~ code:",a)}}catch{console.log("Connection failed"),process.exit(1)}},5e3),this.socket?.ev.on("creds.update",t),n.bind(this.socket?.ev),this.event.setup(this.socket)}on(e,t){this.event.on(e,t)}}export{Ws as default};
|
|
2
|
-
//# sourceMappingURL=index.esm.js.map
|