zaileys 0.29.8-beta → 0.29.10-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.
@@ -0,0 +1,17 @@
1
+ import { z } from "zod";
2
+ import { ClientClassesType } from "../types/classes/client";
3
+ import { EventCallbackType, EventEnumType } from "../types/classes/event";
4
+ declare class Client {
5
+ private props;
6
+ options: z.infer<typeof ClientClassesType> | undefined;
7
+ private chatId;
8
+ private logger;
9
+ private event;
10
+ private db;
11
+ private socket;
12
+ private groupCache;
13
+ constructor(props: z.input<typeof ClientClassesType>);
14
+ initialize(): Promise<void>;
15
+ on<T extends EventEnumType>(event: T, handler: EventCallbackType[T]): void;
16
+ }
17
+ export default Client;
@@ -0,0 +1,12 @@
1
+ import { WASocket } from "baileys";
2
+ import { EventCallbackType, EventEnumType } from "../types/classes/event";
3
+ import Client from "./Client";
4
+ declare class Event {
5
+ private client;
6
+ private events;
7
+ constructor(client: Client);
8
+ setup(sock: WASocket): void;
9
+ on<T extends EventEnumType>(event: T, handler: EventCallbackType[T]): void;
10
+ private emit;
11
+ }
12
+ export default Event;
@@ -0,0 +1,3 @@
1
+ export default class Parser {
2
+ constructor();
3
+ }
@@ -0,0 +1,12 @@
1
+ import { Kysely } from "kysely";
2
+ import { z } from "zod";
3
+ import { AuthAdapterHandlerType } from "../types/adapter/general";
4
+ import { AdapterDatabaseType } from "../types/classes/client";
5
+ import type { DB } from "./schema";
6
+ import { BaileysEventEmitter } from "baileys";
7
+ export declare const ConnectDB: (type: z.infer<typeof AdapterDatabaseType>["type"], url: string) => Kysely<DB>;
8
+ export declare const MigrateDB: (db: Kysely<DB>) => Promise<void>;
9
+ export declare const AuthAdapterHandler: (db: Kysely<DB>, session: string) => AuthAdapterHandlerType;
10
+ export declare const StoreAdapterHandler: (db: Kysely<DB>, session: string) => Promise<{
11
+ bind: (event: BaileysEventEmitter) => void;
12
+ }>;
@@ -0,0 +1,63 @@
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
+ };
@@ -0,0 +1,57 @@
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
+ };
@@ -0,0 +1,8 @@
1
+ import { ZodError } from "zod";
2
+ export declare const handleZodError: (error: ZodError) => {
3
+ status: string;
4
+ errors: {
5
+ field: string;
6
+ message: string;
7
+ }[];
8
+ };
@@ -0,0 +1 @@
1
+ "use strict";var e=require("baileys"),t=require("node-cache"),s=require("pino"),a=require("better-sqlite3"),n=require("fs"),r=require("kysely"),i=require("mysql2"),o=require("path"),d=require("pg"),c=require("url"),u=require("crypto");const l=require("libsignal").curve,h=()=>{const{pubKey:e,privKey:t}=l.generateKeyPair();return{private:Buffer.from(t),public:Buffer.from(e.slice(1))}},p=(e,t)=>{const s=h(),a=(e=>33===e.length?e:Buffer.concat([Buffer.from([5]),e]))(s.public),n=((e,t)=>l.calculateSignature(e,t))(e.private,a);return{keyPair:s,signature:n,keyId:t}},m=e=>"string"==typeof e?parseInt(e,10):e,f=e=>{const t={...e.fingerprint,deviceIndexes:Array.isArray(e.fingerprint.deviceIndexes)?e.fingerprint.deviceIndexes:[]},s={keyData:Array.isArray(e.keyData)?e.keyData:new Uint8Array,fingerprint:{rawId:t.rawId||0,currentIndex:t.rawId||0,deviceIndexes:t.deviceIndexes},timestamp:m(e.timestamp)};return"string"==typeof e.keyData&&(s.keyData=(e=>{let t=e.length;if(!t)return new Uint8Array(1);let s=0;for(;--t%4>1&&"="===e.charAt(t);)++s;return new Uint8Array(Math.ceil(3*e.length)/4-s).fill(0)})(e.keyData)),s},y=(e,t)=>"Buffer"===t?.type&&Array.isArray(t?.data)?{type:"Buffer",data:Buffer.from(t?.data).toString("base64")}:t,g=(e,t)=>"Buffer"===t?.type?Buffer.from(t?.data,"base64"):t,v=async(e,t)=>{const s="auth";await(async e=>{await e.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 e.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 e.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 e.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 e.schema.createIndex("auth_session_idx").ifNotExists().on("auth").column("session").execute(),await e.schema.createIndex("auth_id_idx").ifNotExists().on("auth").column("id").execute(),await e.schema.createIndex("chats_session_idx").ifNotExists().on("chats").column("session").execute(),await e.schema.createIndex("chats_id_idx").ifNotExists().on("chats").column("id").execute(),await e.schema.createIndex("contacts_session_idx").ifNotExists().on("contacts").column("session").execute(),await e.schema.createIndex("contacts_id_idx").ifNotExists().on("contacts").column("id").execute(),await e.schema.createIndex("messages_session_idx").ifNotExists().on("messages").column("session").execute(),await e.schema.createIndex("messages_id_idx").ifNotExists().on("messages").column("id").execute()})(e);const a=async e=>{for(let t=0;t<10;t++)try{return await e()}catch{await new Promise((e=>setTimeout(e,200)))}throw new Error("Max retries reached")},n=async n=>{const r=await a((()=>e.selectFrom(s).select(["value"]).where("id","=",n).where("session","=",t).executeTakeFirst()));if(!r?.value)return null;const i="object"==typeof r.value?JSON.stringify(r.value):r.value;return JSON.parse(i,g)},r=async(n,r)=>{const i=JSON.stringify(r,y);await a((()=>e.insertInto(s).values({session:t,id:n,value:i}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:i}))).execute()))},i=async n=>{await a((()=>e.deleteFrom(s).where("id","=",n).where("session","=",t).execute()))},o=await n("creds")||(()=>{const e=h();return{noiseKey:h(),pairingEphemeralKeyPair:h(),signedIdentityKey:e,signedPreKey:p(e,1),registrationId:16383&Uint16Array.from(u.randomBytes(2))[0],advSecretKey:u.randomBytes(32).toString("base64"),processedHistoryMessages:[],nextPreKeyId:1,firstUnuploadedPreKeyId:1,accountSyncCounter:0,accountSettings:{unarchiveChats:!1},deviceId:Buffer.from(u.randomUUID().replace(/-/g,""),"hex").toString("base64url"),phoneId:u.randomUUID(),identityId:u.randomBytes(20),backupToken:u.randomBytes(20),registered:!1,registration:{},pairingCode:void 0,lastPropHash:void 0,routingInfo:void 0}})();return{state:{creds:o,keys:{get:async(e,t)=>{const s={};for(const a of t){let t=await n(`${e}-${a}`);"app-state-sync-key"===e&&t&&(t=f(t)),s[a]=t}return s},set:async e=>{for(const t in e)for(const s in e[t]){const a=e[t][s],n=`${t}-${s}`;a?await r(n,a):await i(n)}}}},saveCreds:async()=>{await r("creds",o)},clear:async()=>{await(async()=>{await a((()=>e.deleteFrom(s).where("session","=",t).where("id","!=","creds").execute()))})()},removeCreds:async()=>{await(async()=>{await a((()=>e.deleteFrom(s).where("session","=",t).execute()))})()}}};var _,x,b;(x=_||(_={})).assertEqual=e=>e,x.assertIs=function(e){},x.assertNever=function(e){throw new Error},x.arrayToEnum=e=>{const t={};for(const s of e)t[s]=s;return t},x.getValidEnumValues=e=>{const t=x.objectKeys(e).filter((t=>"number"!=typeof e[e[t]])),s={};for(const a of t)s[a]=e[a];return x.objectValues(s)},x.objectValues=e=>x.objectKeys(e).map((function(t){return e[t]})),x.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.push(s);return t},x.find=(e,t)=>{for(const s of e)if(t(s))return s},x.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,x.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},x.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t,(b||(b={})).mergeShapes=(e,t)=>({...e,...t});const k=_.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),w=e=>{switch(typeof e){case"undefined":return k.undefined;case"string":return k.string;case"number":return isNaN(e)?k.nan:k.number;case"boolean":return k.boolean;case"function":return k.function;case"bigint":return k.bigint;case"symbol":return k.symbol;case"object":return Array.isArray(e)?k.array:null===e?k.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?k.promise:typeof Map<"u"&&e instanceof Map?k.map:typeof Set<"u"&&e instanceof Set?k.set:typeof Date<"u"&&e instanceof Date?k.date:k.object;default:return k.unknown}},Z=_.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"]);class T extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};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(e){return e.message},s={_errors:[]},a=e=>{for(const n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(a);else if("invalid_return_type"===n.code)a(n.returnTypeError);else if("invalid_arguments"===n.code)a(n.argumentsError);else if(0===n.path.length)s._errors.push(t(n));else{let e=s,a=0;for(;a<n.path.length;){const s=n.path[a];a===n.path.length-1?(e[s]=e[s]||{_errors:[]},e[s]._errors.push(t(n))):e[s]=e[s]||{_errors:[]},e=e[s],a++}}};return a(this),s}static assert(e){if(!(e instanceof T))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,_.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},s=[];for(const a of this.issues)a.path.length>0?(t[a.path[0]]=t[a.path[0]]||[],t[a.path[0]].push(e(a))):s.push(e(a));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}T.create=e=>new T(e);const C=(e,t)=>{let s;switch(e.code){case Z.invalid_type:s=e.received===k.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case Z.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(e.expected,_.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:s=`Unrecognized key(s) in object: ${_.joinValues(e.keys,", ")}`;break;case Z.invalid_union:s="Invalid input";break;case Z.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${_.joinValues(e.options)}`;break;case Z.invalid_enum_value:s=`Invalid enum value. Expected ${_.joinValues(e.options)}, received '${e.received}'`;break;case Z.invalid_arguments:s="Invalid function arguments";break;case Z.invalid_return_type:s="Invalid function return type";break;case Z.invalid_date:s="Invalid date";break;case Z.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(s=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(s=`${s} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?s=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?s=`Invalid input: must end with "${e.validation.endsWith}"`:_.assertNever(e.validation):s="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case Z.too_small:s="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case Z.too_big:s="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case Z.custom:s="Invalid input";break;case Z.invalid_intersection_types:s="Intersection results could not be merged";break;case Z.not_multiple_of:s=`Number must be a multiple of ${e.multipleOf}`;break;case Z.not_finite:s="Number must be finite";break;default:s=t.defaultError,_.assertNever(e)}return{message:s}};let N=C;function O(){return N}const S=e=>{const{data:t,path:s,errorMaps:a,issueData:n}=e,r=[...s,...n.path||[]],i={...n,path:r};if(void 0!==n.message)return{...n,path:r,message:n.message};let o="";const d=a.filter((e=>!!e)).slice().reverse();for(const e of d)o=e(i,{data:t,defaultError:o}).message;return{...n,path:r,message:o}};function I(e,t){const s=O(),a=S({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,s,s===C?void 0:C].filter((e=>!!e))});e.common.issues.push(a)}class A{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const a of t){if("aborted"===a.status)return E;"dirty"===a.status&&e.dirty(),s.push(a.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const e of t){const t=await e.key,a=await e.value;s.push({key:t,value:a})}return A.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const a of t){const{key:t,value:n}=a;if("aborted"===t.status||"aborted"===n.status)return E;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"!==t.value&&(typeof n.value<"u"||a.alwaysSet)&&(s[t.value]=n.value)}return{status:e.value,value:s}}}const E=Object.freeze({status:"aborted"}),j=e=>({status:"dirty",value:e}),P=e=>({status:"valid",value:e}),R=e=>"aborted"===e.status,$=e=>"dirty"===e.status,M=e=>"valid"===e.status,F=e=>typeof Promise<"u"&&e instanceof Promise;function D(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)}function U(e,t,s,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,s):n?n.value=s:t.set(e,s),s}var L,q,z;"function"==typeof SuppressedError&&SuppressedError,function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(L||(L={}));class K{constructor(e,t,s,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,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 V=(e,t)=>{if(M(t))return{success:!0,data:t.value};if(!e.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 T(e.common.issues);return this._error=t,this._error}}};function B(e){if(!e)return{};const{errorMap:t,invalid_type_error:s,required_error:a,description:n}=e;if(t&&(s||a))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:n}:{errorMap:(t,n)=>{var r,i;const{message:o}=e;return"invalid_enum_value"===t.code?{message:o??n.defaultError}:typeof n.data>"u"?{message:null!==(r=o??a)&&void 0!==r?r:n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:null!==(i=o??s)&&void 0!==i?i:n.defaultError}},description:n}}class J{get description(){return this._def.description}_getType(e){return w(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:w(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new A,ctx:{common:e.parent.common,data:e.data,parsedType:w(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(F(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const a={common:{issues:[],async:null!==(s=t?.async)&&void 0!==s&&s,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:w(e)},n=this._parseSync({data:e,path:a.path,parent:a});return V(a,n)}"~validate"(e){var t,s;const a={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:w(e)};if(!this["~standard"].async)try{const t=this._parseSync({data:e,path:[],parent:a});return M(t)?{value:t.value}:{issues:a.common.issues}}catch(e){!(null===(s=null===(t=e?.message)||void 0===t?void 0:t.toLowerCase())||void 0===s)&&s.includes("encountered")&&(this["~standard"].async=!0),a.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:a}).then((e=>M(e)?{value:e.value}:{issues:a.common.issues}))}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:w(e)},a=this._parse({data:e,path:s.path,parent:s}),n=await(F(a)?a:Promise.resolve(a));return V(s,n)}refine(e,t){const s=e=>"string"==typeof t||typeof t>"u"?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,a)=>{const n=e(t),r=()=>a.addIssue({code:Z.custom,...s(t)});return typeof Promise<"u"&&n instanceof Promise?n.then((e=>!!e||(r(),!1))):!!n||(r(),!1)}))}refinement(e,t){return this._refinement(((s,a)=>!!e(s)||(a.addIssue("function"==typeof t?t(s,a):t),!1)))}_refinement(e){return new He({schema:this,typeName:dt.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:e=>this["~validate"](e)}}optional(){return Ye.create(this,this._def)}nullable(){return Ge.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ie.create(this)}promise(){return We.create(this,this._def)}or(e){return je.create([this,e],this._def)}and(e){return Me.create(this,e,this._def)}transform(e){return new He({...B(this._def),schema:this,typeName:dt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Qe({...B(this._def),innerType:this,defaultValue:t,typeName:dt.ZodDefault})}brand(){return new st({typeName:dt.ZodBranded,type:this,...B(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Xe({...B(this._def),innerType:this,catchValue:t,typeName:dt.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return at.create(this,e)}readonly(){return nt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const W=/^c[^\s-]{8,}$/i,H=/^[0-9a-z]+$/,Y=/^[0-9A-HJKMNP-TV-Z]{26}$/i,G=/^[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,Q=/^[a-z0-9_-]{21}$/i,X=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ee=/^[-+]?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)?)??$/,te=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let se;const ae=/^(?:(?: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])$/,ne=/^(?:(?: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])$/,re=/^(([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]))$/,ie=/^(([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])$/,oe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,de=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ce="((\\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])))",ue=new RegExp(`^${ce}$`);function le(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function he(e){return new RegExp(`^${le(e)}$`)}function pe(e){let t=`${ce}T${le(e)}`;const s=[];return s.push(e.local?"Z?":"Z"),e.offset&&s.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${s.join("|")})`,new RegExp(`^${t}$`)}function me(e,t){return!(("v4"!==t&&t||!ae.test(e))&&("v6"!==t&&t||!re.test(e)))}function fe(e,t){if(!X.test(e))return!1;try{const[s]=e.split("."),a=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),n=JSON.parse(atob(a));return!("object"!=typeof n||null===n||!n.typ||!n.alg||t&&n.alg!==t)}catch{return!1}}function ye(e,t){return!(("v4"!==t&&t||!ne.test(e))&&("v6"!==t&&t||!ie.test(e)))}class ge extends J{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==k.string){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.string,received:t.parsedType}),E}const t=new A;let s;for(const a of this._def.checks)if("min"===a.kind)e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),I(s,{code:Z.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),t.dirty());else if("max"===a.kind)e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),I(s,{code:Z.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),t.dirty());else if("length"===a.kind){const n=e.data.length>a.value,r=e.data.length<a.value;(n||r)&&(s=this._getOrReturnCtx(e,s),n?I(s,{code:Z.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):r&&I(s,{code:Z.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),t.dirty())}else if("email"===a.kind)te.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"email",code:Z.invalid_string,message:a.message}),t.dirty());else if("emoji"===a.kind)se||(se=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),se.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"emoji",code:Z.invalid_string,message:a.message}),t.dirty());else if("uuid"===a.kind)G.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"uuid",code:Z.invalid_string,message:a.message}),t.dirty());else if("nanoid"===a.kind)Q.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"nanoid",code:Z.invalid_string,message:a.message}),t.dirty());else if("cuid"===a.kind)W.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"cuid",code:Z.invalid_string,message:a.message}),t.dirty());else if("cuid2"===a.kind)H.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"cuid2",code:Z.invalid_string,message:a.message}),t.dirty());else if("ulid"===a.kind)Y.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"ulid",code:Z.invalid_string,message:a.message}),t.dirty());else if("url"===a.kind)try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),I(s,{validation:"url",code:Z.invalid_string,message:a.message}),t.dirty()}else"regex"===a.kind?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"regex",code:Z.invalid_string,message:a.message}),t.dirty())):"trim"===a.kind?e.data=e.data.trim():"includes"===a.kind?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),I(s,{code:Z.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),t.dirty()):"toLowerCase"===a.kind?e.data=e.data.toLowerCase():"toUpperCase"===a.kind?e.data=e.data.toUpperCase():"startsWith"===a.kind?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),I(s,{code:Z.invalid_string,validation:{startsWith:a.value},message:a.message}),t.dirty()):"endsWith"===a.kind?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),I(s,{code:Z.invalid_string,validation:{endsWith:a.value},message:a.message}),t.dirty()):"datetime"===a.kind?pe(a).test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{code:Z.invalid_string,validation:"datetime",message:a.message}),t.dirty()):"date"===a.kind?ue.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{code:Z.invalid_string,validation:"date",message:a.message}),t.dirty()):"time"===a.kind?he(a).test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{code:Z.invalid_string,validation:"time",message:a.message}),t.dirty()):"duration"===a.kind?ee.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"duration",code:Z.invalid_string,message:a.message}),t.dirty()):"ip"===a.kind?me(e.data,a.version)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"ip",code:Z.invalid_string,message:a.message}),t.dirty()):"jwt"===a.kind?fe(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"jwt",code:Z.invalid_string,message:a.message}),t.dirty()):"cidr"===a.kind?ye(e.data,a.version)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"cidr",code:Z.invalid_string,message:a.message}),t.dirty()):"base64"===a.kind?oe.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"base64",code:Z.invalid_string,message:a.message}),t.dirty()):"base64url"===a.kind?de.test(e.data)||(s=this._getOrReturnCtx(e,s),I(s,{validation:"base64url",code:Z.invalid_string,message:a.message}),t.dirty()):_.assertNever(a);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement((t=>e.test(t)),{validation:t,code:Z.invalid_string,...L.errToObj(s)})}_addCheck(e){return new ge({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...L.errToObj(e)})}url(e){return this._addCheck({kind:"url",...L.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...L.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...L.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...L.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...L.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...L.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...L.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...L.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...L.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...L.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...L.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...L.errToObj(e)})}datetime(e){var t,s;return"string"==typeof e?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:null!==(t=e?.offset)&&void 0!==t&&t,local:null!==(s=e?.local)&&void 0!==s&&s,...L.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...L.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...L.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...L.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...L.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...L.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...L.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...L.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...L.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...L.errToObj(t)})}nonempty(e){return this.min(1,L.errToObj(e))}trim(){return new ge({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ge({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ge({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isDate(){return!!this._def.checks.find((e=>"date"===e.kind))}get isTime(){return!!this._def.checks.find((e=>"time"===e.kind))}get isDuration(){return!!this._def.checks.find((e=>"duration"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isNANOID(){return!!this._def.checks.find((e=>"nanoid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get isCIDR(){return!!this._def.checks.find((e=>"cidr"===e.kind))}get isBase64(){return!!this._def.checks.find((e=>"base64"===e.kind))}get isBase64url(){return!!this._def.checks.find((e=>"base64url"===e.kind))}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function ve(e,t){const s=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,n=s>a?s:a;return parseInt(e.toFixed(n).replace(".",""))%parseInt(t.toFixed(n).replace(".",""))/Math.pow(10,n)}ge.create=e=>{var t;return new ge({checks:[],typeName:dt.ZodString,coerce:null!==(t=e?.coerce)&&void 0!==t&&t,...B(e)})};class _e 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)!==k.number){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.number,received:t.parsedType}),E}let t;const s=new A;for(const a of this._def.checks)"int"===a.kind?_.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),I(t,{code:Z.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):"min"===a.kind?(a.inclusive?e.data<a.value:e.data<=a.value)&&(t=this._getOrReturnCtx(e,t),I(t,{code:Z.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):"max"===a.kind?(a.inclusive?e.data>a.value:e.data>=a.value)&&(t=this._getOrReturnCtx(e,t),I(t,{code:Z.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):"multipleOf"===a.kind?0!==ve(e.data,a.value)&&(t=this._getOrReturnCtx(e,t),I(t,{code:Z.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):"finite"===a.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),I(t,{code:Z.not_finite,message:a.message}),s.dirty()):_.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,L.toString(t))}gt(e,t){return this.setLimit("min",e,!1,L.toString(t))}lte(e,t){return this.setLimit("max",e,!0,L.toString(t))}lt(e,t){return this.setLimit("max",e,!1,L.toString(t))}setLimit(e,t,s,a){return new _e({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:L.toString(a)}]})}_addCheck(e){return new _e({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:L.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:L.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:L.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:L.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:L.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:L.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:L.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:L.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:L.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((e=>"int"===e.kind||"multipleOf"===e.kind&&_.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if("finite"===s.kind||"int"===s.kind||"multipleOf"===s.kind)return!0;"min"===s.kind?(null===t||s.value>t)&&(t=s.value):"max"===s.kind&&(null===e||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}_e.create=e=>new _e({checks:[],typeName:dt.ZodNumber,coerce:e?.coerce||!1,...B(e)});class xe extends J{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)!==k.bigint)return this._getInvalidInput(e);let t;const s=new A;for(const a of this._def.checks)"min"===a.kind?(a.inclusive?e.data<a.value:e.data<=a.value)&&(t=this._getOrReturnCtx(e,t),I(t,{code:Z.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):"max"===a.kind?(a.inclusive?e.data>a.value:e.data>=a.value)&&(t=this._getOrReturnCtx(e,t),I(t,{code:Z.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):"multipleOf"===a.kind?e.data%a.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),I(t,{code:Z.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):_.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.bigint,received:t.parsedType}),E}gte(e,t){return this.setLimit("min",e,!0,L.toString(t))}gt(e,t){return this.setLimit("min",e,!1,L.toString(t))}lte(e,t){return this.setLimit("max",e,!0,L.toString(t))}lt(e,t){return this.setLimit("max",e,!1,L.toString(t))}setLimit(e,t,s,a){return new xe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:L.toString(a)}]})}_addCheck(e){return new xe({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:L.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:L.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:L.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:L.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:L.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}xe.create=e=>{var t;return new xe({checks:[],typeName:dt.ZodBigInt,coerce:null!==(t=e?.coerce)&&void 0!==t&&t,...B(e)})};class be extends J{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==k.boolean){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.boolean,received:t.parsedType}),E}return P(e.data)}}be.create=e=>new be({typeName:dt.ZodBoolean,coerce:e?.coerce||!1,...B(e)});class ke extends J{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==k.date){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.date,received:t.parsedType}),E}if(isNaN(e.data.getTime())){return I(this._getOrReturnCtx(e),{code:Z.invalid_date}),E}const t=new A;let s;for(const a of this._def.checks)"min"===a.kind?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),I(s,{code:Z.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),t.dirty()):"max"===a.kind?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),I(s,{code:Z.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),t.dirty()):_.assertNever(a);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ke({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:L.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:L.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}ke.create=e=>new ke({checks:[],coerce:e?.coerce||!1,typeName:dt.ZodDate,...B(e)});class we extends J{_parse(e){if(this._getType(e)!==k.symbol){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.symbol,received:t.parsedType}),E}return P(e.data)}}we.create=e=>new we({typeName:dt.ZodSymbol,...B(e)});class Ze extends J{_parse(e){if(this._getType(e)!==k.undefined){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.undefined,received:t.parsedType}),E}return P(e.data)}}Ze.create=e=>new Ze({typeName:dt.ZodUndefined,...B(e)});class Te extends J{_parse(e){if(this._getType(e)!==k.null){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.null,received:t.parsedType}),E}return P(e.data)}}Te.create=e=>new Te({typeName:dt.ZodNull,...B(e)});class Ce extends J{constructor(){super(...arguments),this._any=!0}_parse(e){return P(e.data)}}Ce.create=e=>new Ce({typeName:dt.ZodAny,...B(e)});class Ne extends J{constructor(){super(...arguments),this._unknown=!0}_parse(e){return P(e.data)}}Ne.create=e=>new Ne({typeName:dt.ZodUnknown,...B(e)});class Oe extends J{_parse(e){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.never,received:t.parsedType}),E}}Oe.create=e=>new Oe({typeName:dt.ZodNever,...B(e)});class Se extends J{_parse(e){if(this._getType(e)!==k.undefined){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.void,received:t.parsedType}),E}return P(e.data)}}Se.create=e=>new Se({typeName:dt.ZodVoid,...B(e)});class Ie extends J{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),a=this._def;if(t.parsedType!==k.array)return I(t,{code:Z.invalid_type,expected:k.array,received:t.parsedType}),E;if(null!==a.exactLength){const e=t.data.length>a.exactLength.value,n=t.data.length<a.exactLength.value;(e||n)&&(I(t,{code:e?Z.too_big:Z.too_small,minimum:n?a.exactLength.value:void 0,maximum:e?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),s.dirty())}if(null!==a.minLength&&t.data.length<a.minLength.value&&(I(t,{code:Z.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),s.dirty()),null!==a.maxLength&&t.data.length>a.maxLength.value&&(I(t,{code:Z.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map(((e,s)=>a.type._parseAsync(new K(t,e,t.path,s))))).then((e=>A.mergeArray(s,e)));const n=[...t.data].map(((e,s)=>a.type._parseSync(new K(t,e,t.path,s))));return A.mergeArray(s,n)}get element(){return this._def.type}min(e,t){return new Ie({...this._def,minLength:{value:e,message:L.toString(t)}})}max(e,t){return new Ie({...this._def,maxLength:{value:e,message:L.toString(t)}})}length(e,t){return new Ie({...this._def,exactLength:{value:e,message:L.toString(t)}})}nonempty(e){return this.min(1,e)}}function Ae(e){if(e instanceof Ee){const t={};for(const s in e.shape){const a=e.shape[s];t[s]=Ye.create(Ae(a))}return new Ee({...e._def,shape:()=>t})}return e instanceof Ie?new Ie({...e._def,type:Ae(e.element)}):e instanceof Ye?Ye.create(Ae(e.unwrap())):e instanceof Ge?Ge.create(Ae(e.unwrap())):e instanceof Fe?Fe.create(e.items.map((e=>Ae(e)))):e}Ie.create=(e,t)=>new Ie({type:e,minLength:null,maxLength:null,exactLength:null,typeName:dt.ZodArray,...B(t)});class Ee extends J{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=_.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==k.object){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.object,received:t.parsedType}),E}const{status:t,ctx:s}=this._processInputParams(e),{shape:a,keys:n}=this._getCached(),r=[];if(!(this._def.catchall instanceof Oe&&"strip"===this._def.unknownKeys))for(const e in s.data)n.includes(e)||r.push(e);const i=[];for(const e of n){const t=a[e],n=s.data[e];i.push({key:{status:"valid",value:e},value:t._parse(new K(s,n,s.path,e)),alwaysSet:e in s.data})}if(this._def.catchall instanceof Oe){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of r)i.push({key:{status:"valid",value:e},value:{status:"valid",value:s.data[e]}});else if("strict"===e)r.length>0&&(I(s,{code:Z.unrecognized_keys,keys:r}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of r){const a=s.data[t];i.push({key:{status:"valid",value:t},value:e._parse(new K(s,a,s.path,t)),alwaysSet:t in s.data})}}return s.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of i){const s=await t.key,a=await t.value;e.push({key:s,value:a,alwaysSet:t.alwaysSet})}return e})).then((e=>A.mergeObjectSync(t,e))):A.mergeObjectSync(t,i)}get shape(){return this._def.shape()}strict(e){return new Ee({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,s)=>{var a,n,r,i;const o=null!==(r=null===(n=(a=this._def).errorMap)||void 0===n?void 0:n.call(a,t,s).message)&&void 0!==r?r:s.defaultError;return"unrecognized_keys"===t.code?{message:null!==(i=L.errToObj(e).message)&&void 0!==i?i:o}:{message:o}}}:{}})}strip(){return new Ee({...this._def,unknownKeys:"strip"})}passthrough(){return new Ee({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ee({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ee({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:dt.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ee({...this._def,catchall:e})}pick(e){const t={};return _.objectKeys(e).forEach((s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])})),new Ee({...this._def,shape:()=>t})}omit(e){const t={};return _.objectKeys(this.shape).forEach((s=>{e[s]||(t[s]=this.shape[s])})),new Ee({...this._def,shape:()=>t})}deepPartial(){return Ae(this)}partial(e){const t={};return _.objectKeys(this.shape).forEach((s=>{const a=this.shape[s];e&&!e[s]?t[s]=a:t[s]=a.optional()})),new Ee({...this._def,shape:()=>t})}required(e){const t={};return _.objectKeys(this.shape).forEach((s=>{if(e&&!e[s])t[s]=this.shape[s];else{let e=this.shape[s];for(;e instanceof Ye;)e=e._def.innerType;t[s]=e}})),new Ee({...this._def,shape:()=>t})}keyof(){return Ve(_.objectKeys(this.shape))}}Ee.create=(e,t)=>new Ee({shape:()=>e,unknownKeys:"strip",catchall:Oe.create(),typeName:dt.ZodObject,...B(t)}),Ee.strictCreate=(e,t)=>new Ee({shape:()=>e,unknownKeys:"strict",catchall:Oe.create(),typeName:dt.ZodObject,...B(t)}),Ee.lazycreate=(e,t)=>new Ee({shape:e,unknownKeys:"strip",catchall:Oe.create(),typeName:dt.ZodObject,...B(t)});class je extends J{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;if(t.common.async)return Promise.all(s.map((async e=>{const s={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const s of e)if("dirty"===s.result.status)return t.common.issues.push(...s.ctx.common.issues),s.result;const s=e.map((e=>new T(e.ctx.common.issues)));return I(t,{code:Z.invalid_union,unionErrors:s}),E}));{let e;const a=[];for(const n of s){const s={...t,common:{...t.common,issues:[]},parent:null},r=n._parseSync({data:t.data,path:t.path,parent:s});if("valid"===r.status)return r;"dirty"===r.status&&!e&&(e={result:r,ctx:s}),s.common.issues.length&&a.push(s.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const n=a.map((e=>new T(e)));return I(t,{code:Z.invalid_union,unionErrors:n}),E}}get options(){return this._def.options}}je.create=(e,t)=>new je({options:e,typeName:dt.ZodUnion,...B(t)});const Pe=e=>e instanceof ze?Pe(e.schema):e instanceof He?Pe(e.innerType()):e instanceof Ke?[e.value]:e instanceof Be?e.options:e instanceof Je?_.objectValues(e.enum):e instanceof Qe?Pe(e._def.innerType):e instanceof Ze?[void 0]:e instanceof Te?[null]:e instanceof Ye?[void 0,...Pe(e.unwrap())]:e instanceof Ge?[null,...Pe(e.unwrap())]:e instanceof st||e instanceof nt?Pe(e.unwrap()):e instanceof Xe?Pe(e._def.innerType):[];class Re extends J{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.object)return I(t,{code:Z.invalid_type,expected:k.object,received:t.parsedType}),E;const s=this.discriminator,a=t.data[s],n=this.optionsMap.get(a);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(I(t,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),E)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const a=new Map;for(const s of t){const t=Pe(s.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const n of t){if(a.has(n))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);a.set(n,s)}}return new Re({typeName:dt.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...B(s)})}}function $e(e,t){const s=w(e),a=w(t);if(e===t)return{valid:!0,data:e};if(s===k.object&&a===k.object){const s=_.objectKeys(t),a=_.objectKeys(e).filter((e=>-1!==s.indexOf(e))),n={...e,...t};for(const s of a){const a=$e(e[s],t[s]);if(!a.valid)return{valid:!1};n[s]=a.data}return{valid:!0,data:n}}if(s===k.array&&a===k.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let a=0;a<e.length;a++){const n=$e(e[a],t[a]);if(!n.valid)return{valid:!1};s.push(n.data)}return{valid:!0,data:s}}return s===k.date&&a===k.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Me extends J{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=(e,a)=>{if(R(e)||R(a))return E;const n=$e(e.value,a.value);return n.valid?(($(e)||$(a))&&t.dirty(),{status:t.value,value:n.data}):(I(s,{code:Z.invalid_intersection_types}),E)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then((([e,t])=>a(e,t))):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}Me.create=(e,t,s)=>new Me({left:e,right:t,typeName:dt.ZodIntersection,...B(s)});class Fe extends J{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==k.array)return I(s,{code:Z.invalid_type,expected:k.array,received:s.parsedType}),E;if(s.data.length<this._def.items.length)return I(s,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),E;!this._def.rest&&s.data.length>this._def.items.length&&(I(s,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...s.data].map(((e,t)=>{const a=this._def.items[t]||this._def.rest;return a?a._parse(new K(s,e,s.path,t)):null})).filter((e=>!!e));return s.common.async?Promise.all(a).then((e=>A.mergeArray(t,e))):A.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new Fe({...this._def,rest:e})}}Fe.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Fe({items:e,typeName:dt.ZodTuple,rest:null,...B(t)})};class De extends J{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==k.object)return I(s,{code:Z.invalid_type,expected:k.object,received:s.parsedType}),E;const a=[],n=this._def.keyType,r=this._def.valueType;for(const e in s.data)a.push({key:n._parse(new K(s,e,s.path,e)),value:r._parse(new K(s,s.data[e],s.path,e)),alwaysSet:e in s.data});return s.common.async?A.mergeObjectAsync(t,a):A.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,s){return new De(t instanceof J?{keyType:e,valueType:t,typeName:dt.ZodRecord,...B(s)}:{keyType:ge.create(),valueType:e,typeName:dt.ZodRecord,...B(t)})}}class Ue extends J{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==k.map)return I(s,{code:Z.invalid_type,expected:k.map,received:s.parsedType}),E;const a=this._def.keyType,n=this._def.valueType,r=[...s.data.entries()].map((([e,t],r)=>({key:a._parse(new K(s,e,s.path,[r,"key"])),value:n._parse(new K(s,t,s.path,[r,"value"]))})));if(s.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const s of r){const a=await s.key,n=await s.value;if("aborted"===a.status||"aborted"===n.status)return E;("dirty"===a.status||"dirty"===n.status)&&t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const s of r){const a=s.key,n=s.value;if("aborted"===a.status||"aborted"===n.status)return E;("dirty"===a.status||"dirty"===n.status)&&t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}}}Ue.create=(e,t,s)=>new Ue({valueType:t,keyType:e,typeName:dt.ZodMap,...B(s)});class Le extends J{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==k.set)return I(s,{code:Z.invalid_type,expected:k.set,received:s.parsedType}),E;const a=this._def;null!==a.minSize&&s.data.size<a.minSize.value&&(I(s,{code:Z.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),null!==a.maxSize&&s.data.size>a.maxSize.value&&(I(s,{code:Z.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const n=this._def.valueType;function r(e){const s=new Set;for(const a of e){if("aborted"===a.status)return E;"dirty"===a.status&&t.dirty(),s.add(a.value)}return{status:t.value,value:s}}const i=[...s.data.values()].map(((e,t)=>n._parse(new K(s,e,s.path,t))));return s.common.async?Promise.all(i).then((e=>r(e))):r(i)}min(e,t){return new Le({...this._def,minSize:{value:e,message:L.toString(t)}})}max(e,t){return new Le({...this._def,maxSize:{value:e,message:L.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Le.create=(e,t)=>new Le({valueType:e,minSize:null,maxSize:null,typeName:dt.ZodSet,...B(t)});class qe extends J{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.function)return I(t,{code:Z.invalid_type,expected:k.function,received:t.parsedType}),E;function s(e,s){return S({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,O(),C].filter((e=>!!e)),issueData:{code:Z.invalid_arguments,argumentsError:s}})}function a(e,s){return S({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,O(),C].filter((e=>!!e)),issueData:{code:Z.invalid_return_type,returnTypeError:s}})}const n={errorMap:t.common.contextualErrorMap},r=t.data;if(this._def.returns instanceof We){const e=this;return P((async function(...t){const i=new T([]),o=await e._def.args.parseAsync(t,n).catch((e=>{throw i.addIssue(s(t,e)),i})),d=await Reflect.apply(r,this,o);return await e._def.returns._def.type.parseAsync(d,n).catch((e=>{throw i.addIssue(a(d,e)),i}))}))}{const e=this;return P((function(...t){const i=e._def.args.safeParse(t,n);if(!i.success)throw new T([s(t,i.error)]);const o=Reflect.apply(r,this,i.data),d=e._def.returns.safeParse(o,n);if(!d.success)throw new T([a(o,d.error)]);return d.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new qe({...this._def,args:Fe.create(e).rest(Ne.create())})}returns(e){return new qe({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new qe({args:e||Fe.create([]).rest(Ne.create()),returns:t||Ne.create(),typeName:dt.ZodFunction,...B(s)})}}class ze extends J{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ze.create=(e,t)=>new ze({getter:e,typeName:dt.ZodLazy,...B(t)});class Ke extends J{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return I(t,{received:t.data,code:Z.invalid_literal,expected:this._def.value}),E}return{status:"valid",value:e.data}}get value(){return this._def.value}}function Ve(e,t){return new Be({values:e,typeName:dt.ZodEnum,...B(t)})}Ke.create=(e,t)=>new Ke({value:e,typeName:dt.ZodLiteral,...B(t)});class Be extends J{constructor(){super(...arguments),q.set(this,void 0)}_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),s=this._def.values;return I(t,{expected:_.joinValues(s),received:t.parsedType,code:Z.invalid_type}),E}if(D(this,q,"f")||U(this,q,new Set(this._def.values),"f"),!D(this,q,"f").has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return I(t,{received:t.data,code:Z.invalid_enum_value,options:s}),E}return P(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 Be.create(e,{...this._def,...t})}exclude(e,t=this._def){return Be.create(this.options.filter((t=>!e.includes(t))),{...this._def,...t})}}q=new WeakMap,Be.create=Ve;class Je extends J{constructor(){super(...arguments),z.set(this,void 0)}_parse(e){const t=_.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==k.string&&s.parsedType!==k.number){const e=_.objectValues(t);return I(s,{expected:_.joinValues(e),received:s.parsedType,code:Z.invalid_type}),E}if(D(this,z,"f")||U(this,z,new Set(_.getValidEnumValues(this._def.values)),"f"),!D(this,z,"f").has(e.data)){const e=_.objectValues(t);return I(s,{received:s.data,code:Z.invalid_enum_value,options:e}),E}return P(e.data)}get enum(){return this._def.values}}z=new WeakMap,Je.create=(e,t)=>new Je({values:e,typeName:dt.ZodNativeEnum,...B(t)});class We extends J{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==k.promise&&!1===t.common.async)return I(t,{code:Z.invalid_type,expected:k.promise,received:t.parsedType}),E;const s=t.parsedType===k.promise?t.data:Promise.resolve(t.data);return P(s.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}We.create=(e,t)=>new We({type:e,typeName:dt.ZodPromise,...B(t)});class He extends J{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===dt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=this._def.effect||null,n={addIssue:e=>{I(s,e),e.fatal?t.abort():t.dirty()},get path(){return s.path}};if(n.addIssue=n.addIssue.bind(n),"preprocess"===a.type){const e=a.transform(s.data,n);if(s.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===t.value)return E;const a=await this._def.schema._parseAsync({data:e,path:s.path,parent:s});return"aborted"===a.status?E:"dirty"===a.status||"dirty"===t.value?j(a.value):a}));{if("aborted"===t.value)return E;const a=this._def.schema._parseSync({data:e,path:s.path,parent:s});return"aborted"===a.status?E:"dirty"===a.status||"dirty"===t.value?j(a.value):a}}if("refinement"===a.type){const e=e=>{const t=a.refinement(e,n);if(s.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===s.common.async){const a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===a.status?E:("dirty"===a.status&&t.dirty(),e(a.value),{status:t.value,value:a.value})}return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then((s=>"aborted"===s.status?E:("dirty"===s.status&&t.dirty(),e(s.value).then((()=>({status:t.value,value:s.value}))))))}if("transform"===a.type){if(!1===s.common.async){const e=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!M(e))return e;const r=a.transform(e.value,n);if(r instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:r}}return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then((e=>M(e)?Promise.resolve(a.transform(e.value,n)).then((e=>({status:t.value,value:e}))):e))}_.assertNever(a)}}He.create=(e,t,s)=>new He({schema:e,typeName:dt.ZodEffects,effect:t,...B(s)}),He.createWithPreprocess=(e,t,s)=>new He({schema:t,effect:{type:"preprocess",transform:e},typeName:dt.ZodEffects,...B(s)});class Ye extends J{_parse(e){return this._getType(e)===k.undefined?P(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ye.create=(e,t)=>new Ye({innerType:e,typeName:dt.ZodOptional,...B(t)});class Ge extends J{_parse(e){return this._getType(e)===k.null?P(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ge.create=(e,t)=>new Ge({innerType:e,typeName:dt.ZodNullable,...B(t)});class Qe extends J{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===k.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Qe.create=(e,t)=>new Qe({innerType:e,typeName:dt.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...B(t)});class Xe extends J{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return F(a)?a.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new T(s.common.issues)},input:s.data})}))):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new T(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Xe.create=(e,t)=>new Xe({innerType:e,typeName:dt.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...B(t)});class et extends J{_parse(e){if(this._getType(e)!==k.nan){const t=this._getOrReturnCtx(e);return I(t,{code:Z.invalid_type,expected:k.nan,received:t.parsedType}),E}return{status:"valid",value:e.data}}}et.create=e=>new et({typeName:dt.ZodNaN,...B(e)});const tt=Symbol("zod_brand");class st extends J{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class at extends J{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const e=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?E:"dirty"===e.status?(t.dirty(),j(e.value)):this._def.out._parseAsync({data:e.value,path:s.path,parent:s})})();{const e=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?E:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:s.path,parent:s})}}static create(e,t){return new at({in:e,out:t,typeName:dt.ZodPipeline})}}class nt extends J{_parse(e){const t=this._def.innerType._parse(e),s=e=>(M(e)&&(e.value=Object.freeze(e.value)),e);return F(t)?t.then((e=>s(e))):s(t)}unwrap(){return this._def.innerType}}function rt(e,t){const s="function"==typeof e?e(t):"string"==typeof e?{message:e}:e;return"string"==typeof s?{message:s}:s}function it(e,t={},s){return e?Ce.create().superRefine(((a,n)=>{var r,i;const o=e(a);if(o instanceof Promise)return o.then((e=>{var r,i;if(!e){const e=rt(t,a),o=null===(i=null!==(r=e.fatal)&&void 0!==r?r:s)||void 0===i||i;n.addIssue({code:"custom",...e,fatal:o})}}));if(!o){const e=rt(t,a),o=null===(i=null!==(r=e.fatal)&&void 0!==r?r:s)||void 0===i||i;n.addIssue({code:"custom",...e,fatal:o})}})):Ce.create()}nt.create=(e,t)=>new nt({innerType:e,typeName:dt.ZodReadonly,...B(t)});const ot={object:Ee.lazycreate};var dt;!function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(dt||(dt={}));const ct=ge.create,ut=_e.create,lt=et.create,ht=xe.create,pt=be.create,mt=ke.create,ft=we.create,yt=Ze.create,gt=Te.create,vt=Ce.create,_t=Ne.create,xt=Oe.create,bt=Se.create,kt=Ie.create,wt=Ee.create,Zt=Ee.strictCreate,Tt=je.create,Ct=Re.create,Nt=Me.create,Ot=Fe.create,St=De.create,It=Ue.create,At=Le.create,Et=qe.create,jt=ze.create,Pt=Ke.create,Rt=Be.create,$t=Je.create,Mt=We.create,Ft=He.create,Dt=Ye.create,Ut=Ge.create,Lt=He.createWithPreprocess,qt=at.create,zt={string:e=>ge.create({...e,coerce:!0}),number:e=>_e.create({...e,coerce:!0}),boolean:e=>be.create({...e,coerce:!0}),bigint:e=>xe.create({...e,coerce:!0}),date:e=>ke.create({...e,coerce:!0})},Kt=E;var Vt=Object.freeze({__proto__:null,defaultErrorMap:C,setErrorMap:function(e){N=e},getErrorMap:O,makeIssue:S,EMPTY_PATH:[],addIssueToContext:I,ParseStatus:A,INVALID:E,DIRTY:j,OK:P,isAborted:R,isDirty:$,isValid:M,isAsync:F,get util(){return _},get objectUtil(){return b},ZodParsedType:k,getParsedType:w,ZodType:J,datetimeRegex:pe,ZodString:ge,ZodNumber:_e,ZodBigInt:xe,ZodBoolean:be,ZodDate:ke,ZodSymbol:we,ZodUndefined:Ze,ZodNull:Te,ZodAny:Ce,ZodUnknown:Ne,ZodNever:Oe,ZodVoid:Se,ZodArray:Ie,ZodObject:Ee,ZodUnion:je,ZodDiscriminatedUnion:Re,ZodIntersection:Me,ZodTuple:Fe,ZodRecord:De,ZodMap:Ue,ZodSet:Le,ZodFunction:qe,ZodLazy:ze,ZodLiteral:Ke,ZodEnum:Be,ZodNativeEnum:Je,ZodPromise:We,ZodEffects:He,ZodTransformer:He,ZodOptional:Ye,ZodNullable:Ge,ZodDefault:Qe,ZodCatch:Xe,ZodNaN:et,BRAND:tt,ZodBranded:st,ZodPipeline:at,ZodReadonly:nt,custom:it,Schema:J,ZodSchema:J,late:ot,get ZodFirstPartyTypeKind(){return dt},coerce:zt,any:vt,array:kt,bigint:ht,boolean:pt,date:mt,discriminatedUnion:Ct,effect:Ft,enum:Rt,function:Et,instanceof:(e,t={message:`Input not instance of ${e.name}`})=>it((t=>t instanceof e),t),intersection:Nt,lazy:jt,literal:Pt,map:It,nan:lt,nativeEnum:$t,never:xt,null:gt,nullable:Ut,number:ut,object:wt,oboolean:()=>pt().optional(),onumber:()=>ut().optional(),optional:Dt,ostring:()=>ct().optional(),pipeline:qt,preprocess:Lt,promise:Mt,record:St,set:At,strictObject:Zt,string:ct,symbol:ft,transformer:Ft,tuple:Ot,undefined:yt,union:Tt,unknown:_t,void:bt,NEVER:Kt,ZodIssueCode:Z,quotelessJson:e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),ZodError:T});const Bt=Vt.object({type:Vt.enum(["sqlite","postgresql","mysql"]).default("sqlite"),connection:Vt.object({url:Vt.string().default("./zaileys.db")}).optional().default({})}).optional().default({}),Jt={prefix:Vt.string().optional(),ignoreMe:Vt.boolean().optional().default(!0),showLogs:Vt.boolean().optional().default(!0),autoMentions:Vt.boolean().optional().default(!0),autoOnline:Vt.boolean().optional().default(!0),autoRead:Vt.boolean().optional().default(!0),autoRejectCall:Vt.boolean().optional().default(!0),database:Bt,citation:Vt.record(Vt.function().returns(Vt.union([Vt.number().array(),Vt.promise(Vt.number().array())]))).optional().transform((async e=>{const t={};if(e)for(const s of Object.keys(e)){const a=`is${s.charAt(0).toUpperCase()+s.slice(1)}`,n=await e[s]();t[a]=n}return t}))},Wt=Vt.object({authType:Vt.literal("pairing"),phoneNumber:Vt.number(),...Jt}),Ht=Vt.object({authType:Vt.literal("qr"),phoneNumber:Vt.undefined().optional(),...Jt}),Yt=Vt.discriminatedUnion("authType",[Wt,Ht]);var Gt=class{client;events=new Map;constructor(e){this.client=e}setup(t){t.ev.on("connection.update",(async t=>{const{connection:s,lastDisconnect:a,qr:n}=t;if(this.emit("connection",{status:s||"connecting"}),"qr"==this.client.options?.authType&&n&&console.log("Scan qrcode with your whatsapp: "),"close"===s){const t=a?.error?.output?.statusCode,s=t!==e.DisconnectReason.loggedOut;if(console.log(a?.error?.message),401==t||405==t||500==t)return;s&&await this.client.initialize()}else"open"===s&&this.emit("connection",{status:"open"})})),t.ev.on("messages.upsert",(({messages:e})=>{this.emit("messages",e)})),t.ev.on("call",(e=>{this.emit("call",e)}))}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((e=>e(t)))}};var Qt=class{props;options;chatId="zaileys-chats";logger=s({level:"silent",enabled:!1});event;db;socket;groupCache=new t({stdTTL:300,useClones:!1});constructor(e){this.props=e,this.initialize(),this.event=new Gt(this)}async initialize(){this.options=await Yt.parseAsync(this.props),this.db=((e,t)=>{if("sqlite"===e){const e=t||"./db/zaileys.db",s=o.resolve(e);return n.mkdirSync(o.dirname(s),{recursive:!0}),n.writeFileSync(s,"",{flag:"a"}),new r.Kysely({dialect:new r.SqliteDialect({database:new a(s)})})}const s=new c.URL(t),u=s.protocol.replace(":","");if("mysql"===e)return new r.Kysely({dialect:new r.MysqlDialect({pool:i.createPool({host:s.hostname,user:s.username,password:s.password,database:s.pathname.replace("/",""),port:parseInt(s.port||"3306",10)})})});if("postgresql"===e)return new r.Kysely({dialect:new r.PostgresDialect({pool:new d.Pool({host:s.hostname,user:s.username,password:s.password,database:s.pathname.replace("/",""),port:parseInt(s.port||"5432",10)})})});throw new Error(`Unsupported database protocol: ${u}`)})(this.options.database.type,this.options.database.connection.url);const{state:s,saveCreds:u,removeCreds:l}=await v(this.db,this.chatId),h=await(async(e,t)=>({bind:s=>{s.on("messaging-history.set",(async s=>{const{chats:a,contacts:n,messages:r}=s;for(const s of a)await e.insertInto("chats").values({session:t,id:s.id,value:JSON.stringify(s)}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:JSON.stringify(s)}))).execute();for(const s of n)await e.insertInto("contacts").values({session:t,id:s.id,value:JSON.stringify(s)}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:JSON.stringify(s)}))).execute();for(const s of r)await e.insertInto("messages").values({session:t,id:s.key.id,value:JSON.stringify(s)}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:JSON.stringify(s)}))).execute()})),s.on("messages.upsert",(async({messages:s})=>{for(const a of s)await e.insertInto("messages").values({session:t,id:a.key.id,value:JSON.stringify(a)}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:JSON.stringify(a)}))).execute()})),s.on("chats.upsert",(async s=>{for(const a of s)await e.insertInto("chats").values({session:t,id:a.id,value:JSON.stringify(a)}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:JSON.stringify(a)}))).execute()})),s.on("contacts.upsert",(async s=>{for(const a of s)await e.insertInto("contacts").values({session:t,id:a.id,value:JSON.stringify(a)}).onConflict((e=>e.columns(["session","id"]).doUpdateSet({value:JSON.stringify(a)}))).execute()}))}}))(this.db,this.chatId);this.socket=e({logger:this.logger,markOnlineOnConnect:this.options.autoOnline,syncFullHistory:!1,defaultQueryTimeoutMs:void 0,msgRetryCounterCache:new t,cachedGroupMetadata:async e=>this.groupCache.get(e),printQRInTerminal:"qr"==this.options.authType,browser:e.Browsers.ubuntu("qr"==this.options.authType?"Zaileys Library":"Firefox"),auth:{creds:s.creds,keys:e.makeCacheableSignalKeyStore(s.keys,this.logger)}}),"pairing"==this.options.authType&&this.options.phoneNumber&&!this.socket?.authState.creds.registered&&setTimeout((async()=>{try{if("pairing"==this.options?.authType){const e=await(this.socket?.requestPairingCode(this.options.phoneNumber.toString()));console.log("🚀 ~ Client.ts:53 ~ Client ~ setTimeout ~ code:",e)}}catch{console.log("Connection failed"),process.exit(1)}}),5e3),this.socket?.ev.on("creds.update",u),h.bind(this.socket?.ev),this.event.setup(this.socket)}on(e,t){this.event.on(e,t)}};module.exports=Qt;
package/dist/index.d.ts CHANGED
@@ -1,235 +1,2 @@
1
- import { WABusinessProfile, proto } from '@whiskeysockets/baileys';
2
- import { EventEmitter } from 'events';
3
-
4
- declare const MESSAGE_TYPE: {
5
- readonly text: "text";
6
- readonly conversation: "text";
7
- readonly imageMessage: "image";
8
- readonly contactMessage: "contact";
9
- readonly locationMessage: "location";
10
- readonly documentMessage: "document";
11
- readonly audioMessage: "audio";
12
- readonly videoMessage: "video";
13
- readonly protocolMessage: "protocol";
14
- readonly contactsArrayMessage: "contactsArray";
15
- readonly highlyStructuredMessage: "highlyStructured";
16
- readonly sendPaymentMessage: "sendPayment";
17
- readonly liveLocationMessage: "liveLocation";
18
- readonly requestPaymentMessage: "requestPayment";
19
- readonly declinePaymentRequestMessage: "declinePaymentRequest";
20
- readonly cancelPaymentRequestMessage: "cancelPaymentRequest";
21
- readonly templateMessage: "template";
22
- readonly stickerMessage: "sticker";
23
- readonly groupInviteMessage: "groupInvite";
24
- readonly templateButtonReplyMessage: "templateButtonReply";
25
- readonly productMessage: "product";
26
- readonly deviceSentMessage: "deviceSent";
27
- readonly listMessage: "list";
28
- readonly viewOnceMessage: "viewOnce";
29
- readonly orderMessage: "order";
30
- readonly listResponseMessage: "listResponse";
31
- readonly ephemeralMessage: "ephemeral";
32
- readonly invoiceMessage: "invoice";
33
- readonly buttonsMessage: "buttons";
34
- readonly buttonsResponseMessage: "buttonsResponse";
35
- readonly paymentInviteMessage: "paymentInvite";
36
- readonly interactiveMessage: "interactive";
37
- readonly reactionMessage: "reaction";
38
- readonly stickerSyncRmrMessage: "sticker";
39
- readonly interactiveResponseMessage: "interactiveResponse";
40
- readonly pollCreationMessage: "pollCreation";
41
- readonly pollUpdateMessage: "pollUpdate";
42
- readonly keepInChatMessage: "keepInChat";
43
- readonly documentWithCaptionMessage: "document";
44
- readonly requestPhoneNumberMessage: "requestPhoneNumber";
45
- readonly viewOnceMessageV2: "viewOnce";
46
- readonly encReactionMessage: "reaction";
47
- readonly editedMessage: "text";
48
- readonly viewOnceMessageV2Extension: "viewOnce";
49
- readonly pollCreationMessageV2: "pollCreation";
50
- readonly scheduledCallCreationMessage: "scheduledCallCreation";
51
- readonly groupMentionedMessage: "groupMentioned";
52
- readonly pinInChatMessage: "pinInChat";
53
- readonly pollCreationMessageV3: "pollCreation";
54
- readonly scheduledCallEditMessage: "scheduledCallEdit";
55
- readonly ptvMessage: "ptv";
56
- readonly botInvokeMessage: "botInvoke";
57
- readonly callLogMesssage: "callLog";
58
- readonly encCommentMessage: "encComment";
59
- readonly bcallMessage: "bcall";
60
- readonly lottieStickerMessage: "lottieSticker";
61
- readonly eventMessage: "event";
62
- readonly commentMessage: "comment";
63
- readonly newsletterAdminInviteMessage: "text";
64
- readonly extendedTextMessageWithParentKey: "text";
65
- readonly placeholderMessage: "placeholder";
66
- readonly encEventUpdateMessage: "encEventUpdate";
67
- };
68
- declare const VERIFIED_PLATFORM: {
69
- readonly whatsapp: "0@s.whatsapp.net";
70
- readonly meta: "13135550002@s.whatsapp.net";
71
- readonly chatgpt: "18002428478@s.whatsapp.net";
72
- readonly copilot: "18772241042@s.whatsapp.net";
73
- readonly instagram: "447723442971@s.whatsapp.net";
74
- readonly tiktok: "6285574670498@s.whatsapp.net";
75
- };
76
-
77
- declare const Config_MESSAGE_TYPE: typeof MESSAGE_TYPE;
78
- declare const Config_VERIFIED_PLATFORM: typeof VERIFIED_PLATFORM;
79
- declare namespace Config {
80
- export { Config_MESSAGE_TYPE as MESSAGE_TYPE, Config_VERIFIED_PLATFORM as VERIFIED_PLATFORM };
81
- }
82
-
83
- type FakeVerifiedEnum = keyof typeof VERIFIED_PLATFORM;
84
- type SendActionType = {
85
- asReply?: boolean;
86
- senderId?: string;
87
- };
88
- type ReplyActionType = {
89
- footer?: string;
90
- fakeVerified?: FakeVerifiedEnum;
91
- senderId?: string;
92
- };
93
-
94
- type Action_FakeVerifiedEnum = FakeVerifiedEnum;
95
- type Action_ReplyActionType = ReplyActionType;
96
- type Action_SendActionType = SendActionType;
97
- declare namespace Action {
98
- export type { Action_FakeVerifiedEnum as FakeVerifiedEnum, Action_ReplyActionType as ReplyActionType, Action_SendActionType as SendActionType };
99
- }
100
-
101
- type MessageTypeEnum = (typeof MESSAGE_TYPE)[keyof typeof MESSAGE_TYPE];
102
- type DeviceTypeEnum = "unknown" | "android" | "ios" | "desktop" | "web";
103
- type ExtractCitationType<T> = {
104
- [K in keyof T as `is${Capitalize<K & string>}`]: boolean;
105
- };
106
- type MessageBaseContent<T> = {
107
- fromMe: boolean;
108
- chatId: string;
109
- channelId: string;
110
- roomId: string;
111
- roomImage: () => Promise<string | null>;
112
- senderId: string;
113
- senderName: string;
114
- senderDevice: DeviceTypeEnum;
115
- senderBio: () => Promise<string | null>;
116
- senderImage: () => Promise<string | null>;
117
- senderBusiness: () => Promise<WABusinessProfile | null>;
118
- chatType: MessageTypeEnum;
119
- timestamp: number;
120
- text: string;
121
- command: string;
122
- mentions: string[] | null;
123
- isTagMe: boolean;
124
- isGroup: boolean;
125
- isStory: boolean;
126
- isEdited: boolean;
127
- isChannel: boolean;
128
- isBroadcast: boolean;
129
- isEphemeral: boolean;
130
- isForwarded: boolean;
131
- citation: {
132
- [key: string]: unknown;
133
- } | null;
134
- media: {
135
- buffer?: () => Promise<Buffer | null>;
136
- stream?: () => Promise<Buffer | null>;
137
- [key: string]: unknown;
138
- } | null;
139
- reply: MessageBaseContent<T> | null;
140
- key: () => proto.IMessageKey;
141
- message: () => proto.IWebMessageInfo;
142
- };
143
-
144
- type Message_DeviceTypeEnum = DeviceTypeEnum;
145
- type Message_ExtractCitationType<T> = ExtractCitationType<T>;
146
- type Message_MessageBaseContent<T> = MessageBaseContent<T>;
147
- type Message_MessageTypeEnum = MessageTypeEnum;
148
- declare namespace Message {
149
- export type { Message_DeviceTypeEnum as DeviceTypeEnum, Message_ExtractCitationType as ExtractCitationType, Message_MessageBaseContent as MessageBaseContent, Message_MessageTypeEnum as MessageTypeEnum };
150
- }
151
-
152
- type AuthType = "pairing" | "qr";
153
- type CitationConfig = {
154
- [key: string]: (() => string[]) | (() => Promise<string[]>);
155
- };
156
- interface BaseClientConfig {
157
- prefix?: string;
158
- ignoreMe?: boolean;
159
- authPath?: string;
160
- authType: AuthType;
161
- showLogs?: boolean;
162
- autoMentions?: boolean;
163
- autoOnline?: boolean;
164
- autoRead?: boolean;
165
- autoRejectCall?: boolean;
166
- citation?: CitationConfig;
167
- }
168
- interface PairingClientConfig extends BaseClientConfig {
169
- authType: "pairing";
170
- phoneNumber: number;
171
- }
172
- interface QRClientConfig extends BaseClientConfig {
173
- authType: "qr";
174
- }
175
- type ClientConfig = PairingClientConfig | QRClientConfig;
176
- interface BaseContext {
177
- }
178
- interface ConnectionContext extends BaseContext {
179
- status: "connecting" | "open" | "close";
180
- }
181
- interface ErrorContext extends BaseContext {
182
- error: Error;
183
- }
184
- interface ClientEvents<B> {
185
- connection: (ctx: ConnectionContext) => void;
186
- message: (ctx: MessageBaseContent<B>) => void;
187
- error: (ctx: ErrorContext) => void;
188
- }
189
-
190
- type General_AuthType = AuthType;
191
- type General_BaseClientConfig = BaseClientConfig;
192
- type General_BaseContext = BaseContext;
193
- type General_CitationConfig = CitationConfig;
194
- type General_ClientConfig = ClientConfig;
195
- type General_ClientEvents<B> = ClientEvents<B>;
196
- type General_ConnectionContext = ConnectionContext;
197
- type General_ErrorContext = ErrorContext;
198
- type General_PairingClientConfig = PairingClientConfig;
199
- type General_QRClientConfig = QRClientConfig;
200
- declare namespace General {
201
- export type { General_AuthType as AuthType, General_BaseClientConfig as BaseClientConfig, General_BaseContext as BaseContext, General_CitationConfig as CitationConfig, General_ClientConfig as ClientConfig, General_ClientEvents as ClientEvents, General_ConnectionContext as ConnectionContext, General_ErrorContext as ErrorContext, General_PairingClientConfig as PairingClientConfig, General_QRClientConfig as QRClientConfig };
202
- }
203
-
204
- declare class Client extends EventEmitter {
205
- private config;
206
- private authState;
207
- private authProvider;
208
- private socket;
209
- private store;
210
- private groupCache;
211
- private logger;
212
- protected temporaryMessage: MessageBaseContent<any> | null;
213
- protected parseMention: string[];
214
- private spinner;
215
- constructor(config: ClientConfig);
216
- protected initialize(): Promise<void>;
217
- private deleteSession;
218
- on<K extends keyof ClientEvents<typeof this$1.config.citation>>(event: K, listener: ClientEvents<typeof this$1.config.citation>[K]): this;
219
- emit<K extends keyof ClientEvents<typeof this$1.config.citation>>(event: K, ...args: Parameters<ClientEvents<typeof this$1.config.citation>[K]>): boolean;
220
- protected generateMentions(mentions: string[]): string[];
221
- protected generateFakeVerified(key: proto.IMessageKey, platform: FakeVerifiedEnum): {
222
- participant: "0@s.whatsapp.net" | "13135550002@s.whatsapp.net" | "18002428478@s.whatsapp.net" | "18772241042@s.whatsapp.net" | "447723442971@s.whatsapp.net" | "6285574670498@s.whatsapp.net";
223
- remoteJid?: string | null | undefined;
224
- fromMe?: boolean | null | undefined;
225
- id?: string | null | undefined;
226
- };
227
- sendText(text: string, payload?: ReplyActionType): Promise<void>;
228
- sendReply(text: string, payload?: ReplyActionType): Promise<void>;
229
- sendImage(image: string | Buffer, payload?: SendActionType): Promise<void>;
230
- sendVideo(video: string | Buffer, payload?: SendActionType): Promise<void>;
231
- sendAudio(audio: string | Buffer, payload?: SendActionType): Promise<void>;
232
- sendSticker(sticker: string | Buffer, payload?: SendActionType): Promise<void>;
233
- }
234
-
235
- export { Client, Config, General, Message, Action as Types, Client as default };
1
+ import Client from "./classes/Client";
2
+ export default Client;