import { F } from "../util/Utils.js";
import { Worker } from "../Worker.js";
import { SnapshotOptions } from "../Options.js";
import { ObjectHandle, ObjectVersion, OperationFootprint, ContentFootprint, FieldKey } from "./Data.js";
import { Changeset } from "./Changeset.js";
export declare abstract class Transaction implements Worker {
    static get current(): Transaction;
    abstract readonly id: number;
    abstract readonly name: string;
    abstract readonly caption: string;
    abstract readonly options: SnapshotOptions;
    abstract readonly timestamp: number;
    abstract readonly error: Error | undefined;
    abstract readonly changeset: Changeset;
    abstract readonly margin: number;
    abstract readonly parent?: Transaction;
    abstract run<T>(func: F<T>, ...args: any[]): T;
    abstract inspect<T>(func: F<T>, ...args: any[]): T;
    abstract apply(): void;
    abstract seal(): this;
    abstract wrapAsPending<T>(func: F<T>, secondary: boolean): F<T>;
    abstract cancel(error: Error, retryAfterOrIgnore?: Worker | null): this;
    abstract readonly isCanceled: boolean;
    abstract readonly isFinished: boolean;
    whenFinished(includingParent?: boolean): Promise<void>;
    static create(options: SnapshotOptions | null, parent?: Transaction): Transaction;
    static run<T>(options: SnapshotOptions | null, func: F<T>, ...args: any[]): T;
    static isolate<T>(func: F<T>, ...args: any[]): T;
    static outside<T>(func: F<T>, ...args: any[]): T;
    static isFrameOver(everyN?: number, timeLimit?: number): boolean;
    static requestNextFrame(sleepTime?: number): Promise<void>;
    static get isCanceled(): boolean;
}
export declare class TransactionImpl extends Transaction {
    private static readonly none;
    private static gCurr;
    private static isInspectionMode;
    private static frameStartTime;
    private static frameOverCounter;
    readonly margin: number;
    readonly parent?: TransactionImpl;
    readonly changeset: Changeset;
    private pending;
    private sealed;
    private canceled?;
    private after?;
    private promise?;
    private resolve;
    private reject;
    constructor(options: SnapshotOptions | null, parent?: TransactionImpl);
    static get curr(): TransactionImpl;
    get id(): number;
    get name(): string;
    get caption(): string;
    get options(): SnapshotOptions;
    get timestamp(): number;
    get error(): Error | undefined;
    run<T>(func: F<T>, ...args: any[]): T;
    inspect<T>(func: F<T>, ...args: any[]): T;
    apply(): void;
    seal(): this;
    wrapAsPending<T>(func: F<T>, secondary: boolean): F<T>;
    private static preparePendingFunction;
    private static runPendingFunction;
    cancel(error: Error, restartAfter?: Worker | null): this;
    get isCanceled(): boolean;
    get isFinished(): boolean;
    whenFinished(includingParent?: boolean): Promise<void>;
    static run<T>(options: SnapshotOptions | null, func: F<T>, ...args: any[]): T;
    static isolate<T>(func: F<T>, ...args: any[]): T;
    static outside<T>(func: F<T>, ...args: any[]): T;
    static isFrameOver(everyN?: number, timeLimit?: number): boolean;
    static requestNextFrame(sleepTime?: number): Promise<void>;
    private static acquire;
    private guard;
    private wrapToRetry;
    private wrapToWaitUntilFinish;
    private runImpl;
    private static seal;
    private checkForConflicts;
    private tryResolveConflicts;
    private applyOrDiscard;
    applyOrDiscardChangeset(): Array<OperationFootprint>;
    applyObjectChanges(h: ObjectHandle, ov: ObjectVersion): void;
    static migrateObjectChangesToAnotherTransaction(h: ObjectHandle, ov: ObjectVersion, tParent: Transaction): void;
    static migrateFieldVersionToAnotherTransaction(h: ObjectHandle, fk: FieldKey, ov: ObjectVersion, ovParent: ObjectVersion, tParent: Transaction): void;
    private acquirePromise;
    private static getCurrentChangeset;
    private static getEditableChangeset;
    static migrateContentFootprint: (fv: ContentFootprint, target: Transaction) => ContentFootprint;
    static _init(): void;
}
