/*
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 } from "tslib";
import { ScatterBase } from "./ScatterBase";
import { DependencyProperty } from "igniteui-angular-core";
import { Point_$type, typeCast, runOn, markType, markDep } from "igniteui-angular-core";
import { ScatterFrame } from "./ScatterFrame";
import { ScatterSplineSeriesView } from "./ScatterSplineSeriesView";
import { Defaults } from "./Defaults";
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";
import { isNaN_ } from "igniteui-angular-core";
/**
 * @hidden
 */
var ScatterSplineSeries = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(ScatterSplineSeries, _super);
    function ScatterSplineSeries() {
        var _this = _super.call(this) || this;
        _this.ab = ScatterSplineSeries.$;
        _this.zc = new ScatterFrame();
        _this.ze = new ScatterFrame();
        _this.za = new ScatterFrame();
        return _this;
    }
    ScatterSplineSeries.prototype.bk = function () {
        return new ScatterSplineSeries();
    };
    ScatterSplineSeries.prototype.get_f1 = function () {
        return true;
    };
    ScatterSplineSeries.prototype.ct = function () {
        return new ScatterSplineSeriesView(this);
    };
    ScatterSplineSeries.prototype.z6 = function () {
        return true;
    };
    ScatterSplineSeries.prototype.jn = function () {
        if (!isNaN_(this.jm)) {
            return _super.prototype.jn.call(this);
        }
        return Defaults.ak;
    };
    ScatterSplineSeries.prototype.rg = function (a, b, c, d) {
        _super.prototype.rg.call(this, a, b, c, d);
        switch (b) {
            case ScatterSplineSeries.$$p[0]:
                this.ry(false);
                this.qr();
                break;
        }
    };
    ScatterSplineSeries.prototype.b3 = function () {
        if (this.b4 == 0) {
            return 2;
        }
        else {
            return _super.prototype.b3.call(this);
        }
    };
    ScatterSplineSeries.prototype.abp = function (a, b) {
        var _this = this;
        _super.prototype.abp.call(this, a, b);
        a.n.clear();
        a.v.clear();
        var c = b.ca;
        var d = b.b9;
        var e = this.getEffectiveViewport1(b);
        var f = this.ie * this.ie;
        var g = Math.min(this.zr != null ? this.zr.count : 0, this.zs != null ? this.zs.count : 0);
        var h = new ScalerParams(0, c, d, this.y6.d, e);
        var i = ((function () {
            var $ret = new ScalerParams(0, c, d, _this.y6.e, e);
            $ret.b = _this.i0();
            return $ret;
        })());
        var j = function (k) { return _this.y6.a.ft(_this.zr.item(k), h); };
        var k = function (l) { return _this.y6.b.ft(_this.zs.item(l), i); };
        var l = ((function () {
            var $ret = new Clipper(0, d, false);
            $ret.i = a.n;
            return $ret;
        })());
        for (var m = 0; m < g;) {
            var n = m;
            ++m;
            while (m < g && this.acx(j, k, n, m) < f) {
                ++m;
            }
            if (g > this.aaj) {
                l.j(this.ac1(j, k, n, m - 1));
            }
            else {
                var o = new OwnedPoint();
                o.c = { $type: Point_$type, x: j(n), y: k(n) };
                o.a = this.dp.item(n);
                if (!a.v.containsKey(o.a)) {
                    a.v.addItem(o.a, o);
                }
            }
        }
        if (g > this.aaj) {
            l.i = null;
        }
    };
    ScatterSplineSeries.prototype.ac1 = 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.acx = function (a, b, c, d) {
        var e = a(d) - a(c);
        var f = b(d) - b(c);
        return e * e + f * f;
    };
    ScatterSplineSeries.prototype.get_z0 = function () {
        return true;
    };
    ScatterSplineSeries.prototype.pb = function (a, b) {
        _super.prototype.pb.call(this, a, b);
        var c = typeCast(ScatterSplineSeriesView.$, b);
        c.dm(false);
    };
    ScatterSplineSeries.prototype.ab0 = function (a, b) {
        this.pb(false, b);
        _super.prototype.ab0.call(this, a, b);
        this.abs(a);
        var c = typeCast(ScatterSplineSeriesView.$, b);
        var d = c.dz;
        this.zj.az(this, this.z5(), runOn(this, this.yz));
        var e = false;
        var f = this.zj.b;
        if (f != null) {
            e = true;
        }
        if (e) {
            this.abl(-1, this.zr.count, b.t);
        }
        this.zj.ad(d, true, false, true, false);
        c.dz.an = new PathGeometry();
        c.dz.an.c = Numeric.h(a.n.count, function (g) { return a.n._inner[g].x; }, function (g) { return a.n._inner[g].y; }, this.acy);
    };
    ScatterSplineSeries.$t = markType(ScatterSplineSeries, 'ScatterSplineSeries', ScatterBase.$);
    ScatterSplineSeries.$$p = markDep(DependencyProperty, PropertyMetadata, ScatterSplineSeries, 'raisePropertyChanged', ['Stiffness:acy:ac0', [1, 0.5]]);
    return ScatterSplineSeries;
}(ScatterBase));
export { ScatterSplineSeries };
