"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const schematics_1 = require("@angular-devkit/schematics");
const lib_1 = require("../../lib");
const angular_utility_1 = require("../../lib/angular-utility");
const templateHelpers = __importStar(require("../../lib/template-helpers"));
// import { camelize } from '@angular-devkit/core/src/utils/strings';
function main(_options) {
    return (tree, _context) => {
        var _a, _b;
        const project = lib_1.loadProject(tree, _context);
        const tapConfig = project.tapConfig;
        const sourceTemplates = schematics_1.url('./files');
        const hasMonitoring = (((_b = (_a = project.tapConfig.config.data) === null || _a === void 0 ? void 0 : _a.bundles) === null || _b === void 0 ? void 0 : _b.length) || 0) > 0;
        const { name, path } = lib_1.getAngularProjectPath(_options.name || 'app-lib', tree, _options);
        return angular_utility_1.applyWithOverwriteRule(sourceTemplates, [
            schematics_1.forEach((entry) => {
                if (!hasMonitoring && entry.path.endsWith('/tap-monitoring.service.ts')) {
                    return null;
                }
                return entry;
            }),
            schematics_1.template(Object.assign(Object.assign(Object.assign({ name,
                hasMonitoring }, tapConfig), templateHelpers), project.toTemplate())),
            schematics_1.move(path)
        ], {
            overwrite: _options.overwrite,
            format: true
        });
    };
}
exports.main = main;
//# sourceMappingURL=index.js.map