'use strict';


const TextAnalysisManager = require("./textAnalysisManager");
const TextAnalysisManagerDev = require("./textAnalysisManagerDev");

var srms = {
    production: {
    },
    development: {
    }
};

module.exports = class TextAnalysisCommon {
    constructor() {
    }

    static GetPrefix(language) {
        if (language === "billing" ||
            language === "social" ||
            language === "wording") {
            return "../../accounting/sentenceAnalysis/" + language
        }

        return "../" + language;
    }
    static GetPrefixFolder(language) {
        if (language === "billing" ||
            language === "social" ||
            language === "wording") {
            return {
                root: "./accounting/sentenceAnalysis/",
                local: "../../accounting/sentenceAnalysis/"
            };
        }
        return null;
    }

    static GetProductionTextAnalysisManager(language) {
        let amOptions = {
            prefixFolders: TextAnalysisCommon.GetPrefixFolder(language),
            conflictMode: 0
        };
        if (!srms.production[language]) {
            srms.production[language] = new TextAnalysisManager(amOptions, language, "allRules");
        }
        return srms.production[language];
    }
    static GetTextAnalysisManager(env, language, ruleType, category, jsonRules) {
        var srm = null;
        if (env == "production") {
            srm = TextAnalysisCommon.GetProductionTextAnalysisManager(language);
        }
        else {
            let amOptions = {
                prefixFolders: TextAnalysisCommon.GetPrefixFolder(language),
                conflictMode: 0
            };
            if ((!category || category == "") && !jsonRules) {
                srm = srms[env][language];
                if (!srm) {
                    srms[env][language] = new TextAnalysisManagerDev(amOptions, language, "allRules");
                    srm = srms[env][language];
                }
            }
            else {
                srm = new TextAnalysisManagerDev(amOptions, language, ruleType, category, null, jsonRules);
            }
        }
        return srm;
    }
}
