"use strict";
/**
 *  WidthAncestorAwareStyler
 *
 *  Copyright (C) 2010-2020 R-T Specialty, LLC.
 *
 *  This file is part of liza.
 *
 *  liza is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.WidthAncestorAwareStyler = void 0;
var AncestorAwareStyler_1 = require("./AncestorAwareStyler");
/**
 * Styles an HTML element's width based on an ancestor
 */
var WidthAncestorAwareStyler = /** @class */ (function () {
    function WidthAncestorAwareStyler() {
    }
    /**
     * Apply an ancestor's width to the element
     *
     * @param element - target element
     * @param n       - number of generations back
     */
    WidthAncestorAwareStyler.prototype.style = function (element, generation) {
        var ancestor = AncestorAwareStyler_1.getNthAncestor(element, generation);
        if (ancestor !== null) {
            element.style.width = ancestor.offsetWidth + 'px';
        }
    };
    return WidthAncestorAwareStyler;
}());
exports.WidthAncestorAwareStyler = WidthAncestorAwareStyler;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiV2lkdGhBbmNlc3RvckF3YXJlU3R5bGVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiV2lkdGhBbmNlc3RvckF3YXJlU3R5bGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQW1CRzs7O0FBRUgsNkRBQTBFO0FBRzFFOztHQUVHO0FBQ0g7SUFBQTtJQWNBLENBQUM7SUFiQzs7Ozs7T0FLRztJQUNJLHdDQUFLLEdBQVosVUFBYSxPQUFvQixFQUFFLFVBQTJCO1FBQzVELElBQU0sUUFBUSxHQUFHLG9DQUFjLENBQUMsT0FBTyxFQUFFLFVBQVUsQ0FBQyxDQUFDO1FBRXJELElBQUksUUFBUSxLQUFLLElBQUksRUFBRTtZQUNyQixPQUFPLENBQUMsS0FBSyxDQUFDLEtBQUssR0FBRyxRQUFRLENBQUMsV0FBVyxHQUFHLElBQUksQ0FBQztTQUNuRDtJQUNILENBQUM7SUFDSCwrQkFBQztBQUFELENBQUMsQUFkRCxJQWNDO0FBZFksNERBQXdCIn0=