"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "ViewportColumnsCalculator", {
    enumerable: true,
    get: function() {
        return ViewportColumnsCalculator;
    }
});
const _axisCalculation = require("./axisCalculation");
const _viewportBase = require("./viewportBase");
class ViewportColumnsCalculator extends _viewportBase.ViewportBaseCalculator {
    /**
   * Calculates viewport.
   */ calculate() {
        (0, _axisCalculation.calculateAxis)(this, {
            totalCount: this.totalColumns,
            zeroBasedScrollOffset: this.zeroBasedScrollOffset,
            scrollEnd: this.zeroBasedScrollOffset + this.viewportWidth,
            positionCache: this.positionCache,
            setSizeField: (ctx, size)=>{
                ctx.columnWidth = size;
            },
            setTotalCalculated: (ctx, v)=>{
                ctx.totalCalculatedWidth = v;
            },
            getTotalCalculated: (ctx)=>ctx.totalCalculatedWidth
        });
    }
    /**
   * Gets the column width at the specified column index.
   *
   * @param {number} column Column index.
   * @returns {number}
   */ getColumnWidth(column) {
        return this.positionCache.getSizeAt(column);
    }
    /**
   * @param {ViewportColumnsCalculatorOptions} options Object with all options specified for column viewport calculation.
   */ constructor({ calculationTypes, viewportWidth, scrollOffset, totalColumns, overrideFn, inlineStartOffset, columnWidthCache }){
        super(calculationTypes), this.viewportWidth = 0, this.scrollOffset = 0, this.zeroBasedScrollOffset = 0, this.totalColumns = 0, this.columnWidth = 0, this.overrideFn = null, this.inlineStartOffset = 0, this.totalCalculatedWidth = 0, this.needReverse = true;
        this.viewportWidth = viewportWidth;
        this.scrollOffset = scrollOffset;
        this.zeroBasedScrollOffset = Math.max(scrollOffset, 0);
        this.totalColumns = totalColumns;
        this.overrideFn = overrideFn;
        this.inlineStartOffset = inlineStartOffset;
        this.positionCache = columnWidthCache;
        this.calculate();
    }
}
