"use strict"; /** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ Object.defineProperty(exports, "__esModule", { value: true }); exports.getChildElementIndentation = void 0; const schematics_1 = require("@angular-devkit/schematics"); /** Determines the indentation of child elements for the given Parse5 element. */ function getChildElementIndentation(element) { const childElement = element.childNodes.find(node => node.tagName); if ((childElement && !childElement.sourceCodeLocation) || !element.sourceCodeLocation) { throw new schematics_1.SchematicsException('Cannot determine child element indentation because the ' + 'specified Parse5 element does not have any source code location metadata.'); } const startColumns = childElement ? // In case there are child elements inside of the element, we assume that their // indentation is also applicable for other child elements. childElement.sourceCodeLocation.startCol : // In case there is no child element, we just assume that child elements should be indented // by two spaces. element.sourceCodeLocation.startCol + 2; // Since Parse5 does not set the `startCol` properties as zero-based, we need to subtract // one column in order to have a proper zero-based offset for the indentation. return startColumns - 1; } exports.getChildElementIndentation = getChildElementIndentation; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGFyc2U1LWVsZW1lbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL3NjaGVtYXRpY3MvdXRpbHMvcGFyc2U1LWVsZW1lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7R0FNRzs7O0FBRUgsMkRBQStEO0FBUS9ELGlGQUFpRjtBQUNqRixTQUFnQiwwQkFBMEIsQ0FBQyxPQUFnQjtJQUN6RCxNQUFNLFlBQVksR0FBRyxPQUFPLENBQUMsVUFBVSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsRUFBRSxDQUFFLElBQWdCLENBQUMsT0FBTyxDQUFtQixDQUFDO0lBRWxHLElBQUksQ0FBQyxZQUFZLElBQUksQ0FBQyxZQUFZLENBQUMsa0JBQWtCLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxr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