import { default as _ } from 'lodash';
import { UnionToIntersection } from '../utils';
import { Kind, Story } from './channel';
import { ContactBookProfile } from './contact';

export type Whom = {
    ship: string;
} | {
    club: string;
};
export type ExtendedEventType = 'post' | 'post-mention' | 'reply' | 'reply-mention' | 'dm-invite' | 'dm-post' | 'dm-post-mention' | 'dm-reply' | 'dm-reply-mention' | 'group-ask' | 'group-join' | 'group-kick' | 'group-invite' | 'group-role' | 'flag-post' | 'flag-reply' | 'contact';
export type NotificationLevel = 'hush' | 'soft' | 'default' | 'medium' | 'loud';
export declare enum NotificationNames {
    loud = "Notify for all activity",
    default = "Posts, mentions and replies",
    medium = "Posts, mentions and replies ",
    soft = "Only mentions and replies",
    hush = "Do not notify for any activity"
}
export declare enum NotificationNamesShort {
    loud = "All posts and replies",
    default = "All posts",
    medium = "All posts ",
    soft = "Mentions and replies",
    hush = "No notifications"
}
export interface VolumeLevel {
    notify: NotificationLevel;
    unreads: boolean;
}
export type Volume = {
    unreads: boolean;
    notify: boolean;
};
export interface MessageKey {
    id: string;
    time: string;
}
export interface DmInviteEvent {
    'dm-invite': Whom;
}
export interface GroupKickEvent {
    'group-kick': {
        ship: string;
        group: string;
    };
}
export interface GroupAskEvent {
    'group-ask': {
        ship: string;
        group: string;
    };
}
export interface GroupJoinEvent {
    'group-join': {
        ship: string;
        group: string;
    };
}
export interface GroupRoleEvent {
    'group-role': {
        ship: string;
        group: string;
        roles: string[];
    };
}
export interface GroupInviteEvent {
    'group-invite': {
        ship: string;
        group: string;
    };
}
export interface FlagPostEvent {
    'flag-post': {
        key: MessageKey;
        channel: string;
        group: string;
    };
}
export interface FlagReplyEvent {
    'flag-reply': {
        key: MessageKey;
        parent: MessageKey;
        channel: string;
        group: string;
    };
}
export interface DmPostEvent {
    'dm-post': {
        key: MessageKey;
        whom: Whom;
        content: Story;
        mention: boolean;
    };
}
export interface DmReplyEvent {
    'dm-reply': {
        parent: MessageKey;
        key: MessageKey;
        whom: Whom;
        content: Story;
        mention: boolean;
    };
}
export interface PostEvent {
    post: {
        key: MessageKey;
        group: string;
        channel: string;
        content: Story;
        mention: boolean;
    };
}
export interface ReplyEvent {
    reply: {
        parent: MessageKey;
        key: MessageKey;
        group: string;
        channel: string;
        content: Story;
        mention: boolean;
    };
}
export interface ContactEvent {
    contact: {
        who: string;
        update: ContactBookProfile;
    };
}
export type ActivityIncomingEvent = GroupKickEvent | GroupJoinEvent | GroupRoleEvent | GroupInviteEvent | GroupAskEvent | FlagPostEvent | FlagReplyEvent | DmInviteEvent | DmPostEvent | DmReplyEvent | PostEvent | ReplyEvent | ContactEvent;
export type ActivityEvent = {
    notified: boolean;
} & ActivityIncomingEvent;
export interface PostRead {
    seen: boolean;
    floor: string;
}
export interface Reads {
    floor: number;
    items: Record<string, PostRead>;
}
export interface IndexData {
    stream: Stream;
    reads: Reads;
}
export interface DmSource {
    dm: Whom;
}
export interface ChannelSource {
    channel: {
        nest: string;
        group: string;
    };
}
export type Source = DmSource | {
    base: null;
} | {
    group: string;
} | ChannelSource | {
    thread: {
        key: MessageKey;
        channel: string;
        group: string;
    };
} | {
    'dm-thread': {
        key: MessageKey;
        whom: Whom;
    };
};
export interface MessageKey {
    id: string;
    time: string;
}
export interface UnreadPoint extends MessageKey {
    count: number;
    notify: boolean;
}
export interface UnreadThread extends UnreadPoint {
    'parent-time': string;
}
export interface ActivitySummary {
    recency: number;
    count: number;
    'notify-count': number;
    notify: boolean;
    unread: UnreadPoint | null;
    'recency-uv'?: string;
}
export interface ActivitySummaryFull extends ActivitySummary {
    reads: Reads;
    children: string[];
}
export interface ActivityBundle {
    source: Source;
    latest: string;
    events: {
        event: ActivityEvent;
        time: string;
    }[];
    'source-key': string;
}
export interface ActivityFeed {
    feed: ActivityBundle[];
    summaries: Activity;
}
export type InitActivityFeeds = {
    all: ActivityBundle[];
    mentions: ActivityBundle[];
    replies: ActivityBundle[];
    summaries: Activity;
};
export type Activity = Record<string, ActivitySummary>;
export type Indices = Record<string, IndexData>;
export type Stream = Record<string, ActivityEvent>;
export type VolumeMap = Partial<Record<ExtendedEventType, Volume>>;
export type ReadAction = {
    event: ActivityIncomingEvent;
} | {
    item: string;
} | {
    all: {
        time: string | null;
        deep: boolean;
    };
};
export interface ActivityReadAction {
    source: Source;
    action: ReadAction;
}
export interface ActivityVolumeAction {
    source: Source;
    volume: VolumeMap | null;
}
export type PushNotificationsSetting = 'all' | 'some' | 'none';
export type ActivityAction = {
    add: ActivityIncomingEvent;
} | {
    del: Source;
} | {
    read: ActivityReadAction;
} | {
    adjust: ActivityVolumeAction;
} | {
    'clear-group-invites': null;
} | {
    'allow-notifications': PushNotificationsSetting;
};
export interface ActivitySummaryUpdate {
    activity: Activity;
}
export interface ActivityReadUpdate {
    read: {
        source: Source;
        activity: ActivitySummary;
    };
}
export interface ActivityVolumeUpdate {
    adjust: {
        source: Source;
        volume: VolumeMap | null;
    };
}
export interface ActivityAddUpdate {
    add: {
        ['source-key']: string;
        source: Source;
        time: string;
        event: ActivityEvent;
    };
}
export interface ActivityDeleteUpdate {
    del: Source;
}
export interface ActivityPushNotificationsSettingUpdate {
    'allow-notifications': PushNotificationsSetting;
}
export type ActivityUpdate = ActivityReadUpdate | ActivitySummaryUpdate | ActivityVolumeUpdate | ActivityDeleteUpdate | ActivityAddUpdate | ActivityPushNotificationsSettingUpdate;
export interface FullActivity {
    indices: Indices;
    activity: Activity;
}
export type VolumeSettings = Record<string, VolumeMap | null>;
export declare function sourceToString(source: Source, stripPrefix?: boolean): string;
export declare function getUnreadsFromVolumeMap(vmap: VolumeMap): boolean;
export declare function getLevelFromVolumeMap(vmap: VolumeMap): NotificationLevel;
export declare function getVolumeMap(level: NotificationLevel, unreads: boolean): VolumeMap;
export declare function getDefaultVolumeOption(source: Source, settings: VolumeSettings, group?: string): {
    label: string;
    volume: NotificationLevel;
};
export declare function stripSourcePrefix(source: string): string;
export declare function stripPrefixes(unreads: Activity): _.Dictionary<ActivitySummary>;
export declare function onlyChats(unreads: Activity): _.Dictionary<ActivitySummary>;
export declare function getChannelSource(group: string, channel: string): {
    channel: {
        nest: string;
        group: string;
    };
};
export declare function getDmSource(id: string): {
    dm: {
        ship: string;
        club?: undefined;
    };
} | {
    dm: {
        club: string;
        ship?: undefined;
    };
};
export declare function getKey(whom: string): string;
export declare function getThreadKey(whom: string, id: string): string;
export declare const isMessage: (event: ActivityEvent) => boolean;
export declare const isNote: (event: ActivityEvent) => boolean;
export declare const isGalleryBlock: (event: ActivityEvent) => boolean;
export declare const isMention: (event: ActivityEvent) => boolean;
export declare const isComment: (event: ActivityEvent) => boolean;
export declare const isReply: (event: ActivityEvent) => boolean;
export declare const isAsk: (event: ActivityEvent) => boolean;
export declare const isInvite: (event: ActivityEvent) => boolean;
export declare const isJoin: (event: ActivityEvent) => boolean;
export declare const isLeave: (event: ActivityEvent) => boolean;
export declare const isRoleChange: (event: ActivityEvent) => boolean;
export declare const isGroupMeta: (event: ActivityEvent) => boolean;
export declare function getTop(bundle: ActivityBundle): ActivityEvent;
export declare function getSource(bundle: ActivityBundle): Source;
export declare function getSourceForEvent(event: ActivityEvent): Source;
export declare function getContent(event: ActivityEvent): Story;
export declare function getIdParts(id: string): {
    author: string;
    sent: number;
};
export declare function getAuthor(event: ActivityEvent): string;
export declare function getChannelKind(event: PostEvent | ReplyEvent): Kind;
export type ActivityRelevancy = 'mention' | 'involvedThread' | 'replyToGalleryOrNote' | 'replyToChatPost' | 'dm' | 'groupchat' | 'postInYourChannel' | 'postToChannel' | 'groupMeta' | 'flaggedPost' | 'flaggedReply' | 'groupJoinRequest';
export declare function getRelevancy(event: ActivityEvent, us: string): ActivityRelevancy;
export declare namespace ActivityIncomingEvent {
    /**
     * Helper for building exhaustive checks:
     * ```ts
     * declare const event: ActivityIncomingEvent;
     * switch (true) {
     * case is(event, "dm-post"):
     *   // `event` is typed as `DmPostEvent`
     *   return event['dm-post'].content;
     *
     * // TS should complain about missing cases until you add all of them
     * }
     * ```
     */
    function is<K extends keyof UnionToIntersection<ActivityIncomingEvent>>(poly: ActivityIncomingEvent, type: K): poly is Pick<UnionToIntersection<ActivityIncomingEvent>, K>;
}
//# sourceMappingURL=activity.d.ts.map