/*
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 { ScatterBase } from "./ScatterBase";
import { DependencyProperty } from "igniteui-angular-core/ES5/DependencyProperty";
import { Type, Point_$type, typeCast, markType } from "igniteui-angular-core/ES5/type";
import { ScatterFrame } from "./ScatterFrame";
import { ScatterSplineSeriesView } from "./ScatterSplineSeriesView";
import { Clipper } from "igniteui-angular-core/ES5/Clipper";
import { OwnedPoint } from "./OwnedPoint";
import { ScalerParams } from "./ScalerParams";
import { PathGeometry } from "igniteui-angular-core/ES5/PathGeometry";
import { Numeric } from "igniteui-angular-core/ES5/Numeric";
import { PropertyMetadata } from "igniteui-angular-core/ES5/PropertyMetadata";
/**
 * @hidden
 */
var ScatterSplineSeries = /** @class */ (function (_super) {
    tslib_1.__extends(ScatterSplineSeries, _super);
    function ScatterSplineSeries() {
        var _this = _super.call(this) || this;
        _this.ab = ScatterSplineSeries.$;
        _this.m8 = new ScatterFrame();
        _this.na = new ScatterFrame();
        _this.m7 = new ScatterFrame();
        return _this;
    }
    ScatterSplineSeries.prototype.bf = function () {
        return new ScatterSplineSeriesView(this);
    };
    ScatterSplineSeries.prototype.iy = function (a, b, c, d) {
        _super.prototype.iy.call(this, a, b, c, d);
        switch (b) {
            case ScatterSplineSeries.$$p[0]:
                this.jc(false);
                this.ij();
                break;
        }
    };
    ScatterSplineSeries.prototype.bd = function () {
        if (this.be == 0) {
            return 2;
        }
        else {
            return _super.prototype.bd.call(this);
        }
    };
    ScatterSplineSeries.prototype.n1 = function (a, b) {
        var _this = this;
        _super.prototype.n1.call(this, a, b);
        a.m.clear();
        a.u.clear();
        var c = b.bs;
        var d = b.br;
        var e = this.getEffectiveViewport1(b);
        var f = this.eu * this.eu;
        var g = Math.min(this.nc != null ? this.nc.count : 0, this.ne != null ? this.ne.count : 0);
        var h = new ScalerParams(0, c, d, this.m3.d, e);
        var i = ((function () {
            var $ret = new ScalerParams(0, c, d, _this.m3.e, e);
            $ret.b = _this.eh();
            return $ret;
        })());
        var j = function (k) { return _this.m3.a.dv(_this.nc.item(k), h); };
        var k = function (l) { return _this.m3.b.dv(_this.ne.item(l), i); };
        var l = ((function () {
            var $ret = new Clipper(0, d, false);
            $ret.i = a.m;
            return $ret;
        })());
        for (var m = 0; m < g;) {
            var n = m;
            ++m;
            while (m < g && this.ow(j, k, n, m) < f) {
                ++m;
            }
            if (g > this.nj) {
                l.j(this.o0(j, k, n, m - 1));
            }
            else {
                var o = new OwnedPoint();
                o.c = { $type: Point_$type, x: j(n), y: k(n) };
                o.a = this.bz.item(n);
                if (!a.u.containsKey(o.a)) {
                    a.u.addItem(o.a, o);
                }
            }
        }
        if (g > this.nj) {
            l.i = null;
        }
    };
    ScatterSplineSeries.prototype.o0 = function (a, b, c, d) {
        if (c == d) {
            return { $type: Point_$type, x: a(c), y: b(c) };
        }
        var e = 0;
        var f = 0;
        var g = (d - c + 1);
        for (var h = c; h <= d; ++h) {
            e += a(h);
            f += b(h);
        }
        return { $type: Point_$type, x: e / g, y: f / g };
    };
    ScatterSplineSeries.prototype.ow = function (a, b, c, d) {
        var e = a(d) - a(c);
        var f = b(d) - b(c);
        return e * e + f * f;
    };
    ScatterSplineSeries.prototype.hv = function (a, b) {
        _super.prototype.hv.call(this, a, b);
        var c = typeCast(ScatterSplineSeriesView.$, b);
        c.c0(false);
    };
    ScatterSplineSeries.prototype.oa = function (a, b) {
        this.hv(false, b);
        _super.prototype.oa.call(this, a, b);
        this.n4(a);
        var c = typeCast(ScatterSplineSeriesView.$, b);
        c.da.aj = new PathGeometry();
        c.da.aj.b = Numeric.h(a.m.count, function (d) { return a.m._inner[d].x; }, function (d) { return a.m._inner[d].y; }, this.ox);
    };
    ScatterSplineSeries.$t = markType(ScatterSplineSeries, 'ScatterSplineSeries', ScatterBase.$);
    return ScatterSplineSeries;
}(ScatterBase));
export { ScatterSplineSeries };
Type.dep(DependencyProperty, PropertyMetadata, ScatterSplineSeries, 'raisePropertyChanged', ['Stiffness:ox:oz', [1, 0.5]]);
//# sourceMappingURL=ScatterSplineSeries.js.map