"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = mySchematic;
const replacements = [
    [['fdAutoComplete', 'fd-auto-complete'], 'fdkAutoComplete'],
    [['fnClicked'], 'fdkClicked'],
    [['fnDisabled'], 'fdkDisabled'],
    [['fd-focus-key-manager-item', 'fdFocusKeyManagerItem'], 'fdkFocusKeyManagerItem'],
    [['fd-focus-key-manager-list', 'fdFocusKeyManagerList'], 'fdkFocusKeyManagerList'],
    [['fnFocusableItem'], 'fdkFocusableItem'],
    [['fnFocusableList'], 'fdkFocusableList'],
    [['fdIgnoreClickOnSelection', 'fd-ignore-click-on-selection'], 'fdkIgnoreClickOnSelection'],
    [['fdInitialFocus', 'fd-initial-focus'], 'fdkInitialFocus'],
    [['fdLineClamp', 'fd-lineclamp'], 'fdLineClamp'],
    [['fdOnlyDigits', 'fd-only-digits'], 'fdkOnlyDigits'],
    [['fdOverflowListItem', 'fd-overflow-list-item'], 'fdkOverflowListItem'],
    [['fdOverflowList', 'fd-overflow-list'], 'fdkOverflowList'],
    [['fnReadonly'], 'fdkReadonly'],
    [['fdRepeat', 'fd-repeat'], 'fdkRepeat'],
    [['fdResizeHandle', 'fd-resize-handle'], 'fdkResizeHandle'],
    [['fdResize', 'fd-resize'], 'fdkResize'],
    [['fdTemplate', 'fd-template'], 'fdkTemplate'],
    [['fdTruncate', 'fd-truncate'], 'fdkTruncate']
];
function mySchematic() {
    return (tree, context) => {
        const files = getFilesWithExtension(tree, '/', 'html');
        files.forEach((file) => {
            var _a;
            let fileContents = (_a = tree.read(file)) === null || _a === void 0 ? void 0 : _a.toString();
            if (!fileContents) {
                return;
            }
            replacements.forEach((replacement) => {
                const deprecated = replacement[0];
                const actual = replacement[1];
                deprecated.forEach((selector) => {
                    if (!fileContents.includes(selector)) {
                        return;
                    }
                    fileContents = fileContents.split(selector).join(actual);
                    context.logger.info(`✅️ Replaced old ${selector} directive selector with current ${actual}`);
                });
            });
            tree.overwrite(file, fileContents);
        });
    };
}
function getFilesWithExtension(tree, path, extension) {
    const files = [];
    const rootDir = tree.getDir(path);
    const test = rootDir.subfiles.filter((file) => file.endsWith(`.${extension}`)).map((file) => `${path}${file}`);
    files.push(...test);
    rootDir.subdirs.forEach((dir) => {
        files.push(...getFilesWithExtension(tree, `${path}${dir}/`, extension));
    });
    return files;
}
//# sourceMappingURL=index.js.map