"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const index_1 = require("./index");
const fs = require("fs");
const path = require("path");
const archiveRoot = path.resolve(path.join(__dirname, `../archive`));
const supported = ['latest', ...fs.readdirSync(archiveRoot)].sort().reverse();
function getAllVersions() {
    return supported.map(v => create(v));
}
exports.getAllVersions = getAllVersions;
function create(version = 'latest') {
    if (version === 'latest') {
        return new index_1.default(version);
    }
    const archivePath = path.join(archiveRoot, version, 'typescript');
    var tsv;
    try {
        tsv = require(archivePath);
    }
    catch (e) {
        throw new Error(`Unsupported TypeScript version "${version}". Supported values: ${supported.join(', ')}`);
    }
    return new index_1.default(version, tsv, path.dirname(require.resolve(archivePath)));
}
exports.create = create;
