/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import * as tslib_1 from "tslib";
import { StreamingIndicatorCalculationStrategy } from "./StreamingIndicatorCalculationStrategy";
import { String_$type, toEnum, fromEnum, markType } from "igniteui-react-core/ES5/type";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { isNaN_ } from "igniteui-react-core/ES5/number";
var PercentKCalculationStrategy = /** @class */ (function (_super) {
    tslib_1.__extends(PercentKCalculationStrategy, _super);
    function PercentKCalculationStrategy() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    PercentKCalculationStrategy.prototype.b = function (a, b) {
        var c = new List$1(String_$type, 0);
        c.add("HighColumn");
        c.add("LowColumn");
        c.add("CloseColumn");
        return c;
    };
    PercentKCalculationStrategy.prototype._c = function (a, b) {
        var c, d, e, f, g, h, i, j;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    c = a.period;
                    d = a.highColumn;
                    e = a.lowColumn;
                    f = 0;
                    _a.label = 1;
                case 1:
                    if (!(f < a.count)) return [3 /*break*/, 4];
                    g = Math.min(c, f);
                    h = -1.7976931348623157E+308;
                    i = 1.7976931348623157E+308;
                    for (j = 0; j < g; j++) {
                        if (!isNaN_(d.item(f - j))) {
                            h = Math.max(h, d.item(f - j));
                        }
                        if (!isNaN_(e.item(f - j))) {
                            i = Math.min(i, e.item(f - j));
                        }
                    }
                    return [4 /*yield*/, b.i((a.closeColumn.item(f) - i) / (h - i) * 100)];
                case 2:
                    _a.sent();
                    _a.label = 3;
                case 3:
                    f++;
                    return [3 /*break*/, 1];
                case 4: return [2 /*return*/];
            }
        });
    };
    PercentKCalculationStrategy.prototype.c = function (a, b) {
        var _this = this;
        return toEnum(function () { return _this._c(a, b); });
    };
    PercentKCalculationStrategy.prototype.a = function (a, b) {
        var c = 0;
        try {
            for (var _a = tslib_1.__values(fromEnum(this.c(a, b))), _b = _a.next(); !_b.done; _b = _a.next()) {
                var d = _b.value;
                a.indicatorColumn.item(c, d);
                c++;
            }
        }
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
        finally {
            try {
                if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
            }
            finally { if (e_1) throw e_1.error; }
        }
        return true;
        var e_1, _d;
    };
    PercentKCalculationStrategy.$t = markType(PercentKCalculationStrategy, 'PercentKCalculationStrategy', StreamingIndicatorCalculationStrategy.$);
    return PercentKCalculationStrategy;
}(StreamingIndicatorCalculationStrategy));
export { PercentKCalculationStrategy };
