/*
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 { Base, typeCast, Point_$type, markType } from "igniteui-react-core/ES5/type";
import { DataTemplateRenderInfo } from "igniteui-react-core/ES5/DataTemplateRenderInfo";
import { Series } from "./Series";
import { DataTemplate } from "igniteui-react-core/ES5/DataTemplate";
import { LegendItemHelper } from "igniteui-react-core/ES5/LegendItemHelper";
import { RenderingContext } from "igniteui-react-core/ES5/RenderingContext";
import { Line } from "igniteui-react-core/ES5/Line";
import { MarkerSeries } from "./MarkerSeries";
import { CanvasViewRenderer } from "igniteui-react-core/ES5/CanvasViewRenderer";
import { DataTemplateMeasureInfo } from "igniteui-react-core/ES5/DataTemplateMeasureInfo";
import { Path } from "igniteui-react-core/ES5/Path";
import { PathGeometry } from "igniteui-react-core/ES5/PathGeometry";
import { PathFigure } from "igniteui-react-core/ES5/PathFigure";
import { LineSegment } from "igniteui-react-core/ES5/LineSegment";
import { ArcSegment } from "igniteui-react-core/ES5/ArcSegment";
import { Size } from "igniteui-react-core/ES5/Size";
import { isNaN_, isInfinity } from "igniteui-react-core/ES5/number";
/**
 * @hidden
 */
