"use strict";

Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.createGroupForFirstScreen = void 0;

const compute_col_width_1 = require("../../layout/compute-col-width"), compute_row_height_1 = require("../../layout/compute-row-height"), column_1 = require("../column");

function createGroupForFirstScreen(cornerHeaderGroup, colHeaderGroup, rowHeaderGroup, rightFrozenGroup, bottomFrozenGroup, bodyGroup, xOrigin, yOrigin, proxy) {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
    const {table: table} = proxy, {leftBottomCornerGroup: leftBottomCornerGroup, rightTopCornerGroup: rightTopCornerGroup, rightBottomCornerGroup: rightBottomCornerGroup} = table.scenegraph;
    let distCol, distRow, distColForCompute, distRowForCompute;
    proxy.setParamsForRow(), proxy.setParamsForColumn(), "adaptive" === table.widthMode || table.options.autoWrapText && ("adaptive" === table.heightMode || table.isAutoRowHeight(table.columnHeaderLevelCount)) ? (distColForCompute = table.colCount - 1, 
    distCol = Math.min(proxy.firstScreenColLimit - 1, table.colCount - 1)) : distCol = Math.min(proxy.firstScreenColLimit - 1, table.colCount - 1), 
    "adaptive" === table.heightMode ? (distRowForCompute = table.rowCount - 1, distRow = Math.min(proxy.firstScreenRowLimit - 1, table.rowCount - 1)) : distRow = Math.min(proxy.firstScreenRowLimit - 1, table.rowCount - 1), 
    0 === table.internalProps._widthResizedColMap.size && (0, compute_col_width_1.computeColsWidth)(table, 0, null != distColForCompute ? distColForCompute : distCol), 
    0 === table.internalProps._heightResizedRowMap.size && (0, compute_row_height_1.computeRowsHeight)(table, 0, "auto" === table.options.canvasHeight || (null === (_a = table.options.customConfig) || void 0 === _a ? void 0 : _a.forceComputeAllRowHeight) ? table.rowCount - 1 : null != distRowForCompute ? distRowForCompute : distRow), 
    distCol < table.colCount - table.rightFrozenColCount && table.colCount - table.rightFrozenColCount <= table.colCount - 1 && (0, 
    compute_col_width_1.computeColsWidth)(table, table.colCount - table.rightFrozenColCount, table.colCount - 1), 
    distRow < table.rowCount - table.bottomFrozenRowCount && table.rowCount - table.bottomFrozenRowCount <= table.rowCount - 1 && (0, 
    compute_row_height_1.computeRowsHeight)(table, table.rowCount - table.bottomFrozenRowCount, table.rowCount - 1), 
    table.scenegraph.colHeaderGroup.setAttribute("x", table.getFrozenColsWidth()), table.scenegraph.rowHeaderGroup.setAttribute("y", table.getFrozenRowsHeight()), 
    table.scenegraph.bottomFrozenGroup.setAttribute("x", table.getFrozenColsWidth()), 
    table.scenegraph.rightFrozenGroup.setAttribute("y", table.getFrozenRowsHeight()), 
    table.scenegraph.bodyGroup.setAttributes({
        x: table.getFrozenColsWidth(),
        y: table.getFrozenRowsHeight()
    }), (0, column_1.createColGroup)(cornerHeaderGroup, xOrigin, yOrigin, 0, table.frozenColCount - 1, 0, table.frozenRowCount - 1, table.isListTable() ? "columnHeader" : "cornerHeader", table), 
    distCol - table.rightFrozenColCount >= table.frozenColCount && (0, column_1.createColGroup)(colHeaderGroup, xOrigin, yOrigin, table.frozenColCount, distCol - table.rightFrozenColCount, 0, table.frozenRowCount - 1, "columnHeader", table), 
    table.frozenColCount > 0 && (table.leftRowSeriesNumberCount > 0 && (0, column_1.createColGroup)(rowHeaderGroup, xOrigin, yOrigin, 0, table.leftRowSeriesNumberCount - 1, table.frozenRowCount, distRow - table.bottomFrozenRowCount, "rowHeader", table), 
    table.frozenColCount > table.leftRowSeriesNumberCount && (0, column_1.createColGroup)(rowHeaderGroup, xOrigin, yOrigin, table.leftRowSeriesNumberCount, Math.min(table.frozenColCount - 1, table.rowHeaderLevelCount + table.leftRowSeriesNumberCount - 1), table.frozenRowCount, distRow - table.bottomFrozenRowCount, "rowHeader", table), 
    table.frozenColCount > table.rowHeaderLevelCount + table.leftRowSeriesNumberCount && (0, 
    column_1.createColGroup)(rowHeaderGroup, xOrigin, yOrigin, table.rowHeaderLevelCount + table.leftRowSeriesNumberCount, table.frozenColCount - 1, table.frozenRowCount, distRow - table.bottomFrozenRowCount, "body", table)), 
    table.bottomFrozenRowCount > 0 && (table.frozenColCount > 0 && (table.leftRowSeriesNumberCount > 0 && (0, 
    column_1.createColGroup)(leftBottomCornerGroup, xOrigin, yOrigin, 0, table.leftRowSeriesNumberCount - 1, table.rowCount - 1 - table.bottomFrozenRowCount + 1, table.rowCount - 1, "rowHeader", table), 
    table.rowHeaderLevelCount > 0 && (0, column_1.createColGroup)(leftBottomCornerGroup, xOrigin, yOrigin, table.leftRowSeriesNumberCount, table.leftRowSeriesNumberCount + table.rowHeaderLevelCount - 1, table.rowCount - 1 - table.bottomFrozenRowCount + 1, table.rowCount - 1, "rowHeader", table), 
    table.frozenColCount > table.rowHeaderLevelCount + table.leftRowSeriesNumberCount && (0, 
    column_1.createColGroup)(leftBottomCornerGroup, xOrigin, yOrigin, table.rowHeaderLevelCount + table.leftRowSeriesNumberCount, table.frozenColCount - 1, table.rowCount - 1 - table.bottomFrozenRowCount + 1, table.rowCount - 1, "body", table)), 
    distCol - table.rightFrozenColCount >= table.frozenColCount && (0, column_1.createColGroup)(bottomFrozenGroup, xOrigin, yOrigin, table.frozenColCount, distCol - table.rightFrozenColCount, table.rowCount - 1 - table.bottomFrozenRowCount + 1, table.rowCount - 1, table.isPivotChart() ? "rowHeader" : "body", table)), 
    table.rightFrozenColCount > 0 && ((0, column_1.createColGroup)(rightTopCornerGroup, xOrigin, yOrigin, table.colCount - 1 - table.rightFrozenColCount + 1, table.colCount - 1, 0, table.frozenRowCount - 1, "columnHeader", table), 
    (0, column_1.createColGroup)(rightFrozenGroup, xOrigin, yOrigin, table.colCount - 1 - table.rightFrozenColCount + 1, table.colCount - 1, table.frozenRowCount, distRow - table.bottomFrozenRowCount, table.isPivotChart() ? "rowHeader" : "body", table)), 
    table.bottomFrozenRowCount > 0 && table.rightFrozenColCount > 0 && (0, column_1.createColGroup)(rightBottomCornerGroup, xOrigin, yOrigin, table.colCount - 1 - table.rightFrozenColCount + 1, table.colCount - 1, table.rowCount - 1 - table.bottomFrozenRowCount + 1, table.rowCount - 1, "body", table), 
    distCol - table.rightFrozenColCount >= table.frozenColCount && (0, column_1.createColGroup)(bodyGroup, xOrigin, yOrigin, table.frozenColCount, distCol - table.rightFrozenColCount, table.frozenRowCount, distRow - table.bottomFrozenRowCount, "body", table), 
    bodyGroup.firstChild || colHeaderGroup.firstChild || cornerHeaderGroup.firstChild || rowHeaderGroup.firstChild ? (proxy.currentRow = null !== (_e = null !== (_c = null === (_b = bodyGroup.firstChild) || void 0 === _b ? void 0 : _b.rowNumber) && void 0 !== _c ? _c : null === (_d = rowHeaderGroup.firstChild) || void 0 === _d ? void 0 : _d.rowNumber) && void 0 !== _e ? _e : proxy.totalRow, 
    proxy.rowEnd = proxy.currentRow, proxy.rowUpdatePos = proxy.rowEnd + 1, proxy.referenceRow = proxy.rowStart + Math.floor((proxy.rowEnd - proxy.rowStart) / 2), 
    proxy.currentCol = null !== (_o = null !== (_l = null !== (_j = null !== (_g = null === (_f = bodyGroup.lastChild) || void 0 === _f ? void 0 : _f.col) && void 0 !== _g ? _g : null === (_h = colHeaderGroup.lastChild) || void 0 === _h ? void 0 : _h.col) && void 0 !== _j ? _j : null === (_k = rowHeaderGroup.lastChild) || void 0 === _k ? void 0 : _k.col) && void 0 !== _l ? _l : null === (_m = cornerHeaderGroup.lastChild) || void 0 === _m ? void 0 : _m.col) && void 0 !== _o ? _o : proxy.totalCol, 
    proxy.colEnd = proxy.currentCol, proxy.colUpdatePos = proxy.colEnd + 1, proxy.referenceCol = proxy.colStart + Math.floor((proxy.colEnd - proxy.colStart) / 2), 
    proxy.progress()) : (proxy.currentRow = proxy.totalRow, proxy.rowEnd = proxy.currentRow, 
    proxy.rowUpdatePos = proxy.rowEnd + 1, proxy.referenceRow = proxy.rowStart + Math.floor((proxy.rowEnd - proxy.rowStart) / 2), 
    proxy.currentCol = proxy.totalCol, proxy.colEnd = proxy.currentCol, proxy.colUpdatePos = proxy.colEnd + 1, 
    proxy.referenceCol = proxy.colStart + Math.floor((proxy.colEnd - proxy.colStart) / 2));
}

exports.createGroupForFirstScreen = createGroupForFirstScreen;
//# sourceMappingURL=create-group-for-first-screen.js.map
