import { TranspileDocumentError, TranspiledDocumentState } from './TranspileCommand.js';
import { CommandSetMessageHandlerDelegate, IMessageHandlerResult, MessageTransformer } from './Messages.js';
import { PrinterConfig } from './PrinterConfig.js';
import * as Conf from '../Configs/index.js';
import * as Commands from './Commands.js';
/** How a command should be wrapped into a form, if at all */
export declare enum CommandFormInclusionMode {
    /** Command can appear in a shared form with other commands. */
    sharedForm = 0,
    /** Command should not be wrapped in a form at all. */
    noForm = 1
}
/** Describes a command set for a printer. */
export interface CommandSet<TMsgType extends Conf.MessageArrayLike> {
    /** Handle the dispatch of a message received from the printer. */
    handleMessage<TReceived extends Conf.MessageArrayLike>(msg: TReceived, config: PrinterConfig, sentCommand?: Commands.IPrinterCommand): IMessageHandlerResult<TReceived>;
    /** Gets the command language this command set implements */
    get commandLanguage(): Conf.PrinterCommandLanguage;
    /** Gets the prefix to start a new document. */
    get documentStartPrefix(): TMsgType;
    /** Gets the suffix to end a document. */
    get documentEndSuffix(): TMsgType;
    /** Get expanded commands for a given command, if applicable. */
    expandCommand(cmd: Commands.IPrinterCommand): Commands.IPrinterCommand[];
    /** Determine if a given command must appear outside of a form. */
    isCommandNonFormCommand(cmd: Commands.IPrinterCommand): boolean;
    /** Combine separate commands into one. */
    combineCommands(...commands: TMsgType[]): TMsgType;
    /** Dispatch a message to the appropriate handler for it. */
    callMessageHandler(message: TMsgType, sentCommand?: Commands.IPrinterCommand): IMessageHandlerResult<TMsgType>;
    /** Expand a printer config to a language-specific config. */
    getConfig(config: PrinterConfig): PrinterConfig;
    /** Transpile a single command, tracking its effects to a document. */
    transpileCommand(cmd: Commands.IPrinterCommand, docMetadata: TranspiledDocumentState): TMsgType | TranspileDocumentError;
}
/** A method for transpiling a given command to its native command. */
export type TranspileCommandDelegate<TCmd extends Commands.IPrinterCommand, TMsgType extends Conf.MessageArrayLike> = (cmd: TCmd, docState: TranspiledDocumentState, commandSet: CommandSet<TMsgType>) => TMsgType | TranspileDocumentError;
/** A method for expanding one command into multiple other commands. */
export type CommandExpandDelegate<TCmd extends Commands.IPrinterCommand> = (cmd?: TCmd) => Commands.IPrinterCommand[];
/** A method for handling a response message to a command. */
export type MessageHandlerDelegate<TMsgType> = (msg: TMsgType, sentCommand: Commands.IPrinterCommand) => IMessageHandlerResult<TMsgType>;
/** A manifest for a printer command's behavior. */
export interface IPrinterCommandMapping<TMsgType extends Conf.MessageArrayLike> {
    /** The printer command being mapped. */
    commandType: Commands.CommandAnyType;
    /** Method to transpile this command to its native command. */
    transpile?: TranspileCommandDelegate<Commands.IPrinterCommand, TMsgType>;
    /** Method to replace a command with multiple other commands. */
    expand?: CommandExpandDelegate<Commands.IPrinterCommand>;
    /** Method to handle a message from the device in response to this command. */
    readMessage?: MessageHandlerDelegate<TMsgType>;
    /** Compatibility of this command with being included in a form. Defaults to true. */
    formInclusionMode?: CommandFormInclusionMode;
}
export declare abstract class PrinterCommandSet<TMsgType extends Conf.MessageArrayLike> implements CommandSet<TMsgType> {
    private cmdLanguage;
    get commandLanguage(): Conf.PrinterCommandLanguage;
    protected abstract get noop(): TMsgType;
    protected messageTransformer: MessageTransformer<TMsgType>;
    protected messageHandlerDelegate: CommandSetMessageHandlerDelegate<TMsgType>;
    protected commandMap: Map<Commands.CommandAnyType, IPrinterCommandMapping<TMsgType>>;
    protected constructor(transformer: MessageTransformer<TMsgType>, messageHandlerDelegate: CommandSetMessageHandlerDelegate<TMsgType>, implementedLanguage: Conf.PrinterCommandLanguage, basicCommands: Record<Commands.CommandType, IPrinterCommandMapping<TMsgType>>, extendedCommands?: IPrinterCommandMapping<TMsgType>[]);
    abstract get documentStartPrefix(): TMsgType;
    abstract get documentEndSuffix(): TMsgType;
    transpileCommand(cmd: Commands.IPrinterCommand, docMetadata: TranspiledDocumentState): TMsgType | TranspileDocumentError;
    handleMessage<TReceived extends Conf.MessageArrayLike>(msg: TReceived, config: PrinterConfig, sentCommand?: Commands.IPrinterCommand): IMessageHandlerResult<TReceived>;
    protected getMappedCmd(cmd: Commands.IPrinterCommand): IPrinterCommandMapping<TMsgType> | undefined;
    isCommandNonFormCommand(cmd: Commands.IPrinterCommand): boolean;
    expandCommand(cmd: Commands.IPrinterCommand): Commands.IPrinterCommand[];
    combineCommands(...commands: TMsgType[]): TMsgType;
    getConfig(config: PrinterConfig): PrinterConfig;
    callMessageHandler(message: TMsgType, sentCommand?: Commands.IPrinterCommand): IMessageHandlerResult<TMsgType>;
    protected getExtendedCommand(cmd: Commands.IPrinterCommand): TranspileCommandDelegate<Commands.IPrinterCommand, TMsgType>;
}
export declare abstract class RawCommandSet extends PrinterCommandSet<Uint8Array> {
    protected static readonly _noop: Uint8Array<ArrayBuffer>;
    get noop(): Uint8Array<ArrayBuffer>;
    protected constructor(implementedLanguage: Conf.PrinterCommandLanguage, messageHandlerDelegate: CommandSetMessageHandlerDelegate<Uint8Array>, basicCommands: Record<Commands.CommandType, IPrinterCommandMapping<Uint8Array>>, extendedCommands?: IPrinterCommandMapping<Uint8Array>[]);
}
export declare abstract class StringCommandSet extends PrinterCommandSet<string> {
    protected static readonly _noop = "";
    get noop(): string;
    protected constructor(implementedLanguage: Conf.PrinterCommandLanguage, messageHandlerDelegate: CommandSetMessageHandlerDelegate<string>, basicCommands: Record<Commands.CommandType, IPrinterCommandMapping<string>>, extendedCommands?: IPrinterCommandMapping<string>[]);
}
//# sourceMappingURL=CommandSet.d.ts.map