"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.indexFileList = indexFileList;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const indexing_utils_1 = require("./indexing-utils");
const validators_1 = require("./validators");
async function indexFileList(flags) {
    const { out, target, fileId, file, attributes, quiet, exclude, prefixSize } = flags;
    (0, validators_1.validateFileInput)(file);
    const outFlag = target || out || '.';
    const trixDir = path_1.default.join(outFlag, 'trix');
    if (!fs_1.default.existsSync(trixDir)) {
        fs_1.default.mkdirSync(trixDir);
    }
    const trackConfigs = (0, indexing_utils_1.prepareFileTrackConfigs)(file, fileId);
    await (0, indexing_utils_1.indexDriver)({
        trackConfigs,
        outLocation: outFlag,
        name: trackConfigs.length > 1 ? 'aggregate' : path_1.default.basename(file[0]),
        quiet,
        attributes: attributes.split(','),
        typesToExclude: exclude.split(','),
        assemblyNames: [],
        prefixSize,
    });
    console.log('Successfully created index for these files. See https://jbrowse.org/storybook/lgv/main/?path=/story/text-searching--page for info about usage');
}
