import { CLEAR_EDITOR_COMMAND } from 'lexical';
import { DOMExportOutput } from 'lexical';
import { Dropzone } from '@mantine/dropzone';
import { EditorConfig } from 'lexical';
import { LexicalEditor as EditorType } from 'lexical';
import { ElementNode } from 'lexical';
import { FOCUS_COMMAND } from 'lexical';
import { JSX as JSX_2 } from 'react/jsx-runtime';
import { LexicalCommand } from 'lexical';
import { MarkNode } from '@lexical/mark';
import { NodeKey } from 'lexical';
import { RangeSelection } from 'lexical';
import { SerializedEditorState } from 'lexical';
import { SerializedElementNode } from 'lexical';
import { SerializedLexicalNode } from 'lexical';
import { Spread } from 'lexical';

export declare const $createNewParagraph: (editor: EditorType) => void;

export declare type ActiveUserProfile<DATA extends object> = EditorUser<DATA> & {
    id: string;
};

export { CLEAR_EDITOR_COMMAND }

declare type CommentResolve = 'ACCEPTED' | 'REJECTED' | null;

export declare const CREATE_TEMPLATE: LexicalCommand<unknown>;

export { Dropzone }

export declare const Editor: <USER_DATA extends object, CHILD_PAGE extends PageData>({ initialContent, onChange, outputFormat, mode, maxHeight, onBlur, onFocus, fetchUploadMedia, fetchPromptResult, fetchDeleteMedia, fetchRestoreMedia, currentUser, commentOptions, workspaceMembers, maxFileSize, contentModalUploadImage, maxImageSizeError, debounce: debounceMs, disable, ws, excludeNodes, imagePickerSettings, childPages, language, editorRef, }: EditorProps<USER_DATA, CHILD_PAGE>) => JSX_2.Element;

declare interface EditorProps<USER_DATA extends object = object, PAGE_DATA extends PageData = PageData> {
    initialContent: Root | string;
    outputFormat: outputFormat;
    onChange: (e: Root | string, text?: string) => void;
    onBlur?: (e: Root | string) => void;
    onFocus?: () => void;
    mode?: Mode;
    maxHeight?: number;
    fetchUploadMedia?: fetchUploadMedia;
    fetchPromptResult?: fetchPromptResult;
    fetchDeleteMedia?: fetchDeleteRestoreMedia;
    fetchRestoreMedia?: fetchDeleteRestoreMedia;
    maxFileSize?: number;
    contentModalUploadImage?: React.FunctionComponent;
    maxImageSizeError?: () => void;
    currentUser?: IUser;
    commentOptions?: ICommentOptions;
    workspaceMembers?: IMember[];
    debounce?: number;
    disable?: boolean;
    ws?: EditorWebSocketProps<USER_DATA>;
    excludeNodes?: Record<string, boolean>;
    imagePickerSettings?: ImagePickerSettings;
    childPages?: PAGE_DATA[];
    language?: 'ru' | 'en' | 'es';
    editorRef?: {
        current: EditorType | null;
    };
}

export { EditorType }

declare type EditorUser<DATA extends object> = {
    color: string;
    name: string;
    awarenessData?: DATA;
};

declare interface EditorWebSocketProps<USER_DATA extends object> {
    url: string;
    id: string;
    user: EditorUser<USER_DATA>;
    getActiveUsers?: (users: ActiveUserProfile<USER_DATA>[]) => void;
}

export declare type ErrorDeleteImage = (error?: Error) => void;

export declare type ErrorUploadImage = (error?: Error) => void;

export declare class ExtendMarkNode extends MarkNode implements ElementNode {
    __extendIds: string[];
    __resolve: CommentResolve;
    constructor(idsExtend: string[], resolve?: CommentResolve, key?: NodeKey);
    static getType(): string;
    static clone(node: ExtendMarkNode): ExtendMarkNode;
    static importJSON(serializedNode: SerializedMarkNode): ExtendMarkNode;
    static importDOM(): null;
    resolveThreat(value: CommentResolve): CommentResolve;
    createDOM(config: EditorConfig): HTMLElement;
    exportDOM(editor: EditorType): DOMExportOutput;
    updateDOM(prevNode: this, element: HTMLElement, config: EditorConfig): boolean;
    exportJSON(): SerializedMarkNode;
    excludeFromCopy(_destination: 'clone' | 'html'): boolean;
    updateExtendId(tempId: string, realId: string): void;
}

declare type fetchDeleteRestoreMedia = (id: string, success: SuccessDeleteImage, error?: ErrorDeleteImage) => void;

declare type fetchPromptResult = (prompt: string, success: (data: string) => void, error?: () => void) => void;

declare type fetchUploadMedia = (file: File, success: SuccessUploadImage, error?: ErrorDeleteImage, signal?: AbortSignal) => void;

export { FOCUS_COMMAND }

export declare function focusEditor(editor: EditorType, atStart?: boolean): void;

