"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.IndexTickProvider = void 0;
var NumberRange_1 = require("../../../Core/NumberRange");
var NumericTickProvider_1 = require("./NumericTickProvider");
var TickProvider_1 = require("./TickProvider");
/**
 * @summary The IndexTickProvider is a {@link TickProvider} implementation for Index Axis.
 * @description TickProviders are responsible for calculating the interval between major and minor gridlines, ticks and labels.
 *
 *  * The method {@link getMajorTicks} returns an array of major ticks (data-values values where SciChart will place labels and major gridlines.
 *  * The method {@link getMinorTicks} returns an array of minor ticks (data-values values where SciChart will place minor gridlines.
 *  * The method {@link isParamsValid} performs some sanity checks.
 *  * The method {@link calculateTicks} performs the actual calculation
 *
 * Override these methods to create custom implementations of Tick intervals in SciChart
 * @remarks
 * See also {@link TickProvider} for the base implementation.
 */
var IndexTickProvider = /** @class */ (function (_super) {
    __extends(IndexTickProvider, _super);
    /**
     * Creates an instance of an IndexTickProvider
     * @param webAssemblyContext The {@link TSciChart | SciChart 2D WebAssembly Context} or {@link TSciChart | SciChart 3D WebAssembly Context}
     * containing native methods and access to our WebGL2 WebAssembly Rendering Engine
     */
    function IndexTickProvider(webAssemblyContext) {
        var _this = _super.call(this) || this;
        _this.webAssemblyContext = webAssemblyContext;
        _this.numericTickProvider = new NumericTickProvider_1.NumericTickProvider(webAssemblyContext);
        return _this;
    }
    /** @inheritDoc */
    IndexTickProvider.prototype.getMinorTicks = function (minorDelta, majorDelta, visibleRange, coordCalc) {
        var dataGap = this.parentAxis.dataGap;
        if (dataGap === 0)
            return this.numericTickProvider.getMinorTicks(minorDelta, majorDelta, visibleRange);
        var indexCoordCalc = coordCalc;
        var minorTicks = this.numericTickProvider.getMinorTicks(minorDelta / dataGap, majorDelta / dataGap, this.getIndexRange(indexCoordCalc, visibleRange));
        return minorTicks.map(function (t) { return indexCoordCalc.transformIndexToData(t); });
    };
    /** @inheritDoc */
    IndexTickProvider.prototype.getMajorTicks = function (minorDelta, majorDelta, visibleRange, coordCalc) {
        var dataGap = this.parentAxis.dataGap;
        if (dataGap === 0)
            return this.numericTickProvider.getMajorTicks(minorDelta, majorDelta, visibleRange);
        var indexCoordCalc = coordCalc;
        var majorTicks = this.numericTickProvider.getMajorTicks(minorDelta / dataGap, majorDelta / dataGap, this.getIndexRange(indexCoordCalc, visibleRange));
        return majorTicks.map(function (t) { return indexCoordCalc.transformIndexToData(t); });
    };
    IndexTickProvider.prototype.getIndexRange = function (coordCalc, visibleRange) {
        var minIndex = coordCalc.transformDataToIndex(visibleRange.min);
        var maxIndex = coordCalc.transformDataToIndex(visibleRange.max);
        return new NumberRange_1.NumberRange(minIndex, maxIndex);
    };
    return IndexTickProvider;
}(TickProvider_1.TickProvider));
exports.IndexTickProvider = IndexTickProvider;
