/*
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, typeCast, fromEnum, markType, TypeRegistrar } from "igniteui-angular-core";
import { IDataChartToolbarProvider_$type } from "./IDataChartToolbarProvider";
import { ToolActionIconButtonInfo } from "igniteui-angular-core";
import { ToolActionIconMenuInfo } from "igniteui-angular-core";
import { ToolActionGroupHeaderInfo } from "igniteui-angular-core";
import { ToolActionSeparatorInfo } from "igniteui-angular-core";
import { ToolActionLabelInfo } from "igniteui-angular-core";
import { ToolActionCheckboxInfo } from "igniteui-angular-core";
import { DeviceUtils } from "igniteui-angular-core";
import { ToolActionRadioInfo } from "igniteui-angular-core";
import { AutomaticSeriesRequest } from "./AutomaticSeriesRequest";
import { Axis } from "./Axis";
import { XamDataChart } from "./XamDataChart";
import { FastIterationDictionary$2 } from "igniteui-angular-core";
import { Brush } from "igniteui-angular-core";
import { BrushUtil } from "igniteui-angular-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.l = 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, "o", {
        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, "n", {
        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, "m", {
        get: function () {
            return (TypeRegistrar.isRegistered("AnnotationLayerProxy"));
        },
        enumerable: false,
        configurable: true
    });
    DataChartToolbarProvider.prototype.getDesiredToolbarActions = function () {
        var a = new ToolActionIconButtonInfo();
        a.name = "ZoomReset";
        a.iconName = "reset";
        a.iconCollectionName = "ChartToolbarIcons";
        a.title = "Reset";
        var b = new ToolActionIconMenuInfo();
        b.name = "ZoomMenu";
        b.iconName = "zoomin";
        b.iconCollectionName = "ChartToolbarIcons";
        b.actions = this.e();
        var c = new ToolActionGroupHeaderInfo();
        c.name = "AnalyzeHeader";
        c.title = "Analyze";
        var d = new ToolActionSeparatorInfo();
        d.name = "AnalyzeHeaderSeparator";
        d.isGroupHeaderSeparator = true;
        var e = new ToolActionLabelInfo();
        e.name = "LinesMenu";
        e.title = "Lines";
        e.iconName = "analyze-lines";
        e.iconCollectionName = "ChartToolbarIcons";
        e.actions = this.a();
        var f = new ToolActionSeparatorInfo();
        f.name = "LinesMenuSeparator";
        var g = new ToolActionLabelInfo();
        g.name = "TrendsMenu";
        g.title = "Trends";
        g.iconName = "analyze-trends";
        g.iconCollectionName = "ChartToolbarIcons";
        g.actions = this.c();
        var h = new ToolActionGroupHeaderInfo();
        h.name = "HelpersHeader";
        h.title = "Helpers";
        var i = new ToolActionSeparatorInfo();
        i.name = "HelpersHeaderSeparator";
        i.isGroupHeaderSeparator = true;
        var j = new ToolActionCheckboxInfo();
        j.name = "SeriesAvg";
        j.title = "Series Average";
        j.iconName = "analyze-seriesavg";
        j.iconCollectionName = "ChartToolbarIcons";
        var k = new ToolActionSeparatorInfo();
        k.name = "SeriesAvgSeparator";
        var l = new ToolActionLabelInfo();
        l.name = "ValueLabelsMenu";
        l.title = "Value Labels";
        l.iconName = "analyze-valuelabels";
        l.iconCollectionName = "ChartToolbarIcons";
        l.actions = this.d();
        var m = new ToolActionSeparatorInfo();
        m.name = "HelpersSectionSeparator";
        m.size = DeviceUtils.g(10);
        var n = new ToolActionCheckboxInfo();
        n.name = "ShowGridlines";
        n.title = "Grid";
        n.iconName = "analyze-grid";
        n.iconCollectionName = "ChartToolbarIcons";
        var o = new ToolActionSeparatorInfo();
        o.name = "GridSeparator";
        var p = new ToolActionCheckboxInfo();
        p.name = "ShowCrosshairs";
        p.title = "Crosshairs";
        p.iconName = "analyze-crosshairs";
        p.iconCollectionName = "ChartToolbarIcons";
        var q = new ToolActionIconMenuInfo();
        q.name = "AnalyzeMenu";
        q.iconName = "analyze";
        q.iconCollectionName = "ChartToolbarIcons";
        q.actions = [c, d, e, f, g, h, i, j, k, l, m, n, o, p];
        var r = new ToolActionGroupHeaderInfo();
        r.name = "CopyHeader";
        r.title = "Copy...";
        var s = new ToolActionLabelInfo();
        s.name = "CopyAsImage";
        s.title = "As Image";
        s.iconName = "copy-image";
        s.iconCollectionName = "ChartToolbarIcons";
        var t = new ToolActionLabelInfo();
        t.name = "CopyAsTable";
        t.title = "Table Data";
        t.iconName = "copy-table";
        t.iconCollectionName = "ChartToolbarIcons";
        var u = new ToolActionIconMenuInfo();
        u.name = "CopyMenu";
        u.iconName = "copy";
        u.iconCollectionName = "ChartToolbarIcons";
        u.actions = [r, s, t];
        return [a, b, ((function () {
                var $ret = new ToolActionSeparatorInfo();
                $ret.name = "ZoomMenuSeparator";
                return $ret;
            })()), q];
    };
    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.title = "Zoom In";
        var c = new ToolActionLabelInfo();
        c.name = "ZoomOut";
        c.iconName = "zoomout";
        c.iconCollectionName = "ChartToolbarIcons";
        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";
        var d = new ToolActionCheckboxInfo();
        d.name = "MinValue";
        d.title = "Min value";
        d.iconName = "analyze-lines-minvalue";
        d.iconCollectionName = "ChartToolbarIcons";
        var e = new ToolActionCheckboxInfo();
        e.name = "Average";
        e.title = "Average";
        e.iconName = "analyze-seriesavg";
        e.iconCollectionName = "ChartToolbarIcons";
        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.isGroupHeaderSeparator = true;
        var c = new ToolActionRadioInfo();
        c.name = "Exponential";
        c.title = "Exponential";
        c.iconName = "analyze-trends-exp";
        c.iconCollectionName = "ChartToolbarIcons";
        c.channel = "trends";
        var d = new ToolActionRadioInfo();
        d.name = "Linear";
        d.title = "Linear";
        d.iconName = "analyze-trends-trendline";
        d.iconCollectionName = "ChartToolbarIcons";
        d.channel = "trends";
        var e = new ToolActionRadioInfo();
        e.name = "Logarithmic";
        e.title = "Logarithmic";
        e.iconName = "analyze-trends-log";
        e.iconCollectionName = "ChartToolbarIcons";
        e.channel = "trends";
        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 () {
        var a = new ToolActionGroupHeaderInfo();
        a.name = "ValueLabelsHeader";
        a.title = "Value Labels";
        var b = new ToolActionSeparatorInfo();
        b.isGroupHeaderSeparator = true;
        var c = new ToolActionCheckboxInfo();
        c.name = "ShowValueLabels";
        c.title = "Show Value Labels";
        c.iconName = "analyze-valuelabels";
        c.iconCollectionName = "ChartToolbarIcons";
        var d = new ToolActionCheckboxInfo();
        d.name = "ShowLastValueLabel";
        d.title = "Show Last Value Label";
        d.iconName = "analyze-valuelabels-showlast";
        d.iconCollectionName = "ChartToolbarIcons";
        return [a, b, c, d];
    };
    DataChartToolbarProvider.prototype.onToolCommandExecuting = function (a, b) {
        if (b.commandId == null) {
            return;
        }
        switch (b.commandId) {
            case "ZoomReset":
                this.ae(a, b);
                break;
            case "ZoomIn":
                this.ac(a, b);
                break;
            case "ZoomOut":
                this.ad(a, b);
                break;
            case "ShowCrosshairs":
                this.r(a, b);
                break;
            case "ShowGridlines":
                this.t(a, b);
                break;
            case "MaxValue":
                this.w(a, b);
                break;
            case "MinValue":
                this.x(a, b);
                break;
            case "Average":
                this.q(a, b);
                break;
            case "Exponential":
                this.s(a, b);
                break;
            case "Linear":
                this.u(a, b);
                break;
            case "Logarithmic":
                this.v(a, b);
                break;
            case "NoTrends":
                this.y(a, b);
                break;
            case "SeriesAvg":
                this.z(a, b);
                break;
            case "ShowValueLabels":
                this.ab(a, b);
                break;
            case "ShowLastValueLabel":
                this.aa(a, b);
                break;
        }
    };
    DataChartToolbarProvider.prototype.p = 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;
    };
    DataChartToolbarProvider.prototype.r = function (a, b) {
        var _this = this;
        this.af(a, b, "ShowCrosshairs", 0, function () {
            var c = _this.g.createCrosshairLayer();
            _this.g.setCrosshairOnAxesEnabled(c, true);
            var d = new AutomaticSeriesRequest();
            d.a = 0;
            d.e = true;
            d.d = c;
            return d;
        });
    };
    DataChartToolbarProvider.prototype.t = function (a, b) {
        var c = false;
        var f = b.argumentsList;
        for (var e = 0; e < f.length; e++) {
            var d = f[e];
            if (d.argumentName == "ShowGridlines") {
                c = d.value;
            }
        }
        if (!c) {
            for (var g = 0; g < this.l.o.count; g++) {
                var h = this.l.o._inner[g];
                if (h.js != null) {
                    h.jv = BrushUtil.g(0, 0, 0, 0);
                }
            }
        }
        else {
            var i = typeCast(XamDataChart.$, a);
            if (i != null) {
                for (var j = 0; j < i.axes.count; j++) {
                    var k = i.axes._inner[j];
                    if (this.l.d(k)) {
                        k.jv = this.l.item(k);
                    }
                    else {
                        if (k.ca) {
                            if (k.jv == null) {
                                k.jv = i.xv;
                                this.l.s(k, i.xv);
                            }
                            else {
                                this.l.s(k, k.jv);
                            }
                        }
                    }
                }
            }
        }
    };
    DataChartToolbarProvider.prototype.s = function (a, b) {
        var e_1, _a;
        if (!this.o) {
            return;
        }
        var c = this.p(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.dj) {
                        if (this.o && this.k.matchesType(d)) {
                            this.k.setTrendLineType(d, 7);
                        }
                    }
                    else if (d.dv) {
                        if (this.n && this.i.matchesType(d)) {
                            this.i.setTrendLineType(d, 7);
                        }
                    }
                }
            }
            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;
                }
            }
        }
    };
    DataChartToolbarProvider.prototype.u = function (a, b) {
        var e_2, _a;
        if (!this.o) {
            return;
        }
        var c = this.p(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.dj) {
                        if (this.o && this.k.matchesType(d)) {
                            this.k.setTrendLineType(d, 1);
                        }
                    }
                    else if (d.dv) {
                        if (this.n && this.i.matchesType(d)) {
                            this.i.setTrendLineType(d, 1);
                        }
                    }
                }
            }
            catch (e_2_1) {
                e_2 = { error: e_2_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_2)
                        throw e_2.error;
                }
            }
        }
    };
    DataChartToolbarProvider.prototype.v = function (a, b) {
        var e_3, _a;
        var c = this.p(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.dj) {
                        if (this.o && this.k.matchesType(d)) {
                            this.k.setTrendLineType(d, 6);
                        }
                    }
                    else if (d.dv) {
                        if (this.n && this.i.matchesType(d)) {
                            this.i.setTrendLineType(d, 6);
                        }
                    }
                }
            }
            catch (e_3_1) {
                e_3 = { error: e_3_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_3)
                        throw e_3.error;
                }
            }
        }
    };
    DataChartToolbarProvider.prototype.y = function (a, b) {
        var e_4, _a;
        var c = this.p(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.dj) {
                        if (this.o && this.k.matchesType(d)) {
                            this.k.setTrendLineType(d, 0);
                        }
                    }
                    else if (d.dv) {
                        if (this.n && this.i.matchesType(d)) {
                            this.i.setTrendLineType(d, 0);
                        }
                    }
                }
            }
            catch (e_4_1) {
                e_4 = { error: e_4_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_4)
                        throw e_4.error;
                }
            }
        }
    };
    DataChartToolbarProvider.prototype.af = function (a, b, c, d, e) {
        var f = this.p(b, c);
        var g = a.ao(a);
        if (f && !g.e(d)) {
            if (this.m && e != null) {
                g.b.add(e());
            }
        }
        if (!f && g.e(d)) {
            g.l(d);
        }
    };
    DataChartToolbarProvider.prototype.w = function (a, b) {
        var _this = this;
        this.af(a, b, "MaxValue", 1, function () {
            var c = _this.g.createValueLayer();
            _this.g.setValueMode(c, 5);
            _this.g.setValueAxisAnnotationEnabled(c, true);
            _this.g.setBrush(c, BrushUtil.g(255, 99, 208, 0));
            var d = new AutomaticSeriesRequest();
            d.a = 1;
            d.e = true;
            d.d = c;
            return d;
        });
    };
    DataChartToolbarProvider.prototype.x = function (a, b) {
        var _this = this;
        this.af(a, b, "MinValue", 2, function () {
            var c = _this.g.createValueLayer();
            _this.g.setValueMode(c, 4);
            _this.g.setValueAxisAnnotationEnabled(c, true);
            _this.g.setBrush(c, BrushUtil.g(255, 246, 93, 80));
            var d = new AutomaticSeriesRequest();
            d.a = 2;
            d.e = true;
            d.d = c;
            return d;
        });
    };
    DataChartToolbarProvider.prototype.q = function (a, b) {
        var _this = this;
        this.af(a, b, "Average", 3, function () {
            var c = _this.g.createValueLayer();
            _this.g.setValueMode(c, 6);
            _this.g.setValueAxisAnnotationEnabled(c, true);
            _this.g.setBrush(c, BrushUtil.g(255, 248, 173, 118));
            var d = new AutomaticSeriesRequest();
            d.a = 3;
            d.e = true;
            d.d = c;
            return d;
        });
    };
    DataChartToolbarProvider.prototype.z = function (a, b) {
        var _this = this;
        this.af(a, b, "SeriesAvg", 4, function () {
            var c = _this.g.createValueLayer();
            _this.g.setValueMode(c, 3);
            _this.g.setValueAxisAnnotationEnabled(c, true);
            var d = new AutomaticSeriesRequest();
            d.a = 4;
            d.e = true;
            d.d = c;
            return d;
        });
    };
    DataChartToolbarProvider.prototype.ab = function (a, b) {
        var _this = this;
        this.af(a, b, "ShowValueLabels", 5, function () {
            var e_5, _a;
            try {
                for (var _b = __values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var c = _c.value;
                    if (c.dj) {
                        if (_this.o && _this.k.matchesType(c)) {
                            var d = _this.k.getMarkerType(c);
                            if (d == 1) {
                                _this.k.setMarkerType(c, 13);
                            }
                        }
                    }
                }
            }
            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;
                }
            }
            var e = _this.g.createCalloutLayer();
            _this.g.setIsAutoCalloutBehaviorEnabled(e, true);
            var f = new AutomaticSeriesRequest();
            f.a = 5;
            f.e = true;
            f.d = e;
            return f;
        });
    };
    DataChartToolbarProvider.prototype.aa = function (a, b) {
        var _this = this;
        this.af(a, b, "ShowLastValueLabel", 6, function () {
            var e_6, _a;
            try {
                for (var _b = __values(fromEnum(a.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var c = _c.value;
                    var d = c.ag();
                    for (var f = 0; f < d.length; f++) {
                        var e = d[f];
                        if (e.ci) {
                            e.ct = true;
                        }
                    }
                }
            }
            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;
                }
            }
            var g = _this.g.createFinalValueLayer();
            var h = new AutomaticSeriesRequest();
            h.a = 6;
            h.e = true;
            h.d = g;
            return h;
        });
    };
    DataChartToolbarProvider.prototype.ac = function (a, b) {
        a.pk(0.05);
    };
    DataChartToolbarProvider.prototype.ad = function (a, b) {
        a.pl(0.05);
    };
    DataChartToolbarProvider.prototype.ae = function (a, b) {
        a.ou();
    };
    DataChartToolbarProvider.$t = markType(DataChartToolbarProvider, 'DataChartToolbarProvider', Base.$, [IDataChartToolbarProvider_$type]);
    return DataChartToolbarProvider;
}(Base));
export { DataChartToolbarProvider };
