/*
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 { IAxisVisualDataManager_$type } from "./IAxisVisualDataManager";
import { TextBlock } from "igniteui-react-core/ES5/TextBlock";
import { VisualExportHelper } from "./VisualExportHelper";
import { ChartTitleVisualData } from "./ChartTitleVisualData";
import { HorizontalAlignment_$type } from "igniteui-react-core/ES5/HorizontalAlignment";
import { VerticalAlignment_$type } from "igniteui-react-core/ES5/VerticalAlignment";
import { AxisTitlePosition_$type } from "./AxisTitlePosition";
import { RectData } from "igniteui-react-core/ES5/RectData";
import { AppearanceHelper } from "igniteui-react-core/ES5/AppearanceHelper";
import { AxisVisualData } from "./AxisVisualData";
import { PathVisualData } from "igniteui-react-core/ES5/PathVisualData";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { Base, EnumUtil, fromEnum, markType, getInstanceType } from "igniteui-react-core/ES5/type";
import { AxisLabelVisualData } from "./AxisLabelVisualData";
import { PointData } from "igniteui-react-core/ES5/PointData";
import { Size } from "igniteui-react-core/ES5/Size";
import { SizeData } from "igniteui-react-core/ES5/SizeData";
import { FontUtil } from "igniteui-react-core/ES5/FontUtil";
var AxisVisualDataManager = /** @class */ (function (_super) {
    tslib_1.__extends(AxisVisualDataManager, _super);
    function AxisVisualDataManager() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    AxisVisualDataManager.prototype.c = function (a) {
        return a;
    };
    AxisVisualDataManager.prototype.d = function (a, b) {
        var c = VisualExportHelper.a(b);
        return c;
    };
    AxisVisualDataManager.prototype.a = function (a, b, c, d) {
        var e = new ChartTitleVisualData();
        var f = a.a2;
        var g = f.a5();
        e.viewport = RectData.b(g);
        var h = this.d(a, d);
        e.textPlotArea = RectData.b(h);
        var i = d._visibility == 0 && d.x != null;
        var j = a.at.ae.d();
        var k = f.bc(d);
        var l = this.b(a, d, j);
        var m = AppearanceHelper.c(d, l);
        m.marginLeft = k.c;
        m.marginRight = k.d;
        m.marginTop = k.e;
        m.marginBottom = k.b;
        m.fontStretch = "Normal";
        m.textWrapping = "Wrap";
        m.visibility = i;
        if (a.bc != null) {
            m.horizontalAlignment = EnumUtil.getName(HorizontalAlignment_$type, a.bc.horizontalAlignment);
            m.verticalAlignment = EnumUtil.getName(VerticalAlignment_$type, a.bc.verticalAlignment);
            m.textPosition = EnumUtil.getName(AxisTitlePosition_$type, a.bc.position);
        }
        else {
            m.horizontalAlignment = EnumUtil.getName(HorizontalAlignment_$type, (0));
            m.verticalAlignment = EnumUtil.getName(VerticalAlignment_$type, (1));
            m.textPosition = EnumUtil.getName(AxisTitlePosition_$type, (0));
        }
        e.appearance = m;
        return e;
    };
    AxisVisualDataManager.prototype.exportVisualData = function (a) {
        var b = new AxisVisualData();
        b.viewport = RectData.b(a.it);
        b.labelsViewport = RectData.b(a.a2.a5());
        b.type = this.c(getInstanceType(a).typeName);
        b.name = a.name;
        var c = new PathVisualData(1, "axisLine", a.a2.a6);
        b.axisLine = c;
        b.tickMarks = new PathVisualData(1, "tickMarks", a.at.ae.av);
        if (!a.at.ab.contains(a.at.ae.av)) {
            b.tickMarks.data.clear();
        }
        b.minorLines = new PathVisualData(1, "minorLines", a.a2.a8);
        b.majorLines = new PathVisualData(1, "majorLines", a.a2.a7);
        b.strips = new PathVisualData(1, "strips", a.a2.a9);
        if (a.f0 != null) {
            var d = this.a(a, a.bf, b.type, a.hd);
            b.title = d;
        }
        else {
            b.title = null;
        }
        var e = a.bf.getFontInfo();
        if (a.aw != null && a.aw.textStyle != null) {
            e = a.aw.g(a.bf.bk.i.af);
        }
        var f, g, h, i;
        var j = a.at.ae.av.aj.c;
        for (var k = 1; k < j.count; k++) {
            var l = j._inner[k];
            var m = j._inner[k - 1];
            f = l.c.x - l.b.x;
            g = l.c.y - l.b.y;
            h = m.c.x - m.b.x;
            i = m.c.y - m.b.y;
            if (1 == k) {
                b.tickMarksLength = Math.sqrt(Math.pow(f, 2) + Math.pow(g, 2));
            }
        }
        var n = a.at.a2;
        var o = a.at.ae.g();
        var _loop_1 = function (p) {
            var q = a.at.a2._inner[p];
            var r = a.at.a1._inner[p];
            var s = ((function () {
                var $ret = new AxisLabelVisualData();
                $ret.labelPosition = q.d;
                $ret.labelValue = r;
                $ret.panelPosition = PointData.b(a.a2.a2());
                return $ret;
            })());
            var t = new List$1(TextBlock.$, 0);
            try {
                for (var _a = tslib_1.__values(fromEnum(o)), _b = _a.next(); !_b.done; _b = _a.next()) {
                    var u = _b.value;
                    t.add(u);
                }
            }
            catch (e_1_1) { e_1 = { error: e_1_1 }; }
            finally {
                try {
                    if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
                }
                finally { if (e_1) throw e_1.error; }
            }
            if (p < t.count) {
                var v = this_1.b(a, t._inner[p], e);
                s.appearance = AppearanceHelper.c(t._inner[p], v);
                var w = a.bo.a._inner[p];
                s.position = PointData.b(a.a2.a1(w));
                s.size = SizeData.b(new Size(1, w.m, w.l));
            }
            b.labels.add(s);
            var e_1, _c;
        };
        var this_1 = this;
        for (var p = 0; p < n.count; p++) {
            _loop_1(p);
        }
        return b;
    };
    AxisVisualDataManager.prototype.b = function (a, b, c) {
        return FontUtil.getFontInfo(a.bf.bk.i.af, b, c);
    };
    AxisVisualDataManager.$t = markType(AxisVisualDataManager, 'AxisVisualDataManager', Base.$, [IAxisVisualDataManager_$type]);
    return AxisVisualDataManager;
}(Base));
export { AxisVisualDataManager };