var LegendTemplates = /** @class */ (function (_super) {
    tslib_1.__extends(LegendTemplates, _super);
    function LegendTemplates() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    LegendTemplates.d = function (a) {
        var b = a.data;
        var c = b.series;
        var d = c.legendItemBadgeTemplate;
        if (d == null) {
            d = LegendTemplates.ab(c.bj);
        }
        var e = c.fs;
        if (e == null) {
            e = "Series Title";
        }
        LegendItemHelper.d(a.context, a.xPosition, a.yPosition, a.availableWidth, a.availableHeight, a.data, e.toString(), d, a.passInfo, c.aw != null && c.aw.isFinancial, c.d5, c.eq);
    };
    LegendTemplates.resolveLegendItemTemplate = function (a) {
        switch (a) {
            case 0: return LegendTemplates.q;
            case 1: return LegendTemplates.r;
        }
        return LegendTemplates.q;
    };
    LegendTemplates.b = function (a) {
        var b = a.data;
        var c = b.series;
        var d = c.legendItemBadgeTemplate;
        if (d == null) {
            d = LegendTemplates.ab(c.bj);
        }
        var e = b.itemLabel;
        if (e == null) {
            e = "Series Item";
        }
        LegendItemHelper.c(a.context, a.xPosition, a.yPosition, a.availableWidth, a.availableHeight, a.data, e.toString(), d, a.passInfo);
    };
    LegendTemplates.h = function (a) {
        var b = a.data;
        var c = a.context;
        var d = b.series;
        if (b.itemBrush != null) {
            b.actualItemBrush = b.itemBrush;
        }
        else {
            b.actualItemBrush = d.kw;
        }
        var e = new RenderingContext(new CanvasViewRenderer(), c);
        var f = new Line();
        f.aj = 0;
        f.al = a.availableHeight / 2;
        f.ak = a.availableWidth;
        f.am = a.availableHeight / 2;
        f.ac = d.ev;
        f._stroke = b.actualItemBrush;
        f.ai = d.k4;
        e.r(f);
        var g = typeCast(MarkerSeries.$, b.series);
        if (g != null && g.mb != null && g.mb.render != null) {
            b.outline = g.mp;
            b.thickness = 2;
            LegendTemplates.n(g.mb, a);
        }
    };
    LegendTemplates.n = function (a, b) {
        var c = new DataTemplateMeasureInfo();
        c.passInfo = b.passInfo;
        c.width = 11;
        c.height = 11;
        c.data = b.data;
        c.context = b.context;
        c.renderContext = b.renderContext;
        var d = b.data;
        var e = d.actualItemBrush;
        var f = d.itemBrush;
        if (typeCast(Series.$, d.series) !== null) {
            if (d.itemBrush == null) {
                var g = d.series;
                d.actualItemBrush = g.kz();
            }
        }
        if (a.measure != null) {
            a.measure(c);
            if (isNaN_(c.width) || isInfinity(c.width) || c.width > 11) {
                c.width = 11;
            }
            if (isNaN_(c.height) || isInfinity(c.height) || c.height > 11) {
                c.height = 11;
            }
        }
        var h = new DataTemplateRenderInfo();
        h.passInfo = b.passInfo;
        h.availableWidth = c.width;
        h.availableHeight = c.height;
        h.xPosition = b.availableWidth / 2;
        h.yPosition = b.availableHeight / 2;
        h.data = b.data;
        h.context = b.context;
        h.renderContext = b.renderContext;
        a.render(h);
        d.itemBrush = f;
        d.actualItemBrush = e;
    };
    LegendTemplates.p = function (a) {
        var b = null;
        if (typeCast(Series.$, a.series) !== null) {
            b = a.series;
        }
        if (a.itemBrush != null) {
            a.actualItemBrush = a.itemBrush;
        }
        else {
            if (b != null) {
                a.actualItemBrush = b.kw;
            }
            else {
                a.actualItemBrush = a.itemBrush;
            }
        }
    };
    LegendTemplates.c = function (a) {
    };
    LegendTemplates.a = function (a) {
    };
    LegendTemplates.g = function (a) {
    };
    LegendTemplates.m = function (a) {
        var b = a.data;
        var c = a.context;
        LegendTemplates.p(b);
        var d = new RenderingContext(new CanvasViewRenderer(), c);
        var e = new Path();
        var f = new PathGeometry();
        var g = new PathFigure();
        g._isFilled = true;
        var h = 0;
        if (typeCast(Series.$, b.series) !== null) {
            h = b.series.ev / 2;
            e.ac = b.series.ev;
            e._stroke = b.series.kx;
            e.ai = b.series.k4;
        }
        g._startPoint = { $type: Point_$type, x: h, y: 5 };
        g._segments.add(new LineSegment(0, { $type: Point_$type, x: h, y: 14 }));
        g._segments.add(new LineSegment(0, { $type: Point_$type, x: 11, y: 14 }));
        g._segments.add(((function () {
            var $ret = new ArcSegment();
            $ret.f = new Size(1, 5, 5);
            $ret.b = false;
            $ret.e = { $type: Point_$type, x: 16, y: 9 };
            return $ret;
        })()));
        g._segments.add(new LineSegment(0, { $type: Point_$type, x: 16, y: h }));
        g._segments.add(new LineSegment(0, { $type: Point_$type, x: 5, y: h }));
        g._segments.add(((function () {
            var $ret = new ArcSegment();
            $ret.f = new Size(1, 5, 5);
            $ret.b = false;
            $ret.e = { $type: Point_$type, x: h, y: 5 };
            return $ret;
        })()));
        f.b.add(g);
        e.aj = f;
        e._fill = b.actualItemBrush;
        d.s(e);
        var i = typeCast(MarkerSeries.$, b.series);
        if (i != null && i.mb != null && i.mb.render != null) {
            if (typeCast(Series.$, b.series) !== null) {
                b.outline = b.series.kx;
            }
            LegendTemplates.n(i.mb, a);
        }
    };
    LegendTemplates.j = function (a) {
        var b = a.data;
        var c = a.context;
        LegendTemplates.p(b);
        var d = new Path();
        var e = new PathGeometry();
        var f = new PathFigure();
        var g = 0;
        if (typeCast(Series.$, b.series) !== null) {
            g = b.series.ev / 2;
            d.ac = b.series.ev;
            d._stroke = b.series.kx;
            d.ai = b.series.k4;
        }
        f._isFilled = true;
        f._startPoint = { $type: Point_$type, x: g, y: 5 };
        f._segments.add(new LineSegment(0, { $type: Point_$type, x: g, y: 14 }));
        f._segments.add(new LineSegment(0, { $type: Point_$type, x: 11, y: 14 }));
        f._segments.add(((function () {
            var $ret = new ArcSegment();
            $ret.f = new Size(1, 5, 5);
            $ret.b = false;
            $ret.e = { $type: Point_$type, x: 16, y: 9 };
            return $ret;
        })()));
        f._segments.add(new LineSegment(0, { $type: Point_$type, x: 16, y: g }));
        f._segments.add(new LineSegment(0, { $type: Point_$type, x: 5, y: g }));
        f._segments.add(((function () {
            var $ret = new ArcSegment();
            $ret.f = new Size(1, 5, 5);
            $ret.b = false;
            $ret.e = { $type: Point_$type, x: g, y: 5 };
            return $ret;
        })()));
        e.b.add(f);
        d.aj = e;
        d._fill = b.actualItemBrush;
        var h = new RenderingContext(new CanvasViewRenderer(), c);
        h.s(d);
    };
    LegendTemplates.i = function (a) {
        var b = a.data;
        var c = a.context;
        var d = b.series;
        if (b.itemBrush != null) {
            b.actualItemBrush = b.itemBrush;
        }
        else {
            b.actualItemBrush = d.kw;
        }
        var e = new Line();
        e.aj = 0;
        e.al = a.availableHeight / 2;
        e.ak = a.availableWidth;
        e.am = a.availableHeight / 2;
        e.ac = d.ev;
        e.ai = d.k4;
        e._stroke = b.actualItemBrush;
        var f = new RenderingContext(new CanvasViewRenderer(), c);
        f.r(e);
    };
    LegendTemplates.k = function (a) {
        var b = a.data;
        LegendTemplates.p(b);
        var c = typeCast(MarkerSeries.$, b.series);
        if (c != null && c.mb != null && c.mb.render != null) {
            if (typeCast(Series.$, b.series) !== null) {
                b.outline = b.series.k0();
            }
            LegendTemplates.n(c.mb, a);
        }
    };
    LegendTemplates.l = function (a) {
        var b = a.data;
        var c = a.context;
        var d = b.series;
        if (b.itemBrush != null) {
            b.actualItemBrush = b.itemBrush;
        }
        else {
            b.actualItemBrush = d.kw;
        }
        var e = new Path();
        var f = new PathGeometry();
        var g = new PathFigure();
        var h = 0;
        if (typeCast(Series.$, b.series) !== null) {
            h = b.series.ev / 2;
            e.ac = b.series.ev;
            e._stroke = b.series.kx;
            e.ai = b.series.k4;
        }
        g._isFilled = true;
        g._startPoint = { $type: Point_$type, x: h, y: 5 };
        g._segments.add(new LineSegment(0, { $type: Point_$type, x: h, y: 14 }));
        g._segments.add(new LineSegment(0, { $type: Point_$type, x: 16, y: h }));
        g._segments.add(new LineSegment(0, { $type: Point_$type, x: 5, y: h }));
        g._segments.add(((function () {
            var $ret = new ArcSegment();
            $ret.f = new Size(1, 5, 5);
            $ret.b = false;
            $ret.e = { $type: Point_$type, x: h, y: 5 };
            return $ret;
        })()));
        f.b.add(g);
        e.aj = f;
        e._fill = b.actualItemBrush;
        var i = new Path();
        var j = new PathGeometry();
        var k = new PathFigure();
        var l = 0;
        var m = null;
        if (typeCast(Series.$, b.series) !== null) {
            l = b.series.ev / 2;
            i.ac = b.series.ev;
            i._stroke = b.series.kx;
            m = b.series.k2();
        }
        k._isFilled = true;
        k._startPoint = { $type: Point_$type, x: l, y: 14 };
        k._segments.add(new LineSegment(0, { $type: Point_$type, x: 11, y: 14 }));
        k._segments.add(((function () {
            var $ret = new ArcSegment();
            $ret.f = new Size(1, 5, 5);
            $ret.b = false;
            $ret.e = { $type: Point_$type, x: 16, y: 9 };
            return $ret;
        })()));
        k._segments.add(new LineSegment(0, { $type: Point_$type, x: 16, y: l }));
        j.b.add(k);
        i.aj = j;
        if (m != null) {
            i._fill = m;
        }
        var n = new RenderingContext(new CanvasViewRenderer(), c);
        n.s(e);
        n.s(i);
        var o = typeCast(MarkerSeries.$, b.series);
        if (o != null && o.mb != null && o.mb.render != null) {
            if (typeCast(Series.$, b.series) !== null) {
                b.outline = b.series.kx;
            }
            LegendTemplates.n(o.mb, a);
        }
    };
    LegendTemplates.e = function (a) {
        var b = a.data;
        var c = a.context;
        var d = b.series;
        if (b.itemBrush != null) {
            b.actualItemBrush = b.itemBrush;
        }
        else {
            b.actualItemBrush = d.kw;
        }
        var e = new Path();
        var f = new PathGeometry();
        var g = 0;
        if (typeCast(Series.$, b.series) !== null) {
            g = b.series.ev / 2;
            e.ac = b.series.ev;
            e._stroke = b.series.kx;
            e.ai = b.series.k4;
        }
        var h = new PathFigure();
        h._isFilled = true;
        h._startPoint = { $type: Point_$type, x: g, y: 5 };
        h._segments.add(new LineSegment(0, { $type: Point_$type, x: g, y: 14 }));
        h._segments.add(new LineSegment(0, { $type: Point_$type, x: 16, y: g }));
        h._segments.add(new LineSegment(0, { $type: Point_$type, x: 5, y: g }));
        h._segments.add(((function () {
            var $ret = new ArcSegment();
            $ret.f = new Size(1, 5, 5);
            $ret.b = false;
            $ret.e = { $type: Point_$type, x: g, y: 5 };
            return $ret;
        })()));
        f.b.add(h);
        e.aj = f;
        e._fill = b.actualItemBrush;
        var i = new Path();
        var j = new PathGeometry();
        var k = new PathFigure();
        var l = 0;
        var m = null;
        if (typeCast(Series.$, b.series) !== null) {
            i.ac = b.series.ev;
            i._stroke = b.series.kx;
            i.ai = b.series.k4;
            m = b.series.k2();
        }
        k._isFilled = true;
        k._startPoint = { $type: Point_$type, x: l, y: 14 };
        k._segments.add(new LineSegment(0, { $type: Point_$type, x: 11, y: 14 }));
        k._segments.add(((function () {
            var $ret = new ArcSegment();
            $ret.f = new Size(1, 5, 5);
            $ret.b = false;
            $ret.e = { $type: Point_$type, x: 16, y: 9 };
            return $ret;
        })()));
        k._segments.add(new LineSegment(0, { $type: Point_$type, x: 16, y: l }));
        j.b.add(k);
        i.aj = j;
        if (m != null) {
            i._fill = m;
        }
        var n = new RenderingContext(new CanvasViewRenderer(), c);
        n.s(e);
        n.s(i);
    };
    LegendTemplates.f = function (a) {
        var b = a.data;
        var c = a.context;
        var d = b.series;
        if (b.itemBrush != null) {
            b.actualItemBrush = b.itemBrush;
        }
        else {
            b.actualItemBrush = d.kw;
        }
        var e = new Path();
        var f = new PathGeometry();
        var g = new PathFigure();
        var h = 0;
        if (typeCast(Series.$, b.series) !== null) {
            h = b.series.ev / 2;
            e.ac = b.series.ev;
            e._stroke = b.series.kx;
            e.ai = b.series.k4;
        }
        g._isFilled = true;
        g._startPoint = { $type: Point_$type, x: h, y: 5 };
        g._segments.add(new LineSegment(0, { $type: Point_$type, x: h, y: 14 }));
        g._segments.add(new LineSegment(0, { $type: Point_$type, x: 16, y: h }));
        g._segments.add(new LineSegment(0, { $type: Point_$type, x: 5, y: h }));
        g._segments.add(((function () {
            var $ret = new ArcSegment();
            $ret.f = new Size(1, 5, 5);
            $ret.b = false;
            $ret.e = { $type: Point_$type, x: h, y: 5 };
            return $ret;
        })()));
        f.b.add(g);
        e.aj = f;
        e._fill = b.actualItemBrush;
        var i = new Path();
        var j = new PathGeometry();
        var k = new PathFigure();
        var l = 0;
        var m = null;
        if (typeCast(Series.$, b.series) !== null) {
            l = b.series.ev / 2;
            i.ac = b.series.ev;
            i._stroke = b.series.kx;
            i.ai = b.series.k4;
            m = b.series.k2();
        }
        k._isFilled = true;
        k._startPoint = { $type: Point_$type, x: l, y: 14 };
        k._segments.add(new LineSegment(0, { $type: Point_$type, x: 11, y: 14 }));
        k._segments.add(((function () {
            var $ret = new ArcSegment();
            $ret.f = new Size(1, 5, 5);
            $ret.b = false;
            $ret.e = { $type: Point_$type, x: 16, y: 9 };
            return $ret;
        })()));
        k._segments.add(new LineSegment(0, { $type: Point_$type, x: 16, y: l }));
        j.b.add(k);
        i.aj = j;
        if (m != null) {
            i._fill = m;
        }
        var n = new RenderingContext(new CanvasViewRenderer(), c);
        n.s(e);
        n.s(i);
    };
    LegendTemplates.o = function (a) {
        var b = a.data;
        var c = a.context;
        LegendTemplates.p(b);
        var d = typeCast(Series.$, b.series) !== null ? b.series : null;
        if (d != null) {
            b.outline = d.kx;
        }
        var e = new PathGeometry();
        var f = ((function () {
            var $ret = new PathFigure();
            $ret.isClosed = true;
            $ret.isFilled = true;
            return $ret;
        })());
        f._startPoint = { $type: Point_$type, x: 0, y: 0 };
        f._segments.add(new LineSegment(0, { $type: Point_$type, x: 16, y: 0 }));
        f._segments.add(new LineSegment(0, { $type: Point_$type, x: 16, y: 16 }));
        f._segments.add(new LineSegment(0, { $type: Point_$type, x: 0, y: 16 }));
        f._segments.add(new LineSegment(0, { $type: Point_$type, x: 0, y: 0 }));
        e.b.add(f);
        var g = ((function () {
            var $ret = new Path();
            $ret.aj = e;
            $ret.fill = b.actualItemBrush;
            return $ret;
        })());
        var h = new RenderingContext(new CanvasViewRenderer(), c);
        h.s(g);
        h.r(((function () {
            var $ret = new Line();
            $ret.aj = 8;
            $ret.ak = 8;
            $ret.al = 0;
            $ret.am = 16;
            $ret.stroke = b.outline;
            $ret.ac = 2;
            return $ret;
        })()));
    };
    LegendTemplates.ab = function (a) {
        switch (a) {
            case 0: return LegendTemplates.u;
            case 1: return LegendTemplates.z;
            case 4: return LegendTemplates.x;
            case 6: return LegendTemplates.s;
            case 7: return LegendTemplates.t;
            case 2: return LegendTemplates.v;
            case 3: return LegendTemplates.w;
            case 5: return LegendTemplates.y;
            case 8: return LegendTemplates.aa;
        }
        return LegendTemplates.z;
    };
    LegendTemplates.$t = markType(LegendTemplates, 'LegendTemplates');
    LegendTemplates.q = ((function () {
        var $ret = new DataTemplate();
        $ret.measure = LegendTemplates.c;
        $ret.render = LegendTemplates.d;
        return $ret;
    })());
    LegendTemplates.r = ((function () {
        var $ret = new DataTemplate();
        $ret.measure = LegendTemplates.a;
        $ret.render = LegendTemplates.b;
        return $ret;
    })());
    LegendTemplates.u = ((function () {
        var $ret = new DataTemplate();
        $ret.measure = LegendTemplates.c;
        $ret.render = LegendTemplates.h;
        return $ret;
    })());
    LegendTemplates.z = ((function () {
        var $ret = new DataTemplate();
        $ret.measure = LegendTemplates.c;
        $ret.render = LegendTemplates.m;
        return $ret;
    })());
    LegendTemplates.x = ((function () {
        var $ret = new DataTemplate();
        $ret.measure = LegendTemplates.c;
        $ret.render = LegendTemplates.k;
        return $ret;
    })());
    LegendTemplates.s = ((function () {
        var $ret = new DataTemplate();
        $ret.measure = LegendTemplates.c;
        $ret.render = LegendTemplates.e;
        return $ret;
    })());
    LegendTemplates.t = ((function () {
        var $ret = new DataTemplate();
        $ret.measure = LegendTemplates.c;
        $ret.render = LegendTemplates.f;
        return $ret;
    })());
    LegendTemplates.v = ((function () {
        var $ret = new DataTemplate();
        $ret.measure = LegendTemplates.c;
        $ret.render = LegendTemplates.j;
        return $ret;
    })());
    LegendTemplates.w = ((function () {
        var $ret = new DataTemplate();
        $ret.measure = LegendTemplates.c;
        $ret.render = LegendTemplates.i;
        return $ret;
    })());
    LegendTemplates.y = ((function () {
        var $ret = new DataTemplate();
        $ret.measure = LegendTemplates.c;
        $ret.render = LegendTemplates.l;
        return $ret;
    })());
    LegendTemplates.aa = ((function () {
        var $ret = new DataTemplate();
        $ret.measure = LegendTemplates.c;
        $ret.render = LegendTemplates.o;
        return $ret;
    })());
    return LegendTemplates;
}(Base));
export { LegendTemplates };
