/*
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 { Base, BaseError, fromEnum, typeCast, runOn, delegateCombine, delegateRemove, markType, TypeRegistrar } from "igniteui-react-core";
import { IDataChartToolbarProvider_$type } from "./IDataChartToolbarProvider";
import { ToolActionIconButtonInfo } from "igniteui-react-core";
import { ToolActionIconMenuInfo } from "igniteui-react-core";
import { ToolActionGroupHeaderInfo } from "igniteui-react-core";
import { ToolActionSeparatorInfo } from "igniteui-react-core";
import { ToolActionLabelInfo } from "igniteui-react-core";
import { ToolActionCheckboxInfo } from "igniteui-react-core";
import { DeviceUtils } from "igniteui-react-core";
import { ToolActionRadioInfo } from "igniteui-react-core";
import { ToolCommandArgument } from "igniteui-react-core";
import { AutomaticSeriesRequest } from "./AutomaticSeriesRequest";
import { Axis } from "./Axis";
import { XamDataChart } from "./XamDataChart";
import { FastIterationDictionary$2 } from "igniteui-react-core";
import { Brush } from "igniteui-react-core";
import { BrushUtil } from "igniteui-react-core";
import { CaptureImageSettings } from "igniteui-react-core";
/**
 * @hidden
 */
var DataChartToolbarProvider = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(DataChartToolbarProvider, _super);
    function DataChartToolbarProvider() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this._container = null;
        _this.j = null;
        _this.h = null;
        _this.f = null;
        _this.p = null;
        _this.q = new FastIterationDictionary$2(Axis.$, Brush.$, 0);
        return _this;
    }
    Object.defineProperty(DataChartToolbarProvider.prototype, "container", {
        get: function () {
            return this._container;
        },
        set: function (a) {
            this._container = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DataChartToolbarProvider.prototype, "k", {
        get: function () {
            if (TypeRegistrar.isRegistered("HorizontalAnchoredCategorySeriesProxy")) {
                return TypeRegistrar.create("HorizontalAnchoredCategorySeriesProxy");
            }
            else {
                throw new BaseError(1, "category series module is not loaded, but is required.");
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DataChartToolbarProvider.prototype, "t", {
        get: function () {
            return (TypeRegistrar.isRegistered("HorizontalAnchoredCategorySeriesProxy"));
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DataChartToolbarProvider.prototype, "i", {
        get: function () {
            if (TypeRegistrar.isRegistered("FinancialPriceSeriesProxy")) {
                return TypeRegistrar.create("FinancialPriceSeriesProxy");
            }
            else {
                throw new BaseError(1, "category series module is not loaded, but is required.");
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DataChartToolbarProvider.prototype, "s", {
        get: function () {
            return (TypeRegistrar.isRegistered("HorizontalAnchoredCategorySeriesProxy"));
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DataChartToolbarProvider.prototype, "g", {
        get: function () {
            if (this.f == null) {
                if (TypeRegistrar.isRegistered("AnnotationLayerProxy")) {
                    this.f = TypeRegistrar.create("AnnotationLayerProxy");
                    this.f.container = this.container;
                }
                else {
                    throw new BaseError(1, "annotation layer module is not loaded, but is required.");
                }
            }
            return this.f;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(DataChartToolbarProvider.prototype, "r", {
        get: function () {
            return (TypeRegistrar.isRegistered("AnnotationLayerProxy"));
        },
        enumerable: false,
        configurable: true
    });
    DataChartToolbarProvider.prototype.getDesiredToolbarActions = function (a) {
        var b = new ToolActionIconButtonInfo();
        b.name = "ZoomReset";
        b.iconName = "reset";
        b.iconCollectionName = "ChartToolbarIcons";
        b.iconWidth = 24;
        b.iconHeight = 24;
        b.title = "Reset";
        var c = new ToolActionIconMenuInfo();
        c.name = "ZoomMenu";
        c.iconName = "zoomin";
        c.iconCollectionName = "ChartToolbarIcons";
        c.iconWidth = 24;
        c.iconHeight = 25;
        c.actions = this.e();
        var d = new ToolActionGroupHeaderInfo();
        d.name = "AnalyzeHeader";
        d.title = "Analyze";
        var e = new ToolActionSeparatorInfo();
        e.name = "AnalyzeHeaderSeparator";
        e.isGroupHeaderSeparator = true;
        var f = new ToolActionLabelInfo();
        f.name = "LinesMenu";
        f.title = "Lines";
        f.iconName = "analyze-lines";
        f.iconCollectionName = "ChartToolbarIcons";
        f.iconWidth = 24;
        f.iconHeight = 25;
        f.actions = this.a();
        var g = new ToolActionSeparatorInfo();
        g.name = "LinesMenuSeparator";
        var h = new ToolActionLabelInfo();
        h.name = "TrendsMenu";
        h.title = "Trends";
        h.iconName = "analyze-trends";
        h.iconCollectionName = "ChartToolbarIcons";
        h.iconWidth = 24;
        h.iconHeight = 25;
        h.actions = this.c();
        var i = new ToolActionGroupHeaderInfo();
        i.name = "HelpersHeader";
        i.title = "Helpers";
        var j = new ToolActionSeparatorInfo();
        j.name = "HelpersHeaderSeparator";
        j.isGroupHeaderSeparator = true;
        var k = new ToolActionCheckboxInfo();
        k.name = "SeriesAvg";
        k.title = "Series Average";
        k.iconName = "analyze-seriesavg";
        k.iconCollectionName = "ChartToolbarIcons";
        k.iconWidth = 24;
        k.iconHeight = 25;
        var l = new ToolActionSeparatorInfo();
        l.name = "SeriesAvgSeparator";
        var m = new ToolActionLabelInfo();
        m.name = "ValueLabelsMenu";
        m.title = "Value Labels";
        m.iconName = "analyze-valuelabels";
        m.iconCollectionName = "ChartToolbarIcons";
        m.actions = this.d(a);
        m.iconWidth = 24;
        m.iconHeight = 24;
        var n = new ToolActionSeparatorInfo();
        n.name = "HelpersSectionSeparator";
        n.size = DeviceUtils.g(10);
        var o = new ToolActionCheckboxInfo();
        o.name = "ShowGridlines";
        o.title = "Grid";
        o.iconName = "analyze-grid";
        o.iconCollectionName = "ChartToolbarIcons";
        o.iconWidth = 24;
        o.iconHeight = 25;
        var p = new ToolActionSeparatorInfo();
        p.name = "GridSeparator";
        var q = new ToolActionCheckboxInfo();
        q.name = "ShowCrosshairs";
        q.title = "Crosshairs";
        q.iconName = "analyze-crosshairs";
        q.iconCollectionName = "ChartToolbarIcons";
        q.iconWidth = 24;
        q.iconHeight = 25;
        var r = new ToolActionIconMenuInfo();
        r.name = "AnalyzeMenu";
        r.iconName = "analyze";
        r.iconCollectionName = "ChartToolbarIcons";
        r.iconWidth = 24;
        r.iconHeight = 25;
        r.actions = [d, e, f, g, h, i, j, k, l, m, n, o, p, q];
        var s = new ToolActionGroupHeaderInfo();
        s.name = "CopyHeader";
        s.title = "Copy...";
        var t = new ToolActionLabelInfo();
        t.name = "CopyAsImage";
        t.title = "As Image";
        t.iconName = "copy-image";
        t.iconCollectionName = "ChartToolbarIcons";
        t.closeOnExecute = true;
        var u = new ToolActionLabelInfo();
        u.name = "CopyAsTable";
        u.title = "Table Data";
        u.iconName = "copy-table";
        u.iconCollectionName = "ChartToolbarIcons";
        var v = new ToolActionIconMenuInfo();
        v.name = "CopyMenu";
        v.iconName = "copy";
        v.iconCollectionName = "ChartToolbarIcons";
        v.iconWidth = 24;
        v.iconHeight = 24;
        v.actions = [s, t];
        var w = [b, c, ((function () {
                var $ret = new ToolActionSeparatorInfo();
                $ret.name = "ZoomMenuSeparator";
                return $ret;
            })()), r, ((function () {
                var $ret = new ToolActionSeparatorInfo();
                $ret.name = "AnalyzeMenuSeparator";
                return $ret;
            })()), v];
        for (var x = 0; x < w.length; x++) {
            this.a7(a, w[x]);
        }
        return w;
    };
    DataChartToolbarProvider.prototype.a7 = function (a, b) {
        var e_1, _a, e_2, _b, e_3, _c, e_4, _d;
        if (b.actions != null && b.actions.length > 0) {
            for (var c = 0; c < b.actions.length; c++) {
                this.a7(a, b.actions[c]);
            }
        }
        switch (b.name) {
            case "ShowValueLabels":
                {
                    var d = b;
                    var e = this.l(a);
                    d.isChecked = e != null && e._visibility == 0;
                }
                break;
            case "ShowLastValueLabel":
                {
                    var f = b;
                    var g = this.n(a);
                    f.isChecked = g != null && g._visibility == 0;
                }
                break;
            case "Linear":
                {
                    var h = b;
                    try {
                        for (var _e = __values(fromEnum(a.series)), _f = _e.next(); !_f.done; _f = _e.next()) {
                            var i = _f.value;
                            if (i.ey) {
                                if (this.t && this.k.matchesType(i)) {
                                    h.isChecked = this.k.getTrendLineType(i) == 1;
                                }
                            }
                            else if (i.e9) {
                                if (this.s && this.i.matchesType(i)) {
                                    h.isChecked = this.i.getTrendLineType(i) == 1;
                                }
                            }
                        }
                    }
                    catch (e_1_1) {
                        e_1 = { error: e_1_1 };
                    }
                    finally {
                        try {
                            if (_f && !_f.done && (_a = _e.return))
                                _a.call(_e);
                        }
                        finally {
                            if (e_1)
                                throw e_1.error;
                        }
                    }
                }
                break;
            case "Exponential":
                {
                    var j = b;
                    try {
                        for (var _g = __values(fromEnum(a.series)), _h = _g.next(); !_h.done; _h = _g.next()) {
                            var k = _h.value;
                            if (k.ey) {
                                if (this.t && this.k.matchesType(k)) {
                                    j.isChecked = this.k.getTrendLineType(k) == 7;
                                }
                            }
                            else if (k.e9) {
                                if (this.s && this.i.matchesType(k)) {
                                    j.isChecked = this.i.getTrendLineType(k) == 7;
                                }
                            }
                        }
                    }
                    catch (e_2_1) {
                        e_2 = { error: e_2_1 };
                    }
                    finally {
                        try {
                            if (_h && !_h.done && (_b = _g.return))
                                _b.call(_g);
                        }
                        finally {
                            if (e_2)
                                throw e_2.error;
                        }
                    }
                }
                break;
            case "Logarithmic":
                {
                    var l = b;
                    try {
                        for (var _j = __values(fromEnum(a.series)), _k = _j.next(); !_k.done; _k = _j.next()) {
                            var m = _k.value;
                            if (m.ey) {
                                if (this.t && this.k.matchesType(m)) {
                                    l.isChecked = this.k.getTrendLineType(m) == 6;
                                }
                            }
                            else if (m.e9) {
                                if (this.s && this.i.matchesType(m)) {
                                    l.isChecked = this.i.getTrendLineType(m) == 6;
                                }
                            }
                        }
                    }
                    catch (e_3_1) {
                        e_3 = { error: e_3_1 };
                    }
                    finally {
                        try {
                            if (_k && !_k.done && (_c = _j.return))
                                _c.call(_j);
                        }
                        finally {
                            if (e_3)
                                throw e_3.error;
                        }
                    }
                }
                break;
            case "NoTrends":
                {
                    var n = b;
                    var o = 0;
                    var p = a.series.count;
                    try {
                        for (var _l = __values(fromEnum(a.series)), _m = _l.next(); !_m.done; _m = _l.next()) {
                            var q = _m.value;
                            if (q.ey) {
                                if (this.t && this.k.matchesType(q) && this.k.getTrendLineType(q) == 0) {
                                    o = o + 1;
                                }
                            }
                            else if (q.e9) {
                                if (this.s && this.i.matchesType(q) && this.i.getTrendLineType(q) == 0) {
                                    o = o + 1;
                                }
                            }
                            else if (q.es) {
                                p = p - 1;
                            }
                        }
                    }
                    catch (e_4_1) {
                        e_4 = { error: e_4_1 };
                    }
                    finally {
                        try {
                            if (_m && !_m.done && (_d = _l.return))
                                _d.call(_l);
                        }
                        finally {
                            if (e_4)
                                throw e_4.error;
                        }
                    }
                    n.isChecked = o == p;
                }
                break;
            case "MinValue":
                {
                    var r = b;
                    var s = this.o(a, 4);
                    r.isChecked = s != null && s._visibility == 0;
                }
                break;
            case "MaxValue":
                {
                    var t = b;
                    var u = this.o(a, 5);
                    t.isChecked = u != null && u._visibility == 0;
                }
                break;
            case "Average":
                {
                    var v = b;
                    var w = this.o(a, 6);
                    v.isChecked = w != null && w._visibility == 0;
                }
                break;
            case "ShowCrosshairs":
                {
                    var x = b;
                    var y = this.m(a);
                    x.isChecked = y != null && y._visibility == 0;
                }
                break;
            case "SeriesAvg":
                {
                    var z = b;
                    var aa = this.o(a, 3);
                    z.isChecked = aa != null && aa._visibility == 0;
                }
                break;
        }
    };
    DataChartToolbarProvider.prototype.e = function () {
        var a = new ToolActionGroupHeaderInfo();
        a.name = "ZoomHeader";
        a.title = "Zoom";
        var b = new ToolActionLabelInfo();
        b.name = "ZoomIn";
        b.iconName = "zoomin";
        b.iconCollectionName = "ChartToolbarIcons";
        b.iconWidth = 24;
        b.iconHeight = 25;
        b.title = "Zoom In";
        var c = new ToolActionLabelInfo();
        c.name = "ZoomOut";
        c.iconName = "zoomout";
        c.iconCollectionName = "ChartToolbarIcons";
        c.iconWidth = 24;
        c.iconHeight = 25;
        c.title = "Zoom Out";
        return [a, b, c];
    };
    DataChartToolbarProvider.prototype.a = function () {
        var a = new ToolActionGroupHeaderInfo();
        a.name = "LinesHeader";
        a.title = "Lines";
        var b = new ToolActionSeparatorInfo();
        b.isGroupHeaderSeparator = true;
        var c = new ToolActionCheckboxInfo();
        c.name = "MaxValue";
        c.title = "Max value";
        c.iconName = "analyze-lines-maxvalue";
        c.iconCollectionName = "ChartToolbarIcons";
        c.iconWidth = 24;
        c.iconHeight = 25;
        var d = new ToolActionCheckboxInfo();
        d.name = "MinValue";
        d.title = "Min value";
        d.iconName = "analyze-lines-minvalue";
        d.iconCollectionName = "ChartToolbarIcons";
        d.iconWidth = 24;
        d.iconHeight = 25;
        var e = new ToolActionCheckboxInfo();
        e.name = "Average";
        e.title = "Average";
        e.iconName = "analyze-seriesavg";
        e.iconCollectionName = "ChartToolbarIcons";
        e.iconWidth = 24;
        e.iconHeight = 25;
        return [a, b, c, d, e];
    };
    DataChartToolbarProvider.prototype.c = function () {
        var a = new ToolActionGroupHeaderInfo();
        a.name = "TrendsHeader";
        a.title = "Trends";
        var b = new ToolActionSeparatorInfo();
        b.name = "TrendsHeaderSeparator";
        b.isGroupHeaderSeparator = true;
        var c = new ToolActionRadioInfo();
        c.name = "Exponential";
        c.title = "Exponential";
        c.iconName = "analyze-trends-exp";
        c.iconCollectionName = "ChartToolbarIcons";
        c.channel = "trends";
        c.iconWidth = 24;
        c.iconHeight = 25;
        var d = new ToolActionRadioInfo();
        d.name = "Linear";
        d.title = "Linear";
        d.iconName = "analyze-trends-trendline";
        d.iconCollectionName = "ChartToolbarIcons";
        d.channel = "trends";
        d.iconWidth = 24;
        d.iconHeight = 25;
        var e = new ToolActionRadioInfo();
        e.name = "Logarithmic";
        e.title = "Logarithmic";
        e.iconName = "analyze-trends-log";
        e.iconCollectionName = "ChartToolbarIcons";
        e.channel = "trends";
        e.iconWidth = 24;
        e.iconHeight = 25;
        var f = new ToolActionRadioInfo();
        f.name = "NoTrends";
        f.title = "None";
        f.channel = "trends";
        f.iconName = "ig-NoIcon";
        return [a, b, c, d, e, f];
    };
    DataChartToolbarProvider.prototype.b = function () {
        var a = new ToolActionGroupHeaderInfo();
        a.name = "TimePeriodHighlightHeader";
        a.title = "TIME HIGHLIGHT";
        var b = new ToolActionSeparatorInfo();
        b.isGroupHeaderSeparator = true;
        var c = new ToolActionRadioInfo();
        c.name = "Quarters";
        c.title = "Quarters";
        c.channel = "time";
        var d = new ToolActionRadioInfo();
        d.name = "Seasons";
        d.title = "Seasons";
        d.channel = "time";
        var e = new ToolActionRadioInfo();
        e.name = "Weekends";
        e.title = "Weekends";
        e.channel = "time";
        var f = new ToolActionRadioInfo();
        f.name = "WorkDays";
        f.title = "Work days";
        f.channel = "time";
        return [a, b, c, d, e, f];
    };
    DataChartToolbarProvider.prototype.d = function (a) {
        var b = new ToolActionGroupHeaderInfo();
        b.name = "ValueLabelsHeader";
        b.title = "Value Labels";
        var c = new ToolActionSeparatorInfo();
        c.isGroupHeaderSeparator = true;
        var d = new ToolActionCheckboxInfo();
        d.name = "ShowValueLabels";
        d.title = "Show Value Labels";
        d.iconName = "analyze-valuelabels";
        d.iconCollectionName = "ChartToolbarIcons";
        d.iconWidth = 24;
        d.iconHeight = 24;
        var e = new ToolActionCheckboxInfo();
        e.name = "ShowLastValueLabel";
        e.title = "Show Last Value Label";
        e.iconName = "analyze-valuelabels-showlast";
        e.iconCollectionName = "ChartToolbarIcons";
        return [b, c, d, e];
    };
    DataChartToolbarProvider.prototype.l = function (a) {
        var e_5, _a;
        try {
            for (var _b = __values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                if (this.g.isCalloutLayer(b) && this.g.getIsAutoCalloutBehaviorEnabled(b)) {
                    return b;
                }
            }
        }
        catch (e_5_1) {
            e_5 = { error: e_5_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_5)
                    throw e_5.error;
            }
        }
        return null;
    };
    DataChartToolbarProvider.prototype.n = function (a) {
        var e_6, _a;
        try {
            for (var _b = __values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                if (this.g.isFinalValueLayer(b)) {
                    return b;
                }
            }
        }
        catch (e_6_1) {
            e_6 = { error: e_6_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_6)
                    throw e_6.error;
            }
        }
        return null;
    };
    DataChartToolbarProvider.prototype.o = function (a, b) {
        var e_7, _a;
        try {
            for (var _b = __values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var c = _c.value;
                if (this.g.isValueLayer(c) && this.g.getValueMode(c) == b) {
                    return c;
                }
            }
        }
        catch (e_7_1) {
            e_7 = { error: e_7_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_7)
                    throw e_7.error;
            }
        }
        return null;
    };
    DataChartToolbarProvider.prototype.m = function (a) {
        var e_8, _a;
        try {
            for (var _b = __values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var b = _c.value;
                if (this.g.isCrosshairLayer(b)) {
                    return b;
                }
            }
        }
        catch (e_8_1) {
            e_8 = { error: e_8_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_8)
                    throw e_8.error;
            }
        }
        return null;
    };
    DataChartToolbarProvider.prototype.onToolCommandExecuting = function (a, b) {
        switch (b.commandId) {
            case "ZoomReset":
                this.bo(a, b);
                break;
            case "ZoomIn":
                this.bm(a, b);
                break;
            case "ZoomOut":
                this.bn(a, b);
                break;
            case "ShowCrosshairs":
                this.ba(a, b);
                break;
            case "ShowGridlines":
                this.bc(a, b);
                break;
            case "MaxValue":
                this.bg(a, b);
                break;
            case "MinValue":
                this.bh(a, b);
                break;
            case "Average":
                this.a8(a, b);
                break;
            case "Exponential":
                this.bb(a, b);
                break;
            case "Linear":
                this.be(a, b);
                break;
            case "Logarithmic":
                this.bf(a, b);
                break;
            case "NoTrends":
                this.bi(a, b);
                break;
            case "SeriesAvg":
                this.bj(a, b);
                break;
            case "ShowValueLabels":
                this.bl(a, b);
                break;
            case "ShowLastValueLabel":
                this.bk(a, b);
                break;
            case "CopyAsImage":
                this.a9(a, b);
                return 2;
        }
        return 0;
    };
    DataChartToolbarProvider.prototype.u = function (a, b) {
        if (a.commandId == b) {
            var e = a.argumentsList;
            for (var d = 0; d < e.length; d++) {
                var c = e[d];
                if (c.argumentName == "IsChecked") {
                    return c.value;
                }
            }
        }
        return false;
    };
    DataChartToolbarProvider.prototype.ba = function (a, b) {
        var _this = this;
        var c = this.m(a);
        if (this.v(a, c)) {
            return;
        }
        this.bp(a, b, "ShowCrosshairs", 0, function () {
            var d = _this.g.createCrosshairLayer();
            _this.g.setCrosshairOnAxesEnabled(d, true);
            var e = new AutomaticSeriesRequest();
            e.a = 0;
            e.e = true;
            e.d = d;
            return e;
        });
    };
    DataChartToolbarProvider.prototype.bc = function (a, b) {
        var c = this.u(b, "ShowGridlines");
        if (!c) {
            for (var d = 0; d < this.q.o.count; d++) {
                var e = this.q.o._inner[d];
                if (e.jw != null) {
                    e.jz = BrushUtil.h(0, 0, 0, 0);
                }
            }
        }
        else {
            var f = typeCast(XamDataChart.$, a);
            if (f != null) {
                for (var g = 0; g < f.axes.count; g++) {
                    var h = f.axes._inner[g];
                    if (this.q.d(h)) {
                        h.jz = this.q.item(h);
                    }
                    else {
                        if (h.cb) {
                            if (h.jz == null) {
                                h.jz = f.aap;
                                this.q.s(h, f.aap);
                            }
                            else {
                                this.q.s(h, h.jz);
                            }
                        }
                    }
                }
            }
        }
    };
    DataChartToolbarProvider.prototype.bb = function (a, b) {
        var e_9, _a;
        if (!this.t) {
            return;
        }
        var c = this.u(b, "Exponential");
        if (c) {
            try {
                for (var _b = __values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var d = _c.value;
                    if (d.ey) {
                        if (this.t && this.k.matchesType(d)) {
                            this.k.setTrendLineType(d, 7);
                        }
                    }
                    else if (d.e9) {
                        if (this.s && this.i.matchesType(d)) {
                            this.i.setTrendLineType(d, 7);
                        }
                    }
                }
            }
            catch (e_9_1) {
                e_9 = { error: e_9_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_9)
                        throw e_9.error;
                }
            }
        }
    };
    DataChartToolbarProvider.prototype.be = function (a, b) {
        var e_10, _a;
        if (!this.t) {
            return;
        }
        var c = this.u(b, "Linear");
        if (c) {
            try {
                for (var _b = __values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var d = _c.value;
                    if (d.ey) {
                        if (this.t && this.k.matchesType(d)) {
                            this.k.setTrendLineType(d, 1);
                        }
                    }
                    else if (d.e9) {
                        if (this.s && this.i.matchesType(d)) {
                            this.i.setTrendLineType(d, 1);
                        }
                    }
                }
            }
            catch (e_10_1) {
                e_10 = { error: e_10_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_10)
                        throw e_10.error;
                }
            }
        }
    };
    DataChartToolbarProvider.prototype.bf = function (a, b) {
        var e_11, _a;
        var c = this.u(b, "Logarithmic");
        if (c) {
            try {
                for (var _b = __values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var d = _c.value;
                    if (d.ey) {
                        if (this.t && this.k.matchesType(d)) {
                            this.k.setTrendLineType(d, 6);
                        }
                    }
                    else if (d.e9) {
                        if (this.s && this.i.matchesType(d)) {
                            this.i.setTrendLineType(d, 6);
                        }
                    }
                }
            }
            catch (e_11_1) {
                e_11 = { error: e_11_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_11)
                        throw e_11.error;
                }
            }
        }
    };
    DataChartToolbarProvider.prototype.bi = function (a, b) {
        var e_12, _a;
        var c = this.u(b, "NoTrends");
        if (c) {
            try {
                for (var _b = __values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var d = _c.value;
                    if (d.ey) {
                        if (this.t && this.k.matchesType(d)) {
                            this.k.setTrendLineType(d, 0);
                        }
                    }
                    else if (d.e9) {
                        if (this.s && this.i.matchesType(d)) {
                            this.i.setTrendLineType(d, 0);
                        }
                    }
                }
            }
            catch (e_12_1) {
                e_12 = { error: e_12_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_12)
                        throw e_12.error;
                }
            }
        }
    };
    DataChartToolbarProvider.prototype.bp = function (a, b, c, d, e) {
        var f = this.u(b, c);
        var g = a.ao(a);
        if (f && !g.e(d)) {
            if (this.r && e != null) {
                g.b.add(e());
            }
        }
        if (!f && g.e(d)) {
            g.l(d);
        }
    };
    DataChartToolbarProvider.prototype.bg = function (a, b) {
        var _this = this;
        var c = this.o(a, 5);
        if (c != null && this.g.getValueMode(c) == 5 && this.v(a, c)) {
            return;
        }
        this.bp(a, b, "MaxValue", 1, function () {
            var d = _this.g.createValueLayer();
            _this.g.setValueMode(d, 5);
            _this.g.setValueAxisAnnotationEnabled(d, true);
            _this.g.setBrush(d, BrushUtil.h(255, 99, 208, 0));
            _this.g.setUseLegend(d, true);
            _this.g.setTitle(d, "Maximum");
            _this.g.setLegendItemBadgeShape(d, 2);
            var e = new AutomaticSeriesRequest();
            e.a = 1;
            e.e = true;
            e.d = d;
            return e;
        });
    };
    DataChartToolbarProvider.prototype.bh = function (a, b) {
        var _this = this;
        var c = this.o(a, 4);
        if (c != null && this.v(a, c)) {
            return;
        }
        this.bp(a, b, "MinValue", 2, function () {
            var d = _this.g.createValueLayer();
            _this.g.setValueMode(d, 4);
            _this.g.setValueAxisAnnotationEnabled(d, true);
            _this.g.setBrush(d, BrushUtil.h(255, 246, 93, 80));
            _this.g.setUseLegend(d, true);
            _this.g.setTitle(d, "Minimum");
            _this.g.setLegendItemBadgeShape(d, 2);
            var e = new AutomaticSeriesRequest();
            e.a = 2;
            e.e = true;
            e.d = d;
            return e;
        });
    };
    DataChartToolbarProvider.prototype.a8 = function (a, b) {
        var _this = this;
        var c = this.o(a, 6);
        if (c != null && this.v(a, c)) {
            return;
        }
        this.bp(a, b, "Average", 3, function () {
            var d = _this.g.createValueLayer();
            _this.g.setValueMode(d, 6);
            _this.g.setValueAxisAnnotationEnabled(d, true);
            _this.g.setBrush(d, BrushUtil.h(255, 248, 173, 118));
            _this.g.setUseLegend(d, true);
            _this.g.setTitle(d, "Average");
            _this.g.setLegendItemBadgeShape(d, 2);
            var e = new AutomaticSeriesRequest();
            e.a = 3;
            e.e = true;
            e.d = d;
            return e;
        });
    };
    DataChartToolbarProvider.prototype.bj = function (a, b) {
        var c = a.ao(a);
        var d = this.o(a, 3);
        if (d != null) {
            c.l(4);
            return;
        }
        if (!this.r) {
            return;
        }
        var e = a.series.count;
        for (var f = 0; f < e; f++) {
            var g = a.series._inner[f];
            if (g.es) {
                continue;
            }
            var h = this.g.createValueLayer();
            this.g.setValueMode(h, 3);
            this.g.setValueAxisAnnotationEnabled(h, true);
            this.g.setUseLegend(h, a.f2);
            if (g.title != null && typeof g.title === 'string') {
                var i = g.title;
                this.g.setTitle(h, i + " Avg");
            }
            this.g.setLegendItemBadgeShape(h, 2);
            this.g.setTargetSeries(h, g);
            this.g.setBrush(h, g.u7);
            var j = new AutomaticSeriesRequest();
            j.a = 4;
            j.e = true;
            j.d = h;
            c.b.add(j);
        }
    };
    DataChartToolbarProvider.prototype.v = function (a, b) {
        var e_13, _a;
        if (b != null) {
            var c = false;
            var d = a.ao(a);
            try {
                for (var _b = __values(fromEnum(d.b)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var e = _c.value;
                    if (e.d == b) {
                        c = true;
                        break;
                    }
                }
            }
            catch (e_13_1) {
                e_13 = { error: e_13_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_13)
                        throw e_13.error;
                }
            }
            if (!c) {
                if (b._visibility == 0) {
                    var cl_ = b;
                    var v_ = 1;
                    cl_.visibility = v_;
                    return true;
                }
                else if (b._visibility == 1) {
                    var cl_ = b;
                    var v_ = 0;
                    cl_.visibility = v_;
                    return true;
                }
            }
        }
        return false;
    };
    DataChartToolbarProvider.prototype.bl = function (a, b) {
        var _this = this;
        var c = this.l(a);
        if (this.v(a, c)) {
            return;
        }
        this.bp(a, b, "ShowValueLabels", 5, function () {
            var e_14, _a;
            try {
                for (var _b = __values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var d = _c.value;
                    if (d.ey) {
                        if (_this.t && _this.k.matchesType(d)) {
                            var e = _this.k.getMarkerType(d);
                            if (e == 1) {
                                _this.k.setMarkerType(d, 13);
                            }
                        }
                    }
                }
            }
            catch (e_14_1) {
                e_14 = { error: e_14_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_14)
                        throw e_14.error;
                }
            }
            var f = _this.g.createCalloutLayer();
            _this.g.setIsAutoCalloutBehaviorEnabled(f, true);
            var g = new AutomaticSeriesRequest();
            g.a = 5;
            g.e = true;
            g.d = f;
            return g;
        });
    };
    DataChartToolbarProvider.prototype.bk = function (a, b) {
        var _this = this;
        var c = this.n(a);
        if (this.v(a, c)) {
            return;
        }
        this.bp(a, b, "ShowLastValueLabel", 6, function () {
            var e_15, _a;
            try {
                for (var _b = __values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var d = _c.value;
                    var e = d.ai();
                    if (e != null) {
                        for (var g = 0; g < e.length; g++) {
                            var f = e[g];
                            if (f.cj) {
                                f.cu = true;
                            }
                        }
                    }
                }
            }
            catch (e_15_1) {
                e_15 = { error: e_15_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_15)
                        throw e_15.error;
                }
            }
            var h = _this.g.createFinalValueLayer();
            var i = new AutomaticSeriesRequest();
            i.a = 6;
            i.e = true;
            i.d = h;
            return i;
        });
    };
    DataChartToolbarProvider.prototype.a9 = function (a, b) {
        this.p = b;
        var c = new CaptureImageSettings();
        c.b = true;
        c.a = 0;
        a.imageCaptured = delegateCombine(a.imageCaptured, runOn(this, this.bd));
        a.nb(c);
        a.al.q();
    };
    DataChartToolbarProvider.prototype.bd = function (a, b) {
        this.p.argumentsList = [((function () {
                var $ret = new ToolCommandArgument();
                $ret.argumentName = "Image";
                $ret.value = b.base64Data;
                return $ret;
            })())];
        var c = a;
        c.imageCaptured = delegateRemove(c.imageCaptured, runOn(this, this.bd));
        if (c.commandCompleted != null) {
            c.commandCompleted(this.p);
        }
    };
    DataChartToolbarProvider.prototype.bm = function (a, b) {
        a.rz(0.05);
    };
    DataChartToolbarProvider.prototype.bn = function (a, b) {
        a.r0(0.05);
    };
    DataChartToolbarProvider.prototype.bo = function (a, b) {
        a.q8();
    };
    DataChartToolbarProvider.$t = markType(DataChartToolbarProvider, 'DataChartToolbarProvider', Base.$, [IDataChartToolbarProvider_$type]);
    return DataChartToolbarProvider;
}(Base));
export { DataChartToolbarProvider };
