import { GuidString, Id64String } from "@itwin/core-bentley";
import { BriefcaseId, ChangesetFileProps, ChangesetId, ChangesetIdWithIndex, ChangesetIndex, ChangesetIndexOrId, ChangesetProps, ChangesetRange, LocalDirName, LocalFileName, LockState } from "@itwin/core-common";
import { LockMap, LockProps } from "./BackendHubAccess";
/** @internal */
interface MockBriefcaseIdProps {
    id: BriefcaseId;
    user: string;
    alias: string;
    assigned: boolean;
}
/** @internal */
interface LocalHubProps {
    readonly iTwinId: GuidString;
    readonly iModelId: GuidString;
    readonly iModelName: string;
    readonly description?: string;
    readonly version0?: string;
    readonly noLocks?: true;
}
interface LocksEntry {
    id: Id64String;
    level: LockState;
    lastCsIndex?: ChangesetIndex;
    briefcaseId?: BriefcaseId;
}
interface LockStatusNone {
    state: LockState.None;
    lastCsIndex?: ChangesetIndex;
}
/** @internal exported for tests. */
export interface LockStatusExclusive {
    state: LockState.Exclusive;
    briefcaseId: BriefcaseId;
    lastCsIndex?: ChangesetIndex;
}
/** @internal exported for tests. */
export interface LockStatusShared {
    state: LockState.Shared;
    sharedBy: Set<BriefcaseId>;
    lastCsIndex?: ChangesetIndex;
}
interface BriefcaseIdAndChangeset {
    changeset: ChangesetIdWithIndex;
    briefcaseId: BriefcaseId;
}
type LockStatus = LockStatusNone | LockStatusExclusive | LockStatusShared;
/**
 * A "local" mock for IModelHub to provide access to a single iModel. Used by HubMock.
 * @internal
 */
export declare class LocalHub {
    readonly rootDir: LocalDirName;
    readonly iTwinId: GuidString;
    readonly iModelId: GuidString;
    readonly iModelName: string;
    readonly description?: string;
    private _hubDb?;
    private _nextBriefcaseId;
    private _latestChangesetIndex;
    get latestChangesetIndex(): number;
    constructor(rootDir: LocalDirName, arg: LocalHubProps);
    private get db();
    get changesetDir(): string;
    get checkpointDir(): string;
    get mockDbName(): string;
    /** Acquire the next available briefcaseId and assign it to the supplied user */
    acquireNewBriefcaseId(user: string, alias?: string): BriefcaseId;
    /** Release a briefcaseId */
    releaseBriefcaseId(id: BriefcaseId): void;
    /** Get an array of all of the currently assigned Briefcases */
    getBriefcases(onlyAssigned?: boolean): MockBriefcaseIdProps[];
    /** Get an array of all of the currently assigned BriefcaseIds for a user */
    getBriefcaseIds(user: string): BriefcaseId[];
    getBriefcase(id: BriefcaseId): MockBriefcaseIdProps;
    private getChangesetFileName;
    /** Add a changeset to the timeline
     * @return the changesetIndex of the added changeset
     */
    addChangeset(changeset: ChangesetFileProps): ChangesetIndex;
    getIndexFromChangeset(changeset: ChangesetIndexOrId): ChangesetIndex;
    /** Get the index of a changeset by its Id */
    getChangesetIndex(id: ChangesetId): ChangesetIndex;
    /** Get the properties of a changeset by its Id */
    getChangesetById(id: ChangesetId): ChangesetProps;
    getPreviousIndex(index: ChangesetIndex): number;
    getParentId(index: ChangesetIndex): ChangesetId;
    /** Get the properties of a changeset by its index */
    getChangesetByIndex(index: ChangesetIndex): ChangesetProps;
    getLatestChangeset(): ChangesetProps;
    getChangesetId(index: ChangesetIndex): ChangesetId;
    /** Get an array of changesets starting with first to last, by index */
    queryChangesets(range?: ChangesetRange): ChangesetProps[];
    /** Name a version */
    addNamedVersion(arg: {
        versionName: string;
        csIndex: ChangesetIndex;
    }): void;
    /** Delete a named version */
    deleteNamedVersion(versionName: string): void;
    /** find the changeset for a named version */
    findNamedVersion(versionName: string): ChangesetProps;
    checkpointNameFromIndex(csIndex: ChangesetIndex): string;
    /** "upload" a checkpoint */
    uploadCheckpoint(arg: {
        changesetIndex: ChangesetIndex;
        localFile: LocalFileName;
    }): string;
    /** Get an array of the indexes for a range of checkpoints */
    getCheckpoints(range?: ChangesetRange): ChangesetIndex[];
    /** Find the checkpoint that is no newer than a changesetIndex */
    queryPreviousCheckpoint(changesetIndex: ChangesetIndex): ChangesetIndex;
    /** "download" a checkpoint */
    downloadCheckpoint(arg: {
        changeset: ChangesetIndexOrId;
        targetFile: LocalFileName;
    }): {
        index: number;
        id: string;
    };
    private copyChangeset;
    /** "download" a changeset */
    downloadChangeset(arg: {
        index: ChangesetIndex;
        targetDir: LocalDirName;
    }): ChangesetFileProps;
    /** "download" all the changesets in a given range */
    downloadChangesets(arg: {
        range?: ChangesetRange;
        targetDir: LocalDirName;
    }): ChangesetFileProps[];
    private querySharedLockHolders;
    queryAllLocks(briefcaseId: BriefcaseId): LockProps[];
    queryLockStatus(elementId: Id64String): LockStatus;
    private reserveLock;
    private clearLock;
    private updateLockChangeset;
    private requestLock;
    private removeSharedLock;
    private releaseLock;
    /** Acquire a set of locks. If any lock cannot be acquired, no locks are acquired  */
    acquireLocks(locks: LockMap, briefcase: BriefcaseIdAndChangeset): void;
    acquireLock(props: LockProps, briefcase: BriefcaseIdAndChangeset): void;
    releaseLocks(locks: LockProps[], arg: {
        briefcaseId: BriefcaseId;
        changesetIndex: ChangesetIndex;
    }): void;
    releaseAllLocks(arg: {
        briefcaseId: BriefcaseId;
        changesetIndex: ChangesetIndex;
    }): void;
    private countTable;
    countSharedLocks(): number;
    countLocks(): number;
    queryAllSharedLocks(): {
        id: Id64String;
        briefcaseId: BriefcaseId;
    }[];
    queryLocks(): LocksEntry[];
    removeDir(dirName: string): void;
    cleanup(): void;
}
export {};
//# sourceMappingURL=LocalHub.d.ts.map