import Logger from "../../../logger.js";
import { PKC } from "../../../pkc/pkc.js";
import type { CommunityEditOptions, CreateNewLocalCommunityParsedOptions, InternalCommunityRecordBeforeFirstUpdateType, InternalCommunityRecordAfterFirstUpdateType, ParsedCommunityEditOptions, CommunityChallengeSetting, CommunityIpfsType, RpcInternalCommunityRecordBeforeFirstUpdateType, RpcInternalCommunityRecordAfterFirstUpdateType, CommunityEvents } from "../../../community/types.js";
import { LRUCache } from "lru-cache";
import { PageGenerator } from "./page-generator.js";
import { DbHandler } from "./db-handler.js";
import type { ChallengeAnswerMessageType, ChallengeRequestMessageType, DecryptedChallengeAnswer, DecryptedChallengeRequestMessageType } from "../../../pubsub-messages/types.js";
import type { IpfsHttpClientPubsubMessage } from "../../../types.js";
import { SignerWithPublicKeyAddress } from "../../../signer/index.js";
import { RpcLocalCommunity } from "../../../community/rpc-local-community.js";
import type { CommentsTableRow } from "../../../publications/comment/types.js";
import { AllPageCids } from "../../../pages/types.js";
import { createNewLocalCommunityDb, updateDbInternalState, updateInstancePropsWithStartedCommunityOrDb } from "./local-community/db-state.js";
export { createNewLocalCommunityDb, updateInstancePropsWithStartedCommunityOrDb };
import { publishChallengeVerification, publishIdempotentDuplicateVerification } from "./local-community/challenges.js";
import { checkPublicationValidity } from "./local-community/publication-validation.js";
import { calculateLocalMfsPathForCommentUpdate } from "./local-community/comment-updates.js";
import { addOldPageCidsToCidsToUnpin, updateCommunityIpnsIfNeeded } from "./local-community/ipns-publishing.js";
import type { InternalExportHandle } from "./local-community/export.js";
import type { CommunityExportRecord, ExportCommunityUserOptions, ExportCommunityModLogsOptions } from "../../../community/types.js";
import type { CommentModerationTableRow } from "../../../publications/comment-moderation/types.js";
export declare class LocalCommunity extends RpcLocalCommunity implements CreateNewLocalCommunityParsedOptions {
    signer: SignerWithPublicKeyAddress;
    raw: RpcLocalCommunity["raw"];
    _postUpdatesBuckets: number[];
    _defaultCommunityChallenges: CommunityChallengeSetting[];
    _challengeAnswerPromises: LRUCache<string, Promise<DecryptedChallengeAnswer["challengeAnswers"]>>;
    _challengeAnswerResolveReject: LRUCache<string, {
        resolve: (answers: DecryptedChallengeAnswer["challengeAnswers"]) => void;
        reject: (error: Error) => void;
    }>;
    _ongoingChallengeExchanges: LRUCache<string, boolean>;
    _duplicatePublicationAttempts: LRUCache<string, number>;
    _challengeExchangesFromLocalPublishers: Record<string, boolean>;
    _cidsToUnPin: Set<string>;
    _mfsPathsToRemove: Set<string>;
    _communityUpdateTrigger: boolean;
    _combinedHashOfPendingCommentsCids: string;
    _pageGenerator: PageGenerator;
    _dbHandler: DbHandler;
    _stopHasBeenCalled: boolean;
    _publishLoopPromise?: Promise<void>;
    _updateLoopPromise?: Promise<void>;
    _updateLoopAbortController?: AbortController;
    _firstUpdateAfterStart: boolean;
    _internalStateUpdateId: InternalCommunityRecordBeforeFirstUpdateType["_internalStateUpdateId"];
    _lastPubsubTopicRoutingProvideAt?: number;
    _mirroredStartedOrUpdatingCommunity?: {
        community: LocalCommunity;
    } & Pick<CommunityEvents, "error" | "updatingstatechange" | "update" | "statechange" | "startedstatechange" | "challengerequest" | "challengeverification" | "challenge" | "challengeanswer">;
    _pendingEditProps: Partial<ParsedCommunityEditOptions & {
        editId: string;
    }>[];
    _blocksToRm: string[];
    _postsAllPageCids: AllPageCids | undefined;
    _exports: CommunityExportRecord[];
    _activeExports: Map<string, InternalExportHandle>;
    _exportQueue: Promise<void>;
    constructor(pkc: PKC);
    toJSONInternalAfterFirstUpdate(): InternalCommunityRecordAfterFirstUpdateType;
    toJSONInternalBeforeFirstUpdate(): InternalCommunityRecordBeforeFirstUpdateType;
    toJSONInternalRpcAfterFirstUpdate(): RpcInternalCommunityRecordAfterFirstUpdateType;
    toJSONInternalRpcBeforeFirstUpdate(): RpcInternalCommunityRecordBeforeFirstUpdateType;
    _updateStartedValue(): Promise<void>;
    initNewLocalCommunityPropsNoMerge(newProps: CreateNewLocalCommunityParsedOptions): Promise<void>;
    initInternalCommunityAfterFirstUpdateNoMerge(newProps: InternalCommunityRecordAfterFirstUpdateType): Promise<void>;
    initInternalCommunityBeforeFirstUpdateNoMerge(newProps: InternalCommunityRecordBeforeFirstUpdateType): Promise<void>;
    initDbHandlerIfNeeded(): Promise<void>;
    _validateCommunitySizeSchemaAndSignatureBeforePublishing(recordToPublishRaw: CommunityIpfsType): Promise<void>;
    handleChallengeRequest(request: ChallengeRequestMessageType, isLocalPublisher: boolean): Promise<void>;
    handleChallengeAnswer(challengeAnswer: ChallengeAnswerMessageType): Promise<void>;
    handleChallengeExchange(pubsubMsg: IpfsHttpClientPubsubMessage): Promise<void>;
    _addCommentRowToIPFS(unpinnedCommentRow: CommentsTableRow, log: Logger): Promise<void>;
    _assertDomainResolvesCorrectly(newAddressAsDomain: string): Promise<void>;
    start(): Promise<void>;
    update(): Promise<void>;
    stop(): Promise<void>;
    delete(): Promise<void>;
    edit(newCommunityOptions: CommunityEditOptions): Promise<typeof this>;
    get exports(): CommunityExportRecord[];
    export(options?: ExportCommunityUserOptions): Promise<{
        exportId: string;
    }>;
    exportCommunityModLogs(opts?: ExportCommunityModLogsOptions): Promise<{
        moderations: CommentModerationTableRow[];
    }>;
    _cancelExport(exportId: string): Promise<void>;
    _deleteExport(exportId: string): Promise<void>;
    _loadExportsFromKeyv(): Promise<void>;
    _getDbInternalState(includeMutable?: boolean): Promise<InternalCommunityRecordBeforeFirstUpdateType | InternalCommunityRecordAfterFirstUpdateType>;
    _listenToIncomingRequests(): Promise<void>;
    _repinCommentsIPFSIfNeeded(): Promise<void>;
    storePublication(request: DecryptedChallengeRequestMessageType, pendingApproval?: boolean): Promise<{
        comment: import("../../../publications/comment/types.js").CommentIpfsType;
        cid: import("../../../publications/comment/types.js").CommentUpdateType["cid"];
    } | undefined>;
    updateCommunityIpnsIfNeeded(args: {
        commentUpdateRowsToPublishToIpfs: Parameters<typeof updateCommunityIpnsIfNeeded>[1];
    }): Promise<void>;
    _addOldPageCidsToCidsToUnpin(curPages: Parameters<typeof addOldPageCidsToCidsToUnpin>[1], newPages: Parameters<typeof addOldPageCidsToCidsToUnpin>[2], addToBlockRm?: boolean): Promise<void>;
    private shouldResolveDomainForVerification;
    _calculateNewPostUpdates(): Promise<Record<string, string> | undefined>;
    _calculateLatestUpdateTrigger(): void;
    _resolveIpnsAndLogIfPotentialProblematicSequence(): Promise<void>;
    _updateDbInternalState(props: Parameters<typeof updateDbInternalState>[1]): Promise<InternalCommunityRecordBeforeFirstUpdateType | InternalCommunityRecordAfterFirstUpdateType>;
    _updateCommentsThatNeedToBeUpdated(): Promise<import("./local-community/defaults.js").CommentUpdateToWriteToDbAndPublishToIpfs[]>;
    _purgeDisapprovedCommentsOlderThan(): Promise<void>;
    _publishChallengeVerification(challengeResult: Parameters<typeof publishChallengeVerification>[1], request: Parameters<typeof publishChallengeVerification>[2]): Promise<void>;
    _publishIdempotentDuplicateVerification(...args: Parameters<typeof publishIdempotentDuplicateVerification> extends [unknown, ...infer Rest] ? Rest : never): Promise<void>;
    _checkPublicationValidity(...args: Parameters<typeof checkPublicationValidity> extends [unknown, ...infer Rest] ? Rest : never): Promise<import("../../../errors.js").messages | undefined>;
    _calculateLocalMfsPathForCommentUpdate(...args: Parameters<typeof calculateLocalMfsPathForCommentUpdate> extends [unknown, ...infer Rest] ? Rest : never): string;
}
