import { Server as RpcWebsocketsServer } from "rpc-websockets";
import { setPKCJs } from "./lib/pkc-js/index.js";
import type { PKCWsServerClassOptions, JsonRpcSendNotificationOptions, CreatePKCWsServerOptions, PKCRpcServerEvents } from "./types.js";
import { PKC } from "../../pkc/pkc.js";
import WebSocket from "ws";
import Publication from "../../publications/publication.js";
import { LocalCommunity } from "../../runtime/browser/community/local-community.js";
import type { CommentIpfsType } from "../../publications/comment/types.js";
import type { RpcInternalCommunityRecordBeforeFirstUpdateType } from "../../community/types.js";
import { TypedEmitter } from "tiny-typed-emitter";
import type { RpcSubscriptionIdResult, RpcSuccessResult, RpcFetchCidResult, RpcResolveAuthorNameResult, RpcCommentPageResult, RpcCommunityPageResult, RpcLocalCommunityUpdateResultType, RpcExportCommunityResult, RpcExportCommunityModLogsResult } from "../../clients/rpc-client/types.js";
declare class PKCWsServer extends TypedEmitter<PKCRpcServerEvents> {
    pkc: PKC;
    rpcWebsockets: RpcWebsocketsServer;
    ws: RpcWebsocketsServer["wss"];
    connections: {
        [connectionId: string]: WebSocket;
    };
    subscriptionCleanups: {
        [connectionId: string]: {
            [subscriptionId: number]: () => Promise<void>;
        };
    };
    publishing: {
        [subscriptionId: number]: {
            publication: Publication;
            pkc: PKC;
            connectionId: string;
            timeout?: NodeJS.Timeout;
        };
    };
    private _setSettingsQueue;
    authKey: string | undefined;
    private _trackedCommunityListeners;
    private _getIpFromConnectionRequest;
    private _onSettingsChange;
    private _startedCommunities;
    private _autoStartOnBoot;
    private _autoStartConcurrency;
    private _rpcStateDb;
    private _allowPrivateKeyExport;
    private _exportFileMaxAgeMs;
    private _exportCommunityInstances;
    private _httpServer;
    private _ownsHttpServer;
    constructor({ port, server, pkc, authKey, startStartedCommunitiesOnStartup, autoStartConcurrency, allowPrivateKeyExport, exportFileMaxAgeMs }: PKCWsServerClassOptions);
    getStartedCommunity(address: string): Promise<LocalCommunity>;
    private _findCommunityAddress;
    private _emitError;
    private _getRpcStateDb;
    private _updateCommunityState;
    private _removeCommunityState;
    _autoStartPreviousCommunities(): Promise<void>;
    private _internalStartCommunity;
    rpcWebsocketsRegister(method: string, callback: Function): void;
    jsonRpcSendNotification({ method, result, subscription, event, connectionId }: JsonRpcSendNotificationOptions): void;
    private _registerPublishing;
    private _clearPublishing;
    private _forceCleanupPublication;
    private _retirePKCIfNeeded;
    _getPKCInstance(): Promise<PKC>;
    getComment(params: any): Promise<CommentIpfsType>;
    getCommunityPage(params: any): Promise<RpcCommunityPageResult>;
    getCommentPage(params: any): Promise<RpcCommentPageResult>;
    createCommunity(params: any): Promise<RpcInternalCommunityRecordBeforeFirstUpdateType>;
    private _trackCommunityListener;
    private _untrackCommunityListener;
    _setupStartedEvents(community: LocalCommunity, connectionId: string, subscriptionId: number): void;
    startCommunity(params: any, connectionId: string): Promise<RpcSubscriptionIdResult>;
    stopCommunity(params: any): Promise<RpcSuccessResult>;
    private _postStoppingOrDeleting;
    editCommunity(params: any): Promise<RpcLocalCommunityUpdateResultType>;
    deleteCommunity(params: any): Promise<RpcSuccessResult>;
    communitiesSubscribe(params: any, connectionId: string): Promise<RpcSubscriptionIdResult>;
    fetchCid(params: any): Promise<RpcFetchCidResult>;
    private _serializeSettingsFromPKC;
    settingsSubscribe(params: any, connectionId: string): Promise<RpcSubscriptionIdResult>;
    private _initPKC;
    private _createPKCInstanceFromSetSettings;
    setSettings(params: any): Promise<RpcSuccessResult>;
    commentUpdateSubscribe(params: any, connectionId: string): Promise<RpcSubscriptionIdResult>;
    communityUpdateSubscribe(params: any, connectionId: string): Promise<RpcSubscriptionIdResult>;
    private _bindCommunityUpdateSubscription;
    private _createCommentInstanceFromPublishCommentParams;
    publishComment(params: any, connectionId: string): Promise<RpcSubscriptionIdResult>;
    private _createVoteInstanceFromPublishVoteParams;
    publishVote(params: any, connectionId: string): Promise<RpcSubscriptionIdResult>;
    private _createCommunityEditInstanceFromPublishCommunityEditParams;
    publishCommunityEdit(params: any, connectionId: string): Promise<RpcSubscriptionIdResult>;
    private _createCommentEditInstanceFromPublishCommentEditParams;
    publishCommentEdit(params: any, connectionId: string): Promise<RpcSubscriptionIdResult>;
    private _createCommentModerationInstanceFromPublishCommentModerationParams;
    publishCommentModeration(params: any, connectionId: string): Promise<RpcSubscriptionIdResult>;
    publishChallengeAnswers(params: any): Promise<RpcSuccessResult>;
    resolveAuthorName(params: any): Promise<RpcResolveAuthorNameResult>;
    private _resolveLocalCommunityForExport;
    private _toWireExportRecord;
    exportCommunity(params: any, connectionId: string): Promise<RpcExportCommunityResult>;
    exportCommunityModLogs(params: any): Promise<RpcExportCommunityModLogsResult>;
    exportsSubscribe(params: any, connectionId: string): Promise<RpcSubscriptionIdResult>;
    cancelExport(params: any, connectionId: string): Promise<RpcSuccessResult>;
    private _exportLoadedCommunities;
    private _findCommunityOwningExport;
    _sweepOldExportFiles(): Promise<void>;
    private _handleExportsHttpRequest;
    unsubscribe(params: any, connectionId: string): Promise<RpcSuccessResult>;
    destroy(): Promise<void>;
}
declare const PKCRpc: {
    PKCWsServer: (options: CreatePKCWsServerOptions) => Promise<PKCWsServer>;
    setPKCJs: typeof setPKCJs;
};
export default PKCRpc;
