"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TargetLanguage = void 0;
const collection_utils_1 = require("collection-utils");
const ConvenienceRenderer_js_1 = require("./ConvenienceRenderer.js");
const DateTime_js_1 = require("./DateTime.js");
const Source_js_1 = require("./Source.js");
const Support_js_1 = require("./support/Support.js");
class TargetLanguage {
    constructor({ displayName, names, extension }) {
        this.displayName = displayName;
        this.names = names;
        this.extension = extension;
    }
    get optionDefinitions() {
        return Object.values(this.getOptions()).map((o) => o.definition);
    }
    get cliOptionDefinitions() {
        let actual = [];
        let display = [];
        for (const { cliDefinitions } of Object.values(this.getOptions())) {
            actual = actual.concat(cliDefinitions.actual);
            display = display.concat(cliDefinitions.display);
        }
        return { actual, display };
    }
    get name() {
        return (0, Support_js_1.defined)(this.names[0]);
    }
    renderGraphAndSerialize(typeGraph, givenOutputFilename, alphabetizeProperties, leadingComments, rendererOptions, indentation) {
        if (indentation === undefined) {
            indentation = this.defaultIndentation;
        }
        const renderContext = { typeGraph, leadingComments };
        const renderer = this.makeRenderer(renderContext, rendererOptions);
        if (renderer instanceof ConvenienceRenderer_js_1.ConvenienceRenderer) {
            renderer.setAlphabetizeProperties(alphabetizeProperties);
        }
        const renderResult = renderer.render(givenOutputFilename);
        return (0, collection_utils_1.mapMap)(renderResult.sources, (s) => (0, Source_js_1.serializeRenderResult)(s, renderResult.names, (0, Support_js_1.defined)(indentation)));
    }
    get defaultIndentation() {
        return "    ";
    }
    get stringTypeMapping() {
        return new Map();
    }
    get supportsOptionalClassProperties() {
        return false;
    }
    get supportsUnionsWithBothNumberTypes() {
        return false;
    }
    get supportsFullObjectType() {
        return false;
    }
    needsTransformerForType(_t) {
        return false;
    }
    get dateTimeRecognizer() {
        return new DateTime_js_1.DefaultDateTimeRecognizer();
    }
}
exports.TargetLanguage = TargetLanguage;
