/*
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";
import { Point_$type, typeCast, markType, markDep } from "igniteui-angular-core";
import { ScatterFrame } from "./ScatterFrame";
import { ScatterSplineSeriesView } from "./ScatterSplineSeriesView";
import { Clipper } from "igniteui-angular-core";
import { OwnedPoint } from "./OwnedPoint";
import { ScalerParams } from "./ScalerParams";
import { PathGeometry } from "igniteui-angular-core";
import { Numeric } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
/**
 * @hidden
 */
var ScatterSplineSeries = /** @class */ (function (_super) {
    tslib_1.__extends(ScatterSplineSeries, _super);
    function ScatterSplineSeries() {
        var _this = _super.call(this) || this;
        _this.ab = ScatterSplineSeries.$;
        _this.m9 = new ScatterFrame();
        _this.nb = new ScatterFrame();
        _this.m8 = new ScatterFrame();
        return _this;
    }
    ScatterSplineSeries.prototype.bf = function () {
        return new ScatterSplineSeriesView(this);
    };
    ScatterSplineSeries.prototype.iz = function (a, b, c, d) {
        _super.prototype.iz.call(this, a, b, c, d);
        switch (b) {
            case ScatterSplineSeries.$$p[0]:
                this.jd(false);
                this.ik();
                break;
        }
    };
    ScatterSplineSeries.prototype.bd = function () {
        if (this.be == 0) {
            return 2;
        }
        else {
            return _super.prototype.bd.call(this);
        }
    };
    ScatterSplineSeries.prototype.n2 = function (a, b) {
        var _this = this;
        _super.prototype.n2.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.nd != null ? this.nd.count : 0, this.nf != null ? this.nf.count : 0);
        var h = new ScalerParams(0, c, d, this.m4.d, e);
        var i = ((function () {
            var $ret = new ScalerParams(0, c, d, _this.m4.e, e);
            $ret.b = _this.eh();
            return $ret;
        })());
        var j = function (k) { return _this.m4.a.dw(_this.nd.item(k), h); };
        var k = function (l) { return _this.m4.b.dw(_this.nf.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.ox(j, k, n, m) < f) {
                ++m;
            }
            if (g > this.nk) {
                l.j(this.o1(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.nk) {
            l.i = null;
        }
    };
    ScatterSplineSeries.prototype.o1 = 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.ox = 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.ob = function (a, b) {
        this.hv(false, b);
        _super.prototype.ob.call(this, a, b);
        this.n5(a);
        var c = typeCast(ScatterSplineSeriesView.$, b);
        c.da.ak = new PathGeometry();
        c.da.ak.c = Numeric.h(a.m.count, function (d) { return a.m._inner[d].x; }, function (d) { return a.m._inner[d].y; }, this.oy);
    };
    ScatterSplineSeries.$t = markType(ScatterSplineSeries, 'ScatterSplineSeries', ScatterBase.$);
    ScatterSplineSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterSplineSeries, 'raisePropertyChanged', ['Stiffness:oy:o0', [1, 0.5]]);
    return ScatterSplineSeries;
}(ScatterBase));
export { ScatterSplineSeries };
//# sourceMappingURL=ScatterSplineSeries.js.map