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[];
};

type OnUpdateHandler = (post: PostPrimitives) => PostPrimitives | Promise<PostPrimitives>;
declare const onUpdate: (handler: OnUpdateHandler) => Set<OnUpdateHandler>;
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>;

export { EncodedPostClassName, type OnUpdateHandler, currentPost, onUpdate, update };
