/*
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, fromEnum, typeCast, markType, getInstanceType } from "igniteui-react-core";
import { ISeriesVisualDataManager_$type } from "./ISeriesVisualDataManager";
import { StackedSeriesVisualData } from "./StackedSeriesVisualData";
import { SeriesVisualData } from "./SeriesVisualData";
import { MarkerVisualData } from "./MarkerVisualData";
import { RectData } from "igniteui-react-core";
import { PrimitiveAppearanceData } from "igniteui-react-core";
import { DataContext } from "igniteui-react-core";
import { Color } from "igniteui-react-core";
import { ColorData } from "igniteui-react-core";
import { AppearanceHelper } from "igniteui-react-core";
import { PathVisualData } from "igniteui-react-core";
import { PolygonVisualData } from "igniteui-react-core";
import { PolyLineVisualData } from "igniteui-react-core";
import { RectangleVisualData } from "igniteui-react-core";
import { PointerTooltipVisualData } from "./PointerTooltipVisualData";
import { CalloutVisualData } from "./CalloutVisualData";
import { LineVisualData } from "igniteui-react-core";
/**
 * @hidden
 */
var SeriesVisualDataManager = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(SeriesVisualDataManager, _super);
    function SeriesVisualDataManager() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    SeriesVisualDataManager.prototype.addSubSeriesVisualData = function (a, b) {
        var c = a;
        var d = b;
        c.fragmentSeries.add(d);
    };
    SeriesVisualDataManager.prototype.addSubSeriesLayerVisualData = function (a, b) {
        var c = a;
        var d = b;
        c.layers.add(d);
    };
    SeriesVisualDataManager.prototype.copyVisualData = function (a, b) {
        var e_1, _a, e_2, _b;
        var c = a;
        var d = b;
        try {
            for (var _c = __values(fromEnum(d.shapes)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var e = _d.value;
                c.shapes.add(e);
            }
        }
        catch (e_1_1) {
            e_1 = { error: e_1_1 };
        }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return))
                    _a.call(_c);
            }
            finally {
                if (e_1)
                    throw e_1.error;
            }
        }
        try {
            for (var _e = __values(fromEnum(d.markerShapes)), _f = _e.next(); !_f.done; _f = _e.next()) {
                var f = _f.value;
                c.markerShapes.add(f);
            }
        }
        catch (e_2_1) {
            e_2 = { error: e_2_1 };
        }
        finally {
            try {
                if (_f && !_f.done && (_b = _e.return))
                    _b.call(_e);
            }
            finally {
                if (e_2)
                    throw e_2.error;
            }
        }
        c.pixels = d.pixels;
        c.pixelWidth = d.pixelWidth;
    };
    SeriesVisualDataManager.prototype.createFragmentVisualData = function (a, b, c, d) {
        var e = new SeriesVisualData();
        e.viewport = RectData.b(b);
        e.type = c;
        e.name = d;
        return e;
    };
    SeriesVisualDataManager.prototype.exportMarkerVisualData = function (a, b) {
        var _this = this;
        var c = b;
        a.t9.ci(function (d) {
            var e = _this.getMarkerVisualData(a, d, a.uv);
            c.markerShapes.add(typeCast(MarkerVisualData.$, e));
        });
    };
    SeriesVisualDataManager.prototype.getMarkerVisualData = function (a, b, c) {
        var d = new MarkerVisualData();
        var e = new PrimitiveAppearanceData();
        d.x = b.n;
        d.y = b.o;
        d.bounds = new RectData(b.n - (b.m / 2), b.o - (b.l / 2), b.m, b.l);
        e.fill = ColorData.a_1(Color.u(0, 0, 0, 0));
        e.stroke = ColorData.a_1(Color.u(0, 0, 0, 0));
        d.index = -1;
        d.contentTemplate = b.ah;
        if (b.content != null && typeCast(DataContext.$, b.content) !== null && b._visibility == 0) {
            var f = b.content;
            e.fill = AppearanceHelper.b(f.actualItemBrush);
            e.fillExtended = AppearanceHelper.a(f.actualItemBrush);
            e.stroke = AppearanceHelper.b(f.outline);
            e.strokeExtended = AppearanceHelper.a(f.outline);
            e.strokeThickness = a.hs();
            if (f.item != null) {
                d.index = a.c6.indexOf(f.item);
            }
        }
        e.isVisible = b._visibility == 0;
        d.isVisible = b._visibility == 0;
        d.markerAppearance = e;
        d.markerType = this.a(a, c);
        return d;
    };
    SeriesVisualDataManager.prototype.a = function (a, b) {
        if (b == a.cy.py) {
            return "Circle";
        }
        else if (b == a.cy.pz) {
            return "Diamond";
        }
        else if (b == a.cy.p0) {
            return "Hexagon";
        }
        else if (b == a.cy.p1) {
            return "Hexagram";
        }
        else if (b == a.cy.p2) {
            return "Pentagon";
        }
        else if (b == a.cy.p3) {
            return "Pentagram";
        }
        else if (b == a.cy.p4) {
            return "Pyramid";
        }
        else if (b == a.cy.p5) {
            return "Square";
        }
        else if (b == a.cy.p6) {
            return "Tetragram";
        }
        else if (b == a.cy.p7) {
            return "Triangle";
        }
        else {
            return "None";
        }
    };
    SeriesVisualDataManager.prototype.exportMarkerVisualDataFromMarker = function (a, b, c) {
        var d = b;
        var e = new MarkerVisualData();
        var f = new PrimitiveAppearanceData();
        e.x = c.n;
        e.y = c.o;
        e.bounds = new RectData(c.n - (c.m / 2), c.o - (c.l / 2), c.m, c.l);
        e.index = -1;
        e.contentTemplate = c.ah;
        if (typeCast(DataContext.$, c.content) !== null) {
            var g = c.content;
            f.fill = AppearanceHelper.b(g.actualItemBrush);
            f.stroke = AppearanceHelper.b(g.outline);
        }
        e.isVisible = c._visibility == 0;
        e.markerAppearance = f;
        if (c.ah == a.cy.py) {
            e.markerType = "Circle";
        }
        else if (c.ah == a.cy.pz) {
            e.markerType = "Diamond";
        }
        else if (c.ah == a.cy.p0) {
            e.markerType = "Hexagon";
        }
        else if (c.ah == a.cy.p1) {
            e.markerType = "Hexagram";
        }
        else if (c.ah == a.cy.p2) {
            e.markerType = "Pentagon";
        }
        else if (c.ah == a.cy.p3) {
            e.markerType = "Pentagram";
        }
        else if (c.ah == a.cy.p4) {
            e.markerType = "Pyramid";
        }
        else if (c.ah == a.cy.p5) {
            e.markerType = "Square";
        }
        else if (c.ah == a.cy.p6) {
            e.markerType = "Tetragram";
        }
        else if (c.ah == a.cy.p7) {
            e.markerType = "Triangle";
        }
        else {
            e.markerType = "None";
        }
        d.markerShapes.add(e);
    };
    SeriesVisualDataManager.prototype.exportPathData = function (a, b, c, d) {
        var e = a;
        var f = new PathVisualData(1, c, b);
        if (d != null) {
            for (var g = 0; g < d.length; g++) {
                f.tags.add(d[g]);
            }
        }
        e.shapes.add(f);
    };
    SeriesVisualDataManager.prototype.exportPolygonData = function (a, b, c, d) {
        var e = a;
        var f = new PolygonVisualData(1, c, b);
        if (d != null) {
            for (var g = 0; g < d.length; g++) {
                f.tags.add(d[g]);
            }
        }
        e.shapes.add(f);
    };
    SeriesVisualDataManager.prototype.exportPolylineData = function (a, b, c, d) {
        var e = a;
        var f = new PolyLineVisualData(1, c, b);
        if (d != null) {
            for (var g = 0; g < d.length; g++) {
                f.tags.add(d[g]);
            }
        }
        e.shapes.add(f);
    };
    SeriesVisualDataManager.prototype.exportRectangleData = function (a, b, c, d) {
        var e = a;
        var f = new RectangleVisualData(1, c, b);
        if (d != null) {
            for (var g = 0; g < d.length; g++) {
                f.tags.add(d[g]);
            }
        }
        e.shapes.add(f);
    };
    SeriesVisualDataManager.prototype.exportStackedVisualData = function (a, b) {
        var c = new StackedSeriesVisualData();
        c.viewport = RectData.b(b);
        c.type = getInstanceType(a).typeName;
        c.name = a.name;
        return c;
    };
    SeriesVisualDataManager.prototype.exportTrendlineData = function (a, b, c) {
        var d = b;
        var e = new PolyLineVisualData(1, "trendLine", c);
        e.tags.add("Trend");
        d.shapes.add(e);
    };
    SeriesVisualDataManager.prototype.exportVisualData = function (a, b) {
        var c = new SeriesVisualData();
        c.viewport = RectData.b(b);
        c.type = this.b(getInstanceType(a).typeName);
        c.name = a.name;
        c.opacity = a._opacity;
        return c;
    };
    SeriesVisualDataManager.prototype.exportSeriesPixelsData = function (a, b, c, d) {
        var e = a;
        e.pixels = b;
        e.pixelWidth = c;
        e.pixelHeight = d;
    };
    SeriesVisualDataManager.prototype.b = function (a) {
        return a;
    };
    SeriesVisualDataManager.prototype.addPointerTooltipData = function (a, b, c, d, e) {
        if (b == null) {
            return;
        }
        var f = a;
        var g = b;
        g.offsetX = c;
        g.offsetY = d;
        g.categoryNames = e;
        f.pointerTooltips.add(g);
    };
    SeriesVisualDataManager.prototype.addPointerTooltipWithDataLegend = function (a, b, c, d, e) {
        if (b == null) {
            return;
        }
        var f = a;
        var g = b;
        g.offsetX = c;
        g.offsetY = d;
        g.content = e;
        f.pointerTooltips.add(g);
    };
    SeriesVisualDataManager.prototype.exportPointerTooltipData = function (a, b, c, d) {
        var e = new PointerTooltipVisualData();
        e.pointerFillShape = new PolygonVisualData(1, "fillShape", a);
        e.pointerOutlineShape = new PolyLineVisualData(1, "outlineShape", b);
        e.boxShape = new RectangleVisualData(1, "boxShape", c);
        e.viewport = RectData.b(d);
        return e;
    };
    SeriesVisualDataManager.prototype.exportCalloutData = function (a, b, c, d, e, f, g, h, i, j, k) {
        var l = new CalloutVisualData();
        l.left = a;
        l.top = b;
        l.marginLeft = c;
        l.marginTop = d;
        l.background = new RectangleVisualData(1, "calloutBackground", f);
        l.text = AppearanceHelper.c(g, h);
        l.line = new LineVisualData(1, "calloutLeaderLine", i);
        e.calloutShapes.add(l);
    };
    SeriesVisualDataManager.prototype.exportLayerVisualData = function (a, b) {
        for (var c = 0; c < a.actualLayers.count; c++) {
            b.layers.add1(a.actualLayers._inner[c].target.jq());
        }
    };
    SeriesVisualDataManager.$t = markType(SeriesVisualDataManager, 'SeriesVisualDataManager', Base.$, [ISeriesVisualDataManager_$type]);
    return SeriesVisualDataManager;
}(Base));
export { SeriesVisualDataManager };
