/*
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 } from "tslib";
import { Base, runOn, delegateCombine, delegateRemove, markType } from "igniteui-react-core";
import { IDomainChartToolbarProvider_$type } from "./IDomainChartToolbarProvider";
import { ToolCommandStateChanged } from "igniteui-react-core";
import { ValueModeCollection } from "./ValueModeCollection";
import { BrushCollection } from "igniteui-react-core";
import { BrushUtil } from "igniteui-react-core";
import { CaptureImageSettings } from "igniteui-react-core";
/**
 * @hidden
 */
var DomainChartToolbarProvider = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(DomainChartToolbarProvider, _super);
    function DomainChartToolbarProvider() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.a = null;
        _this.b = false;
        _this._container = null;
        _this._commandChanged = null;
        return _this;
    }
    Object.defineProperty(DomainChartToolbarProvider.prototype, "container", {
        get: function () {
            return this._container;
        },
        set: function (a) {
            this._container = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DomainChartToolbarProvider.prototype, "commandChanged", {
        get: function () {
            return this._commandChanged;
        },
        set: function (a) {
            this._commandChanged = a;
        },
        enumerable: false,
        configurable: true
    });
    DomainChartToolbarProvider.prototype.getDesiredToolbarActions = function (a, b) {
        for (var c = 0; c < b.length; c++) {
            this.d(a, b[c]);
        }
        return b;
    };
    DomainChartToolbarProvider.prototype.d = function (a, b) {
        if (b.actions != null && b.actions.length > 0) {
            for (var c = 0; c < b.actions.length; c++) {
                this.d(a, b.actions[c]);
            }
        }
        switch (b.name) {
            case "ShowCrosshairs":
                {
                    var d = b;
                    d.isChecked = a.a9 != 1;
                }
                break;
            case "ShowGridlines":
                {
                    var e = b;
                    e.isChecked = a.fj;
                }
                break;
            case "ShowValueLabels":
                {
                    var f = b;
                    f.isChecked = a.fj;
                }
                break;
            case "ShowLastValueLabel":
                {
                    var g = b;
                    g.isChecked = a.ft;
                }
                break;
            case "MinValue":
                {
                    if (a.du != null) {
                        var h = b;
                        for (var i = 0; i < a.du.count; i++) {
                            if (a.du._inner[i] == 4) {
                                h.isChecked = true;
                                break;
                            }
                        }
                    }
                }
                break;
            case "MaxValue":
                {
                    if (a.du != null) {
                        var j = b;
                        for (var k = 0; k < a.du.count; k++) {
                            if (a.du._inner[k] == 5) {
                                j.isChecked = true;
                                break;
                            }
                        }
                    }
                }
                break;
            case "Average":
                {
                    if (a.du != null) {
                        var l = b;
                        for (var m = 0; m < a.du.count; m++) {
                            if (a.du._inner[m] == 6) {
                                l.isChecked = true;
                                break;
                            }
                        }
                    }
                }
                break;
            case "SeriesAvg":
                {
                    if (a.du != null) {
                        var n = b;
                        for (var o = 0; o < a.du.count; o++) {
                            if (a.du._inner[o] == 3) {
                                n.isChecked = true;
                                break;
                            }
                        }
                    }
                }
                break;
        }
        this.e(a, b);
    };
    DomainChartToolbarProvider.prototype.e = function (a, b) {
    };
    DomainChartToolbarProvider.prototype.onToolCommandExecuting = function (a, b) {
        this.b = true;
        var c = 0;
        switch (b.commandId) {
            case "ZoomReset":
                this.x(a, b);
                break;
            case "ZoomIn":
                this.v(a, b);
                break;
            case "ZoomOut":
                this.w(a, b);
                break;
            case "ShowCrosshairs":
                this.i(a, b);
                break;
            case "ShowGridlines":
                this.k(a, b);
                break;
            case "MaxValue":
                this.o(a, b);
                break;
            case "MinValue":
                this.p(a, b);
                break;
            case "Average":
                this.g(a, b);
                break;
            case "Exponential":
                this.j(a, b);
                break;
            case "Linear":
                this.m(a, b);
                break;
            case "Logarithmic":
                this.n(a, b);
                break;
            case "NoTrends":
                this.q(a, b);
                break;
            case "SeriesAvg":
                this.r(a, b);
                break;
            case "ShowValueLabels":
                this.t(a, b);
                break;
            case "ShowLastValueLabel":
                this.s(a, b);
                break;
            case "CopyAsImage":
                this.h(a, b);
                c = 2;
                break;
        }
        this.b = false;
        return c;
    };
    DomainChartToolbarProvider.prototype.onTargetPropertyChanged = function (a, b, c, d) {
        if (this.b) {
            return;
        }
        switch (b) {
            case "CrosshairsDisplayMode":
                if (a.a9 == 1) {
                    this.f("ShowCrosshairs", 2, false);
                }
                else {
                    this.f("ShowCrosshairs", 2, true);
                }
                break;
            case "AutoCalloutsVisible":
                this.f("ShowValueLabels", 2, a.fj);
                break;
            case "FinalValueAnnotationsVisible":
                this.f("ShowLastValueLabel", 2, a.ft);
                break;
        }
        this.u(a, b, c, d);
    };
    DomainChartToolbarProvider.prototype.u = function (a, b, c, d) {
    };
    DomainChartToolbarProvider.prototype.f = function (a, b, c) {
        if (this.commandChanged != null) {
            this.commandChanged(((function () {
                var $ret = new ToolCommandStateChanged();
                $ret.c = a;
                $ret.a = b;
                $ret.b = c;
                return $ret;
            })()));
        }
    };
    DomainChartToolbarProvider.prototype.c = function (a, b) {
        var e = a.argumentsList;
        for (var d = 0; d < e.length; d++) {
            var c = e[d];
            if (c.argumentName == b) {
                return c.value;
            }
        }
        return false;
    };
    DomainChartToolbarProvider.prototype.i = function (a, b) {
        if (this.c(b, "ShowCrosshairs")) {
            a.a9 = 0;
            a.fm = true;
        }
        else {
            a.a9 = 1;
        }
    };
    DomainChartToolbarProvider.prototype.k = function (a, b) {
    };
    DomainChartToolbarProvider.prototype.j = function (a, b) {
        if (this.c(b, "Exponential")) {
            a.dq = 7;
        }
        else {
            a.dq = 0;
        }
    };
    DomainChartToolbarProvider.prototype.m = function (a, b) {
        if (this.c(b, "Linear")) {
            a.dq = 1;
        }
        else {
            a.dq = 0;
        }
    };
    DomainChartToolbarProvider.prototype.n = function (a, b) {
        if (this.c(b, "Logarithmic")) {
            a.dq = 6;
        }
        else {
            a.dq = 0;
        }
    };
    DomainChartToolbarProvider.prototype.q = function (a, b) {
        if (this.c(b, "NoTrends")) {
            a.dq = 0;
        }
    };
    DomainChartToolbarProvider.prototype.o = function (a, b) {
        if (this.c(b, "MaxValue")) {
            if (a.du == null) {
                a.du = new ValueModeCollection();
            }
            if (a.ai == null) {
                a.ai = new BrushCollection();
            }
            a.du.add(5);
            a.ai.add(BrushUtil.g(255, 99, 208, 0));
        }
        else {
            for (var c = 0; c < a.du.count; c++) {
                if (a.du._inner[c] == 5) {
                    a.du.removeAt(c);
                    a.ai.removeAt(c);
                    c--;
                }
            }
        }
    };
    DomainChartToolbarProvider.prototype.p = function (a, b) {
        if (this.c(b, "MinValue")) {
            if (a.du == null) {
                a.du = new ValueModeCollection();
            }
            if (a.ai == null) {
                a.ai = new BrushCollection();
            }
            a.du.add(4);
            a.ai.add(BrushUtil.g(255, 246, 93, 80));
        }
        else {
            for (var c = 0; c < a.du.count; c++) {
                if (a.du._inner[c] == 4) {
                    a.du.removeAt(c);
                    a.ai.removeAt(c);
                    c--;
                }
            }
        }
    };
    DomainChartToolbarProvider.prototype.g = function (a, b) {
        if (this.c(b, "Average")) {
            if (a.du == null) {
                a.du = new ValueModeCollection();
            }
            if (a.ai == null) {
                a.ai = new BrushCollection();
            }
            a.du.add(6);
            a.ai.add(BrushUtil.g(255, 248, 173, 118));
        }
        else {
            for (var c = 0; c < a.du.count; c++) {
                if (a.du._inner[c] == 6) {
                    a.du.removeAt(c);
                    a.ai.removeAt(c);
                    c--;
                }
            }
        }
    };
    DomainChartToolbarProvider.prototype.r = function (a, b) {
        if (this.c(b, "SeriesAvg")) {
            if (a.du == null) {
                a.du = new ValueModeCollection();
            }
            a.du.add(3);
        }
        else {
            for (var c = 0; c < a.du.count; c++) {
                if (a.du._inner[c] == 3) {
                    a.du.removeAt(c);
                    c--;
                }
            }
        }
    };
    DomainChartToolbarProvider.prototype.t = function (a, b) {
        if (this.c(b, "ShowValueLabels")) {
            a.fj = true;
        }
        else {
            a.fj = false;
        }
    };
    DomainChartToolbarProvider.prototype.s = function (a, b) {
        if (this.c(b, "ShowLastValueLabel")) {
            a.ft = true;
            a.gb = true;
        }
        else {
            a.ft = false;
        }
    };
    DomainChartToolbarProvider.prototype.h = function (a, b) {
        this.a = b;
        var c = new CaptureImageSettings();
        c.b = true;
        c.a = 0;
        var d = a.dataChart;
        d.imageCaptured = delegateCombine(d.imageCaptured, runOn(this, this.l));
        a.dataChart.lr(c);
        a.dataChart.al.q();
    };
    DomainChartToolbarProvider.prototype.l = function (a, b) {
        this.a.argumentsList[0].value = b.base64Data;
        var c = a;
        c.imageCaptured = delegateRemove(c.imageCaptured, runOn(this, this.l));
        if (c.commandCompleted != null) {
            c.commandCompleted(this.a);
        }
    };
    DomainChartToolbarProvider.prototype.v = function (a, b) {
        a.tr(0.05);
    };
    DomainChartToolbarProvider.prototype.w = function (a, b) {
        a.ts(0.05);
    };
    DomainChartToolbarProvider.prototype.x = function (a, b) {
        a.tn();
    };
    DomainChartToolbarProvider.$t = markType(DomainChartToolbarProvider, 'DomainChartToolbarProvider', Base.$, [IDomainChartToolbarProvider_$type]);
    return DomainChartToolbarProvider;
}(Base));
export { DomainChartToolbarProvider };
