import { IConfigurationService } from '../../../platform/configuration/common/configurationService';
import { DocumentId } from '../../../platform/inlineEdits/common/dataTypes/documentId';
import { ObservableWorkspace } from '../../../platform/inlineEdits/common/observableWorkspace';
import { ILogService } from '../../../platform/log/common/logService';
import { IExperimentationService } from '../../../platform/telemetry/common/nullExperimentationService';
import { Disposable } from '../../../util/vs/base/common/lifecycle';
import { AnnotatedStringReplacement, StringEdit, StringReplacement } from '../../../util/vs/editor/common/core/edits/stringEdit';
import { OffsetRange } from '../../../util/vs/editor/common/core/ranges/offsetRange';
import { StringText } from '../../../util/vs/editor/common/core/text/abstractText';
import { EditDataWithIndex } from '../common/editRebase';
import { NextEditFetchRequest } from './nextEditProvider';
import { type RebaseResult } from './rebaseResult';
export interface CachedEditOpts {
    isFromCursorJump: boolean;
    /**
     * For cursor jump edits, this is the edit window around the original cursor position
     * (before the jump), allowing the edit to be served from cache when the cursor is
     * in either the original location or the jump target location.
     */
    originalEditWindow?: OffsetRange;
    /**
     * The cursor offset at the time the edit was cached.
     * Used for cursor-distance filtering: if the user moves farther from the edit,
     * the cached entry is not served.
     */
    cursorOffset?: number;
}
export interface CachedEdit {
    docId: DocumentId;
    documentBeforeEdit: StringText;
    editWindow?: OffsetRange;
    /**
     * For cursor jump edits, the edit window around the original cursor position.
     * @see CachedEditOpts.originalEditWindow
     */
    originalEditWindow?: OffsetRange;
    edit: StringReplacement | undefined;
    isFromCursorJump: boolean;
    edits?: StringReplacement[];
    detailedEdits: AnnotatedStringReplacement<EditDataWithIndex>[][];
    userEditSince?: StringEdit;
    rebaseFailed?: boolean;
    rejected?: boolean;
    /**
     * When caching multiple edits, this is the order in which they were applied.
     */
    subsequentN?: number;
    source: NextEditFetchRequest;
    cacheTime: number;
    /**
     * The cursor offset at the time the edit was cached.
     * @see CachedEditOpts.cursorOffset
     */
    cursorOffsetAtCacheTime?: number;
    /**
     * Set to `true` once this cached suggestion has been rendered as an inline
     * (ghost text at cursor) suggestion. Used by the "mimic ghost text behavior"
     * gating to suppress re-serving the same suggestion in a non-inline form.
     */
    wasRenderedAsInlineSuggestion?: boolean;
}
export type CachedOrRebasedEdit = CachedEdit & {
    rebasedEdit?: StringReplacement;
    rebasedEditIndex?: number;
    isFromSpeculativeRequest?: boolean;
    /**
     * When this is a rebased view of a cached edit, points to the underlying
     * stored {@link CachedEdit} so that flags such as
     * {@link CachedEdit.wasRenderedAsInlineSuggestion} can be persisted on the
     * stable cache entry instead of the transient rebased view.
     */
    baseCacheEntry?: CachedEdit;
};
export declare class NextEditCache extends Disposable {
    readonly workspace: ObservableWorkspace;
    private readonly _logService;
    private readonly _configService;
    private readonly _expService;
    private readonly _documentCaches;
    private readonly _sharedCache;
    constructor(workspace: ObservableWorkspace, _logService: ILogService, _configService: IConfigurationService, _expService: IExperimentationService);
    setKthNextEdit(docId: DocumentId, documentContents: StringText, editWindow: OffsetRange | undefined, nextEdit: StringReplacement, subsequentN: number, nextEdits: StringReplacement[] | undefined, userEditSince: StringEdit | undefined, source: NextEditFetchRequest, opts: CachedEditOpts): CachedEdit | undefined;
    setNoNextEdit(docId: DocumentId, documentContents: StringText, editWindow: OffsetRange | undefined, source: NextEditFetchRequest): void;
    private _getNesRebaseConfigs;
    lookupNextEdit(docId: DocumentId, currentDocumentContents: StringText, currentSelection: readonly OffsetRange[]): CachedOrRebasedEdit | undefined;
    tryRebaseCacheEntry(cachedEdit: CachedEdit, currentDocumentContents: StringText, currentSelection: readonly OffsetRange[]): RebaseResult;
    rejectedNextEdit(requestId: string): void;
    isRejectedNextEdit(docId: DocumentId, currentDocumentContents: StringText, edit: StringReplacement): boolean;
    evictedCachedEdit(cachedEdit: CachedEdit): void;
    clear(): void;
}
//# sourceMappingURL=nextEditCache.d.ts.map