import { ImEventType } from "./im/events";
import { ConversationType } from "./im/conversations";
export interface GoEasyOptions {
    host: string;
    appkey: string;
    modules: Array<string>;
    forceTLS?: boolean;
    supportOldBrowser?: boolean;
    allowNotification?: boolean;
}
export interface CallBackOptions {
    onSuccess?(result?: any): void;
    onFailed?(errInfo?: any): void;
}
export interface ConnectOptions extends CallBackOptions {
    id?: string | number;
    data: string | any;
    otp?: string;
    onProgress?(progress: number): void;
}
export interface PresenceEvent<T> {
    action: string;
    time: number;
    data: T;
    id: string;
}
export interface PresenceEvents<T> {
    channel: string;
    clientAmount: number;
    events: PresenceEvent<T>[];
    userAmount: number;
}
export declare type IMEvent = keyof typeof ImEventType;
export declare type MessageCallback = (message: any) => void;
export interface PublishOptions extends CallBackOptions {
    channel: string;
    message: string;
    notification?: {
        title: string;
        body: string;
    };
}
export interface SubscribeOptions extends CallBackOptions {
    channel: string;
    onMessage(message: {
        channel: string;
        content: string;
    }): void;
}
export interface UnsubscribeOptions extends CallBackOptions {
    channel: string;
}
export interface SubscribePresenceOptions extends CallBackOptions {
    channel: string;
    onPresence<T = any>(presenceEvents: PresenceEvents<T>): void;
}
export interface UnsubscribePresenceOptions extends CallBackOptions {
    channel: string;
}
export interface HistoryOptions extends CallBackOptions {
    channel: string;
    limit: number;
    onSuccess(results: {
        code: number;
        content: {
            messages: Array<{
                time: number;
                content: string;
            }>;
        };
    }): void;
}
export interface HereNowOptions extends CallBackOptions {
    channels: string[];
    includeUsers?: boolean;
    distinct?: boolean;
    onSuccess(results: {
        code: number;
        content: {
            channels: {
                [key: string]: {
                    channel: string;
                    clientAmount: number;
                    userAmount: number;
                    users: any[];
                };
            };
        };
    }): void;
}
export interface HereNowByUserIdsOptions extends CallBackOptions {
    userIds: string[];
    distinct?: boolean;
    onSuccess(results: {
        code: number;
        content: Array<{
            id: string;
            data: any;
        }>;
    }): void;
}
export interface MessageTo {
    type: string;
    id: string;
    data: any;
}
export interface MessageOptions {
    to: MessageTo;
    notification?: {
        title: string;
        body: string;
    };
    onProgress?(progress: ProgressEvent<EventTarget>): void;
}
export interface TextMessageOptions extends MessageOptions {
    text: string;
}
export interface FileMessageOptions extends MessageOptions {
    file: File;
}
export interface CustomMessageOptions<T> extends MessageOptions {
    type: string;
    payload: T;
}
export interface LatestConversationsOptions extends CallBackOptions {
    onSuccess(result: {
        code: number;
        content: {
            unreadTotal: number;
            conversations: Conversation[];
        };
    }): void;
}
export interface RemovePrivateConversationOptions extends CallBackOptions {
    userId: string;
}
export interface RemoveGroupConversationOptions extends CallBackOptions {
    groupId: string;
}
export interface IMHistoryOptions extends CallBackOptions {
    userId?: string;
    groupId?: string;
    lastTimestamp?: number;
    limit?: number;
}
export interface UploadOptions extends CallBackOptions {
    file: File;
    name: string;
    onProgress(progress: ProgressEvent<EventTarget>): void;
}
export interface SendMessageOptions extends CallBackOptions {
    message: IMMessage;
}
export interface MarkGroupMessageAsReadOptions extends CallBackOptions {
    groupId: string;
    timestamp: number;
}
export interface MarkPrivateMessageAsReadOptions extends CallBackOptions {
    userId: string;
    timestamp: number;
}
export interface TopPrivateConversationOptions extends CallBackOptions {
    userId: string;
    top: boolean;
}
export interface TopGroupConversationOptions extends CallBackOptions {
    groupId: string;
    top: boolean;
}
export interface SubscribeUserPresenceOptions extends CallBackOptions {
    userIds: string[];
}
export interface UnsubscribeUserPresenceOptions extends CallBackOptions {
    userId: string;
}
export interface IMHereNowOptions extends CallBackOptions {
    userIds: string[];
    onSuccess(result: {
        code: number;
        content: Array<{
            userId: string;
            userData: string;
        }>;
    }): void;
}
export interface SubscribeGroupOptions extends CallBackOptions {
    groupIds: string;
}
export interface UnsubscribeGroupOptions extends CallBackOptions {
    groupId: string;
}
export interface SubscribeGroupPresenceOptions extends CallBackOptions {
    groupIds: string[];
}
export interface UnsubscribeGroupPresenceOptions extends CallBackOptions {
    groupId: string;
}
export interface GroupHereNowOptions extends CallBackOptions {
    groupId: string;
    onSuccess(result: {
        code: number;
        content: Array<{
            groupId: string;
            userData: string;
        }>;
    }): void;
}
export interface GroupOnlineCountOptions extends CallBackOptions {
    groupId: string;
    onSuccess(result: {
        code: number;
        content: {
            onlineCount: number;
        };
    }): void;
}
export declare enum MessageStatus {
    new = "new",
    sending = "sending",
    success = "success",
    fail = "fail"
}
export interface IMMessage<T = any> {
    type: string;
    senderData?: string;
    to?: MessageTo;
    timestamp?: number;
    senderId: string;
    payload: T;
    messageId: string;
    status: MessageStatus;
}
export interface Conversation {
    type: string;
    groupId: string;
    userId: string;
    data: string;
    unread: number;
    lastMessage: IMMessage<any>;
}
/**
 * @description PubSub 类
 */
