import { Buffer } from 'node:buffer';
import { Readable } from 'node:stream';
import { ExecFileOptions } from 'node:child_process';
import { DirOptions } from 'tmp';

/**
 * LibreOfficeFileConverter options.
 */
type LibreOfficeFileConverterOptions = {
    /**
     * List of paths to soffice binary.
     */
    readonly binaryPaths?: string[];
    /**
     * node:child_process execFile options.
     */
    readonly childProcessOptions?: ExecFileOptions;
    /**
     * Enables debug logs on soffice calls.
     */
    readonly debug?: boolean;
    /**
     * tmp-promise options.
     */
    readonly tmpOptions?: DirOptions;
};
/**
 * Convert input options.
 */
type ConvertInputOptions = {
    /**
     * Input Buffer.
     */
    readonly buffer: Buffer;
    /**
     * Input as a Buffer.
     */
    readonly input: 'buffer';
} | {
    /**
     * Input as a file path.
     */
    readonly input: 'file';
    /**
     * Input file path.
     */
    readonly inputPath: string;
} | {
    /**
     * Input as a readable stream.
     */
    readonly input: 'stream';
    /**
     * Input readable stream.
     */
    readonly stream: Readable;
};
/**
 * Convert output options.
 */
type ConvertOutputOptionsBuffer = {
    /**
     * Return conversion result as a Buffer.
     */
    readonly output: 'buffer';
};
/**
 * Convert output options.
 */
type ConvertOutputOptionsFile = {
    /**
     * Save conversion result as a file.
     */
    readonly output: 'file';
    /**
     * Conversion result path.
     */
    readonly outputPath: string;
};
/**
 * Convert output options.
 */
type ConvertOutputOptionsStream = {
    /**
     * Return conversion result as a readable stream.
     */
    readonly output: 'stream';
};
/**
 * Convert output options.
 */
type ConvertOutputOptions = ConvertOutputOptionsBuffer | ConvertOutputOptionsFile | ConvertOutputOptionsStream;
/**
 * Convert options.
 */
type ConvertOptionsInput = ConvertInputOptions & {
    /**
     * LibreOffice output filter.
     * See LibreOffice docs https://help.libreoffice.org/latest/en-US/text/shared/guide/convertfilters.html
     *
     * @deprecated Use `outputFilter` instead.
     */
    readonly filter?: string;
    /**
     * Requested format.
     */
    readonly format: string;
    /**
     * LibreOffice input filter.
     * See LibreOffice docs https://help.libreoffice.org/latest/en-US/text/shared/guide/convertfilters.html
     */
    readonly inputFilter?: string;
    /**
     * LibreOfficeConverter options.
     */
    readonly options?: LibreOfficeFileConverterOptions;
    /**
     * LibreOffice output filter.
     * See LibreOffice docs https://help.libreoffice.org/latest/en-US/text/shared/guide/convertfilters.html
     */
    readonly outputFilter?: string;
};
/**
 * Convert options.
 */
type ConvertOptions = ConvertOptionsInput & ConvertOutputOptions;

/**
 * Simple NodeJS wrapper for libreoffice CLI for converting office documents to different formats.
 *
 * @example
 * ```ts
 * const libreOfficeFileConverter = new LibreOfficeFileConverter({ childProcessOptions: { timeout: 60 * 1000 } });
 * ```
 *
 * @class
 * @public
 */
declare class LibreOfficeFileConverter {
    private readonly _options;
    /**
     * Create an instance of the LibreOfficeFileConverter.
     *
     * @example
     * ```ts
     * const libreOfficeFileConverter = new LibreOfficeFileConverter({ childProcessOptions: { timeout: 60 * 1000 } });
     * ```
     *
     * @param options The LibreOfficeFileConverter options.
     *
     * @constructor
     * @public
     */
    constructor(options?: LibreOfficeFileConverterOptions);
    /**
     * Converts provided input to the requested format.
     *
     * @example
     * ```ts
     * const outputBuffer = await libreOfficeFileConverter.convert({
     *  buffer: inputBuffer,
     *  format: 'pdf',
     *  input: 'buffer',
     *  output: 'buffer',
     * });
     * ```
     *
     * @param options Convert options: input and output type, format, filter, converter options.
     *
     * @returns Buffer of the converted input.
     *
     * @overload
     * @public
     */
    convert(options: ConvertOptionsInput & ConvertOutputOptionsBuffer): Promise<Buffer>;
    /**
     * Converts provided input to the requested format.
     *
     * @example
     * ```ts
     * await libreOfficeFileConverter.convert({
     *  format: 'pdf',
     *  input: 'file',
     *  inputPath,
     *  output: 'file',
     *  outputPath,
     * });
     * ```
     *
     * @param options Convert options: input and output type, format, filter, converter options.
     *
     * @overload
     * @public
     */
    convert(options: ConvertOptionsInput & ConvertOutputOptionsFile): Promise<void>;
    /**
     * Converts provided input to the requested format.
     *
     * @example
     * ```ts
     * const outputStream = await libreOfficeFileConverter.convert({
     *  format: 'pdf',
     *  input: 'stream',
     *  stream: inputStream,
     *  output: 'stream',
     * });
     * ```
     *
     * @param options Convert options: input and output type, format, filter, converter options.
     *
     * @returns Readable stream of the converted input.
     *
     * @overload
     * @public
     */
    convert(options: ConvertOptionsInput & ConvertOutputOptionsStream): Promise<Readable>;
    private mergeOptions;
    private process;
    private read;
    private write;
}

export { type ConvertInputOptions, type ConvertOptions, type ConvertOptionsInput, type ConvertOutputOptions, type ConvertOutputOptionsBuffer, type ConvertOutputOptionsFile, type ConvertOutputOptionsStream, LibreOfficeFileConverter, type LibreOfficeFileConverterOptions };
