import type { CommandStartEvent, CommandCompleteEvent, KResponse, ScalarResponse } from '@kui-shell/core';
import { isError } from '@kui-shell/core/mdist/api/Response';
export { isError };
export declare const enum BlockState {
    Active = "repl-active",
    Cancelled = "cancelled",
    Empty = "empty",
    Error = "error",
    Processing = "processing",
    ValidResponse = "valid-response"
}
/** Traits that Blocks might have */
type WithCWD = {
    cwd: string;
};
type WithUUID = {
    execUUID: string;
};
type WithOriginalExecUUID = {
    originalExecUUID: string;
};
type WithCommand = {
    command: string;
    isExperimental?: boolean;
} & WithCWD;
type WithStartTime = {
    startTime: number;
};
type WithState<S extends BlockState> = {
    state: S;
};
type WithResponse<R extends KResponse> = {
    response: R;
} & WithStartTime;
type WithValue = {
    value: string;
};
type WithAnnouncement = {
    isAnnouncement: boolean;
    maximized?: boolean;
};
type WithOutputOnly<T extends boolean = boolean> = {
    outputOnly: T;
};
type WithCommandStart = {
    startEvent: CommandStartEvent;
};
type WithCommandComplete = {
    completeEvent: CommandCompleteEvent;
};
type WithRerun = {
    isRerun: true;
    newExecUUID: string;
} & WithOriginalExecUUID;
type WithReplay = {
    isReplay: boolean;
};
/** Blocks with an association to the History model */
type WithHistoryIndex = {
    historyIdx: number;
};
/** The canonical types of Blocks, which mix up the Traits as needed */
export type ActiveBlock = WithState<BlockState.Active> & WithCWD & WithUUID & Partial<WithValue>;
export type AnnouncementBlock = WithState<BlockState.ValidResponse> & WithResponse<ScalarResponse> & WithCWD & WithUUID & WithOutputOnly<true> & WithAnnouncement;
type EmptyBlock = WithState<BlockState.Empty> & WithCWD & Partial<WithCommand> & Partial<WithCommandComplete>;
type ErrorBlock = WithState<BlockState.Error> & WithCommand & WithResponse<Error> & WithUUID & WithHistoryIndex & WithCommandStart & Partial<WithRerun> & WithReplay & WithCommandComplete;
type OkBlock = WithState<BlockState.ValidResponse> & WithCommand & WithResponse<KResponse> & WithUUID & WithHistoryIndex & WithCommandStart & WithCommandComplete & Partial<WithRerun> & WithReplay & WithOutputOnly;
export type ProcessingBlock = WithState<BlockState.Processing> & WithCommand & WithUUID & WithStartTime & Partial<WithOriginalExecUUID> & WithReplay & WithCommandStart;
type CancelledBlock = WithState<BlockState.Cancelled> & WithCWD & WithCommand & WithUUID & WithStartTime;
export type CompleteBlock = OkBlock | ErrorBlock;
/** A Block may be Rerunable. If so, then it can be transitioned to the BlockBeingRerun state. */
type RerunableBlock = CompleteBlock;
type BlockBeingRerun = RerunableBlock & WithRerun;
/** FinishedBlocks are either ok, error, or cancelled */
export type FinishedBlock = OkBlock | ErrorBlock | CancelledBlock | EmptyBlock;
export type BlockModel = ProcessingBlock | FinishedBlock | CancelledBlock | ActiveBlock | AnnouncementBlock;
export default BlockModel;
export declare function isProcessing(block: BlockModel): block is ProcessingBlock;
export declare function isActive(block: BlockModel): block is ActiveBlock;
/** @return true if the given `block` is `Active` and differs from the other `oblock` */
export declare function isActiveAndDifferent(block: BlockModel, oblock: BlockModel): block is ActiveBlock;
export declare function isCancelled(block: BlockModel): block is CancelledBlock;
export declare function isEmpty(block: BlockModel): block is EmptyBlock;
export declare function isOk(block: BlockModel): block is OkBlock;
export declare function isOops(block: BlockModel): block is ErrorBlock;
export declare function isFinished(block: BlockModel): block is FinishedBlock;
export declare function hasCommand(block: BlockModel & Partial<WithCommand>): block is BlockModel & Required<WithCommand>;
export declare function isAnnouncement(block: BlockModel): block is AnnouncementBlock;
export declare function hasUUID(block: BlockModel & Partial<WithUUID>): block is BlockModel & Required<WithUUID>;
export declare function hasValue(block: BlockModel): block is BlockModel & Required<WithValue>;
/** Transform to Active */
export declare function Active(initialValue?: string): ActiveBlock;
/** Transform to AnnouncementBlock */
export declare function Announcement(response: ScalarResponse, execUUID?: string, maximized?: boolean): AnnouncementBlock;
export declare function isRerunable(block: BlockModel): block is RerunableBlock;
export declare function isBeingRerun(block: BlockModel): block is BlockBeingRerun;
export declare function isProcessingOrBeingRerun(block: BlockModel): block is ProcessingBlock | BlockBeingRerun;
export declare function hasOriginalUUID(block: BlockModel | WithOriginalExecUUID): block is WithOriginalExecUUID;
/** Useful e.g. when reloading a snapshot, to clear out any prior "has been rerun" state */
export declare function clearOriginalUUID(block: WithOriginalExecUUID): void;
/** @return whether the block has a completeEvent trait */
export declare function isWithCompleteEvent(block: BlockModel): block is CompleteBlock;
export declare function hasBeenRerun(block: BlockModel): boolean;
/** @return whether the block is from replay */
export declare function isReplay(block: BlockModel): boolean;
/** Transform to Processing */
export declare function Processing(block: BlockModel, startEvent: CommandStartEvent, isExperimental?: boolean, _isReplay?: boolean): ProcessingBlock;
/** Transform to Empty */
export declare function Empty(block: BlockModel, typedSoFar?: string, completeEvent?: CommandCompleteEvent): EmptyBlock;
/** Transform to Cancelled */
export declare function Cancelled(block: BlockModel, typedSoFar?: string, completeEvent?: CommandCompleteEvent): CancelledBlock | EmptyBlock;
/** Transform to Finished */
export declare function Finished(block: ProcessingBlock | BlockBeingRerun, event: CommandCompleteEvent, outputOnly?: boolean, _isReplay?: boolean): FinishedBlock;
export declare function isOutputOnly(block: BlockModel): boolean;
/** @return whether the block as a startEvent trait */
export declare function hasStartEvent(block: BlockModel): block is BlockModel & WithCommandStart;
/** @return whether the output of this command execution be redirected to a file */
export declare function isOutputRedirected(block: BlockModel): boolean;
/** Transform a RerunableBlock to one in the BlockBeingRerun state */
export declare function Rerun(block: RerunableBlock, newStartEvent?: CommandStartEvent, newCommand?: string, newStartTime?: number): RerunableBlock & Required<WithRerun>;
/** this implements support for not showing the Output blocks when replaying a notebook */
export declare function hideOutput(model: BlockModel): boolean;
export declare function isMaximized(model: BlockModel): boolean;