declare interface ICommentActions {
    fetchCommentsApi: (params: IFetchCommentsParams) => Promise<void>;
    resolveCommentApi: (params: IResolveCommentParams) => Promise<void>;
    commentReactionApi: (params: ICommentReactionParams) => Promise<void>;
    deleteReactionApi: (params: IDeleteReactionParams) => Promise<void>;
    deleteCommentApi: (params: IDeleteCommentParams) => Promise<void>;
    restoreCommentApi: (params: IRestoreCommentParams) => Promise<void>;
    updateCommentTextApi: (params: IUpdateCommentTextParams) => Promise<void>;
    deleteCommentImageApi: (params: IDeleteCommentImageParams) => Promise<void>;
    submitCommentApi: (params: ISubmitCommentParams) => Promise<void>;
    getReactionsApi: (params: IGetReactionsParams) => Promise<{
        content: ICommentReaction[];
    }>;
    getPhotosApi: (params: IGetPhotosParams) => Promise<File[]>;
    uploadCommentFileApi: (params: IUploadCommentFileParams) => Promise<void>;
}

declare interface ICommentOptions {
    showComments: boolean;
    setShowComments: (value?: boolean) => void;
    pageId: string;
    workspaceInfo: {
        title: string;
        icon: string;
    };
    commentActions: ICommentActions;
}

declare interface ICommentReaction {
    id: string;
    commentId: string;
    parentId: string;
    parentType: 'COMMENT' | 'THREAD';
    reaction: string;
    userId: string;
    createdAt: string;
    deleted: boolean;
    deletedAt: string;
    version: number;
}

declare interface ICommentReactionParams {
    commentId: string;
    author: string;
    emojiValue: string;
    onSuccess?: (data: ICommentReaction) => void;
    onError: () => void;
}

declare interface IDeleteCommentImageParams {
    photoToRemove: string;
    onSuccess?: () => void;
}

declare interface IDeleteCommentParams {
    deleteCommentId: string;
    onSuccess?: () => void;
}

declare interface IDeleteReactionParams {
    reactionId: string;
    onSuccess?: () => void;
    onError: () => void;
}

declare interface IFetchCommentsParams {
    fetchPageComments?: boolean;
    pageId: string;
    fetchCommentComments?: boolean;
    onSuccess: (data: any) => void;
}

declare interface IGetPhotosParams {
    commentId: string;
}

declare interface IGetReactionsParams {
    commentId: string;
}

declare type ImagePickerSettings = {
    maxUploadFiles?: number;
    unsplashClientId?: string;
    giphyToken?: string;
    download?: boolean;
    link?: boolean;
};

declare interface IMember {
    accepted: boolean;
    avatarUrl: string;
    email: string;
    expiresAt: string | null;
    invitationId: string | null;
    invitationToken: string | null;
    name: string;
    roleType: string;
    roleId: string;
    userId: string;
}

declare interface IResolveCommentParams {
    threatId: string;
    resolveValue: 'ACCEPTED' | 'REJECTED';
    onSuccess?: () => void;
    onError?: () => void;
}

declare interface IRestoreCommentParams {
    commentId: string;
    onSuccess?: () => void;
}

declare interface ISubmitCommentParams {
    text: string;
    parentType: string;
    parentId: string;
    onSuccess?: (data: any) => void;
}

declare interface IUpdateCommentTextParams {
    commentId: string;
    textValue: string;
    onSuccess?: () => void;
    onError?: () => void;
}

declare interface IUploadCommentFileParams {
    file: File;
    commentId: string;
    onSuccess?: (data: any) => void;
}

declare interface IUser {
    activeWorkspaceId: string;
    createdAt: string;
    darkMode: boolean;
    email: string;
    id: string;
    lang: string;
    metaData: {
        cover: Record<string, any>;
        about: string;
        socialNetworks: any[];
        fontFamily: string;
    };
    name: string;
    nickname: string;
    plan: 'FREE' | 'PRO' | 'BUSINESS' | string;
    profilePicture: {
        url: string;
    };
    timeZone: string | null;
    twoFactorEnabled: boolean;
    workspaces: any[];
}

declare type Mode = 'comment' | 'default' | 'full' | 'editor';

export { NodeKey }

declare type outputFormat = 'html' | 'json';

declare interface PageData {
    id: string;
    icon: string | null;
    title: string;
    order: number;
}

export { RangeSelection }

export declare type Root = SerializedEditorState<SerializedLexicalNode>;

declare type SerializedMarkNode = Spread<{
    ids: Array<string>;
}, SerializedElementNode>;

export declare const StylesProvider: ({ children }: {
    children: React.ReactNode;
}) => JSX_2.Element;

export declare type SuccessDeleteImage = () => void;

export declare type SuccessUploadImage = (url: string, id: string, data?: UploadData) => void;

export declare type UploadData = {
    contentType: string;
    fileSize: string;
    originalFileName: string;
};

export { }
