window.rolemasterTables = window.rolemasterTables || {
    alignCriticalCells() {
        const tables = document.querySelectorAll(".critical-table");

        for (const table of tables) {
            for (const cell of table.querySelectorAll("td > .critical-cell")) {
                cell.style.minHeight = "";
            }

            for (const row of table.tBodies) {
                for (const tr of row.rows) {
                    for (const cell of tr.cells) {
                        const criticalCell = cell.querySelector(":scope > .critical-cell");
                        if (!criticalCell) {
                            continue;
                        }

                        criticalCell.style.minHeight = `${cell.clientHeight}px`;
                    }
                }
            }
        }
    }
};

window.addEventListener("resize", () => window.rolemasterTables.alignCriticalCells());