export declare class PubSub {
    static instance: any;
    private options;
    private goEasySocket;
    private publisher;
    private subscriber;
    private presence;
    private histories;
    private hereNows;
    private neverConnect;
    constructor(options: GoEasyOptions);
    initialGoEasySocket(goEasySocket: any): void;
    initialBeforeConnect(): void;
    private validateOptions;
    publish(options: PublishOptions): void;
    subscribe(options: SubscribeOptions): void;
    unsubscribe(options: UnsubscribeOptions): void;
    subscribePresence(options: SubscribePresenceOptions): void;
    unsubscribePresence(options: UnsubscribePresenceOptions): void;
    history(options: HistoryOptions): void;
    hereNow(options: HereNowOptions): void;
    hereNowByUserIds(options: HereNowByUserIdsOptions): void;
}
/**
 * @description IM 聊天类
 *
 * todo：要和IM。js合并，这边应该保持简单，复杂的应该在那边。
 */
export declare class GoEasyIM {
    options: GoEasyOptions;
    constructor(options: GoEasyOptions);
    initialBeforeConnect(user: any): void;
    initialAfterConnect(): void;
    initialGoEasySocket(goEasySocket: any): void;
    private validateOptions;
    private validateMessageToData;
    on(event: IMEvent, fn: MessageCallback): void;
    createTextMessage(options: TextMessageOptions): IMMessage<string>;
    createImageMessage(options: FileMessageOptions): IMMessage<File>;
    createFileMessage(options: FileMessageOptions): IMMessage<File>;
    createAudioMessage(options: FileMessageOptions): IMMessage<File>;
    createVideoMessage(options: FileMessageOptions): IMMessage<File>;
    createCustomMessage<T = any>(options: CustomMessageOptions<T>): IMMessage<T>;
    latestConversations(options: LatestConversationsOptions): void;
    removePrivateConversation(options: RemovePrivateConversationOptions): void;
    removeGroupConversation(options: RemoveGroupConversationOptions): void;
    history(options: IMHistoryOptions): void;
    upload(options: UploadOptions): void;
    sendMessage(message: SendMessageOptions): void;
    markGroupMessageAsRead(options: MarkGroupMessageAsReadOptions): void;
    markPrivateMessageAsRead(options: MarkPrivateMessageAsReadOptions): void;
    topPrivateConversation(options: TopPrivateConversationOptions): void;
    topGroupConversation(options: TopGroupConversationOptions): void;
    subscribeUserPresence(options: SubscribeUserPresenceOptions): void;
    unsubscribeUserPresence(options: UnsubscribeUserPresenceOptions): void;
    hereNow(options: IMHereNowOptions): void;
    subscribeGroup(options: SubscribeGroupOptions): void;
    unsubscribeGroup(options: UnsubscribeGroupOptions): void;
    subscribeGroupPresence(options: SubscribeGroupPresenceOptions): void;
    unsubscribeGroupPresence(options: UnsubscribeGroupPresenceOptions): void;
    groupHereNow(options: GroupHereNowOptions): void;
    groupOnlineCount(options: GroupOnlineCountOptions): void;
}
/**
 * @description GoEasy 对外接口核心类
 */
export default class GoEasy {
    static instance: GoEasy;
    static readonly version: string;
    static readonly IM_EVENT: typeof ImEventType;
    static readonly IM_SCENE: typeof ConversationType;
    readonly im: GoEasyIM;
    readonly pubsub: PubSub;
    private goEasySocket;
    private options;
    private notification;
    private constructor();
    static getInstance(options: GoEasyOptions): GoEasy;
    connect(options: ConnectOptions): void;
    disconnect(options: CallBackOptions): void;
    getConnectionStatus(): string;
    private validateOptions;
    onClickNotification(clickHandler: MessageCallback): void;
    private confirmUserId;
}
