import { Signer } from "../signer/index.js";
import type { DecryptedChallengeAnswerMessageType, DecryptedChallengeMessageType, DecryptedChallengeRequest, DecryptedChallengeRequestMessageType, DecryptedChallengeVerification, DecryptedChallengeVerificationMessageType, PublicationFromDecryptedChallengeRequest } from "../pubsub-messages/types.js";
import type { AuthorPubsubJsonType, CreatePublicationOptions, PublicationTypeName } from "../types.js";
import { PKC } from "../pkc/pkc.js";
import { TypedEmitter } from "tiny-typed-emitter";
import { Comment } from "./comment/comment.js";
import type { CommunityIpfsType } from "../community/types.js";
import type { CommentIpfsType } from "./comment/types.js";
import type { PublicationEvents, PublicationPublishingState, PublicationState } from "./types.js";
import type { SignerType } from "../signer/types.js";
import { PublicationClientsManager } from "./publication-client-manager.js";
import { LocalCommunity } from "../runtime/browser/community/local-community.js";
declare class Publication extends TypedEmitter<PublicationEvents> {
    clients: PublicationClientsManager["clients"];
    communityAddress: string;
    shortCommunityAddress: string;
    communityPublicKey?: string;
    communityName?: string;
    timestamp: PublicationFromDecryptedChallengeRequest["timestamp"];
    signature: PublicationFromDecryptedChallengeRequest["signature"] | CommentIpfsType["signature"];
    signer?: SignerType;
    author: AuthorPubsubJsonType;
    protocolVersion: DecryptedChallengeRequestMessageType["protocolVersion"];
    challengeRequest?: CreatePublicationOptions["challengeRequest"];
    state: PublicationState | Comment["state"];
    publishingState: PublicationPublishingState;
    raw: {
        pubsubMessageToPublish?: PublicationFromDecryptedChallengeRequest;
        unsignedPublicationOptions?: CreatePublicationOptions;
    };
    _community?: {
        address: string;
        publicKey: string;
        name?: string;
        encryption: CommunityIpfsType["encryption"];
        pubsubTopic?: CommunityIpfsType["pubsubTopic"];
    };
    _publishingToLocalCommunity?: LocalCommunity;
    _challengeExchanges: Record<string, // challengeRequestId stringified
    {
        challengeAnswer?: DecryptedChallengeAnswerMessageType;
        challengeRequest: DecryptedChallengeRequestMessageType;
        challenge?: DecryptedChallengeMessageType;
        challengeVerification?: DecryptedChallengeVerificationMessageType;
        challengeRequestPublishTimestamp?: number;
        challengeAnswerPublishTimestamp?: number;
        signer?: Signer;
        challengeRequestPublishError?: Error;
        challengeAnswerPublishError?: Error;
        providerUrl: string;
    }>;
    private _publishToDifferentProviderThresholdSeconds;
    private _setProviderFailureThresholdSeconds;
    private _rpcPublishSubscriptionId?;
    _clientsManager: PublicationClientsManager;
    _pkc: PKC;
    constructor(pkc: PKC);
    protected _initClients(): void;
    setCommunityAddress(communityAddress: string): void;
    _initBaseRemoteProps(props: CommentIpfsType | PublicationFromDecryptedChallengeRequest): void;
    _initUnsignedLocalProps<T extends {
        signer: SignerType;
        communityAddress: string;
        communityPublicKey?: string;
        communityName?: string;
        timestamp: number;
        protocolVersion: string;
        author?: Record<string, unknown>;
    }>(opts: {
        unsignedOptions: T;
        challengeRequest?: CreatePublicationOptions["challengeRequest"];
    }): void;
    protected _signPublicationOptionsToPublish(_cleanedPublication: unknown): Promise<PublicationFromDecryptedChallengeRequest["signature"]>;
    private _signPublication;
    _signPublicationWithCommunityFields(): Promise<void>;
    _signPublicationWithKnownCommunityFieldsIfAvailable(): Promise<void>;
    protected _validateSignatureHook(): Promise<void>;
    protected _verifyDecryptedChallengeVerificationAndUpdateCommentProps(decryptedVerification: DecryptedChallengeVerification): Promise<void>;
    protected getType(): PublicationTypeName;
    toJSONPubsubRequestToEncrypt(): DecryptedChallengeRequest;
    private _handleRpcChallengeVerification;
    private _handleIncomingChallengePubsubMessage;
    private _handleIncomingChallengeVerificationPubsubMessage;
    private _handleChallengeExchange;
    private _updatePubsubState;
    publishChallengeAnswers({ challengeAnswers }: {
        challengeAnswers: DecryptedChallengeAnswerMessageType["challengeAnswers"];
    }): Promise<{
        success: true;
    } | undefined>;
    private _validatePublicationFields;
    private _validateCommunityFields;
    _updatePublishingStateNoEmission(newState: Publication["publishingState"]): void;
    _updatePublishingStateWithEmission(newState: Publication["publishingState"]): void;
    private _updateRpcClientStateFromPublishingState;
    protected _setStateNoEmission(newState: Publication["state"]): void;
    protected _setStateWithEmission(newState: Publication["state"]): void;
    protected _setRpcClientState(newState: Publication["clients"]["pkcRpcClients"][""]["state"]): void;
    private _communityPubsubTopicWithFallback;
    _getCommunityCache(): NonNullable<Publication["_community"]> | undefined;
    _fetchCommunityForPublishing(): Promise<NonNullable<Publication["_community"]>>;
    stop(): Promise<void>;
    _isAllAttemptsExhausted(maxNumOfChallengeExchanges: number): boolean;
    private _postSucessOrFailurePublishing;
    private _handleIncomingChallengeRequestFromRpc;
    private _handleIncomingChallengeFromRpc;
    private _handleIncomingChallengeAnswerFromRpc;
    private _handleIncomingChallengeVerificationFromRpc;
    private _handleIncomingPublishingStateFromRpc;
    private _handleIncomingStateFromRpc;
    private _handleIncomingErrorFromRpc;
    _publishWithRpc(): Promise<void>;
    private _changePublicationStateEmitEventEmitStateChangeEvent;
    private _signAndValidateChallengeRequestBeforePublishing;
    private _didWeReceiveChallengeOrChallengeVerification;
    private _generateChallengeRequestToPublish;
    _initCommunity(): Promise<void>;
    private _challengeExchangesFormattedForErrors;
    private _libp2pJsClientHeliaContexts;
    private _handleNotReceivingResponseToChallengeRequest;
    private _getPubsubProviders;
    private _publishWithLocalCommunity;
    publish(): Promise<void>;
}
export default Publication;
