import { CancellationToken } from "../../../../base/common/cancellation.js";
import { Event } from "../../../../base/common/event.js";
import { IDisposable } from "../../../../base/common/lifecycle.js";
import { IObservable, IReader, ITransaction } from "../../../../base/common/observable.js";
import { URI } from "../../../../base/common/uri.js";
import { TextEdit } from "../../../../editor/common/languages.js";
import { RawContextKey } from "../../../../platform/contextkey/common/contextkey.js";
import { IEditorPane } from "../../../common/editor.js";
import { ICellEditOperation } from "../../notebook/common/notebookCommon.js";
import { IChatResponseModel } from "./chatModel.js";
export interface IChatRequestDraft {
    readonly prompt: string;
    readonly files: readonly URI[];
}
export interface IChatRelatedFileProviderMetadata {
    readonly description: string;
}
export interface IChatRelatedFile {
    readonly uri: URI;
    readonly description: string;
}
export interface IChatRelatedFilesProvider {
    readonly description: string;
    provideRelatedFiles(chatRequest: IChatRequestDraft, token: CancellationToken): Promise<IChatRelatedFile[] | undefined>;
}
export interface WorkingSetDisplayMetadata {
    state: ModifiedFileEntryState;
    description?: string;
}
export interface IStreamingEdits {
    pushText(edits: TextEdit[]): void;
    pushNotebookCellText(cell: URI, edits: TextEdit[]): void;
    pushNotebook(edits: ICellEditOperation[]): void;
    complete(): void;
}
export declare const chatEditingSnapshotScheme = "chat-editing-snapshot-text-model";
export interface IChatEditingSession extends IDisposable {
    readonly isGlobalEditingSession: boolean;
    readonly chatSessionId: string;
    readonly onDidDispose: Event<void>;
    readonly state: IObservable<ChatEditingSessionState>;
    readonly entries: IObservable<readonly IModifiedFileEntry[]>;
    show(previousChanges?: boolean): Promise<void>;
    remove(...uris: URI[]): void;
    accept(...uris: URI[]): Promise<void>;
    reject(...uris: URI[]): Promise<void>;
    getEntry(uri: URI): IModifiedFileEntry | undefined;
    readEntry(uri: URI, reader?: IReader): IModifiedFileEntry | undefined;
    restoreSnapshot(requestId: string, stopId: string | undefined): Promise<void>;
    getSnapshotUri(requestId: string, uri: URI, stopId: string | undefined): URI | undefined;
    stop(clearState?: boolean): Promise<void>;
    startStreamingEdits(resource: URI, responseModel: IChatResponseModel, inUndoStop: string | undefined): IStreamingEdits;
    getEntryDiffBetweenStops(uri: URI, requestId: string | undefined, stopId: string | undefined): IObservable<IEditSessionEntryDiff | undefined> | undefined;
    readonly canUndo: IObservable<boolean>;
    readonly canRedo: IObservable<boolean>;
    undoInteraction(): Promise<void>;
    redoInteraction(): Promise<void>;
}
export interface IEditSessionEntryDiff {
    originalURI: URI;
    modifiedURI: URI;
    quitEarly: boolean;
    identical: boolean;
    added: number;
    removed: number;
}
export declare enum ModifiedFileEntryState {
    Modified = 0,
    Accepted = 1,
    Rejected = 2
}
export interface IModifiedFileEntryChangeHunk {
    accept(): Promise<boolean>;
    reject(): Promise<boolean>;
}
export interface IModifiedFileEntryEditorIntegration extends IDisposable {
    currentIndex: IObservable<number>;
    reveal(firstOrLast: boolean, preserveFocus?: boolean): void;
    next(wrap: boolean): boolean;
    previous(wrap: boolean): boolean;
    enableAccessibleDiffView(): void;
    acceptNearestChange(change?: IModifiedFileEntryChangeHunk): Promise<void>;
    rejectNearestChange(change?: IModifiedFileEntryChangeHunk): Promise<void>;
    toggleDiff(change: IModifiedFileEntryChangeHunk | undefined, show?: boolean): Promise<void>;
}
export interface IModifiedFileEntry {
    readonly entryId: string;
    readonly originalURI: URI;
    readonly modifiedURI: URI;
    readonly lastModifyingRequestId: string;
    readonly state: IObservable<ModifiedFileEntryState>;
    readonly isCurrentlyBeingModifiedBy: IObservable<IChatResponseModel | undefined>;
    readonly lastModifyingResponse: IObservable<IChatResponseModel | undefined>;
    readonly rewriteRatio: IObservable<number>;
    accept(transaction: ITransaction | undefined): Promise<void>;
    reject(transaction: ITransaction | undefined): Promise<void>;
    reviewMode: IObservable<boolean>;
    autoAcceptController: IObservable<{
        total: number;
        remaining: number;
        cancel(): void;
    } | undefined>;
    enableReviewModeUntilSettled(): void;
    readonly changesCount: IObservable<number>;
    getEditorIntegration(editor: IEditorPane): IModifiedFileEntryEditorIntegration;
}
export interface IChatEditingSessionStream {
    textEdits(resource: URI, textEdits: TextEdit[], isLastEdits: boolean, responseModel: IChatResponseModel): void;
    notebookEdits(resource: URI, edits: ICellEditOperation[], isLastEdits: boolean, responseModel: IChatResponseModel): void;
}
export declare enum ChatEditingSessionState {
    Initial = 0,
    StreamingEdits = 1,
    Idle = 2,
    Disposed = 3
}
export declare const CHAT_EDITING_MULTI_DIFF_SOURCE_RESOLVER_SCHEME = "chat-editing-multi-diff-source";
export declare const chatEditingWidgetFileStateContextKey: RawContextKey<ModifiedFileEntryState>;
export declare const chatEditingAgentSupportsReadonlyReferencesContextKey: RawContextKey<boolean>;
export declare const decidedChatEditingResourceContextKey: RawContextKey<string[]>;
export declare const chatEditingResourceContextKey: RawContextKey<string | undefined>;
export declare const inChatEditingSessionContextKey: RawContextKey<boolean | undefined>;
export declare const hasUndecidedChatEditingResourceContextKey: RawContextKey<boolean | undefined>;
export declare const hasAppliedChatEditsContextKey: RawContextKey<boolean | undefined>;
export declare const applyingChatEditsFailedContextKey: RawContextKey<boolean | undefined>;
export declare const chatEditingMaxFileAssignmentName = "chatEditingSessionFileLimit";
export declare const defaultChatEditingMaxFileLimit = 10;
export declare enum ChatEditKind {
    Created = 0,
    Modified = 1
}
export interface IChatEditingActionContext {
    sessionId: string;
}
export declare function isChatEditingActionContext(thing: unknown): thing is IChatEditingActionContext;
export declare function getMultiDiffSourceUri(session: IChatEditingSession, showPreviousChanges?: boolean): URI;
export declare function parseChatMultiDiffUri(uri: URI): {
    chatSessionId: string;
    showPreviousChanges: boolean;
};
