import { ClubsGeneralUnit } from '@devprotocol/clubs-core';
import { UndefinedOr } from '@devprotocol/util-ts';

type PostPrimitives = {
    readonly title: string;
    readonly content: string;
    readonly options: readonly PostOption[];
};
type Posts = PostPrimitives & {
    readonly id: string;
    readonly created_by: string;
    readonly created_at: Date;
    readonly updated_at: Date;
    readonly comments: readonly Comment[];
    readonly reactions: Reactions;
    readonly masked?: boolean;
};
type PostOption = {
    readonly key: string;
    readonly value: ClubsGeneralUnit;
};
type CommentPrimitives = {
    readonly content: string;
    readonly options: readonly PostOption[];
};
type Comment = CommentPrimitives & {
    readonly id: string;
    readonly created_by: string;
    readonly created_at: Date;
    readonly updated_at: Date;
};
/**
 * Reaction is a map of emoji to users who reacted to a post
 * An emoji as the key, and an array of addresses as the users who reacted to the post
 * @example
 * {'🦜': ['0x0', '0x2']}
 */
type Reactions = {
    readonly [emoji: string]: readonly string[];
};
declare enum Event {
    PostCreated = "posts:event::post_created",
    RegisterOnUpdateHandler = "posts:event::register_on_update_handler"
}

type OnUpdateHandler = (post: PostPrimitives) => PostPrimitives | Promise<PostPrimitives>;
type OnPostCreatedHandler = (post: Posts) => void | Promise<void>;
type EventRegisterOnUpdateHandler = CustomEvent<{
    readonly handler?: OnUpdateHandler;
}>;
type EventPostCreated = CustomEvent<{
    readonly post: Posts;
}>;
declare const onUpdateHandlers: Set<OnUpdateHandler>;
declare const handleRegisterOnUpdateHandler: (e: EventRegisterOnUpdateHandler) => Set<OnUpdateHandler>;
declare const onUpdate: (handler: OnUpdateHandler) => boolean;
declare const update: (_post: PostPrimitives) => Promise<PostPrimitives>;
declare const EncodedPostClassName = "__input-encoded-post__";
declare const currentPost: (handler: (post: Posts) => unknown, base: Readonly<Element>) => UndefinedOr<HTMLInputElement>;
declare const onPostCreated: (handler: OnPostCreatedHandler) => false | void;
declare const PostCreated: Event;
declare const RegisterOnUpdateHandler: Event;
declare const dispatchPostCreated: (post: Posts) => boolean;
declare global {
    interface DocumentEventMap {
        readonly [RegisterOnUpdateHandler]: EventRegisterOnUpdateHandler;
        readonly [PostCreated]: EventPostCreated;
    }
}

export { EncodedPostClassName, type EventPostCreated, type EventRegisterOnUpdateHandler, type OnPostCreatedHandler, type OnUpdateHandler, currentPost, dispatchPostCreated, handleRegisterOnUpdateHandler, onPostCreated, onUpdate, onUpdateHandlers, update };
