import { BuildBaseFileInputOutputModel, BuildBaseInputFileOutputDirectoryModel, UNARCHIVER_FORMAT_KEY, buildCommandToConvertArchive, buildCommandToDecompressWith7z, buildCommandToDecompressWithUnarchiver, } from '../shared/index.js';
import { buildUseConvert, buildUseDecompress, transform_input_file_output_directory_array, transform_input_output_file_array, } from './base.js';
import { handleCommand, } from './command.js';
// defineCompress('rar', buildCommandToCreateRar, runRarCommand)
// const IORar = BuildBaseInputFileOutputDirectoryModel.superRefine(
//   transform_input_file_output_directory_array(['7z']),
// )
// export const useDecompressWith7z = buildUseDecompress(['7z'], '7z')
// export async function decompressWith7z(source) {
//   const input = IO7z.parse(source)
//   const cmd = buildCommandToDecompressWith7z(input)
//   await run7zCommand(cmd)
// }
const IO7z = BuildBaseInputFileOutputDirectoryModel.superRefine(transform_input_file_output_directory_array(['7z']));
export const useDecompressWith7z = buildUseDecompress(['7z'], '7z');
export async function decompressWith7z(source) {
    const input = IO7z.parse(source);
    const list = buildCommandToDecompressWith7z(input);
    for (const cmd of list) {
        await handleCommand(cmd);
    }
}
const IOUnarchiver = BuildBaseInputFileOutputDirectoryModel.superRefine(transform_input_file_output_directory_array(UNARCHIVER_FORMAT_KEY));
export const useDecompressWithUnarchiver = buildUseDecompress(UNARCHIVER_FORMAT_KEY, 'unarchiver');
export async function decompressWithUnarchiver(source) {
    const input = IOUnarchiver.parse(source);
    const list = buildCommandToDecompressWithUnarchiver(input);
    for (const cmd of list) {
        await handleCommand(cmd);
    }
}
const IOConvertArchive = BuildBaseFileInputOutputModel.superRefine(transform_input_output_file_array(UNARCHIVER_FORMAT_KEY, ['zip']));
export const useConvertArchive = buildUseConvert(UNARCHIVER_FORMAT_KEY, ['zip']);
export async function convertArchive(source) {
    const input = IOConvertArchive.parse(source);
    const list = buildCommandToConvertArchive(input);
    for (const cmd of list) {
        await handleCommand(cmd);
    }
}
//# sourceMappingURL=archive.js.map