/*
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 { __extends, __values } from "tslib";
import { FinancialIndicator } from "./FinancialIndicator";
import { String_$type, Number_$type, typeCast, fromEnum, markType } from "igniteui-angular-core";
import { DependencyProperty } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { AxisRange } from "./AxisRange";
import { isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
var StrategyBasedIndicator = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(StrategyBasedIndicator, _super);
    function StrategyBasedIndicator() {
        var _this = _super.call(this) || this;
        _this.uu();
        return _this;
    }
    StrategyBasedIndicator.prototype.uu = function () {
        this.uf = this.ug;
        this.ab = this.ut;
    };
    StrategyBasedIndicator.prototype.um = function () {
        return -2147483648;
    };
    StrategyBasedIndicator.prototype.uv = function (a) {
    };
    StrategyBasedIndicator.prototype.uo = function () {
        return -2147483648;
    };
    StrategyBasedIndicator.prototype.ul = function () {
        return -2147483648;
    };
    StrategyBasedIndicator.uz = function (a, b, c) {
        var d = DependencyProperty.i(c, Number_$type, b, new PropertyMetadata(2, a, function (e, f) { return (typeCast(StrategyBasedIndicator.$, e)).raisePropertyChanged(c, f.oldValue, f.newValue); }));
        StrategyBasedIndicator.uj.add(c);
        return d;
    };
    StrategyBasedIndicator.uy = function (a, b) {
        return StrategyBasedIndicator.uz(a, b, "Period");
    };
    StrategyBasedIndicator.uw = function (a, b) {
        return StrategyBasedIndicator.uz(a, b, "LongPeriod");
    };
    StrategyBasedIndicator.u0 = function (a, b) {
        return StrategyBasedIndicator.uz(a, b, "ShortPeriod");
    };
    StrategyBasedIndicator.prototype.ts = function (a, b) {
        var c = this.qo(a, b);
        var d = this.qp(c);
        return this.uf.b(c, d);
    };
    StrategyBasedIndicator.prototype.tp = function (a, b) {
        var c = this.qo(a, b);
        if (b == 0) {
            return false;
        }
        if (!this.rk(this.ts(a, b))) {
            return false;
        }
        var d = this.qp(c);
        if (this.tl != null) {
            c.minimumValue = this.tl.c;
            c.maximumValue = this.tl.b;
        }
        var e = this.uf.a(c, d);
        for (var f = 0; f < this.tu && f < c.indicatorColumn.count; f++) {
            c.indicatorColumn.item(f, NaN);
        }
        if (this.qx != null && this.ui(c)) {
            this.qx.c0();
        }
        return e;
    };
    StrategyBasedIndicator.prototype.ui = function (a) {
        var e_1, _a;
        if (!isNaN_(a.minimumValue) && !isNaN_(a.maximumValue) && a.specifiesRange) {
            var b = this.tl;
            this.tl = new AxisRange(a.minimumValue, a.maximumValue);
            return this.uh(b, this.tl);
        }
        var c = 1.7976931348623157E+308;
        var d = -1.7976931348623157E+308;
        try {
            for (var _b = __values(fromEnum(a.indicatorColumn)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var e = _c.value;
                if (!isNaN_(e)) {
                    c = Math.min(c, e);
                    d = Math.max(d, e);
                }
            }
        }
        catch (e_1_1) {
            e_1 = { error: e_1_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_1)
                    throw e_1.error;
            }
        }
        var f = this.tl;
        this.tl = new AxisRange(c, d);
        return this.uh(f, this.tl);
    };
    StrategyBasedIndicator.prototype.uh = function (a, b) {
        if (a == null || b == null) {
            return true;
        }
        if (a.c != b.c) {
            return true;
        }
        if (a.b != b.b) {
            return true;
        }
        return false;
    };
    StrategyBasedIndicator.prototype.un = function (a) {
        if (a == -2147483648) {
            return 0;
        }
        if (a > this.indicatorColumn.count && this.indicatorColumn.count > 0) {
            a = this.indicatorColumn.count - 1;
        }
        if (a < 1) {
            return 1;
        }
        return a;
    };
    StrategyBasedIndicator.prototype.qo = function (a, b) {
        var c = _super.prototype.qo.call(this, a, b);
        c.indicatorColumn = this.indicatorColumn;
        c.period = this.un(this.um());
        c.shortPeriod = this.un(this.uo());
        c.longPeriod = this.un(this.ul());
        c.multiplier = this.uk();
        return c;
    };
    StrategyBasedIndicator.prototype.uk = function () {
        return 1;
    };
    StrategyBasedIndicator.ux = function (a, b) {
        var c = DependencyProperty.i("Multiplier", Number_$type, b, new PropertyMetadata(2, a, function (d, e) { return (typeCast(StrategyBasedIndicator.$, d)).raisePropertyChanged("Multiplier", e.oldValue, e.newValue); }));
        StrategyBasedIndicator.uj.add("Multiplier");
        return c;
    };
    StrategyBasedIndicator.prototype.l3 = function (a, b, c, d) {
        _super.prototype.l3.call(this, a, b, c, d);
        if (StrategyBasedIndicator.uj.contains(b)) {
            if (this.qx != null && !this.qx.c0()) {
                this.qs.bx.e(this.ft);
                this.tp(0, this.indicatorColumn.count);
                if (this.tm.b7) {
                    this.tm.b5.g$i();
                }
                this.mh(false);
            }
        }
    };
    StrategyBasedIndicator.$t = markType(StrategyBasedIndicator, 'StrategyBasedIndicator', FinancialIndicator.$);
    StrategyBasedIndicator.uj = new List$1(String_$type, 0);
    return StrategyBasedIndicator;
}(FinancialIndicator));
export { StrategyBasedIndicator };
